documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module BABYLON {
  480. /**
  481. * File request interface
  482. */
  483. export interface IFileRequest {
  484. /**
  485. * Raised when the request is complete (success or error).
  486. */
  487. onCompleteObservable: Observable<IFileRequest>;
  488. /**
  489. * Aborts the request for a file.
  490. */
  491. abort: () => void;
  492. }
  493. }
  494. declare module BABYLON {
  495. /**
  496. * Scalar computation library
  497. */
  498. export class Scalar {
  499. /**
  500. * Two pi constants convenient for computation.
  501. */
  502. static TwoPi: number;
  503. /**
  504. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  505. * @param a number
  506. * @param b number
  507. * @param epsilon (default = 1.401298E-45)
  508. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  509. */
  510. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  511. /**
  512. * Returns a string : the upper case translation of the number i to hexadecimal.
  513. * @param i number
  514. * @returns the upper case translation of the number i to hexadecimal.
  515. */
  516. static ToHex(i: number): string;
  517. /**
  518. * Returns -1 if value is negative and +1 is value is positive.
  519. * @param value the value
  520. * @returns the value itself if it's equal to zero.
  521. */
  522. static Sign(value: number): number;
  523. /**
  524. * Returns the value itself if it's between min and max.
  525. * Returns min if the value is lower than min.
  526. * Returns max if the value is greater than max.
  527. * @param value the value to clmap
  528. * @param min the min value to clamp to (default: 0)
  529. * @param max the max value to clamp to (default: 1)
  530. * @returns the clamped value
  531. */
  532. static Clamp(value: number, min?: number, max?: number): number;
  533. /**
  534. * the log2 of value.
  535. * @param value the value to compute log2 of
  536. * @returns the log2 of value.
  537. */
  538. static Log2(value: number): number;
  539. /**
  540. * Loops the value, so that it is never larger than length and never smaller than 0.
  541. *
  542. * This is similar to the modulo operator but it works with floating point numbers.
  543. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  544. * With t = 5 and length = 2.5, the result would be 0.0.
  545. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  546. * @param value the value
  547. * @param length the length
  548. * @returns the looped value
  549. */
  550. static Repeat(value: number, length: number): number;
  551. /**
  552. * Normalize the value between 0.0 and 1.0 using min and max values
  553. * @param value value to normalize
  554. * @param min max to normalize between
  555. * @param max min to normalize between
  556. * @returns the normalized value
  557. */
  558. static Normalize(value: number, min: number, max: number): number;
  559. /**
  560. * Denormalize the value from 0.0 and 1.0 using min and max values
  561. * @param normalized value to denormalize
  562. * @param min max to denormalize between
  563. * @param max min to denormalize between
  564. * @returns the denormalized value
  565. */
  566. static Denormalize(normalized: number, min: number, max: number): number;
  567. /**
  568. * Calculates the shortest difference between two given angles given in degrees.
  569. * @param current current angle in degrees
  570. * @param target target angle in degrees
  571. * @returns the delta
  572. */
  573. static DeltaAngle(current: number, target: number): number;
  574. /**
  575. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  576. * @param tx value
  577. * @param length length
  578. * @returns The returned value will move back and forth between 0 and length
  579. */
  580. static PingPong(tx: number, length: number): number;
  581. /**
  582. * Interpolates between min and max with smoothing at the limits.
  583. *
  584. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  585. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  586. * @param from from
  587. * @param to to
  588. * @param tx value
  589. * @returns the smooth stepped value
  590. */
  591. static SmoothStep(from: number, to: number, tx: number): number;
  592. /**
  593. * Moves a value current towards target.
  594. *
  595. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  596. * Negative values of maxDelta pushes the value away from target.
  597. * @param current current value
  598. * @param target target value
  599. * @param maxDelta max distance to move
  600. * @returns resulting value
  601. */
  602. static MoveTowards(current: number, target: number, maxDelta: number): number;
  603. /**
  604. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  605. *
  606. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  607. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  608. * @param current current value
  609. * @param target target value
  610. * @param maxDelta max distance to move
  611. * @returns resulting angle
  612. */
  613. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  614. /**
  615. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  616. * @param start start value
  617. * @param end target value
  618. * @param amount amount to lerp between
  619. * @returns the lerped value
  620. */
  621. static Lerp(start: number, end: number, amount: number): number;
  622. /**
  623. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  624. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  625. * @param start start value
  626. * @param end target value
  627. * @param amount amount to lerp between
  628. * @returns the lerped value
  629. */
  630. static LerpAngle(start: number, end: number, amount: number): number;
  631. /**
  632. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  633. * @param a start value
  634. * @param b target value
  635. * @param value value between a and b
  636. * @returns the inverseLerp value
  637. */
  638. static InverseLerp(a: number, b: number, value: number): number;
  639. /**
  640. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  641. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  642. * @param value1 spline value
  643. * @param tangent1 spline value
  644. * @param value2 spline value
  645. * @param tangent2 spline value
  646. * @param amount input value
  647. * @returns hermite result
  648. */
  649. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  650. /**
  651. * Returns a random float number between and min and max values
  652. * @param min min value of random
  653. * @param max max value of random
  654. * @returns random value
  655. */
  656. static RandomRange(min: number, max: number): number;
  657. /**
  658. * This function returns percentage of a number in a given range.
  659. *
  660. * RangeToPercent(40,20,60) will return 0.5 (50%)
  661. * RangeToPercent(34,0,100) will return 0.34 (34%)
  662. * @param number to convert to percentage
  663. * @param min min range
  664. * @param max max range
  665. * @returns the percentage
  666. */
  667. static RangeToPercent(number: number, min: number, max: number): number;
  668. /**
  669. * This function returns number that corresponds to the percentage in a given range.
  670. *
  671. * PercentToRange(0.34,0,100) will return 34.
  672. * @param percent to convert to number
  673. * @param min min range
  674. * @param max max range
  675. * @returns the number
  676. */
  677. static PercentToRange(percent: number, min: number, max: number): number;
  678. /**
  679. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  680. * @param angle The angle to normalize in radian.
  681. * @return The converted angle.
  682. */
  683. static NormalizeRadians(angle: number): number;
  684. }
  685. }
  686. declare module BABYLON {
  687. /**
  688. * Constant used to convert a value to gamma space
  689. * @ignorenaming
  690. */
  691. export const ToGammaSpace: number;
  692. /**
  693. * Constant used to convert a value to linear space
  694. * @ignorenaming
  695. */
  696. export const ToLinearSpace = 2.2;
  697. /**
  698. * Constant used to define the minimal number value in Babylon.js
  699. * @ignorenaming
  700. */
  701. let Epsilon: number;
  702. }
  703. declare module BABYLON {
  704. /**
  705. * Class used to represent a viewport on screen
  706. */
  707. export class Viewport {
  708. /** viewport left coordinate */
  709. x: number;
  710. /** viewport top coordinate */
  711. y: number;
  712. /**viewport width */
  713. width: number;
  714. /** viewport height */
  715. height: number;
  716. /**
  717. * Creates a Viewport object located at (x, y) and sized (width, height)
  718. * @param x defines viewport left coordinate
  719. * @param y defines viewport top coordinate
  720. * @param width defines the viewport width
  721. * @param height defines the viewport height
  722. */
  723. constructor(
  724. /** viewport left coordinate */
  725. x: number,
  726. /** viewport top coordinate */
  727. y: number,
  728. /**viewport width */
  729. width: number,
  730. /** viewport height */
  731. height: number);
  732. /**
  733. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  734. * @param renderWidth defines the rendering width
  735. * @param renderHeight defines the rendering height
  736. * @returns a new Viewport
  737. */
  738. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  739. /**
  740. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  741. * @param renderWidth defines the rendering width
  742. * @param renderHeight defines the rendering height
  743. * @param ref defines the target viewport
  744. * @returns the current viewport
  745. */
  746. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  747. /**
  748. * Returns a new Viewport copied from the current one
  749. * @returns a new Viewport
  750. */
  751. clone(): Viewport;
  752. }
  753. }
  754. declare module BABYLON {
  755. /**
  756. * Class containing a set of static utilities functions for arrays.
  757. */
  758. export class ArrayTools {
  759. /**
  760. * Returns an array of the given size filled with element built from the given constructor and the paramters
  761. * @param size the number of element to construct and put in the array
  762. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  763. * @returns a new array filled with new objects
  764. */
  765. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  766. }
  767. }
  768. declare module BABYLON {
  769. /**
  770. * @hidden
  771. */
  772. export interface IColor4Like {
  773. r: float;
  774. g: float;
  775. b: float;
  776. a: float;
  777. }
  778. /**
  779. * @hidden
  780. */
  781. export interface IColor3Like {
  782. r: float;
  783. g: float;
  784. b: float;
  785. }
  786. /**
  787. * @hidden
  788. */
  789. export interface IVector4Like {
  790. x: float;
  791. y: float;
  792. z: float;
  793. w: float;
  794. }
  795. /**
  796. * @hidden
  797. */
  798. export interface IVector3Like {
  799. x: float;
  800. y: float;
  801. z: float;
  802. }
  803. /**
  804. * @hidden
  805. */
  806. export interface IVector2Like {
  807. x: float;
  808. y: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IMatrixLike {
  814. toArray(): DeepImmutable<Float32Array>;
  815. updateFlag: int;
  816. }
  817. /**
  818. * @hidden
  819. */
  820. export interface IViewportLike {
  821. x: float;
  822. y: float;
  823. width: float;
  824. height: float;
  825. }
  826. /**
  827. * @hidden
  828. */
  829. export interface IPlaneLike {
  830. normal: IVector3Like;
  831. d: float;
  832. normalize(): void;
  833. }
  834. }
  835. declare module BABYLON {
  836. /**
  837. * Class representing a vector containing 2 coordinates
  838. */
  839. export class Vector2 {
  840. /** defines the first coordinate */
  841. x: number;
  842. /** defines the second coordinate */
  843. y: number;
  844. /**
  845. * Creates a new Vector2 from the given x and y coordinates
  846. * @param x defines the first coordinate
  847. * @param y defines the second coordinate
  848. */
  849. constructor(
  850. /** defines the first coordinate */
  851. x?: number,
  852. /** defines the second coordinate */
  853. y?: number);
  854. /**
  855. * Gets a string with the Vector2 coordinates
  856. * @returns a string with the Vector2 coordinates
  857. */
  858. toString(): string;
  859. /**
  860. * Gets class name
  861. * @returns the string "Vector2"
  862. */
  863. getClassName(): string;
  864. /**
  865. * Gets current vector hash code
  866. * @returns the Vector2 hash code as a number
  867. */
  868. getHashCode(): number;
  869. /**
  870. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  871. * @param array defines the source array
  872. * @param index defines the offset in source array
  873. * @returns the current Vector2
  874. */
  875. toArray(array: FloatArray, index?: number): Vector2;
  876. /**
  877. * Copy the current vector to an array
  878. * @returns a new array with 2 elements: the Vector2 coordinates.
  879. */
  880. asArray(): number[];
  881. /**
  882. * Sets the Vector2 coordinates with the given Vector2 coordinates
  883. * @param source defines the source Vector2
  884. * @returns the current updated Vector2
  885. */
  886. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  887. /**
  888. * Sets the Vector2 coordinates with the given floats
  889. * @param x defines the first coordinate
  890. * @param y defines the second coordinate
  891. * @returns the current updated Vector2
  892. */
  893. copyFromFloats(x: number, y: number): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. set(x: number, y: number): Vector2;
  901. /**
  902. * Add another vector with the current one
  903. * @param otherVector defines the other vector
  904. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  905. */
  906. add(otherVector: DeepImmutable<Vector2>): Vector2;
  907. /**
  908. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  909. * @param otherVector defines the other vector
  910. * @param result defines the target vector
  911. * @returns the unmodified current Vector2
  912. */
  913. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  914. /**
  915. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  916. * @param otherVector defines the other vector
  917. * @returns the current updated Vector2
  918. */
  919. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  920. /**
  921. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. addVector3(otherVector: Vector3): Vector2;
  926. /**
  927. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  928. * @param otherVector defines the other vector
  929. * @returns a new Vector2
  930. */
  931. subtract(otherVector: Vector2): Vector2;
  932. /**
  933. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  934. * @param otherVector defines the other vector
  935. * @param result defines the target vector
  936. * @returns the unmodified current Vector2
  937. */
  938. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  939. /**
  940. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Multiplies in place the current Vector2 coordinates by the given ones
  947. * @param otherVector defines the other vector
  948. * @returns the current updated Vector2
  949. */
  950. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns a new Vector2
  955. */
  956. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @param result defines the target vector
  961. * @returns the unmodified current Vector2
  962. */
  963. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  964. /**
  965. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  966. * @param x defines the first coordinate
  967. * @param y defines the second coordinate
  968. * @returns a new Vector2
  969. */
  970. multiplyByFloats(x: number, y: number): Vector2;
  971. /**
  972. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @returns a new Vector2
  975. */
  976. divide(otherVector: Vector2): Vector2;
  977. /**
  978. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  979. * @param otherVector defines the other vector
  980. * @param result defines the target vector
  981. * @returns the unmodified current Vector2
  982. */
  983. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  984. /**
  985. * Divides the current Vector2 coordinates by the given ones
  986. * @param otherVector defines the other vector
  987. * @returns the current updated Vector2
  988. */
  989. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  990. /**
  991. * Gets a new Vector2 with current Vector2 negated coordinates
  992. * @returns a new Vector2
  993. */
  994. negate(): Vector2;
  995. /**
  996. * Multiply the Vector2 coordinates by scale
  997. * @param scale defines the scaling factor
  998. * @returns the current updated Vector2
  999. */
  1000. scaleInPlace(scale: number): Vector2;
  1001. /**
  1002. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1003. * @param scale defines the scaling factor
  1004. * @returns a new Vector2
  1005. */
  1006. scale(scale: number): Vector2;
  1007. /**
  1008. * Scale the current Vector2 values by a factor to a given Vector2
  1009. * @param scale defines the scale factor
  1010. * @param result defines the Vector2 object where to store the result
  1011. * @returns the unmodified current Vector2
  1012. */
  1013. scaleToRef(scale: number, result: Vector2): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Gets a boolean if two vectors are equals
  1023. * @param otherVector defines the other vector
  1024. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1025. */
  1026. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1027. /**
  1028. * Gets a boolean if two vectors are equals (using an epsilon value)
  1029. * @param otherVector defines the other vector
  1030. * @param epsilon defines the minimal distance to consider equality
  1031. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1032. */
  1033. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. floor(): Vector2;
  1039. /**
  1040. * Gets a new Vector2 from current Vector2 floored values
  1041. * @returns a new Vector2
  1042. */
  1043. fract(): Vector2;
  1044. /**
  1045. * Gets the length of the vector
  1046. * @returns the vector length (float)
  1047. */
  1048. length(): number;
  1049. /**
  1050. * Gets the vector squared length
  1051. * @returns the vector squared length (float)
  1052. */
  1053. lengthSquared(): number;
  1054. /**
  1055. * Normalize the vector
  1056. * @returns the current updated Vector2
  1057. */
  1058. normalize(): Vector2;
  1059. /**
  1060. * Gets a new Vector2 copied from the Vector2
  1061. * @returns a new Vector2
  1062. */
  1063. clone(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(0, 0)
  1066. * @returns a new Vector2
  1067. */
  1068. static Zero(): Vector2;
  1069. /**
  1070. * Gets a new Vector2(1, 1)
  1071. * @returns a new Vector2
  1072. */
  1073. static One(): Vector2;
  1074. /**
  1075. * Gets a new Vector2 set from the given index element of the given array
  1076. * @param array defines the data source
  1077. * @param offset defines the offset in the data source
  1078. * @returns a new Vector2
  1079. */
  1080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1081. /**
  1082. * Sets "result" from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @param result defines the target vector
  1086. */
  1087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1088. /**
  1089. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1090. * @param value1 defines 1st point of control
  1091. * @param value2 defines 2nd point of control
  1092. * @param value3 defines 3rd point of control
  1093. * @param value4 defines 4th point of control
  1094. * @param amount defines the interpolation factor
  1095. * @returns a new Vector2
  1096. */
  1097. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1098. /**
  1099. * 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".
  1100. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1101. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1102. * @param value defines the value to clamp
  1103. * @param min defines the lower limit
  1104. * @param max defines the upper limit
  1105. * @returns a new Vector2
  1106. */
  1107. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1108. /**
  1109. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1110. * @param value1 defines the 1st control point
  1111. * @param tangent1 defines the outgoing tangent
  1112. * @param value2 defines the 2nd control point
  1113. * @param tangent2 defines the incoming tangent
  1114. * @param amount defines the interpolation factor
  1115. * @returns a new Vector2
  1116. */
  1117. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1118. /**
  1119. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1120. * @param start defines the start vector
  1121. * @param end defines the end vector
  1122. * @param amount defines the interpolation factor
  1123. * @returns a new Vector2
  1124. */
  1125. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1126. /**
  1127. * Gets the dot product of the vector "left" and the vector "right"
  1128. * @param left defines first vector
  1129. * @param right defines second vector
  1130. * @returns the dot product (float)
  1131. */
  1132. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1133. /**
  1134. * Returns a new Vector2 equal to the normalized given vector
  1135. * @param vector defines the vector to normalize
  1136. * @returns a new Vector2
  1137. */
  1138. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1139. /**
  1140. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1141. * @param left defines 1st vector
  1142. * @param right defines 2nd vector
  1143. * @returns a new Vector2
  1144. */
  1145. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1155. * @param vector defines the vector to transform
  1156. * @param transformation defines the matrix to apply
  1157. * @returns a new Vector2
  1158. */
  1159. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1160. /**
  1161. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @param result defines the target vector
  1165. */
  1166. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1167. /**
  1168. * Determines if a given vector is included in a triangle
  1169. * @param p defines the vector to test
  1170. * @param p0 defines 1st triangle point
  1171. * @param p1 defines 2nd triangle point
  1172. * @param p2 defines 3rd triangle point
  1173. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1174. */
  1175. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1176. /**
  1177. * Gets the distance between the vectors "value1" and "value2"
  1178. * @param value1 defines first vector
  1179. * @param value2 defines second vector
  1180. * @returns the distance between vectors
  1181. */
  1182. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1183. /**
  1184. * Returns the squared distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the squared distance between vectors
  1188. */
  1189. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns a new Vector2
  1195. */
  1196. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1197. /**
  1198. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1199. * @param p defines the middle point
  1200. * @param segA defines one point of the segment
  1201. * @param segB defines the other point of the segment
  1202. * @returns the shortest distance
  1203. */
  1204. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1205. }
  1206. /**
  1207. * Classed used to store (x,y,z) vector representation
  1208. * A Vector3 is the main object used in 3D geometry
  1209. * It can represent etiher the coordinates of a point the space, either a direction
  1210. * Reminder: js uses a left handed forward facing system
  1211. */
  1212. export class Vector3 {
  1213. /**
  1214. * Defines the first coordinates (on X axis)
  1215. */
  1216. x: number;
  1217. /**
  1218. * Defines the second coordinates (on Y axis)
  1219. */
  1220. y: number;
  1221. /**
  1222. * Defines the third coordinates (on Z axis)
  1223. */
  1224. z: number;
  1225. private static _UpReadOnly;
  1226. private static _ZeroReadOnly;
  1227. /**
  1228. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1229. * @param x defines the first coordinates (on X axis)
  1230. * @param y defines the second coordinates (on Y axis)
  1231. * @param z defines the third coordinates (on Z axis)
  1232. */
  1233. constructor(
  1234. /**
  1235. * Defines the first coordinates (on X axis)
  1236. */
  1237. x?: number,
  1238. /**
  1239. * Defines the second coordinates (on Y axis)
  1240. */
  1241. y?: number,
  1242. /**
  1243. * Defines the third coordinates (on Z axis)
  1244. */
  1245. z?: number);
  1246. /**
  1247. * Creates a string representation of the Vector3
  1248. * @returns a string with the Vector3 coordinates.
  1249. */
  1250. toString(): string;
  1251. /**
  1252. * Gets the class name
  1253. * @returns the string "Vector3"
  1254. */
  1255. getClassName(): string;
  1256. /**
  1257. * Creates the Vector3 hash code
  1258. * @returns a number which tends to be unique between Vector3 instances
  1259. */
  1260. getHashCode(): number;
  1261. /**
  1262. * Creates an array containing three elements : the coordinates of the Vector3
  1263. * @returns a new array of numbers
  1264. */
  1265. asArray(): number[];
  1266. /**
  1267. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1268. * @param array defines the destination array
  1269. * @param index defines the offset in the destination array
  1270. * @returns the current Vector3
  1271. */
  1272. toArray(array: FloatArray, index?: number): Vector3;
  1273. /**
  1274. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1275. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1276. */
  1277. toQuaternion(): Quaternion;
  1278. /**
  1279. * Adds the given vector to the current Vector3
  1280. * @param otherVector defines the second operand
  1281. * @returns the current updated Vector3
  1282. */
  1283. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1284. /**
  1285. * Adds the given coordinates to the current Vector3
  1286. * @param x defines the x coordinate of the operand
  1287. * @param y defines the y coordinate of the operand
  1288. * @param z defines the z coordinate of the operand
  1289. * @returns the current updated Vector3
  1290. */
  1291. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1292. /**
  1293. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1294. * @param otherVector defines the second operand
  1295. * @returns the resulting Vector3
  1296. */
  1297. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1300. * @param otherVector defines the second operand
  1301. * @param result defines the Vector3 object where to store the result
  1302. * @returns the current Vector3
  1303. */
  1304. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1305. /**
  1306. * Subtract the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1313. * @param otherVector defines the second operand
  1314. * @returns the resulting Vector3
  1315. */
  1316. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1319. * @param otherVector defines the second operand
  1320. * @param result defines the Vector3 object where to store the result
  1321. * @returns the current Vector3
  1322. */
  1323. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1324. /**
  1325. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1326. * @param x defines the x coordinate of the operand
  1327. * @param y defines the y coordinate of the operand
  1328. * @param z defines the z coordinate of the operand
  1329. * @returns the resulting Vector3
  1330. */
  1331. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1332. /**
  1333. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1334. * @param x defines the x coordinate of the operand
  1335. * @param y defines the y coordinate of the operand
  1336. * @param z defines the z coordinate of the operand
  1337. * @param result defines the Vector3 object where to store the result
  1338. * @returns the current Vector3
  1339. */
  1340. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1341. /**
  1342. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1343. * @returns a new Vector3
  1344. */
  1345. negate(): Vector3;
  1346. /**
  1347. * Multiplies the Vector3 coordinates by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns the current updated Vector3
  1350. */
  1351. scaleInPlace(scale: number): Vector3;
  1352. /**
  1353. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1354. * @param scale defines the multiplier factor
  1355. * @returns a new Vector3
  1356. */
  1357. scale(scale: number): Vector3;
  1358. /**
  1359. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1360. * @param scale defines the multiplier factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the current Vector3
  1363. */
  1364. scaleToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1367. * @param scale defines the scale factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the unmodified current Vector3
  1370. */
  1371. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1374. * @param otherVector defines the second operand
  1375. * @returns true if both vectors are equals
  1376. */
  1377. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1380. * @param otherVector defines the second operand
  1381. * @param epsilon defines the minimal distance to define values as equals
  1382. * @returns true if both vectors are distant less than epsilon
  1383. */
  1384. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 coordinates equals the given floats
  1387. * @param x defines the x coordinate of the operand
  1388. * @param y defines the y coordinate of the operand
  1389. * @param z defines the z coordinate of the operand
  1390. * @returns true if both vectors are equals
  1391. */
  1392. equalsToFloats(x: number, y: number, z: number): boolean;
  1393. /**
  1394. * Multiplies the current Vector3 coordinates by the given ones
  1395. * @param otherVector defines the second operand
  1396. * @returns the current updated Vector3
  1397. */
  1398. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1401. * @param otherVector defines the second operand
  1402. * @returns the new Vector3
  1403. */
  1404. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1405. /**
  1406. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1407. * @param otherVector defines the second operand
  1408. * @param result defines the Vector3 object where to store the result
  1409. * @returns the current Vector3
  1410. */
  1411. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1412. /**
  1413. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns the new Vector3
  1418. */
  1419. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1420. /**
  1421. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the new Vector3
  1424. */
  1425. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1428. * @param otherVector defines the second operand
  1429. * @param result defines the Vector3 object where to store the result
  1430. * @returns the current Vector3
  1431. */
  1432. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones.
  1435. * @param otherVector defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. divideInPlace(otherVector: Vector3): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1447. * @param other defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1453. * @param x defines the x coordinate of the operand
  1454. * @param y defines the y coordinate of the operand
  1455. * @param z defines the z coordinate of the operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1461. * @param x defines the x coordinate of the operand
  1462. * @param y defines the y coordinate of the operand
  1463. * @param z defines the z coordinate of the operand
  1464. * @returns the current updated Vector3
  1465. */
  1466. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1467. /**
  1468. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1469. * Check if is non uniform within a certain amount of decimal places to account for this
  1470. * @param epsilon the amount the values can differ
  1471. * @returns if the the vector is non uniform to a certain number of decimal places
  1472. */
  1473. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1474. /**
  1475. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1476. */
  1477. readonly isNonUniform: boolean;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. floor(): Vector3;
  1483. /**
  1484. * Gets a new Vector3 from current Vector3 floored values
  1485. * @returns a new Vector3
  1486. */
  1487. fract(): Vector3;
  1488. /**
  1489. * Gets the length of the Vector3
  1490. * @returns the length of the Vector3
  1491. */
  1492. length(): number;
  1493. /**
  1494. * Gets the squared length of the Vector3
  1495. * @returns squared length of the Vector3
  1496. */
  1497. lengthSquared(): number;
  1498. /**
  1499. * Normalize the current Vector3.
  1500. * Please note that this is an in place operation.
  1501. * @returns the current updated Vector3
  1502. */
  1503. normalize(): Vector3;
  1504. /**
  1505. * Reorders the x y z properties of the vector in place
  1506. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1507. * @returns the current updated vector
  1508. */
  1509. reorderInPlace(order: string): this;
  1510. /**
  1511. * Rotates the vector around 0,0,0 by a quaternion
  1512. * @param quaternion the rotation quaternion
  1513. * @param result vector to store the result
  1514. * @returns the resulting vector
  1515. */
  1516. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1517. /**
  1518. * Rotates a vector around a given point
  1519. * @param quaternion the rotation quaternion
  1520. * @param point the point to rotate around
  1521. * @param result vector to store the result
  1522. * @returns the resulting vector
  1523. */
  1524. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1525. /**
  1526. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1527. * The cross product is then orthogonal to both current and "other"
  1528. * @param other defines the right operand
  1529. * @returns the cross product
  1530. */
  1531. cross(other: Vector3): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 with the given input length.
  1534. * Please note that this is an in place operation.
  1535. * @param len the length of the vector
  1536. * @returns the current updated Vector3
  1537. */
  1538. normalizeFromLength(len: number): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 to a new vector
  1541. * @returns the new Vector3
  1542. */
  1543. normalizeToNew(): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to the reference
  1546. * @param reference define the Vector3 to update
  1547. * @returns the updated Vector3
  1548. */
  1549. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1550. /**
  1551. * Creates a new Vector3 copied from the current Vector3
  1552. * @returns the new Vector3
  1553. */
  1554. clone(): Vector3;
  1555. /**
  1556. * Copies the given vector coordinates to the current Vector3 ones
  1557. * @param source defines the source Vector3
  1558. * @returns the current updated Vector3
  1559. */
  1560. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1561. /**
  1562. * Copies the given floats to the current Vector3 coordinates
  1563. * @param x defines the x coordinate of the operand
  1564. * @param y defines the y coordinate of the operand
  1565. * @param z defines the z coordinate of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. copyFromFloats(x: number, y: number, z: number): Vector3;
  1569. /**
  1570. * Copies the given floats to the current Vector3 coordinates
  1571. * @param x defines the x coordinate of the operand
  1572. * @param y defines the y coordinate of the operand
  1573. * @param z defines the z coordinate of the operand
  1574. * @returns the current updated Vector3
  1575. */
  1576. set(x: number, y: number, z: number): Vector3;
  1577. /**
  1578. * Copies the given float to the current Vector3 coordinates
  1579. * @param v defines the x, y and z coordinates of the operand
  1580. * @returns the current updated Vector3
  1581. */
  1582. setAll(v: number): Vector3;
  1583. /**
  1584. * Get the clip factor between two vectors
  1585. * @param vector0 defines the first operand
  1586. * @param vector1 defines the second operand
  1587. * @param axis defines the axis to use
  1588. * @param size defines the size along the axis
  1589. * @returns the clip factor
  1590. */
  1591. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1592. /**
  1593. * Get angle between two vectors
  1594. * @param vector0 angle between vector0 and vector1
  1595. * @param vector1 angle between vector0 and vector1
  1596. * @param normal direction of the normal
  1597. * @return the angle between vector0 and vector1
  1598. */
  1599. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1600. /**
  1601. * Returns a new Vector3 set from the index "offset" of the given array
  1602. * @param array defines the source array
  1603. * @param offset defines the offset in the source array
  1604. * @returns the new Vector3
  1605. */
  1606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1609. * This function is deprecated. Use FromArray instead
  1610. * @param array defines the source array
  1611. * @param offset defines the offset in the source array
  1612. * @returns the new Vector3
  1613. */
  1614. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1615. /**
  1616. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @param result defines the Vector3 where to store the result
  1620. */
  1621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1624. * This function is deprecated. Use FromArrayToRef instead.
  1625. * @param array defines the source array
  1626. * @param offset defines the offset in the source array
  1627. * @param result defines the Vector3 where to store the result
  1628. */
  1629. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1630. /**
  1631. * Sets the given vector "result" with the given floats.
  1632. * @param x defines the x coordinate of the source
  1633. * @param y defines the y coordinate of the source
  1634. * @param z defines the z coordinate of the source
  1635. * @param result defines the Vector3 where to store the result
  1636. */
  1637. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1638. /**
  1639. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1640. * @returns a new empty Vector3
  1641. */
  1642. static Zero(): Vector3;
  1643. /**
  1644. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1645. * @returns a new unit Vector3
  1646. */
  1647. static One(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1650. * @returns a new up Vector3
  1651. */
  1652. static Up(): Vector3;
  1653. /**
  1654. * Gets a up Vector3 that must not be updated
  1655. */
  1656. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1657. /**
  1658. * Gets a zero Vector3 that must not be updated
  1659. */
  1660. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1661. /**
  1662. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1663. * @returns a new down Vector3
  1664. */
  1665. static Down(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1668. * @returns a new forward Vector3
  1669. */
  1670. static Forward(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Backward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1678. * @returns a new right Vector3
  1679. */
  1680. static Right(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1683. * @returns a new left Vector3
  1684. */
  1685. static Left(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1688. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @returns the transformed Vector3
  1692. */
  1693. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1694. /**
  1695. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @param result defines the Vector3 where to store the result
  1700. */
  1701. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1702. /**
  1703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1704. * This method computes tranformed coordinates only, not transformed direction vectors
  1705. * @param x define the x coordinate of the source vector
  1706. * @param y define the y coordinate of the source vector
  1707. * @param z define the z coordinate of the source vector
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @returns the new Vector3
  1718. */
  1719. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1720. /**
  1721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1723. * @param vector defines the Vector3 to transform
  1724. * @param transformation defines the transformation matrix
  1725. * @param result defines the Vector3 where to store the result
  1726. */
  1727. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1728. /**
  1729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1731. * @param x define the x coordinate of the source vector
  1732. * @param y define the y coordinate of the source vector
  1733. * @param z define the z coordinate of the source vector
  1734. * @param transformation defines the transformation matrix
  1735. * @param result defines the Vector3 where to store the result
  1736. */
  1737. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1738. /**
  1739. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1740. * @param value1 defines the first control point
  1741. * @param value2 defines the second control point
  1742. * @param value3 defines the third control point
  1743. * @param value4 defines the fourth control point
  1744. * @param amount defines the amount on the spline to use
  1745. * @returns the new Vector3
  1746. */
  1747. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1748. /**
  1749. * 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"
  1750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1752. * @param value defines the current value
  1753. * @param min defines the lower range value
  1754. * @param max defines the upper range value
  1755. * @returns the new Vector3
  1756. */
  1757. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1758. /**
  1759. * 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"
  1760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1762. * @param value defines the current value
  1763. * @param min defines the lower range value
  1764. * @param max defines the upper range value
  1765. * @param result defines the Vector3 where to store the result
  1766. */
  1767. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1768. /**
  1769. * Checks if a given vector is inside a specific range
  1770. * @param v defines the vector to test
  1771. * @param min defines the minimum range
  1772. * @param max defines the maximum range
  1773. */
  1774. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Class used to store quaternion data
  2363. * @see https://en.wikipedia.org/wiki/Quaternion
  2364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2365. */
  2366. export class Quaternion {
  2367. /** defines the first component (0 by default) */
  2368. x: number;
  2369. /** defines the second component (0 by default) */
  2370. y: number;
  2371. /** defines the third component (0 by default) */
  2372. z: number;
  2373. /** defines the fourth component (1.0 by default) */
  2374. w: number;
  2375. /**
  2376. * Creates a new Quaternion from the given floats
  2377. * @param x defines the first component (0 by default)
  2378. * @param y defines the second component (0 by default)
  2379. * @param z defines the third component (0 by default)
  2380. * @param w defines the fourth component (1.0 by default)
  2381. */
  2382. constructor(
  2383. /** defines the first component (0 by default) */
  2384. x?: number,
  2385. /** defines the second component (0 by default) */
  2386. y?: number,
  2387. /** defines the third component (0 by default) */
  2388. z?: number,
  2389. /** defines the fourth component (1.0 by default) */
  2390. w?: number);
  2391. /**
  2392. * Gets a string representation for the current quaternion
  2393. * @returns a string with the Quaternion coordinates
  2394. */
  2395. toString(): string;
  2396. /**
  2397. * Gets the class name of the quaternion
  2398. * @returns the string "Quaternion"
  2399. */
  2400. getClassName(): string;
  2401. /**
  2402. * Gets a hash code for this quaternion
  2403. * @returns the quaternion hash code
  2404. */
  2405. getHashCode(): number;
  2406. /**
  2407. * Copy the quaternion to an array
  2408. * @returns a new array populated with 4 elements from the quaternion coordinates
  2409. */
  2410. asArray(): number[];
  2411. /**
  2412. * Check if two quaternions are equals
  2413. * @param otherQuaternion defines the second operand
  2414. * @return true if the current quaternion and the given one coordinates are strictly equals
  2415. */
  2416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2417. /**
  2418. * Clone the current quaternion
  2419. * @returns a new quaternion copied from the current one
  2420. */
  2421. clone(): Quaternion;
  2422. /**
  2423. * Copy a quaternion to the current one
  2424. * @param other defines the other quaternion
  2425. * @returns the updated current quaternion
  2426. */
  2427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2428. /**
  2429. * Updates the current quaternion with the given float coordinates
  2430. * @param x defines the x coordinate
  2431. * @param y defines the y coordinate
  2432. * @param z defines the z coordinate
  2433. * @param w defines the w coordinate
  2434. * @returns the updated current quaternion
  2435. */
  2436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2437. /**
  2438. * Updates the current quaternion from the given float coordinates
  2439. * @param x defines the x coordinate
  2440. * @param y defines the y coordinate
  2441. * @param z defines the z coordinate
  2442. * @param w defines the w coordinate
  2443. * @returns the updated current quaternion
  2444. */
  2445. set(x: number, y: number, z: number, w: number): Quaternion;
  2446. /**
  2447. * Adds two quaternions
  2448. * @param other defines the second operand
  2449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2450. */
  2451. add(other: DeepImmutable<Quaternion>): Quaternion;
  2452. /**
  2453. * Add a quaternion to the current one
  2454. * @param other defines the quaternion to add
  2455. * @returns the current quaternion
  2456. */
  2457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2458. /**
  2459. * Subtract two quaternions
  2460. * @param other defines the second operand
  2461. * @returns a new quaternion as the subtraction result of the given one from the current one
  2462. */
  2463. subtract(other: Quaternion): Quaternion;
  2464. /**
  2465. * Multiplies the current quaternion by a scale factor
  2466. * @param value defines the scale factor
  2467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2468. */
  2469. scale(value: number): Quaternion;
  2470. /**
  2471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2472. * @param scale defines the scale factor
  2473. * @param result defines the Quaternion object where to store the result
  2474. * @returns the unmodified current quaternion
  2475. */
  2476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2477. /**
  2478. * Multiplies in place the current quaternion by a scale factor
  2479. * @param value defines the scale factor
  2480. * @returns the current modified quaternion
  2481. */
  2482. scaleInPlace(value: number): Quaternion;
  2483. /**
  2484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2485. * @param scale defines the scale factor
  2486. * @param result defines the Quaternion object where to store the result
  2487. * @returns the unmodified current quaternion
  2488. */
  2489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2490. /**
  2491. * Multiplies two quaternions
  2492. * @param q1 defines the second operand
  2493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2494. */
  2495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2496. /**
  2497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2498. * @param q1 defines the second operand
  2499. * @param result defines the target quaternion
  2500. * @returns the current quaternion
  2501. */
  2502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2503. /**
  2504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @returns the currentupdated quaternion
  2507. */
  2508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2509. /**
  2510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2511. * @param ref defines the target quaternion
  2512. * @returns the current quaternion
  2513. */
  2514. conjugateToRef(ref: Quaternion): Quaternion;
  2515. /**
  2516. * Conjugates in place (1-q) the current quaternion
  2517. * @returns the current updated quaternion
  2518. */
  2519. conjugateInPlace(): Quaternion;
  2520. /**
  2521. * Conjugates in place (1-q) the current quaternion
  2522. * @returns a new quaternion
  2523. */
  2524. conjugate(): Quaternion;
  2525. /**
  2526. * Gets length of current quaternion
  2527. * @returns the quaternion length (float)
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Normalize in place the current quaternion
  2532. * @returns the current updated quaternion
  2533. */
  2534. normalize(): Quaternion;
  2535. /**
  2536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2537. * @param order is a reserved parameter and is ignore for now
  2538. * @returns a new Vector3 containing the Euler angles
  2539. */
  2540. toEulerAngles(order?: string): Vector3;
  2541. /**
  2542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2543. * @param result defines the vector which will be filled with the Euler angles
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns the current unchanged quaternion
  2546. */
  2547. toEulerAnglesToRef(result: Vector3): Quaternion;
  2548. /**
  2549. * Updates the given rotation matrix with the current quaternion values
  2550. * @param result defines the target matrix
  2551. * @returns the current unchanged quaternion
  2552. */
  2553. toRotationMatrix(result: Matrix): Quaternion;
  2554. /**
  2555. * Updates the current quaternion from the given rotation matrix values
  2556. * @param matrix defines the source matrix
  2557. * @returns the current updated quaternion
  2558. */
  2559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2560. /**
  2561. * Creates a new quaternion from a rotation matrix
  2562. * @param matrix defines the source matrix
  2563. * @returns a new quaternion created from the given rotation matrix values
  2564. */
  2565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2566. /**
  2567. * Updates the given quaternion with the given rotation matrix values
  2568. * @param matrix defines the source matrix
  2569. * @param result defines the target quaternion
  2570. */
  2571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2572. /**
  2573. * Returns the dot product (float) between the quaternions "left" and "right"
  2574. * @param left defines the left operand
  2575. * @param right defines the right operand
  2576. * @returns the dot product
  2577. */
  2578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2579. /**
  2580. * Checks if the two quaternions are close to each other
  2581. * @param quat0 defines the first quaternion to check
  2582. * @param quat1 defines the second quaternion to check
  2583. * @returns true if the two quaternions are close to each other
  2584. */
  2585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2586. /**
  2587. * Creates an empty quaternion
  2588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2589. */
  2590. static Zero(): Quaternion;
  2591. /**
  2592. * Inverse a given quaternion
  2593. * @param q defines the source quaternion
  2594. * @returns a new quaternion as the inverted current quaternion
  2595. */
  2596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Inverse a given quaternion
  2599. * @param q defines the source quaternion
  2600. * @param result the quaternion the result will be stored in
  2601. * @returns the result quaternion
  2602. */
  2603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2604. /**
  2605. * Creates an identity quaternion
  2606. * @returns the identity quaternion
  2607. */
  2608. static Identity(): Quaternion;
  2609. /**
  2610. * Gets a boolean indicating if the given quaternion is identity
  2611. * @param quaternion defines the quaternion to check
  2612. * @returns true if the quaternion is identity
  2613. */
  2614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2615. /**
  2616. * Creates a quaternion from a rotation around an axis
  2617. * @param axis defines the axis to use
  2618. * @param angle defines the angle to use
  2619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2620. */
  2621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2622. /**
  2623. * Creates a rotation around an axis and stores it into the given quaternion
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @param result defines the target quaternion
  2627. * @returns the target quaternion
  2628. */
  2629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2630. /**
  2631. * Creates a new quaternion from data stored into an array
  2632. * @param array defines the data source
  2633. * @param offset defines the offset in the source array where the data starts
  2634. * @returns a new quaternion
  2635. */
  2636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2637. /**
  2638. * Create a quaternion from Euler rotation angles
  2639. * @param x Pitch
  2640. * @param y Yaw
  2641. * @param z Roll
  2642. * @returns the new Quaternion
  2643. */
  2644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2645. /**
  2646. * Updates a quaternion from Euler rotation angles
  2647. * @param x Pitch
  2648. * @param y Yaw
  2649. * @param z Roll
  2650. * @param result the quaternion to store the result
  2651. * @returns the updated quaternion
  2652. */
  2653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2654. /**
  2655. * Create a quaternion from Euler rotation vector
  2656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2657. * @returns the new Quaternion
  2658. */
  2659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2660. /**
  2661. * Updates a quaternion from Euler rotation vector
  2662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2663. * @param result the quaternion to store the result
  2664. * @returns the updated quaternion
  2665. */
  2666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2667. /**
  2668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2669. * @param yaw defines the rotation around Y axis
  2670. * @param pitch defines the rotation around X axis
  2671. * @param roll defines the rotation around Z axis
  2672. * @returns the new quaternion
  2673. */
  2674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2675. /**
  2676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2677. * @param yaw defines the rotation around Y axis
  2678. * @param pitch defines the rotation around X axis
  2679. * @param roll defines the rotation around Z axis
  2680. * @param result defines the target quaternion
  2681. */
  2682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2683. /**
  2684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2685. * @param alpha defines the rotation around first axis
  2686. * @param beta defines the rotation around second axis
  2687. * @param gamma defines the rotation around third axis
  2688. * @returns the new quaternion
  2689. */
  2690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2691. /**
  2692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2693. * @param alpha defines the rotation around first axis
  2694. * @param beta defines the rotation around second axis
  2695. * @param gamma defines the rotation around third axis
  2696. * @param result defines the target quaternion
  2697. */
  2698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2699. /**
  2700. * 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)
  2701. * @param axis1 defines the first axis
  2702. * @param axis2 defines the second axis
  2703. * @param axis3 defines the third axis
  2704. * @returns the new quaternion
  2705. */
  2706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2707. /**
  2708. * 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
  2709. * @param axis1 defines the first axis
  2710. * @param axis2 defines the second axis
  2711. * @param axis3 defines the third axis
  2712. * @param ref defines the target quaternion
  2713. */
  2714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2715. /**
  2716. * Interpolates between two quaternions
  2717. * @param left defines first quaternion
  2718. * @param right defines second quaternion
  2719. * @param amount defines the gradient to use
  2720. * @returns the new interpolated quaternion
  2721. */
  2722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2723. /**
  2724. * Interpolates between two quaternions and stores it into a target quaternion
  2725. * @param left defines first quaternion
  2726. * @param right defines second quaternion
  2727. * @param amount defines the gradient to use
  2728. * @param result defines the target quaternion
  2729. */
  2730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2731. /**
  2732. * Interpolate between two quaternions using Hermite interpolation
  2733. * @param value1 defines first quaternion
  2734. * @param tangent1 defines the incoming tangent
  2735. * @param value2 defines second quaternion
  2736. * @param tangent2 defines the outgoing tangent
  2737. * @param amount defines the target quaternion
  2738. * @returns the new interpolated quaternion
  2739. */
  2740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2741. }
  2742. /**
  2743. * Class used to store matrix data (4x4)
  2744. */
  2745. export class Matrix {
  2746. private static _updateFlagSeed;
  2747. private static _identityReadOnly;
  2748. private _isIdentity;
  2749. private _isIdentityDirty;
  2750. private _isIdentity3x2;
  2751. private _isIdentity3x2Dirty;
  2752. /**
  2753. * Gets the update flag of the matrix which is an unique number for the matrix.
  2754. * It will be incremented every time the matrix data change.
  2755. * You can use it to speed the comparison between two versions of the same matrix.
  2756. */
  2757. updateFlag: number;
  2758. private readonly _m;
  2759. /**
  2760. * Gets the internal data of the matrix
  2761. */
  2762. readonly m: DeepImmutable<Float32Array>;
  2763. /** @hidden */
  2764. _markAsUpdated(): void;
  2765. /** @hidden */
  2766. private _updateIdentityStatus;
  2767. /**
  2768. * Creates an empty matrix (filled with zeros)
  2769. */
  2770. constructor();
  2771. /**
  2772. * Check if the current matrix is identity
  2773. * @returns true is the matrix is the identity matrix
  2774. */
  2775. isIdentity(): boolean;
  2776. /**
  2777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2778. * @returns true is the matrix is the identity matrix
  2779. */
  2780. isIdentityAs3x2(): boolean;
  2781. /**
  2782. * Gets the determinant of the matrix
  2783. * @returns the matrix determinant
  2784. */
  2785. determinant(): number;
  2786. /**
  2787. * Returns the matrix as a Float32Array
  2788. * @returns the matrix underlying array
  2789. */
  2790. toArray(): DeepImmutable<Float32Array>;
  2791. /**
  2792. * Returns the matrix as a Float32Array
  2793. * @returns the matrix underlying array.
  2794. */
  2795. asArray(): DeepImmutable<Float32Array>;
  2796. /**
  2797. * Inverts the current matrix in place
  2798. * @returns the current inverted matrix
  2799. */
  2800. invert(): Matrix;
  2801. /**
  2802. * Sets all the matrix elements to zero
  2803. * @returns the current matrix
  2804. */
  2805. reset(): Matrix;
  2806. /**
  2807. * Adds the current matrix with a second one
  2808. * @param other defines the matrix to add
  2809. * @returns a new matrix as the addition of the current matrix and the given one
  2810. */
  2811. add(other: DeepImmutable<Matrix>): Matrix;
  2812. /**
  2813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2814. * @param other defines the matrix to add
  2815. * @param result defines the target matrix
  2816. * @returns the current matrix
  2817. */
  2818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2819. /**
  2820. * Adds in place the given matrix to the current matrix
  2821. * @param other defines the second operand
  2822. * @returns the current updated matrix
  2823. */
  2824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2825. /**
  2826. * Sets the given matrix to the current inverted Matrix
  2827. * @param other defines the target matrix
  2828. * @returns the unmodified current matrix
  2829. */
  2830. invertToRef(other: Matrix): Matrix;
  2831. /**
  2832. * add a value at the specified position in the current Matrix
  2833. * @param index the index of the value within the matrix. between 0 and 15.
  2834. * @param value the value to be added
  2835. * @returns the current updated matrix
  2836. */
  2837. addAtIndex(index: number, value: number): Matrix;
  2838. /**
  2839. * mutiply the specified position in the current Matrix by a value
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. multiplyAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * Inserts the translation vector (using 3 floats) in the current matrix
  2847. * @param x defines the 1st component of the translation
  2848. * @param y defines the 2nd component of the translation
  2849. * @param z defines the 3rd component of the translation
  2850. * @returns the current updated matrix
  2851. */
  2852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2853. /**
  2854. * Adds the translation vector (using 3 floats) in the current matrix
  2855. * @param x defines the 1st component of the translation
  2856. * @param y defines the 2nd component of the translation
  2857. * @param z defines the 3rd component of the translation
  2858. * @returns the current updated matrix
  2859. */
  2860. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2861. /**
  2862. * Inserts the translation vector in the current matrix
  2863. * @param vector3 defines the translation to insert
  2864. * @returns the current updated matrix
  2865. */
  2866. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2867. /**
  2868. * Gets the translation value of the current matrix
  2869. * @returns a new Vector3 as the extracted translation from the matrix
  2870. */
  2871. getTranslation(): Vector3;
  2872. /**
  2873. * Fill a Vector3 with the extracted translation from the matrix
  2874. * @param result defines the Vector3 where to store the translation
  2875. * @returns the current matrix
  2876. */
  2877. getTranslationToRef(result: Vector3): Matrix;
  2878. /**
  2879. * Remove rotation and scaling part from the matrix
  2880. * @returns the updated matrix
  2881. */
  2882. removeRotationAndScaling(): Matrix;
  2883. /**
  2884. * Multiply two matrices
  2885. * @param other defines the second operand
  2886. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2887. */
  2888. multiply(other: DeepImmutable<Matrix>): Matrix;
  2889. /**
  2890. * Copy the current matrix from the given one
  2891. * @param other defines the source matrix
  2892. * @returns the current updated matrix
  2893. */
  2894. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2895. /**
  2896. * Populates the given array from the starting index with the current matrix values
  2897. * @param array defines the target array
  2898. * @param offset defines the offset in the target array where to start storing values
  2899. * @returns the current matrix
  2900. */
  2901. copyToArray(array: Float32Array, offset?: number): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2904. * @param other defines the second operand
  2905. * @param result defines the matrix where to store the multiplication
  2906. * @returns the current matrix
  2907. */
  2908. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the array where to store the multiplication
  2913. * @param offset defines the offset in the target array where to start storing values
  2914. * @returns the current matrix
  2915. */
  2916. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2917. /**
  2918. * Check equality between this matrix and a second one
  2919. * @param value defines the second matrix to compare
  2920. * @returns true is the current matrix and the given one values are strictly equal
  2921. */
  2922. equals(value: DeepImmutable<Matrix>): boolean;
  2923. /**
  2924. * Clone the current matrix
  2925. * @returns a new matrix from the current matrix
  2926. */
  2927. clone(): Matrix;
  2928. /**
  2929. * Returns the name of the current matrix class
  2930. * @returns the string "Matrix"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets the hash code of the current matrix
  2935. * @returns the hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Decomposes the current Matrix into a translation, rotation and scaling components
  2940. * @param scale defines the scale vector3 given as a reference to update
  2941. * @param rotation defines the rotation quaternion given as a reference to update
  2942. * @param translation defines the translation vector3 given as a reference to update
  2943. * @returns true if operation was successful
  2944. */
  2945. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2946. /**
  2947. * Gets specific row of the matrix
  2948. * @param index defines the number of the row to get
  2949. * @returns the index-th row of the current matrix as a new Vector4
  2950. */
  2951. getRow(index: number): Nullable<Vector4>;
  2952. /**
  2953. * Sets the index-th row of the current matrix to the vector4 values
  2954. * @param index defines the number of the row to set
  2955. * @param row defines the target vector4
  2956. * @returns the updated current matrix
  2957. */
  2958. setRow(index: number, row: Vector4): Matrix;
  2959. /**
  2960. * Compute the transpose of the matrix
  2961. * @returns the new transposed matrix
  2962. */
  2963. transpose(): Matrix;
  2964. /**
  2965. * Compute the transpose of the matrix and store it in a given matrix
  2966. * @param result defines the target matrix
  2967. * @returns the current matrix
  2968. */
  2969. transposeToRef(result: Matrix): Matrix;
  2970. /**
  2971. * Sets the index-th row of the current matrix with the given 4 x float values
  2972. * @param index defines the row index
  2973. * @param x defines the x component to set
  2974. * @param y defines the y component to set
  2975. * @param z defines the z component to set
  2976. * @param w defines the w component to set
  2977. * @returns the updated current matrix
  2978. */
  2979. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2980. /**
  2981. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2982. * @param scale defines the scale factor
  2983. * @returns a new matrix
  2984. */
  2985. scale(scale: number): Matrix;
  2986. /**
  2987. * Scale the current matrix values by a factor to a given result matrix
  2988. * @param scale defines the scale factor
  2989. * @param result defines the matrix to store the result
  2990. * @returns the current matrix
  2991. */
  2992. scaleToRef(scale: number, result: Matrix): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor and add the result to a given matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the Matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3002. * @param ref matrix to store the result
  3003. */
  3004. toNormalMatrix(ref: Matrix): void;
  3005. /**
  3006. * Gets only rotation part of the current matrix
  3007. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3008. */
  3009. getRotationMatrix(): Matrix;
  3010. /**
  3011. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3012. * @param result defines the target matrix to store data to
  3013. * @returns the current matrix
  3014. */
  3015. getRotationMatrixToRef(result: Matrix): Matrix;
  3016. /**
  3017. * Toggles model matrix from being right handed to left handed in place and vice versa
  3018. */
  3019. toggleModelMatrixHandInPlace(): void;
  3020. /**
  3021. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3022. */
  3023. toggleProjectionMatrixHandInPlace(): void;
  3024. /**
  3025. * Creates a matrix from an array
  3026. * @param array defines the source array
  3027. * @param offset defines an offset in the source array
  3028. * @returns a new Matrix set from the starting index of the given array
  3029. */
  3030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3031. /**
  3032. * Copy the content of an array into a given matrix
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @param result defines the target matrix
  3036. */
  3037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3038. /**
  3039. * Stores an array into a matrix after having multiplied each component by a given factor
  3040. * @param array defines the source array
  3041. * @param offset defines the offset in the source array
  3042. * @param scale defines the scaling factor
  3043. * @param result defines the target matrix
  3044. */
  3045. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3046. /**
  3047. * Gets an identity matrix that must not be updated
  3048. */
  3049. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3050. /**
  3051. * Stores a list of values (16) inside a given matrix
  3052. * @param initialM11 defines 1st value of 1st row
  3053. * @param initialM12 defines 2nd value of 1st row
  3054. * @param initialM13 defines 3rd value of 1st row
  3055. * @param initialM14 defines 4th value of 1st row
  3056. * @param initialM21 defines 1st value of 2nd row
  3057. * @param initialM22 defines 2nd value of 2nd row
  3058. * @param initialM23 defines 3rd value of 2nd row
  3059. * @param initialM24 defines 4th value of 2nd row
  3060. * @param initialM31 defines 1st value of 3rd row
  3061. * @param initialM32 defines 2nd value of 3rd row
  3062. * @param initialM33 defines 3rd value of 3rd row
  3063. * @param initialM34 defines 4th value of 3rd row
  3064. * @param initialM41 defines 1st value of 4th row
  3065. * @param initialM42 defines 2nd value of 4th row
  3066. * @param initialM43 defines 3rd value of 4th row
  3067. * @param initialM44 defines 4th value of 4th row
  3068. * @param result defines the target matrix
  3069. */
  3070. 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;
  3071. /**
  3072. * Creates new matrix from a list of values (16)
  3073. * @param initialM11 defines 1st value of 1st row
  3074. * @param initialM12 defines 2nd value of 1st row
  3075. * @param initialM13 defines 3rd value of 1st row
  3076. * @param initialM14 defines 4th value of 1st row
  3077. * @param initialM21 defines 1st value of 2nd row
  3078. * @param initialM22 defines 2nd value of 2nd row
  3079. * @param initialM23 defines 3rd value of 2nd row
  3080. * @param initialM24 defines 4th value of 2nd row
  3081. * @param initialM31 defines 1st value of 3rd row
  3082. * @param initialM32 defines 2nd value of 3rd row
  3083. * @param initialM33 defines 3rd value of 3rd row
  3084. * @param initialM34 defines 4th value of 3rd row
  3085. * @param initialM41 defines 1st value of 4th row
  3086. * @param initialM42 defines 2nd value of 4th row
  3087. * @param initialM43 defines 3rd value of 4th row
  3088. * @param initialM44 defines 4th value of 4th row
  3089. * @returns the new matrix
  3090. */
  3091. 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;
  3092. /**
  3093. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3094. * @param scale defines the scale vector3
  3095. * @param rotation defines the rotation quaternion
  3096. * @param translation defines the translation vector3
  3097. * @returns a new matrix
  3098. */
  3099. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3100. /**
  3101. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3102. * @param scale defines the scale vector3
  3103. * @param rotation defines the rotation quaternion
  3104. * @param translation defines the translation vector3
  3105. * @param result defines the target matrix
  3106. */
  3107. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3108. /**
  3109. * Creates a new identity matrix
  3110. * @returns a new identity matrix
  3111. */
  3112. static Identity(): Matrix;
  3113. /**
  3114. * Creates a new identity matrix and stores the result in a given matrix
  3115. * @param result defines the target matrix
  3116. */
  3117. static IdentityToRef(result: Matrix): void;
  3118. /**
  3119. * Creates a new zero matrix
  3120. * @returns a new zero matrix
  3121. */
  3122. static Zero(): Matrix;
  3123. /**
  3124. * Creates a new rotation matrix for "angle" radians around the X axis
  3125. * @param angle defines the angle (in radians) to use
  3126. * @return the new matrix
  3127. */
  3128. static RotationX(angle: number): Matrix;
  3129. /**
  3130. * Creates a new matrix as the invert of a given matrix
  3131. * @param source defines the source matrix
  3132. * @returns the new matrix
  3133. */
  3134. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3135. /**
  3136. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3137. * @param angle defines the angle (in radians) to use
  3138. * @param result defines the target matrix
  3139. */
  3140. static RotationXToRef(angle: number, result: Matrix): void;
  3141. /**
  3142. * Creates a new rotation matrix for "angle" radians around the Y axis
  3143. * @param angle defines the angle (in radians) to use
  3144. * @return the new matrix
  3145. */
  3146. static RotationY(angle: number): Matrix;
  3147. /**
  3148. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3149. * @param angle defines the angle (in radians) to use
  3150. * @param result defines the target matrix
  3151. */
  3152. static RotationYToRef(angle: number, result: Matrix): void;
  3153. /**
  3154. * Creates a new rotation matrix for "angle" radians around the Z axis
  3155. * @param angle defines the angle (in radians) to use
  3156. * @return the new matrix
  3157. */
  3158. static RotationZ(angle: number): Matrix;
  3159. /**
  3160. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3161. * @param angle defines the angle (in radians) to use
  3162. * @param result defines the target matrix
  3163. */
  3164. static RotationZToRef(angle: number, result: Matrix): void;
  3165. /**
  3166. * Creates a new rotation matrix for "angle" radians around the given axis
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle (in radians) to use
  3169. * @return the new matrix
  3170. */
  3171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @param result defines the target matrix
  3177. */
  3178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3179. /**
  3180. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3181. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3182. * @param from defines the vector to align
  3183. * @param to defines the vector to align to
  3184. * @param result defines the target matrix
  3185. */
  3186. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3187. /**
  3188. * Creates a rotation matrix
  3189. * @param yaw defines the yaw angle in radians (Y axis)
  3190. * @param pitch defines the pitch angle in radians (X axis)
  3191. * @param roll defines the roll angle in radians (X axis)
  3192. * @returns the new rotation matrix
  3193. */
  3194. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3195. /**
  3196. * Creates a rotation matrix and stores it in a given matrix
  3197. * @param yaw defines the yaw angle in radians (Y axis)
  3198. * @param pitch defines the pitch angle in radians (X axis)
  3199. * @param roll defines the roll angle in radians (X axis)
  3200. * @param result defines the target matrix
  3201. */
  3202. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3203. /**
  3204. * Creates a scaling matrix
  3205. * @param x defines the scale factor on X axis
  3206. * @param y defines the scale factor on Y axis
  3207. * @param z defines the scale factor on Z axis
  3208. * @returns the new matrix
  3209. */
  3210. static Scaling(x: number, y: number, z: number): Matrix;
  3211. /**
  3212. * Creates a scaling matrix and stores it in a given matrix
  3213. * @param x defines the scale factor on X axis
  3214. * @param y defines the scale factor on Y axis
  3215. * @param z defines the scale factor on Z axis
  3216. * @param result defines the target matrix
  3217. */
  3218. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3219. /**
  3220. * Creates a translation matrix
  3221. * @param x defines the translation on X axis
  3222. * @param y defines the translation on Y axis
  3223. * @param z defines the translationon Z axis
  3224. * @returns the new matrix
  3225. */
  3226. static Translation(x: number, y: number, z: number): Matrix;
  3227. /**
  3228. * Creates a translation matrix and stores it in a given matrix
  3229. * @param x defines the translation on X axis
  3230. * @param y defines the translation on Y axis
  3231. * @param z defines the translationon Z axis
  3232. * @param result defines the target matrix
  3233. */
  3234. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3235. /**
  3236. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3237. * @param startValue defines the start value
  3238. * @param endValue defines the end value
  3239. * @param gradient defines the gradient factor
  3240. * @returns the new matrix
  3241. */
  3242. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3243. /**
  3244. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3245. * @param startValue defines the start value
  3246. * @param endValue defines the end value
  3247. * @param gradient defines the gradient factor
  3248. * @param result defines the Matrix object where to store data
  3249. */
  3250. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3251. /**
  3252. * Builds a new matrix whose values are computed by:
  3253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3256. * @param startValue defines the first matrix
  3257. * @param endValue defines the second matrix
  3258. * @param gradient defines the gradient between the two matrices
  3259. * @returns the new matrix
  3260. */
  3261. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3262. /**
  3263. * Update a matrix to values which are computed by:
  3264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3267. * @param startValue defines the first matrix
  3268. * @param endValue defines the second matrix
  3269. * @param gradient defines the gradient between the two matrices
  3270. * @param result defines the target matrix
  3271. */
  3272. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3273. /**
  3274. * 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"
  3275. * This function works in left handed mode
  3276. * @param eye defines the final position of the entity
  3277. * @param target defines where the entity should look at
  3278. * @param up defines the up vector for the entity
  3279. * @returns the new matrix
  3280. */
  3281. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3282. /**
  3283. * 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".
  3284. * This function works in left handed mode
  3285. * @param eye defines the final position of the entity
  3286. * @param target defines where the entity should look at
  3287. * @param up defines the up vector for the entity
  3288. * @param result defines the target matrix
  3289. */
  3290. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3291. /**
  3292. * 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"
  3293. * This function works in right handed mode
  3294. * @param eye defines the final position of the entity
  3295. * @param target defines where the entity should look at
  3296. * @param up defines the up vector for the entity
  3297. * @returns the new matrix
  3298. */
  3299. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3300. /**
  3301. * 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".
  3302. * This function works in right handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @param result defines the target matrix
  3307. */
  3308. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3309. /**
  3310. * Create a left-handed orthographic projection matrix
  3311. * @param width defines the viewport width
  3312. * @param height defines the viewport height
  3313. * @param znear defines the near clip plane
  3314. * @param zfar defines the far clip plane
  3315. * @returns a new matrix as a left-handed orthographic projection matrix
  3316. */
  3317. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3318. /**
  3319. * Store a left-handed orthographic projection to a given matrix
  3320. * @param width defines the viewport width
  3321. * @param height defines the viewport height
  3322. * @param znear defines the near clip plane
  3323. * @param zfar defines the far clip plane
  3324. * @param result defines the target matrix
  3325. */
  3326. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3327. /**
  3328. * Create a left-handed orthographic projection matrix
  3329. * @param left defines the viewport left coordinate
  3330. * @param right defines the viewport right coordinate
  3331. * @param bottom defines the viewport bottom coordinate
  3332. * @param top defines the viewport top coordinate
  3333. * @param znear defines the near clip plane
  3334. * @param zfar defines the far clip plane
  3335. * @returns a new matrix as a left-handed orthographic projection matrix
  3336. */
  3337. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3338. /**
  3339. * Stores a left-handed orthographic projection into a given matrix
  3340. * @param left defines the viewport left coordinate
  3341. * @param right defines the viewport right coordinate
  3342. * @param bottom defines the viewport bottom coordinate
  3343. * @param top defines the viewport top coordinate
  3344. * @param znear defines the near clip plane
  3345. * @param zfar defines the far clip plane
  3346. * @param result defines the target matrix
  3347. */
  3348. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3349. /**
  3350. * Creates a right-handed orthographic projection matrix
  3351. * @param left defines the viewport left coordinate
  3352. * @param right defines the viewport right coordinate
  3353. * @param bottom defines the viewport bottom coordinate
  3354. * @param top defines the viewport top coordinate
  3355. * @param znear defines the near clip plane
  3356. * @param zfar defines the far clip plane
  3357. * @returns a new matrix as a right-handed orthographic projection matrix
  3358. */
  3359. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3360. /**
  3361. * Stores a right-handed orthographic projection into a given matrix
  3362. * @param left defines the viewport left coordinate
  3363. * @param right defines the viewport right coordinate
  3364. * @param bottom defines the viewport bottom coordinate
  3365. * @param top defines the viewport top coordinate
  3366. * @param znear defines the near clip plane
  3367. * @param zfar defines the far clip plane
  3368. * @param result defines the target matrix
  3369. */
  3370. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3371. /**
  3372. * Creates a left-handed perspective projection matrix
  3373. * @param width defines the viewport width
  3374. * @param height defines the viewport height
  3375. * @param znear defines the near clip plane
  3376. * @param zfar defines the far clip plane
  3377. * @returns a new matrix as a left-handed perspective projection matrix
  3378. */
  3379. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3380. /**
  3381. * Creates a left-handed perspective projection matrix
  3382. * @param fov defines the horizontal field of view
  3383. * @param aspect defines the aspect ratio
  3384. * @param znear defines the near clip plane
  3385. * @param zfar defines the far clip plane
  3386. * @returns a new matrix as a left-handed perspective projection matrix
  3387. */
  3388. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3389. /**
  3390. * Stores a left-handed perspective projection into a given matrix
  3391. * @param fov defines the horizontal field of view
  3392. * @param aspect defines the aspect ratio
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3397. */
  3398. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3399. /**
  3400. * Creates a right-handed perspective projection matrix
  3401. * @param fov defines the horizontal field of view
  3402. * @param aspect defines the aspect ratio
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a right-handed perspective projection matrix
  3406. */
  3407. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a right-handed perspective projection into a given matrix
  3410. * @param fov defines the horizontal field of view
  3411. * @param aspect defines the aspect ratio
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3416. */
  3417. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3418. /**
  3419. * Stores a perspective projection for WebVR info a given matrix
  3420. * @param fov defines the field of view
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @param result defines the target matrix
  3424. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3425. */
  3426. static PerspectiveFovWebVRToRef(fov: {
  3427. upDegrees: number;
  3428. downDegrees: number;
  3429. leftDegrees: number;
  3430. rightDegrees: number;
  3431. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3432. /**
  3433. * Computes a complete transformation matrix
  3434. * @param viewport defines the viewport to use
  3435. * @param world defines the world matrix
  3436. * @param view defines the view matrix
  3437. * @param projection defines the projection matrix
  3438. * @param zmin defines the near clip plane
  3439. * @param zmax defines the far clip plane
  3440. * @returns the transformation matrix
  3441. */
  3442. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3443. /**
  3444. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3445. * @param matrix defines the matrix to use
  3446. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3447. */
  3448. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3449. /**
  3450. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3451. * @param matrix defines the matrix to use
  3452. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3453. */
  3454. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3455. /**
  3456. * Compute the transpose of a given matrix
  3457. * @param matrix defines the matrix to transpose
  3458. * @returns the new matrix
  3459. */
  3460. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3461. /**
  3462. * Compute the transpose of a matrix and store it in a target matrix
  3463. * @param matrix defines the matrix to transpose
  3464. * @param result defines the target matrix
  3465. */
  3466. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3467. /**
  3468. * Computes a reflection matrix from a plane
  3469. * @param plane defines the reflection plane
  3470. * @returns a new matrix
  3471. */
  3472. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3473. /**
  3474. * Computes a reflection matrix from a plane
  3475. * @param plane defines the reflection plane
  3476. * @param result defines the target matrix
  3477. */
  3478. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3479. /**
  3480. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3481. * @param xaxis defines the value of the 1st axis
  3482. * @param yaxis defines the value of the 2nd axis
  3483. * @param zaxis defines the value of the 3rd axis
  3484. * @param result defines the target matrix
  3485. */
  3486. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3487. /**
  3488. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3489. * @param quat defines the quaternion to use
  3490. * @param result defines the target matrix
  3491. */
  3492. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3493. }
  3494. /**
  3495. * @hidden
  3496. */
  3497. export class TmpVectors {
  3498. static Vector2: Vector2[];
  3499. static Vector3: Vector3[];
  3500. static Vector4: Vector4[];
  3501. static Quaternion: Quaternion[];
  3502. static Matrix: Matrix[];
  3503. }
  3504. }
  3505. declare module BABYLON {
  3506. /**
  3507. * Class used to hold a RBG color
  3508. */
  3509. export class Color3 {
  3510. /**
  3511. * Defines the red component (between 0 and 1, default is 0)
  3512. */
  3513. r: number;
  3514. /**
  3515. * Defines the green component (between 0 and 1, default is 0)
  3516. */
  3517. g: number;
  3518. /**
  3519. * Defines the blue component (between 0 and 1, default is 0)
  3520. */
  3521. b: number;
  3522. /**
  3523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3524. * @param r defines the red component (between 0 and 1, default is 0)
  3525. * @param g defines the green component (between 0 and 1, default is 0)
  3526. * @param b defines the blue component (between 0 and 1, default is 0)
  3527. */
  3528. constructor(
  3529. /**
  3530. * Defines the red component (between 0 and 1, default is 0)
  3531. */
  3532. r?: number,
  3533. /**
  3534. * Defines the green component (between 0 and 1, default is 0)
  3535. */
  3536. g?: number,
  3537. /**
  3538. * Defines the blue component (between 0 and 1, default is 0)
  3539. */
  3540. b?: number);
  3541. /**
  3542. * Creates a string with the Color3 current values
  3543. * @returns the string representation of the Color3 object
  3544. */
  3545. toString(): string;
  3546. /**
  3547. * Returns the string "Color3"
  3548. * @returns "Color3"
  3549. */
  3550. getClassName(): string;
  3551. /**
  3552. * Compute the Color3 hash code
  3553. * @returns an unique number that can be used to hash Color3 objects
  3554. */
  3555. getHashCode(): number;
  3556. /**
  3557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3558. * @param array defines the array where to store the r,g,b components
  3559. * @param index defines an optional index in the target array to define where to start storing values
  3560. * @returns the current Color3 object
  3561. */
  3562. toArray(array: FloatArray, index?: number): Color3;
  3563. /**
  3564. * Returns a new Color4 object from the current Color3 and the given alpha
  3565. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3566. * @returns a new Color4 object
  3567. */
  3568. toColor4(alpha?: number): Color4;
  3569. /**
  3570. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3571. * @returns the new array
  3572. */
  3573. asArray(): number[];
  3574. /**
  3575. * Returns the luminance value
  3576. * @returns a float value
  3577. */
  3578. toLuminance(): number;
  3579. /**
  3580. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3581. * @param otherColor defines the second operand
  3582. * @returns the new Color3 object
  3583. */
  3584. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3585. /**
  3586. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3587. * @param otherColor defines the second operand
  3588. * @param result defines the Color3 object where to store the result
  3589. * @returns the current Color3
  3590. */
  3591. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3592. /**
  3593. * Determines equality between Color3 objects
  3594. * @param otherColor defines the second operand
  3595. * @returns true if the rgb values are equal to the given ones
  3596. */
  3597. equals(otherColor: DeepImmutable<Color3>): boolean;
  3598. /**
  3599. * Determines equality between the current Color3 object and a set of r,b,g values
  3600. * @param r defines the red component to check
  3601. * @param g defines the green component to check
  3602. * @param b defines the blue component to check
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equalsFloats(r: number, g: number, b: number): boolean;
  3606. /**
  3607. * Multiplies in place each rgb value by scale
  3608. * @param scale defines the scaling factor
  3609. * @returns the updated Color3
  3610. */
  3611. scale(scale: number): Color3;
  3612. /**
  3613. * Multiplies the rgb values by scale and stores the result into "result"
  3614. * @param scale defines the scaling factor
  3615. * @param result defines the Color3 object where to store the result
  3616. * @returns the unmodified current Color3
  3617. */
  3618. scaleToRef(scale: number, result: Color3): Color3;
  3619. /**
  3620. * Scale the current Color3 values by a factor and add the result to a given Color3
  3621. * @param scale defines the scale factor
  3622. * @param result defines color to store the result into
  3623. * @returns the unmodified current Color3
  3624. */
  3625. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3626. /**
  3627. * Clamps the rgb values by the min and max values and stores the result into "result"
  3628. * @param min defines minimum clamping value (default is 0)
  3629. * @param max defines maximum clamping value (default is 1)
  3630. * @param result defines color to store the result into
  3631. * @returns the original Color3
  3632. */
  3633. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3634. /**
  3635. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3636. * @param otherColor defines the second operand
  3637. * @returns the new Color3
  3638. */
  3639. add(otherColor: DeepImmutable<Color3>): Color3;
  3640. /**
  3641. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3642. * @param otherColor defines the second operand
  3643. * @param result defines Color3 object to store the result into
  3644. * @returns the unmodified current Color3
  3645. */
  3646. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3647. /**
  3648. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3649. * @param otherColor defines the second operand
  3650. * @returns the new Color3
  3651. */
  3652. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3653. /**
  3654. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3655. * @param otherColor defines the second operand
  3656. * @param result defines Color3 object to store the result into
  3657. * @returns the unmodified current Color3
  3658. */
  3659. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3660. /**
  3661. * Copy the current object
  3662. * @returns a new Color3 copied the current one
  3663. */
  3664. clone(): Color3;
  3665. /**
  3666. * Copies the rgb values from the source in the current Color3
  3667. * @param source defines the source Color3 object
  3668. * @returns the updated Color3 object
  3669. */
  3670. copyFrom(source: DeepImmutable<Color3>): Color3;
  3671. /**
  3672. * Updates the Color3 rgb values from the given floats
  3673. * @param r defines the red component to read from
  3674. * @param g defines the green component to read from
  3675. * @param b defines the blue component to read from
  3676. * @returns the current Color3 object
  3677. */
  3678. copyFromFloats(r: number, g: number, b: number): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. set(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Compute the Color3 hexadecimal code as a string
  3689. * @returns a string containing the hexadecimal representation of the Color3 object
  3690. */
  3691. toHexString(): string;
  3692. /**
  3693. * Computes a new Color3 converted from the current one to linear space
  3694. * @returns a new Color3 object
  3695. */
  3696. toLinearSpace(): Color3;
  3697. /**
  3698. * Converts current color in rgb space to HSV values
  3699. * @returns a new color3 representing the HSV values
  3700. */
  3701. toHSV(): Color3;
  3702. /**
  3703. * Converts current color in rgb space to HSV values
  3704. * @param result defines the Color3 where to store the HSV values
  3705. */
  3706. toHSVToRef(result: Color3): void;
  3707. /**
  3708. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3709. * @param convertedColor defines the Color3 object where to store the linear space version
  3710. * @returns the unmodified Color3
  3711. */
  3712. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3713. /**
  3714. * Computes a new Color3 converted from the current one to gamma space
  3715. * @returns a new Color3 object
  3716. */
  3717. toGammaSpace(): Color3;
  3718. /**
  3719. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3720. * @param convertedColor defines the Color3 object where to store the gamma space version
  3721. * @returns the unmodified Color3
  3722. */
  3723. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3724. private static _BlackReadOnly;
  3725. /**
  3726. * Convert Hue, saturation and value to a Color3 (RGB)
  3727. * @param hue defines the hue
  3728. * @param saturation defines the saturation
  3729. * @param value defines the value
  3730. * @param result defines the Color3 where to store the RGB values
  3731. */
  3732. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3733. /**
  3734. * Creates a new Color3 from the string containing valid hexadecimal values
  3735. * @param hex defines a string containing valid hexadecimal values
  3736. * @returns a new Color3 object
  3737. */
  3738. static FromHexString(hex: string): Color3;
  3739. /**
  3740. * Creates a new Color3 from the starting index of the given array
  3741. * @param array defines the source array
  3742. * @param offset defines an offset in the source array
  3743. * @returns a new Color3 object
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3746. /**
  3747. * Creates a new Color3 from integer values (< 256)
  3748. * @param r defines the red component to read from (value between 0 and 255)
  3749. * @param g defines the green component to read from (value between 0 and 255)
  3750. * @param b defines the blue component to read from (value between 0 and 255)
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromInts(r: number, g: number, b: number): Color3;
  3754. /**
  3755. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3756. * @param start defines the start Color3 value
  3757. * @param end defines the end Color3 value
  3758. * @param amount defines the gradient value between start and end
  3759. * @returns a new Color3 object
  3760. */
  3761. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param left defines the start value
  3765. * @param right defines the end value
  3766. * @param amount defines the gradient factor
  3767. * @param result defines the Color3 object where to store the result
  3768. */
  3769. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3770. /**
  3771. * Returns a Color3 value containing a red color
  3772. * @returns a new Color3 object
  3773. */
  3774. static Red(): Color3;
  3775. /**
  3776. * Returns a Color3 value containing a green color
  3777. * @returns a new Color3 object
  3778. */
  3779. static Green(): Color3;
  3780. /**
  3781. * Returns a Color3 value containing a blue color
  3782. * @returns a new Color3 object
  3783. */
  3784. static Blue(): Color3;
  3785. /**
  3786. * Returns a Color3 value containing a black color
  3787. * @returns a new Color3 object
  3788. */
  3789. static Black(): Color3;
  3790. /**
  3791. * Gets a Color3 value containing a black color that must not be updated
  3792. */
  3793. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3794. /**
  3795. * Returns a Color3 value containing a white color
  3796. * @returns a new Color3 object
  3797. */
  3798. static White(): Color3;
  3799. /**
  3800. * Returns a Color3 value containing a purple color
  3801. * @returns a new Color3 object
  3802. */
  3803. static Purple(): Color3;
  3804. /**
  3805. * Returns a Color3 value containing a magenta color
  3806. * @returns a new Color3 object
  3807. */
  3808. static Magenta(): Color3;
  3809. /**
  3810. * Returns a Color3 value containing a yellow color
  3811. * @returns a new Color3 object
  3812. */
  3813. static Yellow(): Color3;
  3814. /**
  3815. * Returns a Color3 value containing a gray color
  3816. * @returns a new Color3 object
  3817. */
  3818. static Gray(): Color3;
  3819. /**
  3820. * Returns a Color3 value containing a teal color
  3821. * @returns a new Color3 object
  3822. */
  3823. static Teal(): Color3;
  3824. /**
  3825. * Returns a Color3 value containing a random color
  3826. * @returns a new Color3 object
  3827. */
  3828. static Random(): Color3;
  3829. }
  3830. /**
  3831. * Class used to hold a RBGA color
  3832. */
  3833. export class Color4 {
  3834. /**
  3835. * Defines the red component (between 0 and 1, default is 0)
  3836. */
  3837. r: number;
  3838. /**
  3839. * Defines the green component (between 0 and 1, default is 0)
  3840. */
  3841. g: number;
  3842. /**
  3843. * Defines the blue component (between 0 and 1, default is 0)
  3844. */
  3845. b: number;
  3846. /**
  3847. * Defines the alpha component (between 0 and 1, default is 1)
  3848. */
  3849. a: number;
  3850. /**
  3851. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3852. * @param r defines the red component (between 0 and 1, default is 0)
  3853. * @param g defines the green component (between 0 and 1, default is 0)
  3854. * @param b defines the blue component (between 0 and 1, default is 0)
  3855. * @param a defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. constructor(
  3858. /**
  3859. * Defines the red component (between 0 and 1, default is 0)
  3860. */
  3861. r?: number,
  3862. /**
  3863. * Defines the green component (between 0 and 1, default is 0)
  3864. */
  3865. g?: number,
  3866. /**
  3867. * Defines the blue component (between 0 and 1, default is 0)
  3868. */
  3869. b?: number,
  3870. /**
  3871. * Defines the alpha component (between 0 and 1, default is 1)
  3872. */
  3873. a?: number);
  3874. /**
  3875. * Adds in place the given Color4 values to the current Color4 object
  3876. * @param right defines the second operand
  3877. * @returns the current updated Color4 object
  3878. */
  3879. addInPlace(right: DeepImmutable<Color4>): Color4;
  3880. /**
  3881. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3882. * @returns the new array
  3883. */
  3884. asArray(): number[];
  3885. /**
  3886. * Stores from the starting index in the given array the Color4 successive values
  3887. * @param array defines the array where to store the r,g,b components
  3888. * @param index defines an optional index in the target array to define where to start storing values
  3889. * @returns the current Color4 object
  3890. */
  3891. toArray(array: number[], index?: number): Color4;
  3892. /**
  3893. * Determines equality between Color4 objects
  3894. * @param otherColor defines the second operand
  3895. * @returns true if the rgba values are equal to the given ones
  3896. */
  3897. equals(otherColor: DeepImmutable<Color4>): boolean;
  3898. /**
  3899. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3900. * @param right defines the second operand
  3901. * @returns a new Color4 object
  3902. */
  3903. add(right: DeepImmutable<Color4>): Color4;
  3904. /**
  3905. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3906. * @param right defines the second operand
  3907. * @returns a new Color4 object
  3908. */
  3909. subtract(right: DeepImmutable<Color4>): Color4;
  3910. /**
  3911. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3912. * @param right defines the second operand
  3913. * @param result defines the Color4 object where to store the result
  3914. * @returns the current Color4 object
  3915. */
  3916. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3917. /**
  3918. * Creates a new Color4 with the current Color4 values multiplied by scale
  3919. * @param scale defines the scaling factor to apply
  3920. * @returns a new Color4 object
  3921. */
  3922. scale(scale: number): Color4;
  3923. /**
  3924. * Multiplies the current Color4 values by scale and stores the result in "result"
  3925. * @param scale defines the scaling factor to apply
  3926. * @param result defines the Color4 object where to store the result
  3927. * @returns the current unmodified Color4
  3928. */
  3929. scaleToRef(scale: number, result: Color4): Color4;
  3930. /**
  3931. * Scale the current Color4 values by a factor and add the result to a given Color4
  3932. * @param scale defines the scale factor
  3933. * @param result defines the Color4 object where to store the result
  3934. * @returns the unmodified current Color4
  3935. */
  3936. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3937. /**
  3938. * Clamps the rgb values by the min and max values and stores the result into "result"
  3939. * @param min defines minimum clamping value (default is 0)
  3940. * @param max defines maximum clamping value (default is 1)
  3941. * @param result defines color to store the result into.
  3942. * @returns the cuurent Color4
  3943. */
  3944. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3945. /**
  3946. * Multipy an Color4 value by another and return a new Color4 object
  3947. * @param color defines the Color4 value to multiply by
  3948. * @returns a new Color4 object
  3949. */
  3950. multiply(color: Color4): Color4;
  3951. /**
  3952. * Multipy a Color4 value by another and push the result in a reference value
  3953. * @param color defines the Color4 value to multiply by
  3954. * @param result defines the Color4 to fill the result in
  3955. * @returns the result Color4
  3956. */
  3957. multiplyToRef(color: Color4, result: Color4): Color4;
  3958. /**
  3959. * Creates a string with the Color4 current values
  3960. * @returns the string representation of the Color4 object
  3961. */
  3962. toString(): string;
  3963. /**
  3964. * Returns the string "Color4"
  3965. * @returns "Color4"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Compute the Color4 hash code
  3970. * @returns an unique number that can be used to hash Color4 objects
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Creates a new Color4 copied from the current one
  3975. * @returns a new Color4 object
  3976. */
  3977. clone(): Color4;
  3978. /**
  3979. * Copies the given Color4 values into the current one
  3980. * @param source defines the source Color4 object
  3981. * @returns the current updated Color4 object
  3982. */
  3983. copyFrom(source: Color4): Color4;
  3984. /**
  3985. * Copies the given float values into the current one
  3986. * @param r defines the red component to read from
  3987. * @param g defines the green component to read from
  3988. * @param b defines the blue component to read from
  3989. * @param a defines the alpha component to read from
  3990. * @returns the current updated Color4 object
  3991. */
  3992. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3993. /**
  3994. * Copies the given float values into the current one
  3995. * @param r defines the red component to read from
  3996. * @param g defines the green component to read from
  3997. * @param b defines the blue component to read from
  3998. * @param a defines the alpha component to read from
  3999. * @returns the current updated Color4 object
  4000. */
  4001. set(r: number, g: number, b: number, a: number): Color4;
  4002. /**
  4003. * Compute the Color4 hexadecimal code as a string
  4004. * @returns a string containing the hexadecimal representation of the Color4 object
  4005. */
  4006. toHexString(): string;
  4007. /**
  4008. * Computes a new Color4 converted from the current one to linear space
  4009. * @returns a new Color4 object
  4010. */
  4011. toLinearSpace(): Color4;
  4012. /**
  4013. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4014. * @param convertedColor defines the Color4 object where to store the linear space version
  4015. * @returns the unmodified Color4
  4016. */
  4017. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4018. /**
  4019. * Computes a new Color4 converted from the current one to gamma space
  4020. * @returns a new Color4 object
  4021. */
  4022. toGammaSpace(): Color4;
  4023. /**
  4024. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4025. * @param convertedColor defines the Color4 object where to store the gamma space version
  4026. * @returns the unmodified Color4
  4027. */
  4028. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4029. /**
  4030. * Creates a new Color4 from the string containing valid hexadecimal values
  4031. * @param hex defines a string containing valid hexadecimal values
  4032. * @returns a new Color4 object
  4033. */
  4034. static FromHexString(hex: string): Color4;
  4035. /**
  4036. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4037. * @param left defines the start value
  4038. * @param right defines the end value
  4039. * @param amount defines the gradient factor
  4040. * @returns a new Color4 object
  4041. */
  4042. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4043. /**
  4044. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @param result defines the Color4 object where to store data
  4049. */
  4050. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4051. /**
  4052. * Creates a new Color4 from a Color3 and an alpha value
  4053. * @param color3 defines the source Color3 to read from
  4054. * @param alpha defines the alpha component (1.0 by default)
  4055. * @returns a new Color4 object
  4056. */
  4057. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4058. /**
  4059. * Creates a new Color4 from the starting index element of the given array
  4060. * @param array defines the source array to read from
  4061. * @param offset defines the offset in the source array
  4062. * @returns a new Color4 object
  4063. */
  4064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4065. /**
  4066. * Creates a new Color3 from integer values (< 256)
  4067. * @param r defines the red component to read from (value between 0 and 255)
  4068. * @param g defines the green component to read from (value between 0 and 255)
  4069. * @param b defines the blue component to read from (value between 0 and 255)
  4070. * @param a defines the alpha component to read from (value between 0 and 255)
  4071. * @returns a new Color3 object
  4072. */
  4073. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4074. /**
  4075. * Check the content of a given array and convert it to an array containing RGBA data
  4076. * If the original array was already containing count * 4 values then it is returned directly
  4077. * @param colors defines the array to check
  4078. * @param count defines the number of RGBA data to expect
  4079. * @returns an array containing count * 4 values (RGBA)
  4080. */
  4081. static CheckColors4(colors: number[], count: number): number[];
  4082. }
  4083. /**
  4084. * @hidden
  4085. */
  4086. export class TmpColors {
  4087. static Color3: Color3[];
  4088. static Color4: Color4[];
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. /**
  4093. * Class representing spherical harmonics coefficients to the 3rd degree
  4094. */
  4095. export class SphericalHarmonics {
  4096. /**
  4097. * Defines whether or not the harmonics have been prescaled for rendering.
  4098. */
  4099. preScaled: boolean;
  4100. /**
  4101. * The l0,0 coefficients of the spherical harmonics
  4102. */
  4103. l00: Vector3;
  4104. /**
  4105. * The l1,-1 coefficients of the spherical harmonics
  4106. */
  4107. l1_1: Vector3;
  4108. /**
  4109. * The l1,0 coefficients of the spherical harmonics
  4110. */
  4111. l10: Vector3;
  4112. /**
  4113. * The l1,1 coefficients of the spherical harmonics
  4114. */
  4115. l11: Vector3;
  4116. /**
  4117. * The l2,-2 coefficients of the spherical harmonics
  4118. */
  4119. l2_2: Vector3;
  4120. /**
  4121. * The l2,-1 coefficients of the spherical harmonics
  4122. */
  4123. l2_1: Vector3;
  4124. /**
  4125. * The l2,0 coefficients of the spherical harmonics
  4126. */
  4127. l20: Vector3;
  4128. /**
  4129. * The l2,1 coefficients of the spherical harmonics
  4130. */
  4131. l21: Vector3;
  4132. /**
  4133. * The l2,2 coefficients of the spherical harmonics
  4134. */
  4135. l22: Vector3;
  4136. /**
  4137. * Adds a light to the spherical harmonics
  4138. * @param direction the direction of the light
  4139. * @param color the color of the light
  4140. * @param deltaSolidAngle the delta solid angle of the light
  4141. */
  4142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4143. /**
  4144. * Scales the spherical harmonics by the given amount
  4145. * @param scale the amount to scale
  4146. */
  4147. scaleInPlace(scale: number): void;
  4148. /**
  4149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4150. *
  4151. * ```
  4152. * E_lm = A_l * L_lm
  4153. * ```
  4154. *
  4155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4157. * the scaling factors are given in equation 9.
  4158. */
  4159. convertIncidentRadianceToIrradiance(): void;
  4160. /**
  4161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4162. *
  4163. * ```
  4164. * L = (1/pi) * E * rho
  4165. * ```
  4166. *
  4167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4168. */
  4169. convertIrradianceToLambertianRadiance(): void;
  4170. /**
  4171. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4172. * required operations at run time.
  4173. *
  4174. * This is simply done by scaling back the SH with Ylm constants parameter.
  4175. * The trigonometric part being applied by the shader at run time.
  4176. */
  4177. preScaleForRendering(): void;
  4178. /**
  4179. * Constructs a spherical harmonics from an array.
  4180. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4181. * @returns the spherical harmonics
  4182. */
  4183. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4184. /**
  4185. * Gets the spherical harmonics from polynomial
  4186. * @param polynomial the spherical polynomial
  4187. * @returns the spherical harmonics
  4188. */
  4189. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4190. }
  4191. /**
  4192. * Class representing spherical polynomial coefficients to the 3rd degree
  4193. */
  4194. export class SphericalPolynomial {
  4195. private _harmonics;
  4196. /**
  4197. * The spherical harmonics used to create the polynomials.
  4198. */
  4199. readonly preScaledHarmonics: SphericalHarmonics;
  4200. /**
  4201. * The x coefficients of the spherical polynomial
  4202. */
  4203. x: Vector3;
  4204. /**
  4205. * The y coefficients of the spherical polynomial
  4206. */
  4207. y: Vector3;
  4208. /**
  4209. * The z coefficients of the spherical polynomial
  4210. */
  4211. z: Vector3;
  4212. /**
  4213. * The xx coefficients of the spherical polynomial
  4214. */
  4215. xx: Vector3;
  4216. /**
  4217. * The yy coefficients of the spherical polynomial
  4218. */
  4219. yy: Vector3;
  4220. /**
  4221. * The zz coefficients of the spherical polynomial
  4222. */
  4223. zz: Vector3;
  4224. /**
  4225. * The xy coefficients of the spherical polynomial
  4226. */
  4227. xy: Vector3;
  4228. /**
  4229. * The yz coefficients of the spherical polynomial
  4230. */
  4231. yz: Vector3;
  4232. /**
  4233. * The zx coefficients of the spherical polynomial
  4234. */
  4235. zx: Vector3;
  4236. /**
  4237. * Adds an ambient color to the spherical polynomial
  4238. * @param color the color to add
  4239. */
  4240. addAmbient(color: Color3): void;
  4241. /**
  4242. * Scales the spherical polynomial by the given amount
  4243. * @param scale the amount to scale
  4244. */
  4245. scaleInPlace(scale: number): void;
  4246. /**
  4247. * Gets the spherical polynomial from harmonics
  4248. * @param harmonics the spherical harmonics
  4249. * @returns the spherical polynomial
  4250. */
  4251. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4252. /**
  4253. * Constructs a spherical polynomial from an array.
  4254. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4255. * @returns the spherical polynomial
  4256. */
  4257. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4258. }
  4259. }
  4260. declare module BABYLON {
  4261. /**
  4262. * Define options used to create a render target texture
  4263. */
  4264. export class RenderTargetCreationOptions {
  4265. /**
  4266. * Specifies is mipmaps must be generated
  4267. */
  4268. generateMipMaps?: boolean;
  4269. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4270. generateDepthBuffer?: boolean;
  4271. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4272. generateStencilBuffer?: boolean;
  4273. /** Defines texture type (int by default) */
  4274. type?: number;
  4275. /** Defines sampling mode (trilinear by default) */
  4276. samplingMode?: number;
  4277. /** Defines format (RGBA by default) */
  4278. format?: number;
  4279. }
  4280. }
  4281. declare module BABYLON {
  4282. /**
  4283. * @hidden
  4284. **/
  4285. export class _TimeToken {
  4286. _startTimeQuery: Nullable<WebGLQuery>;
  4287. _endTimeQuery: Nullable<WebGLQuery>;
  4288. _timeElapsedQuery: Nullable<WebGLQuery>;
  4289. _timeElapsedQueryEnded: boolean;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /** Defines the cross module used constants to avoid circular dependncies */
  4294. export class Constants {
  4295. /** Defines that alpha blending is disabled */
  4296. static readonly ALPHA_DISABLE: number;
  4297. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4298. static readonly ALPHA_ADD: number;
  4299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4300. static readonly ALPHA_COMBINE: number;
  4301. /** Defines that alpha blending to DEST - SRC * DEST */
  4302. static readonly ALPHA_SUBTRACT: number;
  4303. /** Defines that alpha blending to SRC * DEST */
  4304. static readonly ALPHA_MULTIPLY: number;
  4305. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4306. static readonly ALPHA_MAXIMIZED: number;
  4307. /** Defines that alpha blending to SRC + DEST */
  4308. static readonly ALPHA_ONEONE: number;
  4309. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4310. static readonly ALPHA_PREMULTIPLIED: number;
  4311. /**
  4312. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4313. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4314. */
  4315. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4316. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4317. static readonly ALPHA_INTERPOLATE: number;
  4318. /**
  4319. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4320. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4321. */
  4322. static readonly ALPHA_SCREENMODE: number;
  4323. /**
  4324. * Defines that alpha blending to SRC + DST
  4325. * Alpha will be set to SRC ALPHA + DST ALPHA
  4326. */
  4327. static readonly ALPHA_ONEONE_ONEONE: number;
  4328. /**
  4329. * Defines that alpha blending to SRC * DST ALPHA + DST
  4330. * Alpha will be set to 0
  4331. */
  4332. static readonly ALPHA_ALPHATOCOLOR: number;
  4333. /**
  4334. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4335. */
  4336. static readonly ALPHA_REVERSEONEMINUS: number;
  4337. /**
  4338. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4339. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4340. */
  4341. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + DST
  4344. * Alpha will be set to SRC ALPHA
  4345. */
  4346. static readonly ALPHA_ONEONE_ONEZERO: number;
  4347. /** Defines that alpha blending equation a SUM */
  4348. static readonly ALPHA_EQUATION_ADD: number;
  4349. /** Defines that alpha blending equation a SUBSTRACTION */
  4350. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4351. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4352. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4353. /** Defines that alpha blending equation a MAX operation */
  4354. static readonly ALPHA_EQUATION_MAX: number;
  4355. /** Defines that alpha blending equation a MIN operation */
  4356. static readonly ALPHA_EQUATION_MIN: number;
  4357. /**
  4358. * Defines that alpha blending equation a DARKEN operation:
  4359. * It takes the min of the src and sums the alpha channels.
  4360. */
  4361. static readonly ALPHA_EQUATION_DARKEN: number;
  4362. /** Defines that the ressource is not delayed*/
  4363. static readonly DELAYLOADSTATE_NONE: number;
  4364. /** Defines that the ressource was successfully delay loaded */
  4365. static readonly DELAYLOADSTATE_LOADED: number;
  4366. /** Defines that the ressource is currently delay loading */
  4367. static readonly DELAYLOADSTATE_LOADING: number;
  4368. /** Defines that the ressource is delayed and has not started loading */
  4369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4371. static readonly NEVER: number;
  4372. /** 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 */
  4373. static readonly ALWAYS: number;
  4374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4375. static readonly LESS: number;
  4376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4377. static readonly EQUAL: number;
  4378. /** 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 */
  4379. static readonly LEQUAL: number;
  4380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4381. static readonly GREATER: number;
  4382. /** 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 */
  4383. static readonly GEQUAL: number;
  4384. /** 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 */
  4385. static readonly NOTEQUAL: number;
  4386. /** Passed to stencilOperation to specify that stencil value must be kept */
  4387. static readonly KEEP: number;
  4388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4389. static readonly REPLACE: number;
  4390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4391. static readonly INCR: number;
  4392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4393. static readonly DECR: number;
  4394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4395. static readonly INVERT: number;
  4396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4397. static readonly INCR_WRAP: number;
  4398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4399. static readonly DECR_WRAP: number;
  4400. /** Texture is not repeating outside of 0..1 UVs */
  4401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4402. /** Texture is repeating outside of 0..1 UVs */
  4403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4404. /** Texture is repeating and mirrored */
  4405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4406. /** ALPHA */
  4407. static readonly TEXTUREFORMAT_ALPHA: number;
  4408. /** LUMINANCE */
  4409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4410. /** LUMINANCE_ALPHA */
  4411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4412. /** RGB */
  4413. static readonly TEXTUREFORMAT_RGB: number;
  4414. /** RGBA */
  4415. static readonly TEXTUREFORMAT_RGBA: number;
  4416. /** RED */
  4417. static readonly TEXTUREFORMAT_RED: number;
  4418. /** RED (2nd reference) */
  4419. static readonly TEXTUREFORMAT_R: number;
  4420. /** RG */
  4421. static readonly TEXTUREFORMAT_RG: number;
  4422. /** RED_INTEGER */
  4423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4424. /** RED_INTEGER (2nd reference) */
  4425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4426. /** RG_INTEGER */
  4427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4428. /** RGB_INTEGER */
  4429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4430. /** RGBA_INTEGER */
  4431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4432. /** UNSIGNED_BYTE */
  4433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4434. /** UNSIGNED_BYTE (2nd reference) */
  4435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4436. /** FLOAT */
  4437. static readonly TEXTURETYPE_FLOAT: number;
  4438. /** HALF_FLOAT */
  4439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4440. /** BYTE */
  4441. static readonly TEXTURETYPE_BYTE: number;
  4442. /** SHORT */
  4443. static readonly TEXTURETYPE_SHORT: number;
  4444. /** UNSIGNED_SHORT */
  4445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4446. /** INT */
  4447. static readonly TEXTURETYPE_INT: number;
  4448. /** UNSIGNED_INT */
  4449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4450. /** UNSIGNED_SHORT_4_4_4_4 */
  4451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4452. /** UNSIGNED_SHORT_5_5_5_1 */
  4453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4454. /** UNSIGNED_SHORT_5_6_5 */
  4455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4456. /** UNSIGNED_INT_2_10_10_10_REV */
  4457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4458. /** UNSIGNED_INT_24_8 */
  4459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4460. /** UNSIGNED_INT_10F_11F_11F_REV */
  4461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4462. /** UNSIGNED_INT_5_9_9_9_REV */
  4463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4466. /** nearest is mag = nearest and min = nearest and mip = linear */
  4467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4470. /** Trilinear is mag = linear and min = linear and mip = linear */
  4471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4472. /** nearest is mag = nearest and min = nearest and mip = linear */
  4473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4476. /** Trilinear is mag = linear and min = linear and mip = linear */
  4477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4478. /** mag = nearest and min = nearest and mip = nearest */
  4479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4480. /** mag = nearest and min = linear and mip = nearest */
  4481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4482. /** mag = nearest and min = linear and mip = linear */
  4483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4484. /** mag = nearest and min = linear and mip = none */
  4485. static readonly TEXTURE_NEAREST_LINEAR: number;
  4486. /** mag = nearest and min = nearest and mip = none */
  4487. static readonly TEXTURE_NEAREST_NEAREST: number;
  4488. /** mag = linear and min = nearest and mip = nearest */
  4489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4490. /** mag = linear and min = nearest and mip = linear */
  4491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4492. /** mag = linear and min = linear and mip = none */
  4493. static readonly TEXTURE_LINEAR_LINEAR: number;
  4494. /** mag = linear and min = nearest and mip = none */
  4495. static readonly TEXTURE_LINEAR_NEAREST: number;
  4496. /** Explicit coordinates mode */
  4497. static readonly TEXTURE_EXPLICIT_MODE: number;
  4498. /** Spherical coordinates mode */
  4499. static readonly TEXTURE_SPHERICAL_MODE: number;
  4500. /** Planar coordinates mode */
  4501. static readonly TEXTURE_PLANAR_MODE: number;
  4502. /** Cubic coordinates mode */
  4503. static readonly TEXTURE_CUBIC_MODE: number;
  4504. /** Projection coordinates mode */
  4505. static readonly TEXTURE_PROJECTION_MODE: number;
  4506. /** Skybox coordinates mode */
  4507. static readonly TEXTURE_SKYBOX_MODE: number;
  4508. /** Inverse Cubic coordinates mode */
  4509. static readonly TEXTURE_INVCUBIC_MODE: number;
  4510. /** Equirectangular coordinates mode */
  4511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4512. /** Equirectangular Fixed coordinates mode */
  4513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4514. /** Equirectangular Fixed Mirrored coordinates mode */
  4515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4517. static readonly SCALEMODE_FLOOR: number;
  4518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4519. static readonly SCALEMODE_NEAREST: number;
  4520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4521. static readonly SCALEMODE_CEILING: number;
  4522. /**
  4523. * The dirty texture flag value
  4524. */
  4525. static readonly MATERIAL_TextureDirtyFlag: number;
  4526. /**
  4527. * The dirty light flag value
  4528. */
  4529. static readonly MATERIAL_LightDirtyFlag: number;
  4530. /**
  4531. * The dirty fresnel flag value
  4532. */
  4533. static readonly MATERIAL_FresnelDirtyFlag: number;
  4534. /**
  4535. * The dirty attribute flag value
  4536. */
  4537. static readonly MATERIAL_AttributesDirtyFlag: number;
  4538. /**
  4539. * The dirty misc flag value
  4540. */
  4541. static readonly MATERIAL_MiscDirtyFlag: number;
  4542. /**
  4543. * The all dirty flag value
  4544. */
  4545. static readonly MATERIAL_AllDirtyFlag: number;
  4546. /**
  4547. * Returns the triangle fill mode
  4548. */
  4549. static readonly MATERIAL_TriangleFillMode: number;
  4550. /**
  4551. * Returns the wireframe mode
  4552. */
  4553. static readonly MATERIAL_WireFrameFillMode: number;
  4554. /**
  4555. * Returns the point fill mode
  4556. */
  4557. static readonly MATERIAL_PointFillMode: number;
  4558. /**
  4559. * Returns the point list draw mode
  4560. */
  4561. static readonly MATERIAL_PointListDrawMode: number;
  4562. /**
  4563. * Returns the line list draw mode
  4564. */
  4565. static readonly MATERIAL_LineListDrawMode: number;
  4566. /**
  4567. * Returns the line loop draw mode
  4568. */
  4569. static readonly MATERIAL_LineLoopDrawMode: number;
  4570. /**
  4571. * Returns the line strip draw mode
  4572. */
  4573. static readonly MATERIAL_LineStripDrawMode: number;
  4574. /**
  4575. * Returns the triangle strip draw mode
  4576. */
  4577. static readonly MATERIAL_TriangleStripDrawMode: number;
  4578. /**
  4579. * Returns the triangle fan draw mode
  4580. */
  4581. static readonly MATERIAL_TriangleFanDrawMode: number;
  4582. /**
  4583. * Stores the clock-wise side orientation
  4584. */
  4585. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4586. /**
  4587. * Stores the counter clock-wise side orientation
  4588. */
  4589. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4590. /**
  4591. * Nothing
  4592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4593. */
  4594. static readonly ACTION_NothingTrigger: number;
  4595. /**
  4596. * On pick
  4597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4598. */
  4599. static readonly ACTION_OnPickTrigger: number;
  4600. /**
  4601. * On left pick
  4602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4603. */
  4604. static readonly ACTION_OnLeftPickTrigger: number;
  4605. /**
  4606. * On right pick
  4607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4608. */
  4609. static readonly ACTION_OnRightPickTrigger: number;
  4610. /**
  4611. * On center pick
  4612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4613. */
  4614. static readonly ACTION_OnCenterPickTrigger: number;
  4615. /**
  4616. * On pick down
  4617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4618. */
  4619. static readonly ACTION_OnPickDownTrigger: number;
  4620. /**
  4621. * On double pick
  4622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4623. */
  4624. static readonly ACTION_OnDoublePickTrigger: number;
  4625. /**
  4626. * On pick up
  4627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4628. */
  4629. static readonly ACTION_OnPickUpTrigger: number;
  4630. /**
  4631. * On pick out.
  4632. * This trigger will only be raised if you also declared a OnPickDown
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnPickOutTrigger: number;
  4636. /**
  4637. * On long press
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnLongPressTrigger: number;
  4641. /**
  4642. * On pointer over
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnPointerOverTrigger: number;
  4646. /**
  4647. * On pointer out
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPointerOutTrigger: number;
  4651. /**
  4652. * On every frame
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnEveryFrameTrigger: number;
  4656. /**
  4657. * On intersection enter
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4661. /**
  4662. * On intersection exit
  4663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4664. */
  4665. static readonly ACTION_OnIntersectionExitTrigger: number;
  4666. /**
  4667. * On key down
  4668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4669. */
  4670. static readonly ACTION_OnKeyDownTrigger: number;
  4671. /**
  4672. * On key up
  4673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4674. */
  4675. static readonly ACTION_OnKeyUpTrigger: number;
  4676. /**
  4677. * Billboard mode will only apply to Y axis
  4678. */
  4679. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4680. /**
  4681. * Billboard mode will apply to all axes
  4682. */
  4683. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4684. /**
  4685. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4686. */
  4687. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4688. /**
  4689. * Gets or sets base Assets URL
  4690. */
  4691. static PARTICLES_BaseAssetsUrl: string;
  4692. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4693. * Test order :
  4694. * Is the bounding sphere outside the frustum ?
  4695. * If not, are the bounding box vertices outside the frustum ?
  4696. * It not, then the cullable object is in the frustum.
  4697. */
  4698. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4699. /** Culling strategy : Bounding Sphere Only.
  4700. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4701. * It's also less accurate than the standard because some not visible objects can still be selected.
  4702. * Test : is the bounding sphere outside the frustum ?
  4703. * If not, then the cullable object is in the frustum.
  4704. */
  4705. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4706. /** Culling strategy : Optimistic Inclusion.
  4707. * This in an inclusion test first, then the standard exclusion test.
  4708. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4709. * 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.
  4710. * Anyway, it's as accurate as the standard strategy.
  4711. * Test :
  4712. * Is the cullable object bounding sphere center in the frustum ?
  4713. * If not, apply the default culling strategy.
  4714. */
  4715. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4716. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4717. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4718. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4719. * 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.
  4720. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4721. * Test :
  4722. * Is the cullable object bounding sphere center in the frustum ?
  4723. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4724. */
  4725. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4726. /**
  4727. * No logging while loading
  4728. */
  4729. static readonly SCENELOADER_NO_LOGGING: number;
  4730. /**
  4731. * Minimal logging while loading
  4732. */
  4733. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4734. /**
  4735. * Summary logging while loading
  4736. */
  4737. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4738. /**
  4739. * Detailled logging while loading
  4740. */
  4741. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4742. }
  4743. }
  4744. declare module BABYLON {
  4745. /**
  4746. * This represents the required contract to create a new type of texture loader.
  4747. */
  4748. export interface IInternalTextureLoader {
  4749. /**
  4750. * Defines wether the loader supports cascade loading the different faces.
  4751. */
  4752. supportCascades: boolean;
  4753. /**
  4754. * This returns if the loader support the current file information.
  4755. * @param extension defines the file extension of the file being loaded
  4756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4757. * @param fallback defines the fallback internal texture if any
  4758. * @param isBase64 defines whether the texture is encoded as a base64
  4759. * @param isBuffer defines whether the texture data are stored as a buffer
  4760. * @returns true if the loader can load the specified file
  4761. */
  4762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4763. /**
  4764. * Transform the url before loading if required.
  4765. * @param rootUrl the url of the texture
  4766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4767. * @returns the transformed texture
  4768. */
  4769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4770. /**
  4771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4772. * @param rootUrl the url of the texture
  4773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4774. * @returns the fallback texture
  4775. */
  4776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4777. /**
  4778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4779. * @param data contains the texture data
  4780. * @param texture defines the BabylonJS internal texture
  4781. * @param createPolynomials will be true if polynomials have been requested
  4782. * @param onLoad defines the callback to trigger once the texture is ready
  4783. * @param onError defines the callback to trigger in case of error
  4784. */
  4785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4786. /**
  4787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4788. * @param data contains the texture data
  4789. * @param texture defines the BabylonJS internal texture
  4790. * @param callback defines the method to call once ready to upload
  4791. */
  4792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. /**
  4797. * Class used to store and describe the pipeline context associated with an effect
  4798. */
  4799. export interface IPipelineContext {
  4800. /**
  4801. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4802. */
  4803. isAsync: boolean;
  4804. /**
  4805. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4806. */
  4807. isReady: boolean;
  4808. /** @hidden */
  4809. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4810. }
  4811. }
  4812. declare module BABYLON {
  4813. /**
  4814. * Class used to store gfx data (like WebGLBuffer)
  4815. */
  4816. export class DataBuffer {
  4817. /**
  4818. * Gets or sets the number of objects referencing this buffer
  4819. */
  4820. references: number;
  4821. /** Gets or sets the size of the underlying buffer */
  4822. capacity: number;
  4823. /**
  4824. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4825. */
  4826. is32Bits: boolean;
  4827. /**
  4828. * Gets the underlying buffer
  4829. */
  4830. readonly underlyingResource: any;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. /** @hidden */
  4835. export interface IShaderProcessor {
  4836. attributeProcessor?: (attribute: string) => string;
  4837. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4838. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4839. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4840. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4841. lineProcessor?: (line: string, isFragment: boolean) => string;
  4842. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4843. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4844. }
  4845. }
  4846. declare module BABYLON {
  4847. /** @hidden */
  4848. export interface ProcessingOptions {
  4849. defines: string[];
  4850. indexParameters: any;
  4851. isFragment: boolean;
  4852. shouldUseHighPrecisionShader: boolean;
  4853. supportsUniformBuffers: boolean;
  4854. shadersRepository: string;
  4855. includesShadersStore: {
  4856. [key: string]: string;
  4857. };
  4858. processor?: IShaderProcessor;
  4859. version: string;
  4860. platformName: string;
  4861. lookForClosingBracketForUniformBuffer?: boolean;
  4862. }
  4863. }
  4864. declare module BABYLON {
  4865. /**
  4866. * Helper to manipulate strings
  4867. */
  4868. export class StringTools {
  4869. /**
  4870. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4871. * @param str Source string
  4872. * @param suffix Suffix to search for in the source string
  4873. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4874. */
  4875. static EndsWith(str: string, suffix: string): boolean;
  4876. /**
  4877. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4878. * @param str Source string
  4879. * @param suffix Suffix to search for in the source string
  4880. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4881. */
  4882. static StartsWith(str: string, suffix: string): boolean;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /** @hidden */
  4887. export class ShaderCodeNode {
  4888. line: string;
  4889. children: ShaderCodeNode[];
  4890. additionalDefineKey?: string;
  4891. additionalDefineValue?: string;
  4892. isValid(preprocessors: {
  4893. [key: string]: string;
  4894. }): boolean;
  4895. process(preprocessors: {
  4896. [key: string]: string;
  4897. }, options: ProcessingOptions): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /** @hidden */
  4902. export class ShaderCodeCursor {
  4903. private _lines;
  4904. lineIndex: number;
  4905. readonly currentLine: string;
  4906. readonly canRead: boolean;
  4907. lines: string[];
  4908. }
  4909. }
  4910. declare module BABYLON {
  4911. /** @hidden */
  4912. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4913. process(preprocessors: {
  4914. [key: string]: string;
  4915. }, options: ProcessingOptions): string;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class ShaderDefineExpression {
  4921. isTrue(preprocessors: {
  4922. [key: string]: string;
  4923. }): boolean;
  4924. }
  4925. }
  4926. declare module BABYLON {
  4927. /** @hidden */
  4928. export class ShaderCodeTestNode extends ShaderCodeNode {
  4929. testExpression: ShaderDefineExpression;
  4930. isValid(preprocessors: {
  4931. [key: string]: string;
  4932. }): boolean;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /** @hidden */
  4937. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4938. define: string;
  4939. not: boolean;
  4940. constructor(define: string, not?: boolean);
  4941. isTrue(preprocessors: {
  4942. [key: string]: string;
  4943. }): boolean;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /** @hidden */
  4948. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4949. leftOperand: ShaderDefineExpression;
  4950. rightOperand: ShaderDefineExpression;
  4951. isTrue(preprocessors: {
  4952. [key: string]: string;
  4953. }): boolean;
  4954. }
  4955. }
  4956. declare module BABYLON {
  4957. /** @hidden */
  4958. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4959. leftOperand: ShaderDefineExpression;
  4960. rightOperand: ShaderDefineExpression;
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module BABYLON {
  4967. /** @hidden */
  4968. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4969. define: string;
  4970. operand: string;
  4971. testValue: string;
  4972. constructor(define: string, operand: string, testValue: string);
  4973. isTrue(preprocessors: {
  4974. [key: string]: string;
  4975. }): boolean;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * @ignore
  4981. * Application error to support additional information when loading a file
  4982. */
  4983. export class LoadFileError extends Error {
  4984. /** defines the optional web request */
  4985. request?: WebRequest | undefined;
  4986. private static _setPrototypeOf;
  4987. /**
  4988. * Creates a new LoadFileError
  4989. * @param message defines the message of the error
  4990. * @param request defines the optional web request
  4991. */
  4992. constructor(message: string,
  4993. /** defines the optional web request */
  4994. request?: WebRequest | undefined);
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class used to enable access to offline support
  5000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5001. */
  5002. export interface IOfflineProvider {
  5003. /**
  5004. * Gets a boolean indicating if scene must be saved in the database
  5005. */
  5006. enableSceneOffline: boolean;
  5007. /**
  5008. * Gets a boolean indicating if textures must be saved in the database
  5009. */
  5010. enableTexturesOffline: boolean;
  5011. /**
  5012. * Open the offline support and make it available
  5013. * @param successCallback defines the callback to call on success
  5014. * @param errorCallback defines the callback to call on error
  5015. */
  5016. open(successCallback: () => void, errorCallback: () => void): void;
  5017. /**
  5018. * Loads an image from the offline support
  5019. * @param url defines the url to load from
  5020. * @param image defines the target DOM image
  5021. */
  5022. loadImage(url: string, image: HTMLImageElement): void;
  5023. /**
  5024. * Loads a file from offline support
  5025. * @param url defines the URL to load from
  5026. * @param sceneLoaded defines a callback to call on success
  5027. * @param progressCallBack defines a callback to call when progress changed
  5028. * @param errorCallback defines a callback to call on error
  5029. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5030. */
  5031. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5032. }
  5033. }
  5034. declare module BABYLON {
  5035. /**
  5036. * Class used to help managing file picking and drag'n'drop
  5037. * File Storage
  5038. */
  5039. export class FilesInputStore {
  5040. /**
  5041. * List of files ready to be loaded
  5042. */
  5043. static FilesToLoad: {
  5044. [key: string]: File;
  5045. };
  5046. }
  5047. }
  5048. declare module BABYLON {
  5049. /**
  5050. * Class used to define a retry strategy when error happens while loading assets
  5051. */
  5052. export class RetryStrategy {
  5053. /**
  5054. * Function used to defines an exponential back off strategy
  5055. * @param maxRetries defines the maximum number of retries (3 by default)
  5056. * @param baseInterval defines the interval between retries
  5057. * @returns the strategy function to use
  5058. */
  5059. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5060. }
  5061. }
  5062. declare module BABYLON {
  5063. /**
  5064. * @hidden
  5065. */
  5066. export class FileTools {
  5067. /**
  5068. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5069. */
  5070. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5071. /**
  5072. * Gets or sets the base URL to use to load assets
  5073. */
  5074. static BaseUrl: string;
  5075. /**
  5076. * Default behaviour for cors in the application.
  5077. * It can be a string if the expected behavior is identical in the entire app.
  5078. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5079. */
  5080. static CorsBehavior: string | ((url: string | string[]) => string);
  5081. /**
  5082. * Gets or sets a function used to pre-process url before using them to load assets
  5083. */
  5084. static PreprocessUrl: (url: string) => string;
  5085. /**
  5086. * Removes unwanted characters from an url
  5087. * @param url defines the url to clean
  5088. * @returns the cleaned url
  5089. */
  5090. private static _CleanUrl;
  5091. /**
  5092. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5093. * @param url define the url we are trying
  5094. * @param element define the dom element where to configure the cors policy
  5095. */
  5096. static SetCorsBehavior(url: string | string[], element: {
  5097. crossOrigin: string | null;
  5098. }): void;
  5099. /**
  5100. * Loads an image as an HTMLImageElement.
  5101. * @param input url string, ArrayBuffer, or Blob to load
  5102. * @param onLoad callback called when the image successfully loads
  5103. * @param onError callback called when the image fails to load
  5104. * @param offlineProvider offline provider for caching
  5105. * @returns the HTMLImageElement of the loaded image
  5106. */
  5107. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5108. /**
  5109. * Loads a file
  5110. * @param fileToLoad defines the file to load
  5111. * @param callback defines the callback to call when data is loaded
  5112. * @param progressCallBack defines the callback to call during loading process
  5113. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5114. * @returns a file request object
  5115. */
  5116. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5117. /**
  5118. * Loads a file
  5119. * @param url url string, ArrayBuffer, or Blob to load
  5120. * @param onSuccess callback called when the file successfully loads
  5121. * @param onProgress callback called while file is loading (if the server supports this mode)
  5122. * @param offlineProvider defines the offline provider for caching
  5123. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5124. * @param onError callback called when the file fails to load
  5125. * @returns a file request object
  5126. */
  5127. 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;
  5128. /**
  5129. * Checks if the loaded document was accessed via `file:`-Protocol.
  5130. * @returns boolean
  5131. */
  5132. static IsFileURL(): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /** @hidden */
  5137. export class ShaderProcessor {
  5138. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5139. private static _ProcessPrecision;
  5140. private static _ExtractOperation;
  5141. private static _BuildSubExpression;
  5142. private static _BuildExpression;
  5143. private static _MoveCursorWithinIf;
  5144. private static _MoveCursor;
  5145. private static _EvaluatePreProcessors;
  5146. private static _PreparePreProcessors;
  5147. private static _ProcessShaderConversion;
  5148. private static _ProcessIncludes;
  5149. }
  5150. }
  5151. declare module BABYLON {
  5152. /**
  5153. * Interface used to define common properties for effect fallbacks
  5154. */
  5155. export interface IEffectFallbacks {
  5156. /**
  5157. * Removes the defines that should be removed when falling back.
  5158. * @param currentDefines defines the current define statements for the shader.
  5159. * @param effect defines the current effect we try to compile
  5160. * @returns The resulting defines with defines of the current rank removed.
  5161. */
  5162. reduce(currentDefines: string, effect: Effect): string;
  5163. /**
  5164. * Removes the fallback from the bound mesh.
  5165. */
  5166. unBindMesh(): void;
  5167. /**
  5168. * Checks to see if more fallbacks are still availible.
  5169. */
  5170. hasMoreFallbacks: boolean;
  5171. }
  5172. }
  5173. declare module BABYLON {
  5174. /**
  5175. * Class used to evalaute queries containing `and` and `or` operators
  5176. */
  5177. export class AndOrNotEvaluator {
  5178. /**
  5179. * Evaluate a query
  5180. * @param query defines the query to evaluate
  5181. * @param evaluateCallback defines the callback used to filter result
  5182. * @returns true if the query matches
  5183. */
  5184. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5185. private static _HandleParenthesisContent;
  5186. private static _SimplifyNegation;
  5187. }
  5188. }
  5189. declare module BABYLON {
  5190. /**
  5191. * Class used to store custom tags
  5192. */
  5193. export class Tags {
  5194. /**
  5195. * Adds support for tags on the given object
  5196. * @param obj defines the object to use
  5197. */
  5198. static EnableFor(obj: any): void;
  5199. /**
  5200. * Removes tags support
  5201. * @param obj defines the object to use
  5202. */
  5203. static DisableFor(obj: any): void;
  5204. /**
  5205. * Gets a boolean indicating if the given object has tags
  5206. * @param obj defines the object to use
  5207. * @returns a boolean
  5208. */
  5209. static HasTags(obj: any): boolean;
  5210. /**
  5211. * Gets the tags available on a given object
  5212. * @param obj defines the object to use
  5213. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5214. * @returns the tags
  5215. */
  5216. static GetTags(obj: any, asString?: boolean): any;
  5217. /**
  5218. * Adds tags to an object
  5219. * @param obj defines the object to use
  5220. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5221. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5222. */
  5223. static AddTagsTo(obj: any, tagsString: string): void;
  5224. /**
  5225. * @hidden
  5226. */
  5227. static _AddTagTo(obj: any, tag: string): void;
  5228. /**
  5229. * Removes specific tags from a specific object
  5230. * @param obj defines the object to use
  5231. * @param tagsString defines the tags to remove
  5232. */
  5233. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5234. /**
  5235. * @hidden
  5236. */
  5237. static _RemoveTagFrom(obj: any, tag: string): void;
  5238. /**
  5239. * Defines if tags hosted on an object match a given query
  5240. * @param obj defines the object to use
  5241. * @param tagsQuery defines the tag query
  5242. * @returns a boolean
  5243. */
  5244. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Defines potential orientation for back face culling
  5250. */
  5251. export enum Orientation {
  5252. /**
  5253. * Clockwise
  5254. */
  5255. CW = 0,
  5256. /** Counter clockwise */
  5257. CCW = 1
  5258. }
  5259. /** Class used to represent a Bezier curve */
  5260. export class BezierCurve {
  5261. /**
  5262. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5263. * @param t defines the time
  5264. * @param x1 defines the left coordinate on X axis
  5265. * @param y1 defines the left coordinate on Y axis
  5266. * @param x2 defines the right coordinate on X axis
  5267. * @param y2 defines the right coordinate on Y axis
  5268. * @returns the interpolated value
  5269. */
  5270. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5271. }
  5272. /**
  5273. * Defines angle representation
  5274. */
  5275. export class Angle {
  5276. private _radians;
  5277. /**
  5278. * Creates an Angle object of "radians" radians (float).
  5279. * @param radians the angle in radians
  5280. */
  5281. constructor(radians: number);
  5282. /**
  5283. * Get value in degrees
  5284. * @returns the Angle value in degrees (float)
  5285. */
  5286. degrees(): number;
  5287. /**
  5288. * Get value in radians
  5289. * @returns the Angle value in radians (float)
  5290. */
  5291. radians(): number;
  5292. /**
  5293. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5294. * @param a defines first vector
  5295. * @param b defines second vector
  5296. * @returns a new Angle
  5297. */
  5298. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5299. /**
  5300. * Gets a new Angle object from the given float in radians
  5301. * @param radians defines the angle value in radians
  5302. * @returns a new Angle
  5303. */
  5304. static FromRadians(radians: number): Angle;
  5305. /**
  5306. * Gets a new Angle object from the given float in degrees
  5307. * @param degrees defines the angle value in degrees
  5308. * @returns a new Angle
  5309. */
  5310. static FromDegrees(degrees: number): Angle;
  5311. }
  5312. /**
  5313. * This represents an arc in a 2d space.
  5314. */
  5315. export class Arc2 {
  5316. /** Defines the start point of the arc */
  5317. startPoint: Vector2;
  5318. /** Defines the mid point of the arc */
  5319. midPoint: Vector2;
  5320. /** Defines the end point of the arc */
  5321. endPoint: Vector2;
  5322. /**
  5323. * Defines the center point of the arc.
  5324. */
  5325. centerPoint: Vector2;
  5326. /**
  5327. * Defines the radius of the arc.
  5328. */
  5329. radius: number;
  5330. /**
  5331. * Defines the angle of the arc (from mid point to end point).
  5332. */
  5333. angle: Angle;
  5334. /**
  5335. * Defines the start angle of the arc (from start point to middle point).
  5336. */
  5337. startAngle: Angle;
  5338. /**
  5339. * Defines the orientation of the arc (clock wise/counter clock wise).
  5340. */
  5341. orientation: Orientation;
  5342. /**
  5343. * Creates an Arc object from the three given points : start, middle and end.
  5344. * @param startPoint Defines the start point of the arc
  5345. * @param midPoint Defines the midlle point of the arc
  5346. * @param endPoint Defines the end point of the arc
  5347. */
  5348. constructor(
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2,
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2,
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2);
  5355. }
  5356. /**
  5357. * Represents a 2D path made up of multiple 2D points
  5358. */
  5359. export class Path2 {
  5360. private _points;
  5361. private _length;
  5362. /**
  5363. * If the path start and end point are the same
  5364. */
  5365. closed: boolean;
  5366. /**
  5367. * Creates a Path2 object from the starting 2D coordinates x and y.
  5368. * @param x the starting points x value
  5369. * @param y the starting points y value
  5370. */
  5371. constructor(x: number, y: number);
  5372. /**
  5373. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5374. * @param x the added points x value
  5375. * @param y the added points y value
  5376. * @returns the updated Path2.
  5377. */
  5378. addLineTo(x: number, y: number): Path2;
  5379. /**
  5380. * 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.
  5381. * @param midX middle point x value
  5382. * @param midY middle point y value
  5383. * @param endX end point x value
  5384. * @param endY end point y value
  5385. * @param numberOfSegments (default: 36)
  5386. * @returns the updated Path2.
  5387. */
  5388. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5389. /**
  5390. * Closes the Path2.
  5391. * @returns the Path2.
  5392. */
  5393. close(): Path2;
  5394. /**
  5395. * Gets the sum of the distance between each sequential point in the path
  5396. * @returns the Path2 total length (float).
  5397. */
  5398. length(): number;
  5399. /**
  5400. * Gets the points which construct the path
  5401. * @returns the Path2 internal array of points.
  5402. */
  5403. getPoints(): Vector2[];
  5404. /**
  5405. * Retreives the point at the distance aways from the starting point
  5406. * @param normalizedLengthPosition the length along the path to retreive the point from
  5407. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5408. */
  5409. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5410. /**
  5411. * Creates a new path starting from an x and y position
  5412. * @param x starting x value
  5413. * @param y starting y value
  5414. * @returns a new Path2 starting at the coordinates (x, y).
  5415. */
  5416. static StartingAt(x: number, y: number): Path2;
  5417. }
  5418. /**
  5419. * Represents a 3D path made up of multiple 3D points
  5420. */
  5421. export class Path3D {
  5422. /**
  5423. * an array of Vector3, the curve axis of the Path3D
  5424. */
  5425. path: Vector3[];
  5426. private _curve;
  5427. private _distances;
  5428. private _tangents;
  5429. private _normals;
  5430. private _binormals;
  5431. private _raw;
  5432. /**
  5433. * new Path3D(path, normal, raw)
  5434. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5435. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5436. * @param path an array of Vector3, the curve axis of the Path3D
  5437. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5438. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5439. */
  5440. constructor(
  5441. /**
  5442. * an array of Vector3, the curve axis of the Path3D
  5443. */
  5444. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5445. /**
  5446. * Returns the Path3D array of successive Vector3 designing its curve.
  5447. * @returns the Path3D array of successive Vector3 designing its curve.
  5448. */
  5449. getCurve(): Vector3[];
  5450. /**
  5451. * Returns an array populated with tangent vectors on each Path3D curve point.
  5452. * @returns an array populated with tangent vectors on each Path3D curve point.
  5453. */
  5454. getTangents(): Vector3[];
  5455. /**
  5456. * Returns an array populated with normal vectors on each Path3D curve point.
  5457. * @returns an array populated with normal vectors on each Path3D curve point.
  5458. */
  5459. getNormals(): Vector3[];
  5460. /**
  5461. * Returns an array populated with binormal vectors on each Path3D curve point.
  5462. * @returns an array populated with binormal vectors on each Path3D curve point.
  5463. */
  5464. getBinormals(): Vector3[];
  5465. /**
  5466. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5467. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. */
  5469. getDistances(): number[];
  5470. /**
  5471. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5472. * @param path path which all values are copied into the curves points
  5473. * @param firstNormal which should be projected onto the curve
  5474. * @returns the same object updated.
  5475. */
  5476. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5477. private _compute;
  5478. private _getFirstNonNullVector;
  5479. private _getLastNonNullVector;
  5480. private _normalVector;
  5481. }
  5482. /**
  5483. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5484. * A Curve3 is designed from a series of successive Vector3.
  5485. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5486. */
  5487. export class Curve3 {
  5488. private _points;
  5489. private _length;
  5490. /**
  5491. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5492. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5493. * @param v1 (Vector3) the control point
  5494. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5495. * @param nbPoints (integer) the wanted number of points in the curve
  5496. * @returns the created Curve3
  5497. */
  5498. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5499. /**
  5500. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5501. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5502. * @param v1 (Vector3) the first control point
  5503. * @param v2 (Vector3) the second control point
  5504. * @param v3 (Vector3) the end point of the Cubic Bezier
  5505. * @param nbPoints (integer) the wanted number of points in the curve
  5506. * @returns the created Curve3
  5507. */
  5508. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5509. /**
  5510. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5511. * @param p1 (Vector3) the origin point of the Hermite Spline
  5512. * @param t1 (Vector3) the tangent vector at the origin point
  5513. * @param p2 (Vector3) the end point of the Hermite Spline
  5514. * @param t2 (Vector3) the tangent vector at the end point
  5515. * @param nbPoints (integer) the wanted number of points in the curve
  5516. * @returns the created Curve3
  5517. */
  5518. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5519. /**
  5520. * Returns a Curve3 object along a CatmullRom Spline curve :
  5521. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5522. * @param nbPoints (integer) the wanted number of points between each curve control points
  5523. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5524. * @returns the created Curve3
  5525. */
  5526. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5527. /**
  5528. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5529. * A Curve3 is designed from a series of successive Vector3.
  5530. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5531. * @param points points which make up the curve
  5532. */
  5533. constructor(points: Vector3[]);
  5534. /**
  5535. * @returns the Curve3 stored array of successive Vector3
  5536. */
  5537. getPoints(): Vector3[];
  5538. /**
  5539. * @returns the computed length (float) of the curve.
  5540. */
  5541. length(): number;
  5542. /**
  5543. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5544. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5545. * curveA and curveB keep unchanged.
  5546. * @param curve the curve to continue from this curve
  5547. * @returns the newly constructed curve
  5548. */
  5549. continue(curve: DeepImmutable<Curve3>): Curve3;
  5550. private _computeLength;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. /**
  5555. * This represents the main contract an easing function should follow.
  5556. * Easing functions are used throughout the animation system.
  5557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5558. */
  5559. export interface IEasingFunction {
  5560. /**
  5561. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5562. * of the easing function.
  5563. * The link below provides some of the most common examples of easing functions.
  5564. * @see https://easings.net/
  5565. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5566. * @returns the corresponding value on the curve defined by the easing function
  5567. */
  5568. ease(gradient: number): number;
  5569. }
  5570. /**
  5571. * Base class used for every default easing function.
  5572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5573. */
  5574. export class EasingFunction implements IEasingFunction {
  5575. /**
  5576. * Interpolation follows the mathematical formula associated with the easing function.
  5577. */
  5578. static readonly EASINGMODE_EASEIN: number;
  5579. /**
  5580. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5581. */
  5582. static readonly EASINGMODE_EASEOUT: number;
  5583. /**
  5584. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5585. */
  5586. static readonly EASINGMODE_EASEINOUT: number;
  5587. private _easingMode;
  5588. /**
  5589. * Sets the easing mode of the current function.
  5590. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5591. */
  5592. setEasingMode(easingMode: number): void;
  5593. /**
  5594. * Gets the current easing mode.
  5595. * @returns the easing mode
  5596. */
  5597. getEasingMode(): number;
  5598. /**
  5599. * @hidden
  5600. */
  5601. easeInCore(gradient: number): number;
  5602. /**
  5603. * Given an input gradient between 0 and 1, this returns the corresponding value
  5604. * of the easing function.
  5605. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5606. * @returns the corresponding value on the curve defined by the easing function
  5607. */
  5608. ease(gradient: number): number;
  5609. }
  5610. /**
  5611. * Easing function with a circle shape (see link below).
  5612. * @see https://easings.net/#easeInCirc
  5613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5614. */
  5615. export class CircleEase extends EasingFunction implements IEasingFunction {
  5616. /** @hidden */
  5617. easeInCore(gradient: number): number;
  5618. }
  5619. /**
  5620. * Easing function with a ease back shape (see link below).
  5621. * @see https://easings.net/#easeInBack
  5622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5623. */
  5624. export class BackEase extends EasingFunction implements IEasingFunction {
  5625. /** Defines the amplitude of the function */
  5626. amplitude: number;
  5627. /**
  5628. * Instantiates a back ease easing
  5629. * @see https://easings.net/#easeInBack
  5630. * @param amplitude Defines the amplitude of the function
  5631. */
  5632. constructor(
  5633. /** Defines the amplitude of the function */
  5634. amplitude?: number);
  5635. /** @hidden */
  5636. easeInCore(gradient: number): number;
  5637. }
  5638. /**
  5639. * Easing function with a bouncing shape (see link below).
  5640. * @see https://easings.net/#easeInBounce
  5641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5642. */
  5643. export class BounceEase extends EasingFunction implements IEasingFunction {
  5644. /** Defines the number of bounces */
  5645. bounces: number;
  5646. /** Defines the amplitude of the bounce */
  5647. bounciness: number;
  5648. /**
  5649. * Instantiates a bounce easing
  5650. * @see https://easings.net/#easeInBounce
  5651. * @param bounces Defines the number of bounces
  5652. * @param bounciness Defines the amplitude of the bounce
  5653. */
  5654. constructor(
  5655. /** Defines the number of bounces */
  5656. bounces?: number,
  5657. /** Defines the amplitude of the bounce */
  5658. bounciness?: number);
  5659. /** @hidden */
  5660. easeInCore(gradient: number): number;
  5661. }
  5662. /**
  5663. * Easing function with a power of 3 shape (see link below).
  5664. * @see https://easings.net/#easeInCubic
  5665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5666. */
  5667. export class CubicEase extends EasingFunction implements IEasingFunction {
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with an elastic shape (see link below).
  5673. * @see https://easings.net/#easeInElastic
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of oscillations*/
  5678. oscillations: number;
  5679. /** Defines the amplitude of the oscillations*/
  5680. springiness: number;
  5681. /**
  5682. * Instantiates an elastic easing function
  5683. * @see https://easings.net/#easeInElastic
  5684. * @param oscillations Defines the number of oscillations
  5685. * @param springiness Defines the amplitude of the oscillations
  5686. */
  5687. constructor(
  5688. /** Defines the number of oscillations*/
  5689. oscillations?: number,
  5690. /** Defines the amplitude of the oscillations*/
  5691. springiness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with an exponential shape (see link below).
  5697. * @see https://easings.net/#easeInExpo
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5701. /** Defines the exponent of the function */
  5702. exponent: number;
  5703. /**
  5704. * Instantiates an exponential easing function
  5705. * @see https://easings.net/#easeInExpo
  5706. * @param exponent Defines the exponent of the function
  5707. */
  5708. constructor(
  5709. /** Defines the exponent of the function */
  5710. exponent?: number);
  5711. /** @hidden */
  5712. easeInCore(gradient: number): number;
  5713. }
  5714. /**
  5715. * Easing function with a power shape (see link below).
  5716. * @see https://easings.net/#easeInQuad
  5717. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5718. */
  5719. export class PowerEase extends EasingFunction implements IEasingFunction {
  5720. /** Defines the power of the function */
  5721. power: number;
  5722. /**
  5723. * Instantiates an power base easing function
  5724. * @see https://easings.net/#easeInQuad
  5725. * @param power Defines the power of the function
  5726. */
  5727. constructor(
  5728. /** Defines the power of the function */
  5729. power?: number);
  5730. /** @hidden */
  5731. easeInCore(gradient: number): number;
  5732. }
  5733. /**
  5734. * Easing function with a power of 2 shape (see link below).
  5735. * @see https://easings.net/#easeInQuad
  5736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5737. */
  5738. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5739. /** @hidden */
  5740. easeInCore(gradient: number): number;
  5741. }
  5742. /**
  5743. * Easing function with a power of 4 shape (see link below).
  5744. * @see https://easings.net/#easeInQuart
  5745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5746. */
  5747. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5748. /** @hidden */
  5749. easeInCore(gradient: number): number;
  5750. }
  5751. /**
  5752. * Easing function with a power of 5 shape (see link below).
  5753. * @see https://easings.net/#easeInQuint
  5754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5755. */
  5756. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a sin shape (see link below).
  5762. * @see https://easings.net/#easeInSine
  5763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class SineEase extends EasingFunction implements IEasingFunction {
  5766. /** @hidden */
  5767. easeInCore(gradient: number): number;
  5768. }
  5769. /**
  5770. * Easing function with a bezier shape (see link below).
  5771. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5773. */
  5774. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5775. /** Defines the x component of the start tangent in the bezier curve */
  5776. x1: number;
  5777. /** Defines the y component of the start tangent in the bezier curve */
  5778. y1: number;
  5779. /** Defines the x component of the end tangent in the bezier curve */
  5780. x2: number;
  5781. /** Defines the y component of the end tangent in the bezier curve */
  5782. y2: number;
  5783. /**
  5784. * Instantiates a bezier function
  5785. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5786. * @param x1 Defines the x component of the start tangent in the bezier curve
  5787. * @param y1 Defines the y component of the start tangent in the bezier curve
  5788. * @param x2 Defines the x component of the end tangent in the bezier curve
  5789. * @param y2 Defines the y component of the end tangent in the bezier curve
  5790. */
  5791. constructor(
  5792. /** Defines the x component of the start tangent in the bezier curve */
  5793. x1?: number,
  5794. /** Defines the y component of the start tangent in the bezier curve */
  5795. y1?: number,
  5796. /** Defines the x component of the end tangent in the bezier curve */
  5797. x2?: number,
  5798. /** Defines the y component of the end tangent in the bezier curve */
  5799. y2?: number);
  5800. /** @hidden */
  5801. easeInCore(gradient: number): number;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. /**
  5806. * Defines an interface which represents an animation key frame
  5807. */
  5808. export interface IAnimationKey {
  5809. /**
  5810. * Frame of the key frame
  5811. */
  5812. frame: number;
  5813. /**
  5814. * Value at the specifies key frame
  5815. */
  5816. value: any;
  5817. /**
  5818. * The input tangent for the cubic hermite spline
  5819. */
  5820. inTangent?: any;
  5821. /**
  5822. * The output tangent for the cubic hermite spline
  5823. */
  5824. outTangent?: any;
  5825. /**
  5826. * The animation interpolation type
  5827. */
  5828. interpolation?: AnimationKeyInterpolation;
  5829. }
  5830. /**
  5831. * Enum for the animation key frame interpolation type
  5832. */
  5833. export enum AnimationKeyInterpolation {
  5834. /**
  5835. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5836. */
  5837. STEP = 1
  5838. }
  5839. }
  5840. declare module BABYLON {
  5841. /**
  5842. * Represents the range of an animation
  5843. */
  5844. export class AnimationRange {
  5845. /**The name of the animation range**/
  5846. name: string;
  5847. /**The starting frame of the animation */
  5848. from: number;
  5849. /**The ending frame of the animation*/
  5850. to: number;
  5851. /**
  5852. * Initializes the range of an animation
  5853. * @param name The name of the animation range
  5854. * @param from The starting frame of the animation
  5855. * @param to The ending frame of the animation
  5856. */
  5857. constructor(
  5858. /**The name of the animation range**/
  5859. name: string,
  5860. /**The starting frame of the animation */
  5861. from: number,
  5862. /**The ending frame of the animation*/
  5863. to: number);
  5864. /**
  5865. * Makes a copy of the animation range
  5866. * @returns A copy of the animation range
  5867. */
  5868. clone(): AnimationRange;
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Composed of a frame, and an action function
  5874. */
  5875. export class AnimationEvent {
  5876. /** The frame for which the event is triggered **/
  5877. frame: number;
  5878. /** The event to perform when triggered **/
  5879. action: (currentFrame: number) => void;
  5880. /** Specifies if the event should be triggered only once**/
  5881. onlyOnce?: boolean | undefined;
  5882. /**
  5883. * Specifies if the animation event is done
  5884. */
  5885. isDone: boolean;
  5886. /**
  5887. * Initializes the animation event
  5888. * @param frame The frame for which the event is triggered
  5889. * @param action The event to perform when triggered
  5890. * @param onlyOnce Specifies if the event should be triggered only once
  5891. */
  5892. constructor(
  5893. /** The frame for which the event is triggered **/
  5894. frame: number,
  5895. /** The event to perform when triggered **/
  5896. action: (currentFrame: number) => void,
  5897. /** Specifies if the event should be triggered only once**/
  5898. onlyOnce?: boolean | undefined);
  5899. /** @hidden */
  5900. _clone(): AnimationEvent;
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Interface used to define a behavior
  5906. */
  5907. export interface Behavior<T> {
  5908. /** gets or sets behavior's name */
  5909. name: string;
  5910. /**
  5911. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5912. */
  5913. init(): void;
  5914. /**
  5915. * Called when the behavior is attached to a target
  5916. * @param target defines the target where the behavior is attached to
  5917. */
  5918. attach(target: T): void;
  5919. /**
  5920. * Called when the behavior is detached from its target
  5921. */
  5922. detach(): void;
  5923. }
  5924. /**
  5925. * Interface implemented by classes supporting behaviors
  5926. */
  5927. export interface IBehaviorAware<T> {
  5928. /**
  5929. * Attach a behavior
  5930. * @param behavior defines the behavior to attach
  5931. * @returns the current host
  5932. */
  5933. addBehavior(behavior: Behavior<T>): T;
  5934. /**
  5935. * Remove a behavior from the current object
  5936. * @param behavior defines the behavior to detach
  5937. * @returns the current host
  5938. */
  5939. removeBehavior(behavior: Behavior<T>): T;
  5940. /**
  5941. * Gets a behavior using its name to search
  5942. * @param name defines the name to search
  5943. * @returns the behavior or null if not found
  5944. */
  5945. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Defines an array and its length.
  5951. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5952. */
  5953. export interface ISmartArrayLike<T> {
  5954. /**
  5955. * The data of the array.
  5956. */
  5957. data: Array<T>;
  5958. /**
  5959. * The active length of the array.
  5960. */
  5961. length: number;
  5962. }
  5963. /**
  5964. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5965. */
  5966. export class SmartArray<T> implements ISmartArrayLike<T> {
  5967. /**
  5968. * The full set of data from the array.
  5969. */
  5970. data: Array<T>;
  5971. /**
  5972. * The active length of the array.
  5973. */
  5974. length: number;
  5975. protected _id: number;
  5976. /**
  5977. * Instantiates a Smart Array.
  5978. * @param capacity defines the default capacity of the array.
  5979. */
  5980. constructor(capacity: number);
  5981. /**
  5982. * Pushes a value at the end of the active data.
  5983. * @param value defines the object to push in the array.
  5984. */
  5985. push(value: T): void;
  5986. /**
  5987. * Iterates over the active data and apply the lambda to them.
  5988. * @param func defines the action to apply on each value.
  5989. */
  5990. forEach(func: (content: T) => void): void;
  5991. /**
  5992. * Sorts the full sets of data.
  5993. * @param compareFn defines the comparison function to apply.
  5994. */
  5995. sort(compareFn: (a: T, b: T) => number): void;
  5996. /**
  5997. * Resets the active data to an empty array.
  5998. */
  5999. reset(): void;
  6000. /**
  6001. * Releases all the data from the array as well as the array.
  6002. */
  6003. dispose(): void;
  6004. /**
  6005. * Concats the active data with a given array.
  6006. * @param array defines the data to concatenate with.
  6007. */
  6008. concat(array: any): void;
  6009. /**
  6010. * Returns the position of a value in the active data.
  6011. * @param value defines the value to find the index for
  6012. * @returns the index if found in the active data otherwise -1
  6013. */
  6014. indexOf(value: T): number;
  6015. /**
  6016. * Returns whether an element is part of the active data.
  6017. * @param value defines the value to look for
  6018. * @returns true if found in the active data otherwise false
  6019. */
  6020. contains(value: T): boolean;
  6021. private static _GlobalId;
  6022. }
  6023. /**
  6024. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6025. * The data in this array can only be present once
  6026. */
  6027. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6028. private _duplicateId;
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6032. * @param value defines the object to push in the array.
  6033. */
  6034. push(value: T): void;
  6035. /**
  6036. * Pushes a value at the end of the active data.
  6037. * If the data is already present, it won t be added again
  6038. * @param value defines the object to push in the array.
  6039. * @returns true if added false if it was already present
  6040. */
  6041. pushNoDuplicate(value: T): boolean;
  6042. /**
  6043. * Resets the active data to an empty array.
  6044. */
  6045. reset(): void;
  6046. /**
  6047. * Concats the active data with a given array.
  6048. * This ensures no dupplicate will be present in the result.
  6049. * @param array defines the data to concatenate with.
  6050. */
  6051. concatWithNoDuplicate(array: any): void;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. /**
  6056. * @ignore
  6057. * This is a list of all the different input types that are available in the application.
  6058. * Fo instance: ArcRotateCameraGamepadInput...
  6059. */
  6060. export var CameraInputTypes: {};
  6061. /**
  6062. * This is the contract to implement in order to create a new input class.
  6063. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6064. */
  6065. export interface ICameraInput<TCamera extends Camera> {
  6066. /**
  6067. * Defines the camera the input is attached to.
  6068. */
  6069. camera: Nullable<TCamera>;
  6070. /**
  6071. * Gets the class name of the current intput.
  6072. * @returns the class name
  6073. */
  6074. getClassName(): string;
  6075. /**
  6076. * Get the friendly name associated with the input class.
  6077. * @returns the input friendly name
  6078. */
  6079. getSimpleName(): string;
  6080. /**
  6081. * Attach the input controls to a specific dom element to get the input from.
  6082. * @param element Defines the element the controls should be listened from
  6083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6084. */
  6085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6086. /**
  6087. * Detach the current controls from the specified dom element.
  6088. * @param element Defines the element to stop listening the inputs from
  6089. */
  6090. detachControl(element: Nullable<HTMLElement>): void;
  6091. /**
  6092. * Update the current camera state depending on the inputs that have been used this frame.
  6093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6094. */
  6095. checkInputs?: () => void;
  6096. }
  6097. /**
  6098. * Represents a map of input types to input instance or input index to input instance.
  6099. */
  6100. export interface CameraInputsMap<TCamera extends Camera> {
  6101. /**
  6102. * Accessor to the input by input type.
  6103. */
  6104. [name: string]: ICameraInput<TCamera>;
  6105. /**
  6106. * Accessor to the input by input index.
  6107. */
  6108. [idx: number]: ICameraInput<TCamera>;
  6109. }
  6110. /**
  6111. * This represents the input manager used within a camera.
  6112. * It helps dealing with all the different kind of input attached to a camera.
  6113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6114. */
  6115. export class CameraInputsManager<TCamera extends Camera> {
  6116. /**
  6117. * Defines the list of inputs attahed to the camera.
  6118. */
  6119. attached: CameraInputsMap<TCamera>;
  6120. /**
  6121. * Defines the dom element the camera is collecting inputs from.
  6122. * This is null if the controls have not been attached.
  6123. */
  6124. attachedElement: Nullable<HTMLElement>;
  6125. /**
  6126. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6127. */
  6128. noPreventDefault: boolean;
  6129. /**
  6130. * Defined the camera the input manager belongs to.
  6131. */
  6132. camera: TCamera;
  6133. /**
  6134. * Update the current camera state depending on the inputs that have been used this frame.
  6135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6136. */
  6137. checkInputs: () => void;
  6138. /**
  6139. * Instantiate a new Camera Input Manager.
  6140. * @param camera Defines the camera the input manager blongs to
  6141. */
  6142. constructor(camera: TCamera);
  6143. /**
  6144. * Add an input method to a camera
  6145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6146. * @param input camera input method
  6147. */
  6148. add(input: ICameraInput<TCamera>): void;
  6149. /**
  6150. * Remove a specific input method from a camera
  6151. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6152. * @param inputToRemove camera input method
  6153. */
  6154. remove(inputToRemove: ICameraInput<TCamera>): void;
  6155. /**
  6156. * Remove a specific input type from a camera
  6157. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6158. * @param inputType the type of the input to remove
  6159. */
  6160. removeByType(inputType: string): void;
  6161. private _addCheckInputs;
  6162. /**
  6163. * Attach the input controls to the currently attached dom element to listen the events from.
  6164. * @param input Defines the input to attach
  6165. */
  6166. attachInput(input: ICameraInput<TCamera>): void;
  6167. /**
  6168. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6169. * @param element Defines the dom element to collect the events from
  6170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6173. /**
  6174. * Detach the current manager inputs controls from a specific dom element.
  6175. * @param element Defines the dom element to collect the events from
  6176. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6177. */
  6178. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6179. /**
  6180. * Rebuild the dynamic inputCheck function from the current list of
  6181. * defined inputs in the manager.
  6182. */
  6183. rebuildInputCheck(): void;
  6184. /**
  6185. * Remove all attached input methods from a camera
  6186. */
  6187. clear(): void;
  6188. /**
  6189. * Serialize the current input manager attached to a camera.
  6190. * This ensures than once parsed,
  6191. * the input associated to the camera will be identical to the current ones
  6192. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6193. */
  6194. serialize(serializedCamera: any): void;
  6195. /**
  6196. * Parses an input manager serialized JSON to restore the previous list of inputs
  6197. * and states associated to a camera.
  6198. * @param parsedCamera Defines the JSON to parse
  6199. */
  6200. parse(parsedCamera: any): void;
  6201. }
  6202. }
  6203. declare module BABYLON {
  6204. /**
  6205. * Class used to store data that will be store in GPU memory
  6206. */
  6207. export class Buffer {
  6208. private _engine;
  6209. private _buffer;
  6210. /** @hidden */
  6211. _data: Nullable<DataArray>;
  6212. private _updatable;
  6213. private _instanced;
  6214. /**
  6215. * Gets the byte stride.
  6216. */
  6217. readonly byteStride: number;
  6218. /**
  6219. * Constructor
  6220. * @param engine the engine
  6221. * @param data the data to use for this buffer
  6222. * @param updatable whether the data is updatable
  6223. * @param stride the stride (optional)
  6224. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6225. * @param instanced whether the buffer is instanced (optional)
  6226. * @param useBytes set to true if the stride in in bytes (optional)
  6227. */
  6228. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6229. /**
  6230. * Create a new VertexBuffer based on the current buffer
  6231. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6232. * @param offset defines offset in the buffer (0 by default)
  6233. * @param size defines the size in floats of attributes (position is 3 for instance)
  6234. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6235. * @param instanced defines if the vertex buffer contains indexed data
  6236. * @param useBytes defines if the offset and stride are in bytes
  6237. * @returns the new vertex buffer
  6238. */
  6239. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6240. /**
  6241. * Gets a boolean indicating if the Buffer is updatable?
  6242. * @returns true if the buffer is updatable
  6243. */
  6244. isUpdatable(): boolean;
  6245. /**
  6246. * Gets current buffer's data
  6247. * @returns a DataArray or null
  6248. */
  6249. getData(): Nullable<DataArray>;
  6250. /**
  6251. * Gets underlying native buffer
  6252. * @returns underlying native buffer
  6253. */
  6254. getBuffer(): Nullable<DataBuffer>;
  6255. /**
  6256. * Gets the stride in float32 units (i.e. byte stride / 4).
  6257. * May not be an integer if the byte stride is not divisible by 4.
  6258. * DEPRECATED. Use byteStride instead.
  6259. * @returns the stride in float32 units
  6260. */
  6261. getStrideSize(): number;
  6262. /**
  6263. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6264. * @param data defines the data to store
  6265. */
  6266. create(data?: Nullable<DataArray>): void;
  6267. /** @hidden */
  6268. _rebuild(): void;
  6269. /**
  6270. * Update current buffer data
  6271. * @param data defines the data to store
  6272. */
  6273. update(data: DataArray): void;
  6274. /**
  6275. * Updates the data directly.
  6276. * @param data the new data
  6277. * @param offset the new offset
  6278. * @param vertexCount the vertex count (optional)
  6279. * @param useBytes set to true if the offset is in bytes
  6280. */
  6281. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6282. /**
  6283. * Release all resources
  6284. */
  6285. dispose(): void;
  6286. }
  6287. /**
  6288. * Specialized buffer used to store vertex data
  6289. */
  6290. export class VertexBuffer {
  6291. /** @hidden */
  6292. _buffer: Buffer;
  6293. private _kind;
  6294. private _size;
  6295. private _ownsBuffer;
  6296. private _instanced;
  6297. private _instanceDivisor;
  6298. /**
  6299. * The byte type.
  6300. */
  6301. static readonly BYTE: number;
  6302. /**
  6303. * The unsigned byte type.
  6304. */
  6305. static readonly UNSIGNED_BYTE: number;
  6306. /**
  6307. * The short type.
  6308. */
  6309. static readonly SHORT: number;
  6310. /**
  6311. * The unsigned short type.
  6312. */
  6313. static readonly UNSIGNED_SHORT: number;
  6314. /**
  6315. * The integer type.
  6316. */
  6317. static readonly INT: number;
  6318. /**
  6319. * The unsigned integer type.
  6320. */
  6321. static readonly UNSIGNED_INT: number;
  6322. /**
  6323. * The float type.
  6324. */
  6325. static readonly FLOAT: number;
  6326. /**
  6327. * Gets or sets the instance divisor when in instanced mode
  6328. */
  6329. instanceDivisor: number;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Gets the byte offset.
  6336. */
  6337. readonly byteOffset: number;
  6338. /**
  6339. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6340. */
  6341. readonly normalized: boolean;
  6342. /**
  6343. * Gets the data type of each component in the array.
  6344. */
  6345. readonly type: number;
  6346. /**
  6347. * Constructor
  6348. * @param engine the engine
  6349. * @param data the data to use for this vertex buffer
  6350. * @param kind the vertex buffer kind
  6351. * @param updatable whether the data is updatable
  6352. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6353. * @param stride the stride (optional)
  6354. * @param instanced whether the buffer is instanced (optional)
  6355. * @param offset the offset of the data (optional)
  6356. * @param size the number of components (optional)
  6357. * @param type the type of the component (optional)
  6358. * @param normalized whether the data contains normalized data (optional)
  6359. * @param useBytes set to true if stride and offset are in bytes (optional)
  6360. */
  6361. 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);
  6362. /** @hidden */
  6363. _rebuild(): void;
  6364. /**
  6365. * Returns the kind of the VertexBuffer (string)
  6366. * @returns a string
  6367. */
  6368. getKind(): string;
  6369. /**
  6370. * Gets a boolean indicating if the VertexBuffer is updatable?
  6371. * @returns true if the buffer is updatable
  6372. */
  6373. isUpdatable(): boolean;
  6374. /**
  6375. * Gets current buffer's data
  6376. * @returns a DataArray or null
  6377. */
  6378. getData(): Nullable<DataArray>;
  6379. /**
  6380. * Gets underlying native buffer
  6381. * @returns underlying native buffer
  6382. */
  6383. getBuffer(): Nullable<DataBuffer>;
  6384. /**
  6385. * Gets the stride in float32 units (i.e. byte stride / 4).
  6386. * May not be an integer if the byte stride is not divisible by 4.
  6387. * DEPRECATED. Use byteStride instead.
  6388. * @returns the stride in float32 units
  6389. */
  6390. getStrideSize(): number;
  6391. /**
  6392. * Returns the offset as a multiple of the type byte length.
  6393. * DEPRECATED. Use byteOffset instead.
  6394. * @returns the offset in bytes
  6395. */
  6396. getOffset(): number;
  6397. /**
  6398. * Returns the number of components per vertex attribute (integer)
  6399. * @returns the size in float
  6400. */
  6401. getSize(): number;
  6402. /**
  6403. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6404. * @returns true if this buffer is instanced
  6405. */
  6406. getIsInstanced(): boolean;
  6407. /**
  6408. * Returns the instancing divisor, zero for non-instanced (integer).
  6409. * @returns a number
  6410. */
  6411. getInstanceDivisor(): number;
  6412. /**
  6413. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6414. * @param data defines the data to store
  6415. */
  6416. create(data?: DataArray): void;
  6417. /**
  6418. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6419. * This function will create a new buffer if the current one is not updatable
  6420. * @param data defines the data to store
  6421. */
  6422. update(data: DataArray): void;
  6423. /**
  6424. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6425. * Returns the directly updated WebGLBuffer.
  6426. * @param data the new data
  6427. * @param offset the new offset
  6428. * @param useBytes set to true if the offset is in bytes
  6429. */
  6430. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6431. /**
  6432. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6433. */
  6434. dispose(): void;
  6435. /**
  6436. * Enumerates each value of this vertex buffer as numbers.
  6437. * @param count the number of values to enumerate
  6438. * @param callback the callback function called for each value
  6439. */
  6440. forEach(count: number, callback: (value: number, index: number) => void): void;
  6441. /**
  6442. * Positions
  6443. */
  6444. static readonly PositionKind: string;
  6445. /**
  6446. * Normals
  6447. */
  6448. static readonly NormalKind: string;
  6449. /**
  6450. * Tangents
  6451. */
  6452. static readonly TangentKind: string;
  6453. /**
  6454. * Texture coordinates
  6455. */
  6456. static readonly UVKind: string;
  6457. /**
  6458. * Texture coordinates 2
  6459. */
  6460. static readonly UV2Kind: string;
  6461. /**
  6462. * Texture coordinates 3
  6463. */
  6464. static readonly UV3Kind: string;
  6465. /**
  6466. * Texture coordinates 4
  6467. */
  6468. static readonly UV4Kind: string;
  6469. /**
  6470. * Texture coordinates 5
  6471. */
  6472. static readonly UV5Kind: string;
  6473. /**
  6474. * Texture coordinates 6
  6475. */
  6476. static readonly UV6Kind: string;
  6477. /**
  6478. * Colors
  6479. */
  6480. static readonly ColorKind: string;
  6481. /**
  6482. * Matrix indices (for bones)
  6483. */
  6484. static readonly MatricesIndicesKind: string;
  6485. /**
  6486. * Matrix weights (for bones)
  6487. */
  6488. static readonly MatricesWeightsKind: string;
  6489. /**
  6490. * Additional matrix indices (for bones)
  6491. */
  6492. static readonly MatricesIndicesExtraKind: string;
  6493. /**
  6494. * Additional matrix weights (for bones)
  6495. */
  6496. static readonly MatricesWeightsExtraKind: string;
  6497. /**
  6498. * Deduces the stride given a kind.
  6499. * @param kind The kind string to deduce
  6500. * @returns The deduced stride
  6501. */
  6502. static DeduceStride(kind: string): number;
  6503. /**
  6504. * Gets the byte length of the given type.
  6505. * @param type the type
  6506. * @returns the number of bytes
  6507. */
  6508. static GetTypeByteLength(type: number): number;
  6509. /**
  6510. * Enumerates each value of the given parameters as numbers.
  6511. * @param data the data to enumerate
  6512. * @param byteOffset the byte offset of the data
  6513. * @param byteStride the byte stride of the data
  6514. * @param componentCount the number of components per element
  6515. * @param componentType the type of the component
  6516. * @param count the number of values to enumerate
  6517. * @param normalized whether the data is normalized
  6518. * @param callback the callback function called for each value
  6519. */
  6520. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6521. private static _GetFloatValue;
  6522. }
  6523. }
  6524. declare module BABYLON {
  6525. /**
  6526. * @hidden
  6527. */
  6528. export class IntersectionInfo {
  6529. bu: Nullable<number>;
  6530. bv: Nullable<number>;
  6531. distance: number;
  6532. faceId: number;
  6533. subMeshId: number;
  6534. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * Represens a plane by the equation ax + by + cz + d = 0
  6540. */
  6541. export class Plane {
  6542. private static _TmpMatrix;
  6543. /**
  6544. * Normal of the plane (a,b,c)
  6545. */
  6546. normal: Vector3;
  6547. /**
  6548. * d component of the plane
  6549. */
  6550. d: number;
  6551. /**
  6552. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6553. * @param a a component of the plane
  6554. * @param b b component of the plane
  6555. * @param c c component of the plane
  6556. * @param d d component of the plane
  6557. */
  6558. constructor(a: number, b: number, c: number, d: number);
  6559. /**
  6560. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6561. */
  6562. asArray(): number[];
  6563. /**
  6564. * @returns a new plane copied from the current Plane.
  6565. */
  6566. clone(): Plane;
  6567. /**
  6568. * @returns the string "Plane".
  6569. */
  6570. getClassName(): string;
  6571. /**
  6572. * @returns the Plane hash code.
  6573. */
  6574. getHashCode(): number;
  6575. /**
  6576. * Normalize the current Plane in place.
  6577. * @returns the updated Plane.
  6578. */
  6579. normalize(): Plane;
  6580. /**
  6581. * Applies a transformation the plane and returns the result
  6582. * @param transformation the transformation matrix to be applied to the plane
  6583. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6584. */
  6585. transform(transformation: DeepImmutable<Matrix>): Plane;
  6586. /**
  6587. * Calcualtte the dot product between the point and the plane normal
  6588. * @param point point to calculate the dot product with
  6589. * @returns the dot product (float) of the point coordinates and the plane normal.
  6590. */
  6591. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6592. /**
  6593. * Updates the current Plane from the plane defined by the three given points.
  6594. * @param point1 one of the points used to contruct the plane
  6595. * @param point2 one of the points used to contruct the plane
  6596. * @param point3 one of the points used to contruct the plane
  6597. * @returns the updated Plane.
  6598. */
  6599. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6600. /**
  6601. * Checks if the plane is facing a given direction
  6602. * @param direction the direction to check if the plane is facing
  6603. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6604. * @returns True is the vector "direction" is the same side than the plane normal.
  6605. */
  6606. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6607. /**
  6608. * Calculates the distance to a point
  6609. * @param point point to calculate distance to
  6610. * @returns the signed distance (float) from the given point to the Plane.
  6611. */
  6612. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6613. /**
  6614. * Creates a plane from an array
  6615. * @param array the array to create a plane from
  6616. * @returns a new Plane from the given array.
  6617. */
  6618. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6619. /**
  6620. * Creates a plane from three points
  6621. * @param point1 point used to create the plane
  6622. * @param point2 point used to create the plane
  6623. * @param point3 point used to create the plane
  6624. * @returns a new Plane defined by the three given points.
  6625. */
  6626. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6627. /**
  6628. * Creates a plane from an origin point and a normal
  6629. * @param origin origin of the plane to be constructed
  6630. * @param normal normal of the plane to be constructed
  6631. * @returns a new Plane the normal vector to this plane at the given origin point.
  6632. * Note : the vector "normal" is updated because normalized.
  6633. */
  6634. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6635. /**
  6636. * Calculates the distance from a plane and a point
  6637. * @param origin origin of the plane to be constructed
  6638. * @param normal normal of the plane to be constructed
  6639. * @param point point to calculate distance to
  6640. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6641. */
  6642. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6643. }
  6644. }
  6645. declare module BABYLON {
  6646. /**
  6647. * Class used to store bounding sphere information
  6648. */
  6649. export class BoundingSphere {
  6650. /**
  6651. * Gets the center of the bounding sphere in local space
  6652. */
  6653. readonly center: Vector3;
  6654. /**
  6655. * Radius of the bounding sphere in local space
  6656. */
  6657. radius: number;
  6658. /**
  6659. * Gets the center of the bounding sphere in world space
  6660. */
  6661. readonly centerWorld: Vector3;
  6662. /**
  6663. * Radius of the bounding sphere in world space
  6664. */
  6665. radiusWorld: number;
  6666. /**
  6667. * Gets the minimum vector in local space
  6668. */
  6669. readonly minimum: Vector3;
  6670. /**
  6671. * Gets the maximum vector in local space
  6672. */
  6673. readonly maximum: Vector3;
  6674. private _worldMatrix;
  6675. private static readonly TmpVector3;
  6676. /**
  6677. * Creates a new bounding sphere
  6678. * @param min defines the minimum vector (in local space)
  6679. * @param max defines the maximum vector (in local space)
  6680. * @param worldMatrix defines the new world matrix
  6681. */
  6682. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6683. /**
  6684. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6685. * @param min defines the new minimum vector (in local space)
  6686. * @param max defines the new maximum vector (in local space)
  6687. * @param worldMatrix defines the new world matrix
  6688. */
  6689. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6690. /**
  6691. * Scale the current bounding sphere by applying a scale factor
  6692. * @param factor defines the scale factor to apply
  6693. * @returns the current bounding box
  6694. */
  6695. scale(factor: number): BoundingSphere;
  6696. /**
  6697. * Gets the world matrix of the bounding box
  6698. * @returns a matrix
  6699. */
  6700. getWorldMatrix(): DeepImmutable<Matrix>;
  6701. /** @hidden */
  6702. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6703. /**
  6704. * Tests if the bounding sphere is intersecting the frustum planes
  6705. * @param frustumPlanes defines the frustum planes to test
  6706. * @returns true if there is an intersection
  6707. */
  6708. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6709. /**
  6710. * Tests if the bounding sphere center is in between the frustum planes.
  6711. * Used for optimistic fast inclusion.
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if the sphere center is in between the frustum planes
  6714. */
  6715. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding sphere
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding sphere
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Checks if two sphere intersct
  6724. * @param sphere0 sphere 0
  6725. * @param sphere1 sphere 1
  6726. * @returns true if the speres intersect
  6727. */
  6728. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6729. }
  6730. }
  6731. declare module BABYLON {
  6732. /**
  6733. * Class used to store bounding box information
  6734. */
  6735. export class BoundingBox implements ICullable {
  6736. /**
  6737. * Gets the 8 vectors representing the bounding box in local space
  6738. */
  6739. readonly vectors: Vector3[];
  6740. /**
  6741. * Gets the center of the bounding box in local space
  6742. */
  6743. readonly center: Vector3;
  6744. /**
  6745. * Gets the center of the bounding box in world space
  6746. */
  6747. readonly centerWorld: Vector3;
  6748. /**
  6749. * Gets the extend size in local space
  6750. */
  6751. readonly extendSize: Vector3;
  6752. /**
  6753. * Gets the extend size in world space
  6754. */
  6755. readonly extendSizeWorld: Vector3;
  6756. /**
  6757. * Gets the OBB (object bounding box) directions
  6758. */
  6759. readonly directions: Vector3[];
  6760. /**
  6761. * Gets the 8 vectors representing the bounding box in world space
  6762. */
  6763. readonly vectorsWorld: Vector3[];
  6764. /**
  6765. * Gets the minimum vector in world space
  6766. */
  6767. readonly minimumWorld: Vector3;
  6768. /**
  6769. * Gets the maximum vector in world space
  6770. */
  6771. readonly maximumWorld: Vector3;
  6772. /**
  6773. * Gets the minimum vector in local space
  6774. */
  6775. readonly minimum: Vector3;
  6776. /**
  6777. * Gets the maximum vector in local space
  6778. */
  6779. readonly maximum: Vector3;
  6780. private _worldMatrix;
  6781. private static readonly TmpVector3;
  6782. /**
  6783. * @hidden
  6784. */
  6785. _tag: number;
  6786. /**
  6787. * Creates a new bounding box
  6788. * @param min defines the minimum vector (in local space)
  6789. * @param max defines the maximum vector (in local space)
  6790. * @param worldMatrix defines the new world matrix
  6791. */
  6792. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6793. /**
  6794. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6795. * @param min defines the new minimum vector (in local space)
  6796. * @param max defines the new maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6800. /**
  6801. * Scale the current bounding box by applying a scale factor
  6802. * @param factor defines the scale factor to apply
  6803. * @returns the current bounding box
  6804. */
  6805. scale(factor: number): BoundingBox;
  6806. /**
  6807. * Gets the world matrix of the bounding box
  6808. * @returns a matrix
  6809. */
  6810. getWorldMatrix(): DeepImmutable<Matrix>;
  6811. /** @hidden */
  6812. _update(world: DeepImmutable<Matrix>): void;
  6813. /**
  6814. * Tests if the bounding box is intersecting the frustum planes
  6815. * @param frustumPlanes defines the frustum planes to test
  6816. * @returns true if there is an intersection
  6817. */
  6818. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6819. /**
  6820. * Tests if the bounding box is entirely inside the frustum planes
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @returns true if there is an inclusion
  6823. */
  6824. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a point is inside the bounding box
  6827. * @param point defines the point to test
  6828. * @returns true if the point is inside the bounding box
  6829. */
  6830. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6831. /**
  6832. * Tests if the bounding box intersects with a bounding sphere
  6833. * @param sphere defines the sphere to test
  6834. * @returns true if there is an intersection
  6835. */
  6836. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6837. /**
  6838. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6839. * @param min defines the min vector to use
  6840. * @param max defines the max vector to use
  6841. * @returns true if there is an intersection
  6842. */
  6843. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6844. /**
  6845. * Tests if two bounding boxes are intersections
  6846. * @param box0 defines the first box to test
  6847. * @param box1 defines the second box to test
  6848. * @returns true if there is an intersection
  6849. */
  6850. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6851. /**
  6852. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6853. * @param minPoint defines the minimum vector of the bounding box
  6854. * @param maxPoint defines the maximum vector of the bounding box
  6855. * @param sphereCenter defines the sphere center
  6856. * @param sphereRadius defines the sphere radius
  6857. * @returns true if there is an intersection
  6858. */
  6859. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6860. /**
  6861. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6862. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6863. * @param frustumPlanes defines the frustum planes to test
  6864. * @return true if there is an inclusion
  6865. */
  6866. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6867. /**
  6868. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6869. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @return true if there is an intersection
  6872. */
  6873. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. }
  6875. }
  6876. declare module BABYLON {
  6877. /** @hidden */
  6878. export class Collider {
  6879. /** Define if a collision was found */
  6880. collisionFound: boolean;
  6881. /**
  6882. * Define last intersection point in local space
  6883. */
  6884. intersectionPoint: Vector3;
  6885. /**
  6886. * Define last collided mesh
  6887. */
  6888. collidedMesh: Nullable<AbstractMesh>;
  6889. private _collisionPoint;
  6890. private _planeIntersectionPoint;
  6891. private _tempVector;
  6892. private _tempVector2;
  6893. private _tempVector3;
  6894. private _tempVector4;
  6895. private _edge;
  6896. private _baseToVertex;
  6897. private _destinationPoint;
  6898. private _slidePlaneNormal;
  6899. private _displacementVector;
  6900. /** @hidden */
  6901. _radius: Vector3;
  6902. /** @hidden */
  6903. _retry: number;
  6904. private _velocity;
  6905. private _basePoint;
  6906. private _epsilon;
  6907. /** @hidden */
  6908. _velocityWorldLength: number;
  6909. /** @hidden */
  6910. _basePointWorld: Vector3;
  6911. private _velocityWorld;
  6912. private _normalizedVelocity;
  6913. /** @hidden */
  6914. _initialVelocity: Vector3;
  6915. /** @hidden */
  6916. _initialPosition: Vector3;
  6917. private _nearestDistance;
  6918. private _collisionMask;
  6919. collisionMask: number;
  6920. /**
  6921. * Gets the plane normal used to compute the sliding response (in local space)
  6922. */
  6923. readonly slidePlaneNormal: Vector3;
  6924. /** @hidden */
  6925. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6926. /** @hidden */
  6927. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6928. /** @hidden */
  6929. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6930. /** @hidden */
  6931. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6932. /** @hidden */
  6933. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6934. /** @hidden */
  6935. _getResponse(pos: Vector3, vel: Vector3): void;
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Interface for cullable objects
  6941. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6942. */
  6943. export interface ICullable {
  6944. /**
  6945. * Checks if the object or part of the object is in the frustum
  6946. * @param frustumPlanes Camera near/planes
  6947. * @returns true if the object is in frustum otherwise false
  6948. */
  6949. isInFrustum(frustumPlanes: Plane[]): boolean;
  6950. /**
  6951. * Checks if a cullable object (mesh...) is in the camera frustum
  6952. * Unlike isInFrustum this cheks the full bounding box
  6953. * @param frustumPlanes Camera near/planes
  6954. * @returns true if the object is in frustum otherwise false
  6955. */
  6956. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6957. }
  6958. /**
  6959. * Info for a bounding data of a mesh
  6960. */
  6961. export class BoundingInfo implements ICullable {
  6962. /**
  6963. * Bounding box for the mesh
  6964. */
  6965. readonly boundingBox: BoundingBox;
  6966. /**
  6967. * Bounding sphere for the mesh
  6968. */
  6969. readonly boundingSphere: BoundingSphere;
  6970. private _isLocked;
  6971. private static readonly TmpVector3;
  6972. /**
  6973. * Constructs bounding info
  6974. * @param minimum min vector of the bounding box/sphere
  6975. * @param maximum max vector of the bounding box/sphere
  6976. * @param worldMatrix defines the new world matrix
  6977. */
  6978. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6979. /**
  6980. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6981. * @param min defines the new minimum vector (in local space)
  6982. * @param max defines the new maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6986. /**
  6987. * min vector of the bounding box/sphere
  6988. */
  6989. readonly minimum: Vector3;
  6990. /**
  6991. * max vector of the bounding box/sphere
  6992. */
  6993. readonly maximum: Vector3;
  6994. /**
  6995. * If the info is locked and won't be updated to avoid perf overhead
  6996. */
  6997. isLocked: boolean;
  6998. /**
  6999. * Updates the bounding sphere and box
  7000. * @param world world matrix to be used to update
  7001. */
  7002. update(world: DeepImmutable<Matrix>): void;
  7003. /**
  7004. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7005. * @param center New center of the bounding info
  7006. * @param extend New extend of the bounding info
  7007. * @returns the current bounding info
  7008. */
  7009. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7010. /**
  7011. * Scale the current bounding info by applying a scale factor
  7012. * @param factor defines the scale factor to apply
  7013. * @returns the current bounding info
  7014. */
  7015. scale(factor: number): BoundingInfo;
  7016. /**
  7017. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7018. * @param frustumPlanes defines the frustum to test
  7019. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7020. * @returns true if the bounding info is in the frustum planes
  7021. */
  7022. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7023. /**
  7024. * Gets the world distance between the min and max points of the bounding box
  7025. */
  7026. readonly diagonalLength: number;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7034. /** @hidden */
  7035. _checkCollision(collider: Collider): boolean;
  7036. /**
  7037. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7038. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7039. * @param point the point to check intersection with
  7040. * @returns if the point intersects
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7045. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7046. * @param boundingInfo the bounding info to check intersection with
  7047. * @param precise if the intersection should be done using OBB
  7048. * @returns if the bounding info intersects
  7049. */
  7050. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /**
  7055. * Extracts minimum and maximum values from a list of indexed positions
  7056. * @param positions defines the positions to use
  7057. * @param indices defines the indices to the positions
  7058. * @param indexStart defines the start index
  7059. * @param indexCount defines the end index
  7060. * @param bias defines bias value to add to the result
  7061. * @return minimum and maximum values
  7062. */
  7063. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7064. minimum: Vector3;
  7065. maximum: Vector3;
  7066. };
  7067. /**
  7068. * Extracts minimum and maximum values from a list of positions
  7069. * @param positions defines the positions to use
  7070. * @param start defines the start index in the positions array
  7071. * @param count defines the number of positions to handle
  7072. * @param bias defines bias value to add to the result
  7073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7074. * @return minimum and maximum values
  7075. */
  7076. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7077. minimum: Vector3;
  7078. maximum: Vector3;
  7079. };
  7080. }
  7081. declare module BABYLON {
  7082. /** @hidden */
  7083. export class WebGLDataBuffer extends DataBuffer {
  7084. private _buffer;
  7085. constructor(resource: WebGLBuffer);
  7086. readonly underlyingResource: any;
  7087. }
  7088. }
  7089. declare module BABYLON {
  7090. /** @hidden */
  7091. export class WebGLPipelineContext implements IPipelineContext {
  7092. engine: ThinEngine;
  7093. program: Nullable<WebGLProgram>;
  7094. context?: WebGLRenderingContext;
  7095. vertexShader?: WebGLShader;
  7096. fragmentShader?: WebGLShader;
  7097. isParallelCompiled: boolean;
  7098. onCompiled?: () => void;
  7099. transformFeedback?: WebGLTransformFeedback | null;
  7100. readonly isAsync: boolean;
  7101. readonly isReady: boolean;
  7102. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. interface ThinEngine {
  7107. /**
  7108. * Create an uniform buffer
  7109. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7110. * @param elements defines the content of the uniform buffer
  7111. * @returns the webGL uniform buffer
  7112. */
  7113. createUniformBuffer(elements: FloatArray): DataBuffer;
  7114. /**
  7115. * Create a dynamic uniform buffer
  7116. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7117. * @param elements defines the content of the uniform buffer
  7118. * @returns the webGL uniform buffer
  7119. */
  7120. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7121. /**
  7122. * Update an existing uniform buffer
  7123. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7124. * @param uniformBuffer defines the target uniform buffer
  7125. * @param elements defines the content to update
  7126. * @param offset defines the offset in the uniform buffer where update should start
  7127. * @param count defines the size of the data to update
  7128. */
  7129. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7130. /**
  7131. * Bind an uniform buffer to the current webGL context
  7132. * @param buffer defines the buffer to bind
  7133. */
  7134. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7135. /**
  7136. * Bind a buffer to the current webGL context at a given location
  7137. * @param buffer defines the buffer to bind
  7138. * @param location defines the index where to bind the buffer
  7139. */
  7140. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7141. /**
  7142. * Bind a specific block at a given index in a specific shader program
  7143. * @param pipelineContext defines the pipeline context to use
  7144. * @param blockName defines the block name
  7145. * @param index defines the index where to bind the block
  7146. */
  7147. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7148. }
  7149. }
  7150. declare module BABYLON {
  7151. /**
  7152. * Uniform buffer objects.
  7153. *
  7154. * Handles blocks of uniform on the GPU.
  7155. *
  7156. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7157. *
  7158. * For more information, please refer to :
  7159. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7160. */
  7161. export class UniformBuffer {
  7162. private _engine;
  7163. private _buffer;
  7164. private _data;
  7165. private _bufferData;
  7166. private _dynamic?;
  7167. private _uniformLocations;
  7168. private _uniformSizes;
  7169. private _uniformLocationPointer;
  7170. private _needSync;
  7171. private _noUBO;
  7172. private _currentEffect;
  7173. private static _MAX_UNIFORM_SIZE;
  7174. private static _tempBuffer;
  7175. /**
  7176. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7177. * This is dynamic to allow compat with webgl 1 and 2.
  7178. * You will need to pass the name of the uniform as well as the value.
  7179. */
  7180. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7181. /**
  7182. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a single float in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateFloat: (name: string, x: number) => void;
  7193. /**
  7194. * Lambda to Update a vec2 of float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7199. /**
  7200. * Lambda to Update a vec3 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec4 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateMatrix: (name: string, mat: Matrix) => void;
  7217. /**
  7218. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateVector3: (name: string, vector: Vector3) => void;
  7223. /**
  7224. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector4: (name: string, vector: Vector4) => void;
  7229. /**
  7230. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7235. /**
  7236. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7241. /**
  7242. * Instantiates a new Uniform buffer objects.
  7243. *
  7244. * Handles blocks of uniform on the GPU.
  7245. *
  7246. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7247. *
  7248. * For more information, please refer to :
  7249. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7250. * @param engine Define the engine the buffer is associated with
  7251. * @param data Define the data contained in the buffer
  7252. * @param dynamic Define if the buffer is updatable
  7253. */
  7254. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7255. /**
  7256. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7257. * or just falling back on setUniformXXX calls.
  7258. */
  7259. readonly useUbo: boolean;
  7260. /**
  7261. * Indicates if the WebGL underlying uniform buffer is in sync
  7262. * with the javascript cache data.
  7263. */
  7264. readonly isSync: boolean;
  7265. /**
  7266. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7267. * Also, a dynamic UniformBuffer will disable cache verification and always
  7268. * update the underlying WebGL uniform buffer to the GPU.
  7269. * @returns if Dynamic, otherwise false
  7270. */
  7271. isDynamic(): boolean;
  7272. /**
  7273. * The data cache on JS side.
  7274. * @returns the underlying data as a float array
  7275. */
  7276. getData(): Float32Array;
  7277. /**
  7278. * The underlying WebGL Uniform buffer.
  7279. * @returns the webgl buffer
  7280. */
  7281. getBuffer(): Nullable<DataBuffer>;
  7282. /**
  7283. * std140 layout specifies how to align data within an UBO structure.
  7284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7285. * for specs.
  7286. */
  7287. private _fillAlignment;
  7288. /**
  7289. * Adds an uniform in the buffer.
  7290. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7291. * for the layout to be correct !
  7292. * @param name Name of the uniform, as used in the uniform block in the shader.
  7293. * @param size Data size, or data directly.
  7294. */
  7295. addUniform(name: string, size: number | number[]): void;
  7296. /**
  7297. * Adds a Matrix 4x4 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param mat A 4x4 matrix.
  7300. */
  7301. addMatrix(name: string, mat: Matrix): void;
  7302. /**
  7303. * Adds a vec2 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param x Define the x component value of the vec2
  7306. * @param y Define the y component value of the vec2
  7307. */
  7308. addFloat2(name: string, x: number, y: number): void;
  7309. /**
  7310. * Adds a vec3 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param x Define the x component value of the vec3
  7313. * @param y Define the y component value of the vec3
  7314. * @param z Define the z component value of the vec3
  7315. */
  7316. addFloat3(name: string, x: number, y: number, z: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param color Define the vec3 from a Color
  7321. */
  7322. addColor3(name: string, color: Color3): void;
  7323. /**
  7324. * Adds a vec4 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the rgb components from a Color
  7327. * @param alpha Define the a component of the vec4
  7328. */
  7329. addColor4(name: string, color: Color3, alpha: number): void;
  7330. /**
  7331. * Adds a vec3 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param vector Define the vec3 components from a Vector
  7334. */
  7335. addVector3(name: string, vector: Vector3): void;
  7336. /**
  7337. * Adds a Matrix 3x3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. */
  7340. addMatrix3x3(name: string): void;
  7341. /**
  7342. * Adds a Matrix 2x2 to the uniform buffer.
  7343. * @param name Name of the uniform, as used in the uniform block in the shader.
  7344. */
  7345. addMatrix2x2(name: string): void;
  7346. /**
  7347. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7348. */
  7349. create(): void;
  7350. /** @hidden */
  7351. _rebuild(): void;
  7352. /**
  7353. * Updates the WebGL Uniform Buffer on the GPU.
  7354. * If the `dynamic` flag is set to true, no cache comparison is done.
  7355. * Otherwise, the buffer will be updated only if the cache differs.
  7356. */
  7357. update(): void;
  7358. /**
  7359. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7360. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7361. * @param data Define the flattened data
  7362. * @param size Define the size of the data.
  7363. */
  7364. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7365. private _valueCache;
  7366. private _cacheMatrix;
  7367. private _updateMatrix3x3ForUniform;
  7368. private _updateMatrix3x3ForEffect;
  7369. private _updateMatrix2x2ForEffect;
  7370. private _updateMatrix2x2ForUniform;
  7371. private _updateFloatForEffect;
  7372. private _updateFloatForUniform;
  7373. private _updateFloat2ForEffect;
  7374. private _updateFloat2ForUniform;
  7375. private _updateFloat3ForEffect;
  7376. private _updateFloat3ForUniform;
  7377. private _updateFloat4ForEffect;
  7378. private _updateFloat4ForUniform;
  7379. private _updateMatrixForEffect;
  7380. private _updateMatrixForUniform;
  7381. private _updateVector3ForEffect;
  7382. private _updateVector3ForUniform;
  7383. private _updateVector4ForEffect;
  7384. private _updateVector4ForUniform;
  7385. private _updateColor3ForEffect;
  7386. private _updateColor3ForUniform;
  7387. private _updateColor4ForEffect;
  7388. private _updateColor4ForUniform;
  7389. /**
  7390. * Sets a sampler uniform on the effect.
  7391. * @param name Define the name of the sampler.
  7392. * @param texture Define the texture to set in the sampler
  7393. */
  7394. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7395. /**
  7396. * Directly updates the value of the uniform in the cache AND on the GPU.
  7397. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7398. * @param data Define the flattened data
  7399. */
  7400. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7401. /**
  7402. * Binds this uniform buffer to an effect.
  7403. * @param effect Define the effect to bind the buffer to
  7404. * @param name Name of the uniform block in the shader.
  7405. */
  7406. bindToEffect(effect: Effect, name: string): void;
  7407. /**
  7408. * Disposes the uniform buffer.
  7409. */
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Enum that determines the text-wrapping mode to use.
  7416. */
  7417. export enum InspectableType {
  7418. /**
  7419. * Checkbox for booleans
  7420. */
  7421. Checkbox = 0,
  7422. /**
  7423. * Sliders for numbers
  7424. */
  7425. Slider = 1,
  7426. /**
  7427. * Vector3
  7428. */
  7429. Vector3 = 2,
  7430. /**
  7431. * Quaternions
  7432. */
  7433. Quaternion = 3,
  7434. /**
  7435. * Color3
  7436. */
  7437. Color3 = 4,
  7438. /**
  7439. * String
  7440. */
  7441. String = 5
  7442. }
  7443. /**
  7444. * Interface used to define custom inspectable properties.
  7445. * This interface is used by the inspector to display custom property grids
  7446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7447. */
  7448. export interface IInspectable {
  7449. /**
  7450. * Gets the label to display
  7451. */
  7452. label: string;
  7453. /**
  7454. * Gets the name of the property to edit
  7455. */
  7456. propertyName: string;
  7457. /**
  7458. * Gets the type of the editor to use
  7459. */
  7460. type: InspectableType;
  7461. /**
  7462. * Gets the minimum value of the property when using in "slider" mode
  7463. */
  7464. min?: number;
  7465. /**
  7466. * Gets the maximum value of the property when using in "slider" mode
  7467. */
  7468. max?: number;
  7469. /**
  7470. * Gets the setp to use when using in "slider" mode
  7471. */
  7472. step?: number;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class used to provide helper for timing
  7478. */
  7479. export class TimingTools {
  7480. /**
  7481. * Polyfill for setImmediate
  7482. * @param action defines the action to execute after the current execution block
  7483. */
  7484. static SetImmediate(action: () => void): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Class used to enable instatition of objects by class name
  7490. */
  7491. export class InstantiationTools {
  7492. /**
  7493. * Use this object to register external classes like custom textures or material
  7494. * to allow the laoders to instantiate them
  7495. */
  7496. static RegisteredExternalClasses: {
  7497. [key: string]: Object;
  7498. };
  7499. /**
  7500. * Tries to instantiate a new object from a given class name
  7501. * @param className defines the class name to instantiate
  7502. * @returns the new object or null if the system was not able to do the instantiation
  7503. */
  7504. static Instantiate(className: string): any;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Define options used to create a depth texture
  7510. */
  7511. export class DepthTextureCreationOptions {
  7512. /** Specifies whether or not a stencil should be allocated in the texture */
  7513. generateStencil?: boolean;
  7514. /** Specifies whether or not bilinear filtering is enable on the texture */
  7515. bilinearFiltering?: boolean;
  7516. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7517. comparisonFunction?: number;
  7518. /** Specifies if the created texture is a cube texture */
  7519. isCube?: boolean;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. interface ThinEngine {
  7524. /**
  7525. * Creates a depth stencil cube texture.
  7526. * This is only available in WebGL 2.
  7527. * @param size The size of face edge in the cube texture.
  7528. * @param options The options defining the cube texture.
  7529. * @returns The cube texture
  7530. */
  7531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7532. /**
  7533. * Creates a cube texture
  7534. * @param rootUrl defines the url where the files to load is located
  7535. * @param scene defines the current scene
  7536. * @param files defines the list of files to load (1 per face)
  7537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7538. * @param onLoad defines an optional callback raised when the texture is loaded
  7539. * @param onError defines an optional callback raised if there is an issue to load the texture
  7540. * @param format defines the format of the data
  7541. * @param forcedExtension defines the extension to use to pick the right loader
  7542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7547. * @returns the cube texture as an InternalTexture
  7548. */
  7549. 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;
  7550. /**
  7551. * Creates a cube texture
  7552. * @param rootUrl defines the url where the files to load is located
  7553. * @param scene defines the current scene
  7554. * @param files defines the list of files to load (1 per face)
  7555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7556. * @param onLoad defines an optional callback raised when the texture is loaded
  7557. * @param onError defines an optional callback raised if there is an issue to load the texture
  7558. * @param format defines the format of the data
  7559. * @param forcedExtension defines the extension to use to pick the right loader
  7560. * @returns the cube texture as an InternalTexture
  7561. */
  7562. 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;
  7563. /**
  7564. * Creates a cube texture
  7565. * @param rootUrl defines the url where the files to load is located
  7566. * @param scene defines the current scene
  7567. * @param files defines the list of files to load (1 per face)
  7568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7569. * @param onLoad defines an optional callback raised when the texture is loaded
  7570. * @param onError defines an optional callback raised if there is an issue to load the texture
  7571. * @param format defines the format of the data
  7572. * @param forcedExtension defines the extension to use to pick the right loader
  7573. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7574. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7575. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. 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;
  7579. /** @hidden */
  7580. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7581. /** @hidden */
  7582. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /** @hidden */
  7584. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Class for creating a cube texture
  7592. */
  7593. export class CubeTexture extends BaseTexture {
  7594. private _delayedOnLoad;
  7595. /**
  7596. * The url of the texture
  7597. */
  7598. url: string;
  7599. /**
  7600. * Gets or sets the center of the bounding box associated with the cube texture.
  7601. * It must define where the camera used to render the texture was set
  7602. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7603. */
  7604. boundingBoxPosition: Vector3;
  7605. private _boundingBoxSize;
  7606. /**
  7607. * Gets or sets the size of the bounding box associated with the cube texture
  7608. * When defined, the cubemap will switch to local mode
  7609. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7610. * @example https://www.babylonjs-playground.com/#RNASML
  7611. */
  7612. /**
  7613. * Returns the bounding box size
  7614. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7615. */
  7616. boundingBoxSize: Vector3;
  7617. protected _rotationY: number;
  7618. /**
  7619. * Sets texture matrix rotation angle around Y axis in radians.
  7620. */
  7621. /**
  7622. * Gets texture matrix rotation angle around Y axis radians.
  7623. */
  7624. rotationY: number;
  7625. /**
  7626. * Are mip maps generated for this texture or not.
  7627. */
  7628. readonly noMipmap: boolean;
  7629. private _noMipmap;
  7630. private _files;
  7631. protected _forcedExtension: Nullable<string>;
  7632. private _extensions;
  7633. private _textureMatrix;
  7634. private _format;
  7635. private _createPolynomials;
  7636. /** @hidden */
  7637. _prefiltered: boolean;
  7638. /**
  7639. * Creates a cube texture from an array of image urls
  7640. * @param files defines an array of image urls
  7641. * @param scene defines the hosting scene
  7642. * @param noMipmap specifies if mip maps are not used
  7643. * @returns a cube texture
  7644. */
  7645. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7646. /**
  7647. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7648. * @param url defines the url of the prefiltered texture
  7649. * @param scene defines the scene the texture is attached to
  7650. * @param forcedExtension defines the extension of the file if different from the url
  7651. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7652. * @return the prefiltered texture
  7653. */
  7654. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7655. /**
  7656. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7657. * as prefiltered data.
  7658. * @param rootUrl defines the url of the texture or the root name of the six images
  7659. * @param scene defines the scene the texture is attached to
  7660. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7661. * @param noMipmap defines if mipmaps should be created or not
  7662. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7663. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7664. * @param onError defines a callback triggered in case of error during load
  7665. * @param format defines the internal format to use for the texture once loaded
  7666. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7667. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7668. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7671. * @return the cube texture
  7672. */
  7673. 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);
  7674. /**
  7675. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7676. */
  7677. readonly isPrefiltered: boolean;
  7678. /**
  7679. * Get the current class name of the texture useful for serialization or dynamic coding.
  7680. * @returns "CubeTexture"
  7681. */
  7682. getClassName(): string;
  7683. /**
  7684. * Update the url (and optional buffer) of this texture if url was null during construction.
  7685. * @param url the url of the texture
  7686. * @param forcedExtension defines the extension to use
  7687. * @param onLoad callback called when the texture is loaded (defaults to null)
  7688. */
  7689. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7690. /**
  7691. * Delays loading of the cube texture
  7692. * @param forcedExtension defines the extension to use
  7693. */
  7694. delayLoad(forcedExtension?: string): void;
  7695. /**
  7696. * Returns the reflection texture matrix
  7697. * @returns the reflection texture matrix
  7698. */
  7699. getReflectionTextureMatrix(): Matrix;
  7700. /**
  7701. * Sets the reflection texture matrix
  7702. * @param value Reflection texture matrix
  7703. */
  7704. setReflectionTextureMatrix(value: Matrix): void;
  7705. /**
  7706. * Parses text to create a cube texture
  7707. * @param parsedTexture define the serialized text to read from
  7708. * @param scene defines the hosting scene
  7709. * @param rootUrl defines the root url of the cube texture
  7710. * @returns a cube texture
  7711. */
  7712. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7713. /**
  7714. * Makes a clone, or deep copy, of the cube texture
  7715. * @returns a new cube texture
  7716. */
  7717. clone(): CubeTexture;
  7718. }
  7719. }
  7720. declare module BABYLON {
  7721. /**
  7722. * Manages the defines for the Material
  7723. */
  7724. export class MaterialDefines {
  7725. /** @hidden */
  7726. protected _keys: string[];
  7727. private _isDirty;
  7728. /** @hidden */
  7729. _renderId: number;
  7730. /** @hidden */
  7731. _areLightsDirty: boolean;
  7732. /** @hidden */
  7733. _areLightsDisposed: boolean;
  7734. /** @hidden */
  7735. _areAttributesDirty: boolean;
  7736. /** @hidden */
  7737. _areTexturesDirty: boolean;
  7738. /** @hidden */
  7739. _areFresnelDirty: boolean;
  7740. /** @hidden */
  7741. _areMiscDirty: boolean;
  7742. /** @hidden */
  7743. _areImageProcessingDirty: boolean;
  7744. /** @hidden */
  7745. _normals: boolean;
  7746. /** @hidden */
  7747. _uvs: boolean;
  7748. /** @hidden */
  7749. _needNormals: boolean;
  7750. /** @hidden */
  7751. _needUVs: boolean;
  7752. [id: string]: any;
  7753. /**
  7754. * Specifies if the material needs to be re-calculated
  7755. */
  7756. readonly isDirty: boolean;
  7757. /**
  7758. * Marks the material to indicate that it has been re-calculated
  7759. */
  7760. markAsProcessed(): void;
  7761. /**
  7762. * Marks the material to indicate that it needs to be re-calculated
  7763. */
  7764. markAsUnprocessed(): void;
  7765. /**
  7766. * Marks the material to indicate all of its defines need to be re-calculated
  7767. */
  7768. markAllAsDirty(): void;
  7769. /**
  7770. * Marks the material to indicate that image processing needs to be re-calculated
  7771. */
  7772. markAsImageProcessingDirty(): void;
  7773. /**
  7774. * Marks the material to indicate the lights need to be re-calculated
  7775. * @param disposed Defines whether the light is dirty due to dispose or not
  7776. */
  7777. markAsLightDirty(disposed?: boolean): void;
  7778. /**
  7779. * Marks the attribute state as changed
  7780. */
  7781. markAsAttributesDirty(): void;
  7782. /**
  7783. * Marks the texture state as changed
  7784. */
  7785. markAsTexturesDirty(): void;
  7786. /**
  7787. * Marks the fresnel state as changed
  7788. */
  7789. markAsFresnelDirty(): void;
  7790. /**
  7791. * Marks the misc state as changed
  7792. */
  7793. markAsMiscDirty(): void;
  7794. /**
  7795. * Rebuilds the material defines
  7796. */
  7797. rebuild(): void;
  7798. /**
  7799. * Specifies if two material defines are equal
  7800. * @param other - A material define instance to compare to
  7801. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7802. */
  7803. isEqual(other: MaterialDefines): boolean;
  7804. /**
  7805. * Clones this instance's defines to another instance
  7806. * @param other - material defines to clone values to
  7807. */
  7808. cloneTo(other: MaterialDefines): void;
  7809. /**
  7810. * Resets the material define values
  7811. */
  7812. reset(): void;
  7813. /**
  7814. * Converts the material define values to a string
  7815. * @returns - String of material define information
  7816. */
  7817. toString(): string;
  7818. }
  7819. }
  7820. declare module BABYLON {
  7821. /**
  7822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7824. * 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;
  7825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7826. */
  7827. export class ColorCurves {
  7828. private _dirty;
  7829. private _tempColor;
  7830. private _globalCurve;
  7831. private _highlightsCurve;
  7832. private _midtonesCurve;
  7833. private _shadowsCurve;
  7834. private _positiveCurve;
  7835. private _negativeCurve;
  7836. private _globalHue;
  7837. private _globalDensity;
  7838. private _globalSaturation;
  7839. private _globalExposure;
  7840. /**
  7841. * Gets the global Hue value.
  7842. * 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).
  7843. */
  7844. /**
  7845. * Sets the global Hue value.
  7846. * 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).
  7847. */
  7848. globalHue: number;
  7849. /**
  7850. * Gets the global Density value.
  7851. * 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.
  7852. * Values less than zero provide a filter of opposite hue.
  7853. */
  7854. /**
  7855. * Sets the global Density value.
  7856. * 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.
  7857. * Values less than zero provide a filter of opposite hue.
  7858. */
  7859. globalDensity: number;
  7860. /**
  7861. * Gets the global Saturation value.
  7862. * 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.
  7863. */
  7864. /**
  7865. * Sets the global Saturation value.
  7866. * 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.
  7867. */
  7868. globalSaturation: number;
  7869. /**
  7870. * Gets the global Exposure value.
  7871. * 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.
  7872. */
  7873. /**
  7874. * Sets the global Exposure value.
  7875. * 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.
  7876. */
  7877. globalExposure: number;
  7878. private _highlightsHue;
  7879. private _highlightsDensity;
  7880. private _highlightsSaturation;
  7881. private _highlightsExposure;
  7882. /**
  7883. * Gets the highlights Hue value.
  7884. * 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).
  7885. */
  7886. /**
  7887. * Sets the highlights Hue value.
  7888. * 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).
  7889. */
  7890. highlightsHue: number;
  7891. /**
  7892. * Gets the highlights Density value.
  7893. * 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.
  7894. * Values less than zero provide a filter of opposite hue.
  7895. */
  7896. /**
  7897. * Sets the highlights Density value.
  7898. * 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.
  7899. * Values less than zero provide a filter of opposite hue.
  7900. */
  7901. highlightsDensity: number;
  7902. /**
  7903. * Gets the highlights Saturation value.
  7904. * 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.
  7905. */
  7906. /**
  7907. * Sets the highlights Saturation value.
  7908. * 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.
  7909. */
  7910. highlightsSaturation: number;
  7911. /**
  7912. * Gets the highlights Exposure value.
  7913. * 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.
  7914. */
  7915. /**
  7916. * Sets the highlights Exposure value.
  7917. * 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.
  7918. */
  7919. highlightsExposure: number;
  7920. private _midtonesHue;
  7921. private _midtonesDensity;
  7922. private _midtonesSaturation;
  7923. private _midtonesExposure;
  7924. /**
  7925. * Gets the midtones Hue value.
  7926. * 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).
  7927. */
  7928. /**
  7929. * Sets the midtones Hue value.
  7930. * 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).
  7931. */
  7932. midtonesHue: number;
  7933. /**
  7934. * Gets the midtones Density value.
  7935. * 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.
  7936. * Values less than zero provide a filter of opposite hue.
  7937. */
  7938. /**
  7939. * Sets the midtones Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. midtonesDensity: number;
  7944. /**
  7945. * Gets the midtones Saturation value.
  7946. * 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.
  7947. */
  7948. /**
  7949. * Sets the midtones Saturation value.
  7950. * 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.
  7951. */
  7952. midtonesSaturation: number;
  7953. /**
  7954. * Gets the midtones Exposure value.
  7955. * 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.
  7956. */
  7957. /**
  7958. * Sets the midtones Exposure value.
  7959. * 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.
  7960. */
  7961. midtonesExposure: number;
  7962. private _shadowsHue;
  7963. private _shadowsDensity;
  7964. private _shadowsSaturation;
  7965. private _shadowsExposure;
  7966. /**
  7967. * Gets the shadows Hue value.
  7968. * 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).
  7969. */
  7970. /**
  7971. * Sets the shadows Hue value.
  7972. * 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).
  7973. */
  7974. shadowsHue: number;
  7975. /**
  7976. * Gets the shadows Density value.
  7977. * 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.
  7978. * Values less than zero provide a filter of opposite hue.
  7979. */
  7980. /**
  7981. * Sets the shadows Density value.
  7982. * 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.
  7983. * Values less than zero provide a filter of opposite hue.
  7984. */
  7985. shadowsDensity: number;
  7986. /**
  7987. * Gets the shadows Saturation value.
  7988. * 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.
  7989. */
  7990. /**
  7991. * Sets the shadows Saturation value.
  7992. * 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.
  7993. */
  7994. shadowsSaturation: number;
  7995. /**
  7996. * Gets the shadows Exposure value.
  7997. * 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.
  7998. */
  7999. /**
  8000. * Sets the shadows Exposure value.
  8001. * 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.
  8002. */
  8003. shadowsExposure: number;
  8004. /**
  8005. * Returns the class name
  8006. * @returns The class name
  8007. */
  8008. getClassName(): string;
  8009. /**
  8010. * Binds the color curves to the shader.
  8011. * @param colorCurves The color curve to bind
  8012. * @param effect The effect to bind to
  8013. * @param positiveUniform The positive uniform shader parameter
  8014. * @param neutralUniform The neutral uniform shader parameter
  8015. * @param negativeUniform The negative uniform shader parameter
  8016. */
  8017. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8018. /**
  8019. * Prepare the list of uniforms associated with the ColorCurves effects.
  8020. * @param uniformsList The list of uniforms used in the effect
  8021. */
  8022. static PrepareUniforms(uniformsList: string[]): void;
  8023. /**
  8024. * Returns color grading data based on a hue, density, saturation and exposure value.
  8025. * @param filterHue The hue of the color filter.
  8026. * @param filterDensity The density of the color filter.
  8027. * @param saturation The saturation.
  8028. * @param exposure The exposure.
  8029. * @param result The result data container.
  8030. */
  8031. private getColorGradingDataToRef;
  8032. /**
  8033. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8034. * @param value The input slider value in range [-100,100].
  8035. * @returns Adjusted value.
  8036. */
  8037. private static applyColorGradingSliderNonlinear;
  8038. /**
  8039. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8040. * @param hue The hue (H) input.
  8041. * @param saturation The saturation (S) input.
  8042. * @param brightness The brightness (B) input.
  8043. * @result An RGBA color represented as Vector4.
  8044. */
  8045. private static fromHSBToRef;
  8046. /**
  8047. * Returns a value clamped between min and max
  8048. * @param value The value to clamp
  8049. * @param min The minimum of value
  8050. * @param max The maximum of value
  8051. * @returns The clamped value.
  8052. */
  8053. private static clamp;
  8054. /**
  8055. * Clones the current color curve instance.
  8056. * @return The cloned curves
  8057. */
  8058. clone(): ColorCurves;
  8059. /**
  8060. * Serializes the current color curve instance to a json representation.
  8061. * @return a JSON representation
  8062. */
  8063. serialize(): any;
  8064. /**
  8065. * Parses the color curve from a json representation.
  8066. * @param source the JSON source to parse
  8067. * @return The parsed curves
  8068. */
  8069. static Parse(source: any): ColorCurves;
  8070. }
  8071. }
  8072. declare module BABYLON {
  8073. /**
  8074. * Interface to follow in your material defines to integrate easily the
  8075. * Image proccessing functions.
  8076. * @hidden
  8077. */
  8078. export interface IImageProcessingConfigurationDefines {
  8079. IMAGEPROCESSING: boolean;
  8080. VIGNETTE: boolean;
  8081. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8082. VIGNETTEBLENDMODEOPAQUE: boolean;
  8083. TONEMAPPING: boolean;
  8084. TONEMAPPING_ACES: boolean;
  8085. CONTRAST: boolean;
  8086. EXPOSURE: boolean;
  8087. COLORCURVES: boolean;
  8088. COLORGRADING: boolean;
  8089. COLORGRADING3D: boolean;
  8090. SAMPLER3DGREENDEPTH: boolean;
  8091. SAMPLER3DBGRMAP: boolean;
  8092. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8093. }
  8094. /**
  8095. * @hidden
  8096. */
  8097. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8098. IMAGEPROCESSING: boolean;
  8099. VIGNETTE: boolean;
  8100. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8101. VIGNETTEBLENDMODEOPAQUE: boolean;
  8102. TONEMAPPING: boolean;
  8103. TONEMAPPING_ACES: boolean;
  8104. CONTRAST: boolean;
  8105. COLORCURVES: boolean;
  8106. COLORGRADING: boolean;
  8107. COLORGRADING3D: boolean;
  8108. SAMPLER3DGREENDEPTH: boolean;
  8109. SAMPLER3DBGRMAP: boolean;
  8110. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8111. EXPOSURE: boolean;
  8112. constructor();
  8113. }
  8114. /**
  8115. * This groups together the common properties used for image processing either in direct forward pass
  8116. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8117. * or not.
  8118. */
  8119. export class ImageProcessingConfiguration {
  8120. /**
  8121. * Default tone mapping applied in BabylonJS.
  8122. */
  8123. static readonly TONEMAPPING_STANDARD: number;
  8124. /**
  8125. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8126. * to other engines rendering to increase portability.
  8127. */
  8128. static readonly TONEMAPPING_ACES: number;
  8129. /**
  8130. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8131. */
  8132. colorCurves: Nullable<ColorCurves>;
  8133. private _colorCurvesEnabled;
  8134. /**
  8135. * Gets wether the color curves effect is enabled.
  8136. */
  8137. /**
  8138. * Sets wether the color curves effect is enabled.
  8139. */
  8140. colorCurvesEnabled: boolean;
  8141. private _colorGradingTexture;
  8142. /**
  8143. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8144. */
  8145. /**
  8146. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8147. */
  8148. colorGradingTexture: Nullable<BaseTexture>;
  8149. private _colorGradingEnabled;
  8150. /**
  8151. * Gets wether the color grading effect is enabled.
  8152. */
  8153. /**
  8154. * Sets wether the color grading effect is enabled.
  8155. */
  8156. colorGradingEnabled: boolean;
  8157. private _colorGradingWithGreenDepth;
  8158. /**
  8159. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8160. */
  8161. /**
  8162. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8163. */
  8164. colorGradingWithGreenDepth: boolean;
  8165. private _colorGradingBGR;
  8166. /**
  8167. * Gets wether the color grading texture contains BGR values.
  8168. */
  8169. /**
  8170. * Sets wether the color grading texture contains BGR values.
  8171. */
  8172. colorGradingBGR: boolean;
  8173. /** @hidden */
  8174. _exposure: number;
  8175. /**
  8176. * Gets the Exposure used in the effect.
  8177. */
  8178. /**
  8179. * Sets the Exposure used in the effect.
  8180. */
  8181. exposure: number;
  8182. private _toneMappingEnabled;
  8183. /**
  8184. * Gets wether the tone mapping effect is enabled.
  8185. */
  8186. /**
  8187. * Sets wether the tone mapping effect is enabled.
  8188. */
  8189. toneMappingEnabled: boolean;
  8190. private _toneMappingType;
  8191. /**
  8192. * Gets the type of tone mapping effect.
  8193. */
  8194. /**
  8195. * Sets the type of tone mapping effect used in BabylonJS.
  8196. */
  8197. toneMappingType: number;
  8198. protected _contrast: number;
  8199. /**
  8200. * Gets the contrast used in the effect.
  8201. */
  8202. /**
  8203. * Sets the contrast used in the effect.
  8204. */
  8205. contrast: number;
  8206. /**
  8207. * Vignette stretch size.
  8208. */
  8209. vignetteStretch: number;
  8210. /**
  8211. * Vignette centre X Offset.
  8212. */
  8213. vignetteCentreX: number;
  8214. /**
  8215. * Vignette centre Y Offset.
  8216. */
  8217. vignetteCentreY: number;
  8218. /**
  8219. * Vignette weight or intensity of the vignette effect.
  8220. */
  8221. vignetteWeight: number;
  8222. /**
  8223. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8224. * if vignetteEnabled is set to true.
  8225. */
  8226. vignetteColor: Color4;
  8227. /**
  8228. * Camera field of view used by the Vignette effect.
  8229. */
  8230. vignetteCameraFov: number;
  8231. private _vignetteBlendMode;
  8232. /**
  8233. * Gets the vignette blend mode allowing different kind of effect.
  8234. */
  8235. /**
  8236. * Sets the vignette blend mode allowing different kind of effect.
  8237. */
  8238. vignetteBlendMode: number;
  8239. private _vignetteEnabled;
  8240. /**
  8241. * Gets wether the vignette effect is enabled.
  8242. */
  8243. /**
  8244. * Sets wether the vignette effect is enabled.
  8245. */
  8246. vignetteEnabled: boolean;
  8247. private _applyByPostProcess;
  8248. /**
  8249. * Gets wether the image processing is applied through a post process or not.
  8250. */
  8251. /**
  8252. * Sets wether the image processing is applied through a post process or not.
  8253. */
  8254. applyByPostProcess: boolean;
  8255. private _isEnabled;
  8256. /**
  8257. * Gets wether the image processing is enabled or not.
  8258. */
  8259. /**
  8260. * Sets wether the image processing is enabled or not.
  8261. */
  8262. isEnabled: boolean;
  8263. /**
  8264. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8265. */
  8266. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8267. /**
  8268. * Method called each time the image processing information changes requires to recompile the effect.
  8269. */
  8270. protected _updateParameters(): void;
  8271. /**
  8272. * Gets the current class name.
  8273. * @return "ImageProcessingConfiguration"
  8274. */
  8275. getClassName(): string;
  8276. /**
  8277. * Prepare the list of uniforms associated with the Image Processing effects.
  8278. * @param uniforms The list of uniforms used in the effect
  8279. * @param defines the list of defines currently in use
  8280. */
  8281. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8282. /**
  8283. * Prepare the list of samplers associated with the Image Processing effects.
  8284. * @param samplersList The list of uniforms used in the effect
  8285. * @param defines the list of defines currently in use
  8286. */
  8287. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8288. /**
  8289. * Prepare the list of defines associated to the shader.
  8290. * @param defines the list of defines to complete
  8291. * @param forPostProcess Define if we are currently in post process mode or not
  8292. */
  8293. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8294. /**
  8295. * Returns true if all the image processing information are ready.
  8296. * @returns True if ready, otherwise, false
  8297. */
  8298. isReady(): boolean;
  8299. /**
  8300. * Binds the image processing to the shader.
  8301. * @param effect The effect to bind to
  8302. * @param aspectRatio Define the current aspect ratio of the effect
  8303. */
  8304. bind(effect: Effect, aspectRatio?: number): void;
  8305. /**
  8306. * Clones the current image processing instance.
  8307. * @return The cloned image processing
  8308. */
  8309. clone(): ImageProcessingConfiguration;
  8310. /**
  8311. * Serializes the current image processing instance to a json representation.
  8312. * @return a JSON representation
  8313. */
  8314. serialize(): any;
  8315. /**
  8316. * Parses the image processing from a json representation.
  8317. * @param source the JSON source to parse
  8318. * @return The parsed image processing
  8319. */
  8320. static Parse(source: any): ImageProcessingConfiguration;
  8321. private static _VIGNETTEMODE_MULTIPLY;
  8322. private static _VIGNETTEMODE_OPAQUE;
  8323. /**
  8324. * Used to apply the vignette as a mix with the pixel color.
  8325. */
  8326. static readonly VIGNETTEMODE_MULTIPLY: number;
  8327. /**
  8328. * Used to apply the vignette as a replacement of the pixel color.
  8329. */
  8330. static readonly VIGNETTEMODE_OPAQUE: number;
  8331. }
  8332. }
  8333. declare module BABYLON {
  8334. /** @hidden */
  8335. export var postprocessVertexShader: {
  8336. name: string;
  8337. shader: string;
  8338. };
  8339. }
  8340. declare module BABYLON {
  8341. /** Defines supported spaces */
  8342. export enum Space {
  8343. /** Local (object) space */
  8344. LOCAL = 0,
  8345. /** World space */
  8346. WORLD = 1,
  8347. /** Bone space */
  8348. BONE = 2
  8349. }
  8350. /** Defines the 3 main axes */
  8351. export class Axis {
  8352. /** X axis */
  8353. static X: Vector3;
  8354. /** Y axis */
  8355. static Y: Vector3;
  8356. /** Z axis */
  8357. static Z: Vector3;
  8358. }
  8359. }
  8360. declare module BABYLON {
  8361. /**
  8362. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8363. * This is the base of the follow, arc rotate cameras and Free camera
  8364. * @see http://doc.babylonjs.com/features/cameras
  8365. */
  8366. export class TargetCamera extends Camera {
  8367. private static _RigCamTransformMatrix;
  8368. private static _TargetTransformMatrix;
  8369. private static _TargetFocalPoint;
  8370. /**
  8371. * Define the current direction the camera is moving to
  8372. */
  8373. cameraDirection: Vector3;
  8374. /**
  8375. * Define the current rotation the camera is rotating to
  8376. */
  8377. cameraRotation: Vector2;
  8378. /**
  8379. * When set, the up vector of the camera will be updated by the rotation of the camera
  8380. */
  8381. updateUpVectorFromRotation: boolean;
  8382. private _tmpQuaternion;
  8383. /**
  8384. * Define the current rotation of the camera
  8385. */
  8386. rotation: Vector3;
  8387. /**
  8388. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8389. */
  8390. rotationQuaternion: Quaternion;
  8391. /**
  8392. * Define the current speed of the camera
  8393. */
  8394. speed: number;
  8395. /**
  8396. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8397. * around all axis.
  8398. */
  8399. noRotationConstraint: boolean;
  8400. /**
  8401. * Define the current target of the camera as an object or a position.
  8402. */
  8403. lockedTarget: any;
  8404. /** @hidden */
  8405. _currentTarget: Vector3;
  8406. /** @hidden */
  8407. _initialFocalDistance: number;
  8408. /** @hidden */
  8409. _viewMatrix: Matrix;
  8410. /** @hidden */
  8411. _camMatrix: Matrix;
  8412. /** @hidden */
  8413. _cameraTransformMatrix: Matrix;
  8414. /** @hidden */
  8415. _cameraRotationMatrix: Matrix;
  8416. /** @hidden */
  8417. _referencePoint: Vector3;
  8418. /** @hidden */
  8419. _transformedReferencePoint: Vector3;
  8420. protected _globalCurrentTarget: Vector3;
  8421. protected _globalCurrentUpVector: Vector3;
  8422. /** @hidden */
  8423. _reset: () => void;
  8424. private _defaultUp;
  8425. /**
  8426. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8427. * This is the base of the follow, arc rotate cameras and Free camera
  8428. * @see http://doc.babylonjs.com/features/cameras
  8429. * @param name Defines the name of the camera in the scene
  8430. * @param position Defines the start position of the camera in the scene
  8431. * @param scene Defines the scene the camera belongs to
  8432. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8433. */
  8434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8435. /**
  8436. * Gets the position in front of the camera at a given distance.
  8437. * @param distance The distance from the camera we want the position to be
  8438. * @returns the position
  8439. */
  8440. getFrontPosition(distance: number): Vector3;
  8441. /** @hidden */
  8442. _getLockedTargetPosition(): Nullable<Vector3>;
  8443. private _storedPosition;
  8444. private _storedRotation;
  8445. private _storedRotationQuaternion;
  8446. /**
  8447. * Store current camera state of the camera (fov, position, rotation, etc..)
  8448. * @returns the camera
  8449. */
  8450. storeState(): Camera;
  8451. /**
  8452. * Restored camera state. You must call storeState() first
  8453. * @returns whether it was successful or not
  8454. * @hidden
  8455. */
  8456. _restoreStateValues(): boolean;
  8457. /** @hidden */
  8458. _initCache(): void;
  8459. /** @hidden */
  8460. _updateCache(ignoreParentClass?: boolean): void;
  8461. /** @hidden */
  8462. _isSynchronizedViewMatrix(): boolean;
  8463. /** @hidden */
  8464. _computeLocalCameraSpeed(): number;
  8465. /**
  8466. * Defines the target the camera should look at.
  8467. * @param target Defines the new target as a Vector or a mesh
  8468. */
  8469. setTarget(target: Vector3): void;
  8470. /**
  8471. * Return the current target position of the camera. This value is expressed in local space.
  8472. * @returns the target position
  8473. */
  8474. getTarget(): Vector3;
  8475. /** @hidden */
  8476. _decideIfNeedsToMove(): boolean;
  8477. /** @hidden */
  8478. _updatePosition(): void;
  8479. /** @hidden */
  8480. _checkInputs(): void;
  8481. protected _updateCameraRotationMatrix(): void;
  8482. /**
  8483. * 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)
  8484. * @returns the current camera
  8485. */
  8486. private _rotateUpVectorWithCameraRotationMatrix;
  8487. private _cachedRotationZ;
  8488. private _cachedQuaternionRotationZ;
  8489. /** @hidden */
  8490. _getViewMatrix(): Matrix;
  8491. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8492. /**
  8493. * @hidden
  8494. */
  8495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8496. /**
  8497. * @hidden
  8498. */
  8499. _updateRigCameras(): void;
  8500. private _getRigCamPositionAndTarget;
  8501. /**
  8502. * Gets the current object class name.
  8503. * @return the class name
  8504. */
  8505. getClassName(): string;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * Gather the list of keyboard event types as constants.
  8511. */
  8512. export class KeyboardEventTypes {
  8513. /**
  8514. * The keydown event is fired when a key becomes active (pressed).
  8515. */
  8516. static readonly KEYDOWN: number;
  8517. /**
  8518. * The keyup event is fired when a key has been released.
  8519. */
  8520. static readonly KEYUP: number;
  8521. }
  8522. /**
  8523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8524. */
  8525. export class KeyboardInfo {
  8526. /**
  8527. * Defines the type of event (KeyboardEventTypes)
  8528. */
  8529. type: number;
  8530. /**
  8531. * Defines the related dom event
  8532. */
  8533. event: KeyboardEvent;
  8534. /**
  8535. * Instantiates a new keyboard info.
  8536. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8537. * @param type Defines the type of event (KeyboardEventTypes)
  8538. * @param event Defines the related dom event
  8539. */
  8540. constructor(
  8541. /**
  8542. * Defines the type of event (KeyboardEventTypes)
  8543. */
  8544. type: number,
  8545. /**
  8546. * Defines the related dom event
  8547. */
  8548. event: KeyboardEvent);
  8549. }
  8550. /**
  8551. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8552. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8553. */
  8554. export class KeyboardInfoPre extends KeyboardInfo {
  8555. /**
  8556. * Defines the type of event (KeyboardEventTypes)
  8557. */
  8558. type: number;
  8559. /**
  8560. * Defines the related dom event
  8561. */
  8562. event: KeyboardEvent;
  8563. /**
  8564. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8565. */
  8566. skipOnPointerObservable: boolean;
  8567. /**
  8568. * Instantiates a new keyboard pre info.
  8569. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8570. * @param type Defines the type of event (KeyboardEventTypes)
  8571. * @param event Defines the related dom event
  8572. */
  8573. constructor(
  8574. /**
  8575. * Defines the type of event (KeyboardEventTypes)
  8576. */
  8577. type: number,
  8578. /**
  8579. * Defines the related dom event
  8580. */
  8581. event: KeyboardEvent);
  8582. }
  8583. }
  8584. declare module BABYLON {
  8585. /**
  8586. * Manage the keyboard inputs to control the movement of a free camera.
  8587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8588. */
  8589. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8590. /**
  8591. * Defines the camera the input is attached to.
  8592. */
  8593. camera: FreeCamera;
  8594. /**
  8595. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8596. */
  8597. keysUp: number[];
  8598. /**
  8599. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8600. */
  8601. keysDown: number[];
  8602. /**
  8603. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8604. */
  8605. keysLeft: number[];
  8606. /**
  8607. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8608. */
  8609. keysRight: number[];
  8610. private _keys;
  8611. private _onCanvasBlurObserver;
  8612. private _onKeyboardObserver;
  8613. private _engine;
  8614. private _scene;
  8615. /**
  8616. * Attach the input controls to a specific dom element to get the input from.
  8617. * @param element Defines the element the controls should be listened from
  8618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8619. */
  8620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8621. /**
  8622. * Detach the current controls from the specified dom element.
  8623. * @param element Defines the element to stop listening the inputs from
  8624. */
  8625. detachControl(element: Nullable<HTMLElement>): void;
  8626. /**
  8627. * Update the current camera state depending on the inputs that have been used this frame.
  8628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8629. */
  8630. checkInputs(): void;
  8631. /**
  8632. * Gets the class name of the current intput.
  8633. * @returns the class name
  8634. */
  8635. getClassName(): string;
  8636. /** @hidden */
  8637. _onLostFocus(): void;
  8638. /**
  8639. * Get the friendly name associated with the input class.
  8640. * @returns the input friendly name
  8641. */
  8642. getSimpleName(): string;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Interface describing all the common properties and methods a shadow light needs to implement.
  8648. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8649. * as well as binding the different shadow properties to the effects.
  8650. */
  8651. export interface IShadowLight extends Light {
  8652. /**
  8653. * The light id in the scene (used in scene.findLighById for instance)
  8654. */
  8655. id: string;
  8656. /**
  8657. * The position the shdow will be casted from.
  8658. */
  8659. position: Vector3;
  8660. /**
  8661. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8662. */
  8663. direction: Vector3;
  8664. /**
  8665. * The transformed position. Position of the light in world space taking parenting in account.
  8666. */
  8667. transformedPosition: Vector3;
  8668. /**
  8669. * The transformed direction. Direction of the light in world space taking parenting in account.
  8670. */
  8671. transformedDirection: Vector3;
  8672. /**
  8673. * The friendly name of the light in the scene.
  8674. */
  8675. name: string;
  8676. /**
  8677. * Defines the shadow projection clipping minimum z value.
  8678. */
  8679. shadowMinZ: number;
  8680. /**
  8681. * Defines the shadow projection clipping maximum z value.
  8682. */
  8683. shadowMaxZ: number;
  8684. /**
  8685. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8686. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8687. */
  8688. computeTransformedInformation(): boolean;
  8689. /**
  8690. * Gets the scene the light belongs to.
  8691. * @returns The scene
  8692. */
  8693. getScene(): Scene;
  8694. /**
  8695. * Callback defining a custom Projection Matrix Builder.
  8696. * This can be used to override the default projection matrix computation.
  8697. */
  8698. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8699. /**
  8700. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8701. * @param matrix The materix to updated with the projection information
  8702. * @param viewMatrix The transform matrix of the light
  8703. * @param renderList The list of mesh to render in the map
  8704. * @returns The current light
  8705. */
  8706. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8707. /**
  8708. * Gets the current depth scale used in ESM.
  8709. * @returns The scale
  8710. */
  8711. getDepthScale(): number;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /**
  8727. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8728. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8729. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8730. */
  8731. getShadowDirection(faceIndex?: number): Vector3;
  8732. /**
  8733. * Gets the minZ used for shadow according to both the scene and the light.
  8734. * @param activeCamera The camera we are returning the min for
  8735. * @returns the depth min z
  8736. */
  8737. getDepthMinZ(activeCamera: Camera): number;
  8738. /**
  8739. * Gets the maxZ used for shadow according to both the scene and the light.
  8740. * @param activeCamera The camera we are returning the max for
  8741. * @returns the depth max z
  8742. */
  8743. getDepthMaxZ(activeCamera: Camera): number;
  8744. }
  8745. /**
  8746. * Base implementation IShadowLight
  8747. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8748. */
  8749. export abstract class ShadowLight extends Light implements IShadowLight {
  8750. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8751. protected _position: Vector3;
  8752. protected _setPosition(value: Vector3): void;
  8753. /**
  8754. * Sets the position the shadow will be casted from. Also use as the light position for both
  8755. * point and spot lights.
  8756. */
  8757. /**
  8758. * Sets the position the shadow will be casted from. Also use as the light position for both
  8759. * point and spot lights.
  8760. */
  8761. position: Vector3;
  8762. protected _direction: Vector3;
  8763. protected _setDirection(value: Vector3): void;
  8764. /**
  8765. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8766. * Also use as the light direction on spot and directional lights.
  8767. */
  8768. /**
  8769. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8770. * Also use as the light direction on spot and directional lights.
  8771. */
  8772. direction: Vector3;
  8773. private _shadowMinZ;
  8774. /**
  8775. * Gets the shadow projection clipping minimum z value.
  8776. */
  8777. /**
  8778. * Sets the shadow projection clipping minimum z value.
  8779. */
  8780. shadowMinZ: number;
  8781. private _shadowMaxZ;
  8782. /**
  8783. * Sets the shadow projection clipping maximum z value.
  8784. */
  8785. /**
  8786. * Gets the shadow projection clipping maximum z value.
  8787. */
  8788. shadowMaxZ: number;
  8789. /**
  8790. * Callback defining a custom Projection Matrix Builder.
  8791. * This can be used to override the default projection matrix computation.
  8792. */
  8793. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8794. /**
  8795. * The transformed position. Position of the light in world space taking parenting in account.
  8796. */
  8797. transformedPosition: Vector3;
  8798. /**
  8799. * The transformed direction. Direction of the light in world space taking parenting in account.
  8800. */
  8801. transformedDirection: Vector3;
  8802. private _needProjectionMatrixCompute;
  8803. /**
  8804. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8805. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8806. */
  8807. computeTransformedInformation(): boolean;
  8808. /**
  8809. * Return the depth scale used for the shadow map.
  8810. * @returns the depth scale.
  8811. */
  8812. getDepthScale(): number;
  8813. /**
  8814. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8815. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8816. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8817. */
  8818. getShadowDirection(faceIndex?: number): Vector3;
  8819. /**
  8820. * Returns the ShadowLight absolute position in the World.
  8821. * @returns the position vector in world space
  8822. */
  8823. getAbsolutePosition(): Vector3;
  8824. /**
  8825. * Sets the ShadowLight direction toward the passed target.
  8826. * @param target The point to target in local space
  8827. * @returns the updated ShadowLight direction
  8828. */
  8829. setDirectionToTarget(target: Vector3): Vector3;
  8830. /**
  8831. * Returns the light rotation in euler definition.
  8832. * @returns the x y z rotation in local space.
  8833. */
  8834. getRotation(): Vector3;
  8835. /**
  8836. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8837. * @returns true if a cube texture needs to be use
  8838. */
  8839. needCube(): boolean;
  8840. /**
  8841. * Detects if the projection matrix requires to be recomputed this frame.
  8842. * @returns true if it requires to be recomputed otherwise, false.
  8843. */
  8844. needProjectionMatrixCompute(): boolean;
  8845. /**
  8846. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8847. */
  8848. forceProjectionMatrixCompute(): void;
  8849. /** @hidden */
  8850. _initCache(): void;
  8851. /** @hidden */
  8852. _isSynchronized(): boolean;
  8853. /**
  8854. * Computes the world matrix of the node
  8855. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8856. * @returns the world matrix
  8857. */
  8858. computeWorldMatrix(force?: boolean): Matrix;
  8859. /**
  8860. * Gets the minZ used for shadow according to both the scene and the light.
  8861. * @param activeCamera The camera we are returning the min for
  8862. * @returns the depth min z
  8863. */
  8864. getDepthMinZ(activeCamera: Camera): number;
  8865. /**
  8866. * Gets the maxZ used for shadow according to both the scene and the light.
  8867. * @param activeCamera The camera we are returning the max for
  8868. * @returns the depth max z
  8869. */
  8870. getDepthMaxZ(activeCamera: Camera): number;
  8871. /**
  8872. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8873. * @param matrix The materix to updated with the projection information
  8874. * @param viewMatrix The transform matrix of the light
  8875. * @param renderList The list of mesh to render in the map
  8876. * @returns The current light
  8877. */
  8878. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. /**
  8883. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8884. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8885. */
  8886. export class EffectFallbacks implements IEffectFallbacks {
  8887. private _defines;
  8888. private _currentRank;
  8889. private _maxRank;
  8890. private _mesh;
  8891. /**
  8892. * Removes the fallback from the bound mesh.
  8893. */
  8894. unBindMesh(): void;
  8895. /**
  8896. * Adds a fallback on the specified property.
  8897. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8898. * @param define The name of the define in the shader
  8899. */
  8900. addFallback(rank: number, define: string): void;
  8901. /**
  8902. * Sets the mesh to use CPU skinning when needing to fallback.
  8903. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8904. * @param mesh The mesh to use the fallbacks.
  8905. */
  8906. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8907. /**
  8908. * Checks to see if more fallbacks are still availible.
  8909. */
  8910. readonly hasMoreFallbacks: boolean;
  8911. /**
  8912. * Removes the defines that should be removed when falling back.
  8913. * @param currentDefines defines the current define statements for the shader.
  8914. * @param effect defines the current effect we try to compile
  8915. * @returns The resulting defines with defines of the current rank removed.
  8916. */
  8917. reduce(currentDefines: string, effect: Effect): string;
  8918. }
  8919. }
  8920. declare module BABYLON {
  8921. /**
  8922. * "Static Class" containing the most commonly used helper while dealing with material for
  8923. * rendering purpose.
  8924. *
  8925. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8926. *
  8927. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8928. */
  8929. export class MaterialHelper {
  8930. /**
  8931. * Bind the current view position to an effect.
  8932. * @param effect The effect to be bound
  8933. * @param scene The scene the eyes position is used from
  8934. */
  8935. static BindEyePosition(effect: Effect, scene: Scene): void;
  8936. /**
  8937. * Helps preparing the defines values about the UVs in used in the effect.
  8938. * UVs are shared as much as we can accross channels in the shaders.
  8939. * @param texture The texture we are preparing the UVs for
  8940. * @param defines The defines to update
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8944. /**
  8945. * Binds a texture matrix value to its corrsponding uniform
  8946. * @param texture The texture to bind the matrix for
  8947. * @param uniformBuffer The uniform buffer receivin the data
  8948. * @param key The channel key "diffuse", "specular"... used in the shader
  8949. */
  8950. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8951. /**
  8952. * Gets the current status of the fog (should it be enabled?)
  8953. * @param mesh defines the mesh to evaluate for fog support
  8954. * @param scene defines the hosting scene
  8955. * @returns true if fog must be enabled
  8956. */
  8957. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8958. /**
  8959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8960. * @param mesh defines the current mesh
  8961. * @param scene defines the current scene
  8962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8963. * @param pointsCloud defines if point cloud rendering has to be turned on
  8964. * @param fogEnabled defines if fog has to be turned on
  8965. * @param alphaTest defines if alpha testing has to be turned on
  8966. * @param defines defines the current list of defines
  8967. */
  8968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8969. /**
  8970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8971. * @param scene defines the current scene
  8972. * @param engine defines the current engine
  8973. * @param defines specifies the list of active defines
  8974. * @param useInstances defines if instances have to be turned on
  8975. * @param useClipPlane defines if clip plane have to be turned on
  8976. */
  8977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8978. /**
  8979. * Prepares the defines for bones
  8980. * @param mesh The mesh containing the geometry data we will draw
  8981. * @param defines The defines to update
  8982. */
  8983. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8984. /**
  8985. * Prepares the defines for morph targets
  8986. * @param mesh The mesh containing the geometry data we will draw
  8987. * @param defines The defines to update
  8988. */
  8989. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8990. /**
  8991. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8992. * @param mesh The mesh containing the geometry data we will draw
  8993. * @param defines The defines to update
  8994. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8995. * @param useBones Precise whether bones should be used or not (override mesh info)
  8996. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8997. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8998. * @returns false if defines are considered not dirty and have not been checked
  8999. */
  9000. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9001. /**
  9002. * Prepares the defines related to multiview
  9003. * @param scene The scene we are intending to draw
  9004. * @param defines The defines to update
  9005. */
  9006. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9007. /**
  9008. * Prepares the defines related to the light information passed in parameter
  9009. * @param scene The scene we are intending to draw
  9010. * @param mesh The mesh the effect is compiling for
  9011. * @param light The light the effect is compiling for
  9012. * @param lightIndex The index of the light
  9013. * @param defines The defines to update
  9014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9015. * @param state Defines the current state regarding what is needed (normals, etc...)
  9016. */
  9017. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9018. needNormals: boolean;
  9019. needRebuild: boolean;
  9020. shadowEnabled: boolean;
  9021. specularEnabled: boolean;
  9022. lightmapMode: boolean;
  9023. }): void;
  9024. /**
  9025. * Prepares the defines related to the light information passed in parameter
  9026. * @param scene The scene we are intending to draw
  9027. * @param mesh The mesh the effect is compiling for
  9028. * @param defines The defines to update
  9029. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9030. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9031. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9032. * @returns true if normals will be required for the rest of the effect
  9033. */
  9034. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9037. * @param lightIndex defines the light index
  9038. * @param uniformsList The uniform list
  9039. * @param samplersList The sampler list
  9040. * @param projectedLightTexture defines if projected texture must be used
  9041. * @param uniformBuffersList defines an optional list of uniform buffers
  9042. */
  9043. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9044. /**
  9045. * Prepares the uniforms and samplers list to be used in the effect
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The sampler list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. private static _TmpMorphInfluencers;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param influencers The number of influencers
  9067. */
  9068. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9069. /**
  9070. * Prepares the list of attributes required for morph targets according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the morph targets attributes for
  9073. * @param defines The current Defines of the effect
  9074. */
  9075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9076. /**
  9077. * Prepares the list of attributes required for bones according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param mesh The mesh to prepare the bones attributes for
  9080. * @param defines The current Defines of the effect
  9081. * @param fallbacks The current efffect fallback strategy
  9082. */
  9083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9084. /**
  9085. * Check and prepare the list of attributes required for instances according to the effect defines.
  9086. * @param attribs The current list of supported attribs
  9087. * @param defines The current MaterialDefines of the effect
  9088. */
  9089. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9090. /**
  9091. * Add the list of attributes required for instances to the attribs array.
  9092. * @param attribs The current list of supported attribs
  9093. */
  9094. static PushAttributesForInstances(attribs: string[]): void;
  9095. /**
  9096. * Binds the light shadow information to the effect for the given mesh.
  9097. * @param light The light containing the generator
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param lightIndex The light index in the effect used to render the mesh
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Binds the light information to the effect.
  9106. * @param light The light containing the generator
  9107. * @param effect The effect we are binding the data to
  9108. * @param lightIndex The light index in the effect used to render
  9109. */
  9110. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9111. /**
  9112. * Binds the lights information from the scene to the effect for the given mesh.
  9113. * @param light Light to bind
  9114. * @param lightIndex Light index
  9115. * @param scene The scene where the light belongs to
  9116. * @param mesh The mesh we are binding the information to render
  9117. * @param effect The effect we are binding the data to
  9118. * @param useSpecular Defines if specular is supported
  9119. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9121. */
  9122. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9123. /**
  9124. * Binds the lights information from the scene to the effect for the given mesh.
  9125. * @param scene The scene the lights belongs to
  9126. * @param mesh The mesh we are binding the information to render
  9127. * @param effect The effect we are binding the data to
  9128. * @param defines The generated defines for the effect
  9129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9130. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9131. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9132. */
  9133. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9134. private static _tempFogColor;
  9135. /**
  9136. * Binds the fog information from the scene to the effect for the given mesh.
  9137. * @param scene The scene the lights belongs to
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. * @param linearSpace Defines if the fog effect is applied in linear space
  9141. */
  9142. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9143. /**
  9144. * Binds the bones information from the mesh to the effect.
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9149. /**
  9150. * Binds the morph targets information from the mesh to the effect.
  9151. * @param abstractMesh The mesh we are binding the information to render
  9152. * @param effect The effect we are binding the data to
  9153. */
  9154. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9155. /**
  9156. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9157. * @param defines The generated defines used in the effect
  9158. * @param effect The effect we are binding the data to
  9159. * @param scene The scene we are willing to render with logarithmic scale for
  9160. */
  9161. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Binds the clip plane information from the scene to the effect.
  9164. * @param scene The scene the clip plane information are extracted from
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindClipPlane(effect: Effect, scene: Scene): void;
  9168. }
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var packingFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var shadowMapPixelShader: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var bonesDeclaration: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var morphTargetsVertexGlobalDeclaration: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var morphTargetsVertexDeclaration: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /** @hidden */
  9207. export var instancesDeclaration: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module BABYLON {
  9213. /** @hidden */
  9214. export var helperFunctions: {
  9215. name: string;
  9216. shader: string;
  9217. };
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var morphTargetsVertex: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var instancesVertex: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /** @hidden */
  9235. export var bonesVertex: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module BABYLON {
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module BABYLON {
  9255. /**
  9256. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9257. */
  9258. export interface ICustomShaderOptions {
  9259. /**
  9260. * Gets or sets the custom shader name to use
  9261. */
  9262. shaderName: string;
  9263. /**
  9264. * The list of attribute names used in the shader
  9265. */
  9266. attributes?: string[];
  9267. /**
  9268. * The list of unifrom names used in the shader
  9269. */
  9270. uniforms?: string[];
  9271. /**
  9272. * The list of sampler names used in the shader
  9273. */
  9274. samplers?: string[];
  9275. /**
  9276. * The list of defines used in the shader
  9277. */
  9278. defines?: string[];
  9279. }
  9280. /**
  9281. * Interface to implement to create a shadow generator compatible with BJS.
  9282. */
  9283. export interface IShadowGenerator {
  9284. /**
  9285. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9286. * @returns The render target texture if present otherwise, null
  9287. */
  9288. getShadowMap(): Nullable<RenderTargetTexture>;
  9289. /**
  9290. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9291. * @returns The render target texture if the shadow map is present otherwise, null
  9292. */
  9293. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9294. /**
  9295. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9296. * @param subMesh The submesh we want to render in the shadow map
  9297. * @param useInstances Defines wether will draw in the map using instances
  9298. * @returns true if ready otherwise, false
  9299. */
  9300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9301. /**
  9302. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9303. * @param defines Defines of the material we want to update
  9304. * @param lightIndex Index of the light in the enabled light list of the material
  9305. */
  9306. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9307. /**
  9308. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9309. * defined in the generator but impacting the effect).
  9310. * It implies the unifroms available on the materials are the standard BJS ones.
  9311. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9312. * @param effect The effect we are binfing the information for
  9313. */
  9314. bindShadowLight(lightIndex: string, effect: Effect): void;
  9315. /**
  9316. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9317. * (eq to shadow prjection matrix * light transform matrix)
  9318. * @returns The transform matrix used to create the shadow map
  9319. */
  9320. getTransformMatrix(): Matrix;
  9321. /**
  9322. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9323. * Cube and 2D textures for instance.
  9324. */
  9325. recreateShadowMap(): void;
  9326. /**
  9327. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9328. * @param onCompiled Callback triggered at the and of the effects compilation
  9329. * @param options Sets of optional options forcing the compilation with different modes
  9330. */
  9331. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9332. useInstances: boolean;
  9333. }>): void;
  9334. /**
  9335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9336. * @param options Sets of optional options forcing the compilation with different modes
  9337. * @returns A promise that resolves when the compilation completes
  9338. */
  9339. forceCompilationAsync(options?: Partial<{
  9340. useInstances: boolean;
  9341. }>): Promise<void>;
  9342. /**
  9343. * Serializes the shadow generator setup to a json object.
  9344. * @returns The serialized JSON object
  9345. */
  9346. serialize(): any;
  9347. /**
  9348. * Disposes the Shadow map and related Textures and effects.
  9349. */
  9350. dispose(): void;
  9351. }
  9352. /**
  9353. * Default implementation IShadowGenerator.
  9354. * This is the main object responsible of generating shadows in the framework.
  9355. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9356. */
  9357. export class ShadowGenerator implements IShadowGenerator {
  9358. /**
  9359. * Shadow generator mode None: no filtering applied.
  9360. */
  9361. static readonly FILTER_NONE: number;
  9362. /**
  9363. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9369. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9370. */
  9371. static readonly FILTER_POISSONSAMPLING: number;
  9372. /**
  9373. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9374. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9375. */
  9376. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9377. /**
  9378. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9379. * edge artifacts on steep falloff.
  9380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9381. */
  9382. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9383. /**
  9384. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9385. * edge artifacts on steep falloff.
  9386. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9387. */
  9388. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9389. /**
  9390. * Shadow generator mode PCF: Percentage Closer Filtering
  9391. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9392. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9393. */
  9394. static readonly FILTER_PCF: number;
  9395. /**
  9396. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9397. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9398. * Contact Hardening
  9399. */
  9400. static readonly FILTER_PCSS: number;
  9401. /**
  9402. * Reserved for PCF and PCSS
  9403. * Highest Quality.
  9404. *
  9405. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9406. *
  9407. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9408. */
  9409. static readonly QUALITY_HIGH: number;
  9410. /**
  9411. * Reserved for PCF and PCSS
  9412. * Good tradeoff for quality/perf cross devices
  9413. *
  9414. * Execute PCF on a 3*3 kernel.
  9415. *
  9416. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9417. */
  9418. static readonly QUALITY_MEDIUM: number;
  9419. /**
  9420. * Reserved for PCF and PCSS
  9421. * The lowest quality but the fastest.
  9422. *
  9423. * Execute PCF on a 1*1 kernel.
  9424. *
  9425. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9426. */
  9427. static readonly QUALITY_LOW: number;
  9428. /** Gets or sets the custom shader name to use */
  9429. customShaderOptions: ICustomShaderOptions;
  9430. /**
  9431. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9432. */
  9433. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9434. /**
  9435. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9436. */
  9437. onAfterShadowMapRenderObservable: Observable<Effect>;
  9438. /**
  9439. * Observable triggered before a mesh is rendered in the shadow map.
  9440. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9441. */
  9442. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9443. /**
  9444. * Observable triggered after a mesh is rendered in the shadow map.
  9445. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9446. */
  9447. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9448. private _bias;
  9449. /**
  9450. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9451. */
  9452. /**
  9453. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9454. */
  9455. bias: number;
  9456. private _normalBias;
  9457. /**
  9458. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9459. */
  9460. /**
  9461. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9462. */
  9463. normalBias: number;
  9464. private _blurBoxOffset;
  9465. /**
  9466. * Gets the blur box offset: offset applied during the blur pass.
  9467. * Only useful if useKernelBlur = false
  9468. */
  9469. /**
  9470. * Sets the blur box offset: offset applied during the blur pass.
  9471. * Only useful if useKernelBlur = false
  9472. */
  9473. blurBoxOffset: number;
  9474. private _blurScale;
  9475. /**
  9476. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9477. * 2 means half of the size.
  9478. */
  9479. /**
  9480. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9481. * 2 means half of the size.
  9482. */
  9483. blurScale: number;
  9484. private _blurKernel;
  9485. /**
  9486. * Gets the blur kernel: kernel size of the blur pass.
  9487. * Only useful if useKernelBlur = true
  9488. */
  9489. /**
  9490. * Sets the blur kernel: kernel size of the blur pass.
  9491. * Only useful if useKernelBlur = true
  9492. */
  9493. blurKernel: number;
  9494. private _useKernelBlur;
  9495. /**
  9496. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9497. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9498. */
  9499. /**
  9500. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9501. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9502. */
  9503. useKernelBlur: boolean;
  9504. private _depthScale;
  9505. /**
  9506. * Gets the depth scale used in ESM mode.
  9507. */
  9508. /**
  9509. * Sets the depth scale used in ESM mode.
  9510. * This can override the scale stored on the light.
  9511. */
  9512. depthScale: number;
  9513. private _filter;
  9514. /**
  9515. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9516. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9517. */
  9518. /**
  9519. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9520. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9521. */
  9522. filter: number;
  9523. /**
  9524. * Gets if the current filter is set to Poisson Sampling.
  9525. */
  9526. /**
  9527. * Sets the current filter to Poisson Sampling.
  9528. */
  9529. usePoissonSampling: boolean;
  9530. /**
  9531. * Gets if the current filter is set to ESM.
  9532. */
  9533. /**
  9534. * Sets the current filter is to ESM.
  9535. */
  9536. useExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered ESM.
  9539. */
  9540. /**
  9541. * Gets if the current filter is set to filtered ESM.
  9542. */
  9543. useBlurExponentialShadowMap: boolean;
  9544. /**
  9545. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9546. * exponential to prevent steep falloff artifacts).
  9547. */
  9548. /**
  9549. * Sets the current filter to "close ESM" (using the inverse of the
  9550. * exponential to prevent steep falloff artifacts).
  9551. */
  9552. useCloseExponentialShadowMap: boolean;
  9553. /**
  9554. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9555. * exponential to prevent steep falloff artifacts).
  9556. */
  9557. /**
  9558. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9559. * exponential to prevent steep falloff artifacts).
  9560. */
  9561. useBlurCloseExponentialShadowMap: boolean;
  9562. /**
  9563. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9564. */
  9565. /**
  9566. * Sets the current filter to "PCF" (percentage closer filtering).
  9567. */
  9568. usePercentageCloserFiltering: boolean;
  9569. private _filteringQuality;
  9570. /**
  9571. * Gets the PCF or PCSS Quality.
  9572. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9573. */
  9574. /**
  9575. * Sets the PCF or PCSS Quality.
  9576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9577. */
  9578. filteringQuality: number;
  9579. /**
  9580. * Gets if the current filter is set to "PCSS" (contact hardening).
  9581. */
  9582. /**
  9583. * Sets the current filter to "PCSS" (contact hardening).
  9584. */
  9585. useContactHardeningShadow: boolean;
  9586. private _contactHardeningLightSizeUVRatio;
  9587. /**
  9588. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9589. * Using a ratio helps keeping shape stability independently of the map size.
  9590. *
  9591. * It does not account for the light projection as it was having too much
  9592. * instability during the light setup or during light position changes.
  9593. *
  9594. * Only valid if useContactHardeningShadow is true.
  9595. */
  9596. /**
  9597. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9598. * Using a ratio helps keeping shape stability independently of the map size.
  9599. *
  9600. * It does not account for the light projection as it was having too much
  9601. * instability during the light setup or during light position changes.
  9602. *
  9603. * Only valid if useContactHardeningShadow is true.
  9604. */
  9605. contactHardeningLightSizeUVRatio: number;
  9606. private _darkness;
  9607. /** Gets or sets the actual darkness of a shadow */
  9608. darkness: number;
  9609. /**
  9610. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9611. * 0 means strongest and 1 would means no shadow.
  9612. * @returns the darkness.
  9613. */
  9614. getDarkness(): number;
  9615. /**
  9616. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9617. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9618. * @returns the shadow generator allowing fluent coding.
  9619. */
  9620. setDarkness(darkness: number): ShadowGenerator;
  9621. private _transparencyShadow;
  9622. /** Gets or sets the ability to have transparent shadow */
  9623. transparencyShadow: boolean;
  9624. /**
  9625. * Sets the ability to have transparent shadow (boolean).
  9626. * @param transparent True if transparent else False
  9627. * @returns the shadow generator allowing fluent coding
  9628. */
  9629. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9630. private _shadowMap;
  9631. private _shadowMap2;
  9632. /**
  9633. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9634. * @returns The render target texture if present otherwise, null
  9635. */
  9636. getShadowMap(): Nullable<RenderTargetTexture>;
  9637. /**
  9638. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9639. * @returns The render target texture if the shadow map is present otherwise, null
  9640. */
  9641. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9642. /**
  9643. * Gets the class name of that object
  9644. * @returns "ShadowGenerator"
  9645. */
  9646. getClassName(): string;
  9647. /**
  9648. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9649. * @param mesh Mesh to add
  9650. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9651. * @returns the Shadow Generator itself
  9652. */
  9653. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9654. /**
  9655. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9656. * @param mesh Mesh to remove
  9657. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9658. * @returns the Shadow Generator itself
  9659. */
  9660. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9661. /**
  9662. * Controls the extent to which the shadows fade out at the edge of the frustum
  9663. * Used only by directionals and spots
  9664. */
  9665. frustumEdgeFalloff: number;
  9666. private _light;
  9667. /**
  9668. * Returns the associated light object.
  9669. * @returns the light generating the shadow
  9670. */
  9671. getLight(): IShadowLight;
  9672. /**
  9673. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9674. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9675. * It might on the other hand introduce peter panning.
  9676. */
  9677. forceBackFacesOnly: boolean;
  9678. private _scene;
  9679. private _lightDirection;
  9680. private _effect;
  9681. private _viewMatrix;
  9682. private _projectionMatrix;
  9683. private _transformMatrix;
  9684. private _cachedPosition;
  9685. private _cachedDirection;
  9686. private _cachedDefines;
  9687. private _currentRenderID;
  9688. private _boxBlurPostprocess;
  9689. private _kernelBlurXPostprocess;
  9690. private _kernelBlurYPostprocess;
  9691. private _blurPostProcesses;
  9692. private _mapSize;
  9693. private _currentFaceIndex;
  9694. private _currentFaceIndexCache;
  9695. private _textureType;
  9696. private _defaultTextureMatrix;
  9697. /** @hidden */
  9698. static _SceneComponentInitialization: (scene: Scene) => void;
  9699. /**
  9700. * Creates a ShadowGenerator object.
  9701. * A ShadowGenerator is the required tool to use the shadows.
  9702. * Each light casting shadows needs to use its own ShadowGenerator.
  9703. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9704. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9705. * @param light The light object generating the shadows.
  9706. * @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.
  9707. */
  9708. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9709. private _initializeGenerator;
  9710. private _initializeShadowMap;
  9711. private _initializeBlurRTTAndPostProcesses;
  9712. private _renderForShadowMap;
  9713. private _renderSubMeshForShadowMap;
  9714. private _applyFilterValues;
  9715. /**
  9716. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9717. * @param onCompiled Callback triggered at the and of the effects compilation
  9718. * @param options Sets of optional options forcing the compilation with different modes
  9719. */
  9720. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9721. useInstances: boolean;
  9722. }>): void;
  9723. /**
  9724. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9725. * @param options Sets of optional options forcing the compilation with different modes
  9726. * @returns A promise that resolves when the compilation completes
  9727. */
  9728. forceCompilationAsync(options?: Partial<{
  9729. useInstances: boolean;
  9730. }>): Promise<void>;
  9731. /**
  9732. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9733. * @param subMesh The submesh we want to render in the shadow map
  9734. * @param useInstances Defines wether will draw in the map using instances
  9735. * @returns true if ready otherwise, false
  9736. */
  9737. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9738. /**
  9739. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9740. * @param defines Defines of the material we want to update
  9741. * @param lightIndex Index of the light in the enabled light list of the material
  9742. */
  9743. prepareDefines(defines: any, lightIndex: number): void;
  9744. /**
  9745. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9746. * defined in the generator but impacting the effect).
  9747. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9748. * @param effect The effect we are binfing the information for
  9749. */
  9750. bindShadowLight(lightIndex: string, effect: Effect): void;
  9751. /**
  9752. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9753. * (eq to shadow prjection matrix * light transform matrix)
  9754. * @returns The transform matrix used to create the shadow map
  9755. */
  9756. getTransformMatrix(): Matrix;
  9757. /**
  9758. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9759. * Cube and 2D textures for instance.
  9760. */
  9761. recreateShadowMap(): void;
  9762. private _disposeBlurPostProcesses;
  9763. private _disposeRTTandPostProcesses;
  9764. /**
  9765. * Disposes the ShadowGenerator.
  9766. * Returns nothing.
  9767. */
  9768. dispose(): void;
  9769. /**
  9770. * Serializes the shadow generator setup to a json object.
  9771. * @returns The serialized JSON object
  9772. */
  9773. serialize(): any;
  9774. /**
  9775. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9776. * @param parsedShadowGenerator The JSON object to parse
  9777. * @param scene The scene to create the shadow map for
  9778. * @returns The parsed shadow generator
  9779. */
  9780. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. /**
  9785. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9786. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9787. * 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.
  9788. */
  9789. export abstract class Light extends Node {
  9790. /**
  9791. * Falloff Default: light is falling off following the material specification:
  9792. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9793. */
  9794. static readonly FALLOFF_DEFAULT: number;
  9795. /**
  9796. * Falloff Physical: light is falling off following the inverse squared distance law.
  9797. */
  9798. static readonly FALLOFF_PHYSICAL: number;
  9799. /**
  9800. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9801. * to enhance interoperability with other engines.
  9802. */
  9803. static readonly FALLOFF_GLTF: number;
  9804. /**
  9805. * Falloff Standard: light is falling off like in the standard material
  9806. * to enhance interoperability with other materials.
  9807. */
  9808. static readonly FALLOFF_STANDARD: number;
  9809. /**
  9810. * If every light affecting the material is in this lightmapMode,
  9811. * material.lightmapTexture adds or multiplies
  9812. * (depends on material.useLightmapAsShadowmap)
  9813. * after every other light calculations.
  9814. */
  9815. static readonly LIGHTMAP_DEFAULT: number;
  9816. /**
  9817. * material.lightmapTexture as only diffuse lighting from this light
  9818. * adds only specular lighting from this light
  9819. * adds dynamic shadows
  9820. */
  9821. static readonly LIGHTMAP_SPECULAR: number;
  9822. /**
  9823. * material.lightmapTexture as only lighting
  9824. * no light calculation from this light
  9825. * only adds dynamic shadows from this light
  9826. */
  9827. static readonly LIGHTMAP_SHADOWSONLY: number;
  9828. /**
  9829. * Each light type uses the default quantity according to its type:
  9830. * point/spot lights use luminous intensity
  9831. * directional lights use illuminance
  9832. */
  9833. static readonly INTENSITYMODE_AUTOMATIC: number;
  9834. /**
  9835. * lumen (lm)
  9836. */
  9837. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9838. /**
  9839. * candela (lm/sr)
  9840. */
  9841. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9842. /**
  9843. * lux (lm/m^2)
  9844. */
  9845. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9846. /**
  9847. * nit (cd/m^2)
  9848. */
  9849. static readonly INTENSITYMODE_LUMINANCE: number;
  9850. /**
  9851. * Light type const id of the point light.
  9852. */
  9853. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9854. /**
  9855. * Light type const id of the directional light.
  9856. */
  9857. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9858. /**
  9859. * Light type const id of the spot light.
  9860. */
  9861. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9862. /**
  9863. * Light type const id of the hemispheric light.
  9864. */
  9865. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9866. /**
  9867. * Diffuse gives the basic color to an object.
  9868. */
  9869. diffuse: Color3;
  9870. /**
  9871. * Specular produces a highlight color on an object.
  9872. * Note: This is note affecting PBR materials.
  9873. */
  9874. specular: Color3;
  9875. /**
  9876. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9877. * falling off base on range or angle.
  9878. * This can be set to any values in Light.FALLOFF_x.
  9879. *
  9880. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9881. * other types of materials.
  9882. */
  9883. falloffType: number;
  9884. /**
  9885. * Strength of the light.
  9886. * Note: By default it is define in the framework own unit.
  9887. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9888. */
  9889. intensity: number;
  9890. private _range;
  9891. protected _inverseSquaredRange: number;
  9892. /**
  9893. * Defines how far from the source the light is impacting in scene units.
  9894. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9895. */
  9896. /**
  9897. * Defines how far from the source the light is impacting in scene units.
  9898. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9899. */
  9900. range: number;
  9901. /**
  9902. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9903. * of light.
  9904. */
  9905. private _photometricScale;
  9906. private _intensityMode;
  9907. /**
  9908. * Gets the photometric scale used to interpret the intensity.
  9909. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9910. */
  9911. /**
  9912. * Sets the photometric scale used to interpret the intensity.
  9913. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9914. */
  9915. intensityMode: number;
  9916. private _radius;
  9917. /**
  9918. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9919. */
  9920. /**
  9921. * sets the light radius used by PBR Materials to simulate soft area lights.
  9922. */
  9923. radius: number;
  9924. private _renderPriority;
  9925. /**
  9926. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9927. * exceeding the number allowed of the materials.
  9928. */
  9929. renderPriority: number;
  9930. private _shadowEnabled;
  9931. /**
  9932. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9933. * the current shadow generator.
  9934. */
  9935. /**
  9936. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9937. * the current shadow generator.
  9938. */
  9939. shadowEnabled: boolean;
  9940. private _includedOnlyMeshes;
  9941. /**
  9942. * Gets the only meshes impacted by this light.
  9943. */
  9944. /**
  9945. * Sets the only meshes impacted by this light.
  9946. */
  9947. includedOnlyMeshes: AbstractMesh[];
  9948. private _excludedMeshes;
  9949. /**
  9950. * Gets the meshes not impacted by this light.
  9951. */
  9952. /**
  9953. * Sets the meshes not impacted by this light.
  9954. */
  9955. excludedMeshes: AbstractMesh[];
  9956. private _excludeWithLayerMask;
  9957. /**
  9958. * Gets the layer id use to find what meshes are not impacted by the light.
  9959. * Inactive if 0
  9960. */
  9961. /**
  9962. * Sets the layer id use to find what meshes are not impacted by the light.
  9963. * Inactive if 0
  9964. */
  9965. excludeWithLayerMask: number;
  9966. private _includeOnlyWithLayerMask;
  9967. /**
  9968. * Gets the layer id use to find what meshes are impacted by the light.
  9969. * Inactive if 0
  9970. */
  9971. /**
  9972. * Sets the layer id use to find what meshes are impacted by the light.
  9973. * Inactive if 0
  9974. */
  9975. includeOnlyWithLayerMask: number;
  9976. private _lightmapMode;
  9977. /**
  9978. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9979. */
  9980. /**
  9981. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9982. */
  9983. lightmapMode: number;
  9984. /**
  9985. * Shadow generator associted to the light.
  9986. * @hidden Internal use only.
  9987. */
  9988. _shadowGenerator: Nullable<IShadowGenerator>;
  9989. /**
  9990. * @hidden Internal use only.
  9991. */
  9992. _excludedMeshesIds: string[];
  9993. /**
  9994. * @hidden Internal use only.
  9995. */
  9996. _includedOnlyMeshesIds: string[];
  9997. /**
  9998. * The current light unifom buffer.
  9999. * @hidden Internal use only.
  10000. */
  10001. _uniformBuffer: UniformBuffer;
  10002. /**
  10003. * Creates a Light object in the scene.
  10004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10005. * @param name The firendly name of the light
  10006. * @param scene The scene the light belongs too
  10007. */
  10008. constructor(name: string, scene: Scene);
  10009. protected abstract _buildUniformLayout(): void;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightIndex The index of the light in the effect to update
  10014. * @returns The light
  10015. */
  10016. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10017. /**
  10018. * Sets the passed Effect "effect" with the Light information.
  10019. * @param effect The effect to update
  10020. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10021. * @returns The light
  10022. */
  10023. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10024. /**
  10025. * Returns the string "Light".
  10026. * @returns the class name
  10027. */
  10028. getClassName(): string;
  10029. /** @hidden */
  10030. readonly _isLight: boolean;
  10031. /**
  10032. * Converts the light information to a readable string for debug purpose.
  10033. * @param fullDetails Supports for multiple levels of logging within scene loading
  10034. * @returns the human readable light info
  10035. */
  10036. toString(fullDetails?: boolean): string;
  10037. /** @hidden */
  10038. protected _syncParentEnabledState(): void;
  10039. /**
  10040. * Set the enabled state of this node.
  10041. * @param value - the new enabled state
  10042. */
  10043. setEnabled(value: boolean): void;
  10044. /**
  10045. * Returns the Light associated shadow generator if any.
  10046. * @return the associated shadow generator.
  10047. */
  10048. getShadowGenerator(): Nullable<IShadowGenerator>;
  10049. /**
  10050. * Returns a Vector3, the absolute light position in the World.
  10051. * @returns the world space position of the light
  10052. */
  10053. getAbsolutePosition(): Vector3;
  10054. /**
  10055. * Specifies if the light will affect the passed mesh.
  10056. * @param mesh The mesh to test against the light
  10057. * @return true the mesh is affected otherwise, false.
  10058. */
  10059. canAffectMesh(mesh: AbstractMesh): boolean;
  10060. /**
  10061. * Sort function to order lights for rendering.
  10062. * @param a First Light object to compare to second.
  10063. * @param b Second Light object to compare first.
  10064. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10065. */
  10066. static CompareLightsPriority(a: Light, b: Light): number;
  10067. /**
  10068. * Releases resources associated with this node.
  10069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10071. */
  10072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10073. /**
  10074. * Returns the light type ID (integer).
  10075. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10076. */
  10077. getTypeID(): number;
  10078. /**
  10079. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10080. * @returns the scaled intensity in intensity mode unit
  10081. */
  10082. getScaledIntensity(): number;
  10083. /**
  10084. * Returns a new Light object, named "name", from the current one.
  10085. * @param name The name of the cloned light
  10086. * @returns the new created light
  10087. */
  10088. clone(name: string): Nullable<Light>;
  10089. /**
  10090. * Serializes the current light into a Serialization object.
  10091. * @returns the serialized object.
  10092. */
  10093. serialize(): any;
  10094. /**
  10095. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10096. * This new light is named "name" and added to the passed scene.
  10097. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10098. * @param name The friendly name of the light
  10099. * @param scene The scene the new light will belong to
  10100. * @returns the constructor function
  10101. */
  10102. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10103. /**
  10104. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10105. * @param parsedLight The JSON representation of the light
  10106. * @param scene The scene to create the parsed light in
  10107. * @returns the created light after parsing
  10108. */
  10109. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10110. private _hookArrayForExcluded;
  10111. private _hookArrayForIncludedOnly;
  10112. private _resyncMeshes;
  10113. /**
  10114. * Forces the meshes to update their light related information in their rendering used effects
  10115. * @hidden Internal Use Only
  10116. */
  10117. _markMeshesAsLightDirty(): void;
  10118. /**
  10119. * Recomputes the cached photometric scale if needed.
  10120. */
  10121. private _computePhotometricScale;
  10122. /**
  10123. * Returns the Photometric Scale according to the light type and intensity mode.
  10124. */
  10125. private _getPhotometricScale;
  10126. /**
  10127. * Reorder the light in the scene according to their defined priority.
  10128. * @hidden Internal Use Only
  10129. */
  10130. _reorderLightsInScene(): void;
  10131. /**
  10132. * Prepares the list of defines specific to the light type.
  10133. * @param defines the list of defines
  10134. * @param lightIndex defines the index of the light for the effect
  10135. */
  10136. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10137. }
  10138. }
  10139. declare module BABYLON {
  10140. /**
  10141. * Interface used to define Action
  10142. */
  10143. export interface IAction {
  10144. /**
  10145. * Trigger for the action
  10146. */
  10147. trigger: number;
  10148. /** Options of the trigger */
  10149. triggerOptions: any;
  10150. /**
  10151. * Gets the trigger parameters
  10152. * @returns the trigger parameters
  10153. */
  10154. getTriggerParameter(): any;
  10155. /**
  10156. * Internal only - executes current action event
  10157. * @hidden
  10158. */
  10159. _executeCurrent(evt?: ActionEvent): void;
  10160. /**
  10161. * Serialize placeholder for child classes
  10162. * @param parent of child
  10163. * @returns the serialized object
  10164. */
  10165. serialize(parent: any): any;
  10166. /**
  10167. * Internal only
  10168. * @hidden
  10169. */
  10170. _prepare(): void;
  10171. /**
  10172. * Internal only - manager for action
  10173. * @hidden
  10174. */
  10175. _actionManager: AbstractActionManager;
  10176. /**
  10177. * Adds action to chain of actions, may be a DoNothingAction
  10178. * @param action defines the next action to execute
  10179. * @returns The action passed in
  10180. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10181. */
  10182. then(action: IAction): IAction;
  10183. }
  10184. /**
  10185. * The action to be carried out following a trigger
  10186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10187. */
  10188. export class Action implements IAction {
  10189. /** the trigger, with or without parameters, for the action */
  10190. triggerOptions: any;
  10191. /**
  10192. * Trigger for the action
  10193. */
  10194. trigger: number;
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */
  10199. _actionManager: ActionManager;
  10200. private _nextActiveAction;
  10201. private _child;
  10202. private _condition?;
  10203. private _triggerParameter;
  10204. /**
  10205. * An event triggered prior to action being executed.
  10206. */
  10207. onBeforeExecuteObservable: Observable<Action>;
  10208. /**
  10209. * Creates a new Action
  10210. * @param triggerOptions the trigger, with or without parameters, for the action
  10211. * @param condition an optional determinant of action
  10212. */
  10213. constructor(
  10214. /** the trigger, with or without parameters, for the action */
  10215. triggerOptions: any, condition?: Condition);
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. _prepare(): void;
  10221. /**
  10222. * Gets the trigger parameters
  10223. * @returns the trigger parameters
  10224. */
  10225. getTriggerParameter(): any;
  10226. /**
  10227. * Internal only - executes current action event
  10228. * @hidden
  10229. */
  10230. _executeCurrent(evt?: ActionEvent): void;
  10231. /**
  10232. * Execute placeholder for child classes
  10233. * @param evt optional action event
  10234. */
  10235. execute(evt?: ActionEvent): void;
  10236. /**
  10237. * Skips to next active action
  10238. */
  10239. skipToNextActiveAction(): void;
  10240. /**
  10241. * Adds action to chain of actions, may be a DoNothingAction
  10242. * @param action defines the next action to execute
  10243. * @returns The action passed in
  10244. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10245. */
  10246. then(action: Action): Action;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. _getProperty(propertyPath: string): string;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. _getEffectiveTarget(target: any, propertyPath: string): any;
  10257. /**
  10258. * Serialize placeholder for child classes
  10259. * @param parent of child
  10260. * @returns the serialized object
  10261. */
  10262. serialize(parent: any): any;
  10263. /**
  10264. * Internal only called by serialize
  10265. * @hidden
  10266. */
  10267. protected _serialize(serializedAction: any, parent?: any): any;
  10268. /**
  10269. * Internal only
  10270. * @hidden
  10271. */
  10272. static _SerializeValueAsString: (value: any) => string;
  10273. /**
  10274. * Internal only
  10275. * @hidden
  10276. */
  10277. static _GetTargetProperty: (target: Node | Scene) => {
  10278. name: string;
  10279. targetType: string;
  10280. value: string;
  10281. };
  10282. }
  10283. }
  10284. declare module BABYLON {
  10285. /**
  10286. * A Condition applied to an Action
  10287. */
  10288. export class Condition {
  10289. /**
  10290. * Internal only - manager for action
  10291. * @hidden
  10292. */
  10293. _actionManager: ActionManager;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _evaluationId: number;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. _currentResult: boolean;
  10304. /**
  10305. * Creates a new Condition
  10306. * @param actionManager the manager of the action the condition is applied to
  10307. */
  10308. constructor(actionManager: ActionManager);
  10309. /**
  10310. * Check if the current condition is valid
  10311. * @returns a boolean
  10312. */
  10313. isValid(): boolean;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. _getProperty(propertyPath: string): string;
  10319. /**
  10320. * Internal only
  10321. * @hidden
  10322. */
  10323. _getEffectiveTarget(target: any, propertyPath: string): any;
  10324. /**
  10325. * Serialize placeholder for child classes
  10326. * @returns the serialized object
  10327. */
  10328. serialize(): any;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. protected _serialize(serializedCondition: any): any;
  10334. }
  10335. /**
  10336. * Defines specific conditional operators as extensions of Condition
  10337. */
  10338. export class ValueCondition extends Condition {
  10339. /** path to specify the property of the target the conditional operator uses */
  10340. propertyPath: string;
  10341. /** the value compared by the conditional operator against the current value of the property */
  10342. value: any;
  10343. /** the conditional operator, default ValueCondition.IsEqual */
  10344. operator: number;
  10345. /**
  10346. * Internal only
  10347. * @hidden
  10348. */
  10349. private static _IsEqual;
  10350. /**
  10351. * Internal only
  10352. * @hidden
  10353. */
  10354. private static _IsDifferent;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */
  10359. private static _IsGreater;
  10360. /**
  10361. * Internal only
  10362. * @hidden
  10363. */
  10364. private static _IsLesser;
  10365. /**
  10366. * returns the number for IsEqual
  10367. */
  10368. static readonly IsEqual: number;
  10369. /**
  10370. * Returns the number for IsDifferent
  10371. */
  10372. static readonly IsDifferent: number;
  10373. /**
  10374. * Returns the number for IsGreater
  10375. */
  10376. static readonly IsGreater: number;
  10377. /**
  10378. * Returns the number for IsLesser
  10379. */
  10380. static readonly IsLesser: number;
  10381. /**
  10382. * Internal only The action manager for the condition
  10383. * @hidden
  10384. */
  10385. _actionManager: ActionManager;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. private _target;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. private _effectiveTarget;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. private _property;
  10401. /**
  10402. * Creates a new ValueCondition
  10403. * @param actionManager manager for the action the condition applies to
  10404. * @param target for the action
  10405. * @param propertyPath path to specify the property of the target the conditional operator uses
  10406. * @param value the value compared by the conditional operator against the current value of the property
  10407. * @param operator the conditional operator, default ValueCondition.IsEqual
  10408. */
  10409. constructor(actionManager: ActionManager, target: any,
  10410. /** path to specify the property of the target the conditional operator uses */
  10411. propertyPath: string,
  10412. /** the value compared by the conditional operator against the current value of the property */
  10413. value: any,
  10414. /** the conditional operator, default ValueCondition.IsEqual */
  10415. operator?: number);
  10416. /**
  10417. * Compares the given value with the property value for the specified conditional operator
  10418. * @returns the result of the comparison
  10419. */
  10420. isValid(): boolean;
  10421. /**
  10422. * Serialize the ValueCondition into a JSON compatible object
  10423. * @returns serialization object
  10424. */
  10425. serialize(): any;
  10426. /**
  10427. * Gets the name of the conditional operator for the ValueCondition
  10428. * @param operator the conditional operator
  10429. * @returns the name
  10430. */
  10431. static GetOperatorName(operator: number): string;
  10432. }
  10433. /**
  10434. * Defines a predicate condition as an extension of Condition
  10435. */
  10436. export class PredicateCondition extends Condition {
  10437. /** defines the predicate function used to validate the condition */
  10438. predicate: () => boolean;
  10439. /**
  10440. * Internal only - manager for action
  10441. * @hidden
  10442. */
  10443. _actionManager: ActionManager;
  10444. /**
  10445. * Creates a new PredicateCondition
  10446. * @param actionManager manager for the action the condition applies to
  10447. * @param predicate defines the predicate function used to validate the condition
  10448. */
  10449. constructor(actionManager: ActionManager,
  10450. /** defines the predicate function used to validate the condition */
  10451. predicate: () => boolean);
  10452. /**
  10453. * @returns the validity of the predicate condition
  10454. */
  10455. isValid(): boolean;
  10456. }
  10457. /**
  10458. * Defines a state condition as an extension of Condition
  10459. */
  10460. export class StateCondition extends Condition {
  10461. /** Value to compare with target state */
  10462. value: string;
  10463. /**
  10464. * Internal only - manager for action
  10465. * @hidden
  10466. */
  10467. _actionManager: ActionManager;
  10468. /**
  10469. * Internal only
  10470. * @hidden
  10471. */
  10472. private _target;
  10473. /**
  10474. * Creates a new StateCondition
  10475. * @param actionManager manager for the action the condition applies to
  10476. * @param target of the condition
  10477. * @param value to compare with target state
  10478. */
  10479. constructor(actionManager: ActionManager, target: any,
  10480. /** Value to compare with target state */
  10481. value: string);
  10482. /**
  10483. * Gets a boolean indicating if the current condition is met
  10484. * @returns the validity of the state
  10485. */
  10486. isValid(): boolean;
  10487. /**
  10488. * Serialize the StateCondition into a JSON compatible object
  10489. * @returns serialization object
  10490. */
  10491. serialize(): any;
  10492. }
  10493. }
  10494. declare module BABYLON {
  10495. /**
  10496. * This defines an action responsible to toggle a boolean once triggered.
  10497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10498. */
  10499. export class SwitchBooleanAction extends Action {
  10500. /**
  10501. * The path to the boolean property in the target object
  10502. */
  10503. propertyPath: string;
  10504. private _target;
  10505. private _effectiveTarget;
  10506. private _property;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the object containing the boolean
  10511. * @param propertyPath defines the path to the boolean property in the target object
  10512. * @param condition defines the trigger related conditions
  10513. */
  10514. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10515. /** @hidden */
  10516. _prepare(): void;
  10517. /**
  10518. * Execute the action toggle the boolean value.
  10519. */
  10520. execute(): void;
  10521. /**
  10522. * Serializes the actions and its related information.
  10523. * @param parent defines the object to serialize in
  10524. * @returns the serialized object
  10525. */
  10526. serialize(parent: any): any;
  10527. }
  10528. /**
  10529. * This defines an action responsible to set a the state field of the target
  10530. * to a desired value once triggered.
  10531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10532. */
  10533. export class SetStateAction extends Action {
  10534. /**
  10535. * The value to store in the state field.
  10536. */
  10537. value: string;
  10538. private _target;
  10539. /**
  10540. * Instantiate the action
  10541. * @param triggerOptions defines the trigger options
  10542. * @param target defines the object containing the state property
  10543. * @param value defines the value to store in the state field
  10544. * @param condition defines the trigger related conditions
  10545. */
  10546. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10547. /**
  10548. * Execute the action and store the value on the target state property.
  10549. */
  10550. execute(): void;
  10551. /**
  10552. * Serializes the actions and its related information.
  10553. * @param parent defines the object to serialize in
  10554. * @returns the serialized object
  10555. */
  10556. serialize(parent: any): any;
  10557. }
  10558. /**
  10559. * This defines an action responsible to set a property of the target
  10560. * to a desired value once triggered.
  10561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10562. */
  10563. export class SetValueAction extends Action {
  10564. /**
  10565. * The path of the property to set in the target.
  10566. */
  10567. propertyPath: string;
  10568. /**
  10569. * The value to set in the property
  10570. */
  10571. value: any;
  10572. private _target;
  10573. private _effectiveTarget;
  10574. private _property;
  10575. /**
  10576. * Instantiate the action
  10577. * @param triggerOptions defines the trigger options
  10578. * @param target defines the object containing the property
  10579. * @param propertyPath defines the path of the property to set in the target
  10580. * @param value defines the value to set in the property
  10581. * @param condition defines the trigger related conditions
  10582. */
  10583. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10584. /** @hidden */
  10585. _prepare(): void;
  10586. /**
  10587. * Execute the action and set the targetted property to the desired value.
  10588. */
  10589. execute(): void;
  10590. /**
  10591. * Serializes the actions and its related information.
  10592. * @param parent defines the object to serialize in
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. }
  10597. /**
  10598. * This defines an action responsible to increment the target value
  10599. * to a desired value once triggered.
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class IncrementValueAction extends Action {
  10603. /**
  10604. * The path of the property to increment in the target.
  10605. */
  10606. propertyPath: string;
  10607. /**
  10608. * The value we should increment the property by.
  10609. */
  10610. value: any;
  10611. private _target;
  10612. private _effectiveTarget;
  10613. private _property;
  10614. /**
  10615. * Instantiate the action
  10616. * @param triggerOptions defines the trigger options
  10617. * @param target defines the object containing the property
  10618. * @param propertyPath defines the path of the property to increment in the target
  10619. * @param value defines the value value we should increment the property by
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action and increment the target of the value amount.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to start an animation once triggered.
  10638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class PlayAnimationAction extends Action {
  10641. /**
  10642. * Where the animation should start (animation frame)
  10643. */
  10644. from: number;
  10645. /**
  10646. * Where the animation should stop (animation frame)
  10647. */
  10648. to: number;
  10649. /**
  10650. * Define if the animation should loop or stop after the first play.
  10651. */
  10652. loop?: boolean;
  10653. private _target;
  10654. /**
  10655. * Instantiate the action
  10656. * @param triggerOptions defines the trigger options
  10657. * @param target defines the target animation or animation name
  10658. * @param from defines from where the animation should start (animation frame)
  10659. * @param end defines where the animation should stop (animation frame)
  10660. * @param loop defines if the animation should loop or stop after the first play
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and play the animation.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to stop an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class StopAnimationAction extends Action {
  10682. private _target;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the target animation or animation name
  10687. * @param condition defines the trigger related conditions
  10688. */
  10689. constructor(triggerOptions: any, target: any, condition?: Condition);
  10690. /** @hidden */
  10691. _prepare(): void;
  10692. /**
  10693. * Execute the action and stop the animation.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible that does nothing once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class DoNothingAction extends Action {
  10708. /**
  10709. * Instantiate the action
  10710. * @param triggerOptions defines the trigger options
  10711. * @param condition defines the trigger related conditions
  10712. */
  10713. constructor(triggerOptions?: any, condition?: Condition);
  10714. /**
  10715. * Execute the action and do nothing.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to trigger several actions once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class CombineAction extends Action {
  10730. /**
  10731. * The list of aggregated animations to run.
  10732. */
  10733. children: Action[];
  10734. /**
  10735. * Instantiate the action
  10736. * @param triggerOptions defines the trigger options
  10737. * @param children defines the list of aggregated animations to run
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10741. /** @hidden */
  10742. _prepare(): void;
  10743. /**
  10744. * Execute the action and executes all the aggregated actions.
  10745. */
  10746. execute(evt: ActionEvent): void;
  10747. /**
  10748. * Serializes the actions and its related information.
  10749. * @param parent defines the object to serialize in
  10750. * @returns the serialized object
  10751. */
  10752. serialize(parent: any): any;
  10753. }
  10754. /**
  10755. * This defines an action responsible to run code (external event) once triggered.
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10757. */
  10758. export class ExecuteCodeAction extends Action {
  10759. /**
  10760. * The callback function to run.
  10761. */
  10762. func: (evt: ActionEvent) => void;
  10763. /**
  10764. * Instantiate the action
  10765. * @param triggerOptions defines the trigger options
  10766. * @param func defines the callback function to run
  10767. * @param condition defines the trigger related conditions
  10768. */
  10769. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10770. /**
  10771. * Execute the action and run the attached code.
  10772. */
  10773. execute(evt: ActionEvent): void;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set the parent property of the target once triggered.
  10777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10778. */
  10779. export class SetParentAction extends Action {
  10780. private _parent;
  10781. private _target;
  10782. /**
  10783. * Instantiate the action
  10784. * @param triggerOptions defines the trigger options
  10785. * @param target defines the target containing the parent property
  10786. * @param parent defines from where the animation should start (animation frame)
  10787. * @param condition defines the trigger related conditions
  10788. */
  10789. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10790. /** @hidden */
  10791. _prepare(): void;
  10792. /**
  10793. * Execute the action and set the parent property.
  10794. */
  10795. execute(): void;
  10796. /**
  10797. * Serializes the actions and its related information.
  10798. * @param parent defines the object to serialize in
  10799. * @returns the serialized object
  10800. */
  10801. serialize(parent: any): any;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /**
  10806. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10807. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10809. */
  10810. export class ActionManager extends AbstractActionManager {
  10811. /**
  10812. * Nothing
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10814. */
  10815. static readonly NothingTrigger: number;
  10816. /**
  10817. * On pick
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10819. */
  10820. static readonly OnPickTrigger: number;
  10821. /**
  10822. * On left pick
  10823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10824. */
  10825. static readonly OnLeftPickTrigger: number;
  10826. /**
  10827. * On right pick
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10829. */
  10830. static readonly OnRightPickTrigger: number;
  10831. /**
  10832. * On center pick
  10833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10834. */
  10835. static readonly OnCenterPickTrigger: number;
  10836. /**
  10837. * On pick down
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickDownTrigger: number;
  10841. /**
  10842. * On double pick
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnDoublePickTrigger: number;
  10846. /**
  10847. * On pick up
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPickUpTrigger: number;
  10851. /**
  10852. * On pick out.
  10853. * This trigger will only be raised if you also declared a OnPickDown
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly OnPickOutTrigger: number;
  10857. /**
  10858. * On long press
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnLongPressTrigger: number;
  10862. /**
  10863. * On pointer over
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnPointerOverTrigger: number;
  10867. /**
  10868. * On pointer out
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnPointerOutTrigger: number;
  10872. /**
  10873. * On every frame
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnEveryFrameTrigger: number;
  10877. /**
  10878. * On intersection enter
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnIntersectionEnterTrigger: number;
  10882. /**
  10883. * On intersection exit
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnIntersectionExitTrigger: number;
  10887. /**
  10888. * On key down
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnKeyDownTrigger: number;
  10892. /**
  10893. * On key up
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnKeyUpTrigger: number;
  10897. private _scene;
  10898. /**
  10899. * Creates a new action manager
  10900. * @param scene defines the hosting scene
  10901. */
  10902. constructor(scene: Scene);
  10903. /**
  10904. * Releases all associated resources
  10905. */
  10906. dispose(): void;
  10907. /**
  10908. * Gets hosting scene
  10909. * @returns the hosting scene
  10910. */
  10911. getScene(): Scene;
  10912. /**
  10913. * Does this action manager handles actions of any of the given triggers
  10914. * @param triggers defines the triggers to be tested
  10915. * @return a boolean indicating whether one (or more) of the triggers is handled
  10916. */
  10917. hasSpecificTriggers(triggers: number[]): boolean;
  10918. /**
  10919. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10920. * speed.
  10921. * @param triggerA defines the trigger to be tested
  10922. * @param triggerB defines the trigger to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10926. /**
  10927. * Does this action manager handles actions of a given trigger
  10928. * @param trigger defines the trigger to be tested
  10929. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10930. * @return whether the trigger is handled
  10931. */
  10932. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10933. /**
  10934. * Does this action manager has pointer triggers
  10935. */
  10936. readonly hasPointerTriggers: boolean;
  10937. /**
  10938. * Does this action manager has pick triggers
  10939. */
  10940. readonly hasPickTriggers: boolean;
  10941. /**
  10942. * Registers an action to this action manager
  10943. * @param action defines the action to be registered
  10944. * @return the action amended (prepared) after registration
  10945. */
  10946. registerAction(action: IAction): Nullable<IAction>;
  10947. /**
  10948. * Unregisters an action to this action manager
  10949. * @param action defines the action to be unregistered
  10950. * @return a boolean indicating whether the action has been unregistered
  10951. */
  10952. unregisterAction(action: IAction): Boolean;
  10953. /**
  10954. * Process a specific trigger
  10955. * @param trigger defines the trigger to process
  10956. * @param evt defines the event details to be processed
  10957. */
  10958. processTrigger(trigger: number, evt?: IActionEvent): void;
  10959. /** @hidden */
  10960. _getEffectiveTarget(target: any, propertyPath: string): any;
  10961. /** @hidden */
  10962. _getProperty(propertyPath: string): string;
  10963. /**
  10964. * Serialize this manager to a JSON object
  10965. * @param name defines the property name to store this manager
  10966. * @returns a JSON representation of this manager
  10967. */
  10968. serialize(name: string): any;
  10969. /**
  10970. * Creates a new ActionManager from a JSON data
  10971. * @param parsedActions defines the JSON data to read from
  10972. * @param object defines the hosting mesh
  10973. * @param scene defines the hosting scene
  10974. */
  10975. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10976. /**
  10977. * Get a trigger name by index
  10978. * @param trigger defines the trigger index
  10979. * @returns a trigger name
  10980. */
  10981. static GetTriggerName(trigger: number): string;
  10982. }
  10983. }
  10984. declare module BABYLON {
  10985. /**
  10986. * Class representing a ray with position and direction
  10987. */
  10988. export class Ray {
  10989. /** origin point */
  10990. origin: Vector3;
  10991. /** direction */
  10992. direction: Vector3;
  10993. /** length of the ray */
  10994. length: number;
  10995. private static readonly TmpVector3;
  10996. private _tmpRay;
  10997. /**
  10998. * Creates a new ray
  10999. * @param origin origin point
  11000. * @param direction direction
  11001. * @param length length of the ray
  11002. */
  11003. constructor(
  11004. /** origin point */
  11005. origin: Vector3,
  11006. /** direction */
  11007. direction: Vector3,
  11008. /** length of the ray */
  11009. length?: number);
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param minimum bound of the box
  11013. * @param maximum bound of the box
  11014. * @param intersectionTreshold extra extend to be added to the box in all direction
  11015. * @returns if the box was hit
  11016. */
  11017. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11018. /**
  11019. * Checks if the ray intersects a box
  11020. * @param box the bounding box to check
  11021. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11022. * @returns if the box was hit
  11023. */
  11024. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11025. /**
  11026. * If the ray hits a sphere
  11027. * @param sphere the bounding sphere to check
  11028. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11029. * @returns true if it hits the sphere
  11030. */
  11031. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11032. /**
  11033. * If the ray hits a triange
  11034. * @param vertex0 triangle vertex
  11035. * @param vertex1 triangle vertex
  11036. * @param vertex2 triangle vertex
  11037. * @returns intersection information if hit
  11038. */
  11039. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11040. /**
  11041. * Checks if ray intersects a plane
  11042. * @param plane the plane to check
  11043. * @returns the distance away it was hit
  11044. */
  11045. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11046. /**
  11047. * Calculate the intercept of a ray on a given axis
  11048. * @param axis to check 'x' | 'y' | 'z'
  11049. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11050. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11051. */
  11052. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11053. /**
  11054. * Checks if ray intersects a mesh
  11055. * @param mesh the mesh to check
  11056. * @param fastCheck if only the bounding box should checked
  11057. * @returns picking info of the intersecton
  11058. */
  11059. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11060. /**
  11061. * Checks if ray intersects a mesh
  11062. * @param meshes the meshes to check
  11063. * @param fastCheck if only the bounding box should checked
  11064. * @param results array to store result in
  11065. * @returns Array of picking infos
  11066. */
  11067. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11068. private _comparePickingInfo;
  11069. private static smallnum;
  11070. private static rayl;
  11071. /**
  11072. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11073. * @param sega the first point of the segment to test the intersection against
  11074. * @param segb the second point of the segment to test the intersection against
  11075. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11076. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11077. */
  11078. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11079. /**
  11080. * Update the ray from viewport position
  11081. * @param x position
  11082. * @param y y position
  11083. * @param viewportWidth viewport width
  11084. * @param viewportHeight viewport height
  11085. * @param world world matrix
  11086. * @param view view matrix
  11087. * @param projection projection matrix
  11088. * @returns this ray updated
  11089. */
  11090. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11091. /**
  11092. * Creates a ray with origin and direction of 0,0,0
  11093. * @returns the new ray
  11094. */
  11095. static Zero(): Ray;
  11096. /**
  11097. * Creates a new ray from screen space and viewport
  11098. * @param x position
  11099. * @param y y position
  11100. * @param viewportWidth viewport width
  11101. * @param viewportHeight viewport height
  11102. * @param world world matrix
  11103. * @param view view matrix
  11104. * @param projection projection matrix
  11105. * @returns new ray
  11106. */
  11107. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11108. /**
  11109. * 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
  11110. * transformed to the given world matrix.
  11111. * @param origin The origin point
  11112. * @param end The end point
  11113. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11114. * @returns the new ray
  11115. */
  11116. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11117. /**
  11118. * Transforms a ray by a matrix
  11119. * @param ray ray to transform
  11120. * @param matrix matrix to apply
  11121. * @returns the resulting new ray
  11122. */
  11123. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * Transforms a ray by a matrix
  11126. * @param ray ray to transform
  11127. * @param matrix matrix to apply
  11128. * @param result ray to store result in
  11129. */
  11130. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11131. /**
  11132. * Unproject a ray from screen space to object space
  11133. * @param sourceX defines the screen space x coordinate to use
  11134. * @param sourceY defines the screen space y coordinate to use
  11135. * @param viewportWidth defines the current width of the viewport
  11136. * @param viewportHeight defines the current height of the viewport
  11137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11138. * @param view defines the view matrix to use
  11139. * @param projection defines the projection matrix to use
  11140. */
  11141. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11142. }
  11143. /**
  11144. * Type used to define predicate used to select faces when a mesh intersection is detected
  11145. */
  11146. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11147. interface Scene {
  11148. /** @hidden */
  11149. _tempPickingRay: Nullable<Ray>;
  11150. /** @hidden */
  11151. _cachedRayForTransform: Ray;
  11152. /** @hidden */
  11153. _pickWithRayInverseMatrix: Matrix;
  11154. /** @hidden */
  11155. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11156. /** @hidden */
  11157. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11158. }
  11159. }
  11160. declare module BABYLON {
  11161. /**
  11162. * Groups all the scene component constants in one place to ease maintenance.
  11163. * @hidden
  11164. */
  11165. export class SceneComponentConstants {
  11166. static readonly NAME_EFFECTLAYER: string;
  11167. static readonly NAME_LAYER: string;
  11168. static readonly NAME_LENSFLARESYSTEM: string;
  11169. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11170. static readonly NAME_PARTICLESYSTEM: string;
  11171. static readonly NAME_GAMEPAD: string;
  11172. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11173. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11174. static readonly NAME_DEPTHRENDERER: string;
  11175. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11176. static readonly NAME_SPRITE: string;
  11177. static readonly NAME_OUTLINERENDERER: string;
  11178. static readonly NAME_PROCEDURALTEXTURE: string;
  11179. static readonly NAME_SHADOWGENERATOR: string;
  11180. static readonly NAME_OCTREE: string;
  11181. static readonly NAME_PHYSICSENGINE: string;
  11182. static readonly NAME_AUDIO: string;
  11183. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11184. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11185. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11186. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11187. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11188. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11189. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11190. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11191. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11192. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11193. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11194. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11195. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11196. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11197. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11198. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11199. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11200. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11201. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11202. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11203. static readonly STEP_AFTERRENDER_AUDIO: number;
  11204. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11205. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11206. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11207. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11208. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11209. static readonly STEP_POINTERMOVE_SPRITE: number;
  11210. static readonly STEP_POINTERDOWN_SPRITE: number;
  11211. static readonly STEP_POINTERUP_SPRITE: number;
  11212. }
  11213. /**
  11214. * This represents a scene component.
  11215. *
  11216. * This is used to decouple the dependency the scene is having on the different workloads like
  11217. * layers, post processes...
  11218. */
  11219. export interface ISceneComponent {
  11220. /**
  11221. * The name of the component. Each component must have a unique name.
  11222. */
  11223. name: string;
  11224. /**
  11225. * The scene the component belongs to.
  11226. */
  11227. scene: Scene;
  11228. /**
  11229. * Register the component to one instance of a scene.
  11230. */
  11231. register(): void;
  11232. /**
  11233. * Rebuilds the elements related to this component in case of
  11234. * context lost for instance.
  11235. */
  11236. rebuild(): void;
  11237. /**
  11238. * Disposes the component and the associated ressources.
  11239. */
  11240. dispose(): void;
  11241. }
  11242. /**
  11243. * This represents a SERIALIZABLE scene component.
  11244. *
  11245. * This extends Scene Component to add Serialization methods on top.
  11246. */
  11247. export interface ISceneSerializableComponent extends ISceneComponent {
  11248. /**
  11249. * Adds all the elements from the container to the scene
  11250. * @param container the container holding the elements
  11251. */
  11252. addFromContainer(container: AbstractScene): void;
  11253. /**
  11254. * Removes all the elements in the container from the scene
  11255. * @param container contains the elements to remove
  11256. * @param dispose if the removed element should be disposed (default: false)
  11257. */
  11258. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11259. /**
  11260. * Serializes the component data to the specified json object
  11261. * @param serializationObject The object to serialize to
  11262. */
  11263. serialize(serializationObject: any): void;
  11264. }
  11265. /**
  11266. * Strong typing of a Mesh related stage step action
  11267. */
  11268. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11269. /**
  11270. * Strong typing of a Evaluate Sub Mesh related stage step action
  11271. */
  11272. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11273. /**
  11274. * Strong typing of a Active Mesh related stage step action
  11275. */
  11276. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11277. /**
  11278. * Strong typing of a Camera related stage step action
  11279. */
  11280. export type CameraStageAction = (camera: Camera) => void;
  11281. /**
  11282. * Strong typing of a Camera Frame buffer related stage step action
  11283. */
  11284. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11285. /**
  11286. * Strong typing of a Render Target related stage step action
  11287. */
  11288. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11289. /**
  11290. * Strong typing of a RenderingGroup related stage step action
  11291. */
  11292. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11293. /**
  11294. * Strong typing of a Mesh Render related stage step action
  11295. */
  11296. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11297. /**
  11298. * Strong typing of a simple stage step action
  11299. */
  11300. export type SimpleStageAction = () => void;
  11301. /**
  11302. * Strong typing of a render target action.
  11303. */
  11304. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11305. /**
  11306. * Strong typing of a pointer move action.
  11307. */
  11308. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11309. /**
  11310. * Strong typing of a pointer up/down action.
  11311. */
  11312. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11313. /**
  11314. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11315. * @hidden
  11316. */
  11317. export class Stage<T extends Function> extends Array<{
  11318. index: number;
  11319. component: ISceneComponent;
  11320. action: T;
  11321. }> {
  11322. /**
  11323. * Hide ctor from the rest of the world.
  11324. * @param items The items to add.
  11325. */
  11326. private constructor();
  11327. /**
  11328. * Creates a new Stage.
  11329. * @returns A new instance of a Stage
  11330. */
  11331. static Create<T extends Function>(): Stage<T>;
  11332. /**
  11333. * Registers a step in an ordered way in the targeted stage.
  11334. * @param index Defines the position to register the step in
  11335. * @param component Defines the component attached to the step
  11336. * @param action Defines the action to launch during the step
  11337. */
  11338. registerStep(index: number, component: ISceneComponent, action: T): void;
  11339. /**
  11340. * Clears all the steps from the stage.
  11341. */
  11342. clear(): void;
  11343. }
  11344. }
  11345. declare module BABYLON {
  11346. interface Scene {
  11347. /** @hidden */
  11348. _pointerOverSprite: Nullable<Sprite>;
  11349. /** @hidden */
  11350. _pickedDownSprite: Nullable<Sprite>;
  11351. /** @hidden */
  11352. _tempSpritePickingRay: Nullable<Ray>;
  11353. /**
  11354. * All of the sprite managers added to this scene
  11355. * @see http://doc.babylonjs.com/babylon101/sprites
  11356. */
  11357. spriteManagers: Array<ISpriteManager>;
  11358. /**
  11359. * An event triggered when sprites rendering is about to start
  11360. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11361. */
  11362. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11363. /**
  11364. * An event triggered when sprites rendering is done
  11365. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11366. */
  11367. onAfterSpritesRenderingObservable: Observable<Scene>;
  11368. /** @hidden */
  11369. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11370. /** Launch a ray to try to pick a sprite in the scene
  11371. * @param x position on screen
  11372. * @param y position on screen
  11373. * @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
  11374. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11375. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11376. * @returns a PickingInfo
  11377. */
  11378. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11379. /** Use the given ray to pick a sprite in the scene
  11380. * @param ray The ray (in world space) to use to pick meshes
  11381. * @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
  11382. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11383. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11384. * @returns a PickingInfo
  11385. */
  11386. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11387. /** @hidden */
  11388. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11389. /** Launch a ray to try to pick sprites in the scene
  11390. * @param x position on screen
  11391. * @param y position on screen
  11392. * @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
  11393. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11394. * @returns a PickingInfo array
  11395. */
  11396. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11397. /** Use the given ray to pick sprites in the scene
  11398. * @param ray The ray (in world space) to use to pick meshes
  11399. * @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
  11400. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11401. * @returns a PickingInfo array
  11402. */
  11403. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11404. /**
  11405. * Force the sprite under the pointer
  11406. * @param sprite defines the sprite to use
  11407. */
  11408. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11409. /**
  11410. * Gets the sprite under the pointer
  11411. * @returns a Sprite or null if no sprite is under the pointer
  11412. */
  11413. getPointerOverSprite(): Nullable<Sprite>;
  11414. }
  11415. /**
  11416. * Defines the sprite scene component responsible to manage sprites
  11417. * in a given scene.
  11418. */
  11419. export class SpriteSceneComponent implements ISceneComponent {
  11420. /**
  11421. * The component name helpfull to identify the component in the list of scene components.
  11422. */
  11423. readonly name: string;
  11424. /**
  11425. * The scene the component belongs to.
  11426. */
  11427. scene: Scene;
  11428. /** @hidden */
  11429. private _spritePredicate;
  11430. /**
  11431. * Creates a new instance of the component for the given scene
  11432. * @param scene Defines the scene to register the component in
  11433. */
  11434. constructor(scene: Scene);
  11435. /**
  11436. * Registers the component in a given scene
  11437. */
  11438. register(): void;
  11439. /**
  11440. * Rebuilds the elements related to this component in case of
  11441. * context lost for instance.
  11442. */
  11443. rebuild(): void;
  11444. /**
  11445. * Disposes the component and the associated ressources.
  11446. */
  11447. dispose(): void;
  11448. private _pickSpriteButKeepRay;
  11449. private _pointerMove;
  11450. private _pointerDown;
  11451. private _pointerUp;
  11452. }
  11453. }
  11454. declare module BABYLON {
  11455. /** @hidden */
  11456. export var fogFragmentDeclaration: {
  11457. name: string;
  11458. shader: string;
  11459. };
  11460. }
  11461. declare module BABYLON {
  11462. /** @hidden */
  11463. export var fogFragment: {
  11464. name: string;
  11465. shader: string;
  11466. };
  11467. }
  11468. declare module BABYLON {
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module BABYLON {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module BABYLON {
  11483. /** @hidden */
  11484. export var spritesVertexShader: {
  11485. name: string;
  11486. shader: string;
  11487. };
  11488. }
  11489. declare module BABYLON {
  11490. /**
  11491. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11492. */
  11493. export interface ISpriteManager extends IDisposable {
  11494. /**
  11495. * Restricts the camera to viewing objects with the same layerMask.
  11496. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11497. */
  11498. layerMask: number;
  11499. /**
  11500. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11501. */
  11502. isPickable: boolean;
  11503. /**
  11504. * Specifies the rendering group id for this mesh (0 by default)
  11505. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11506. */
  11507. renderingGroupId: number;
  11508. /**
  11509. * Defines the list of sprites managed by the manager.
  11510. */
  11511. sprites: Array<Sprite>;
  11512. /**
  11513. * Tests the intersection of a sprite with a specific ray.
  11514. * @param ray The ray we are sending to test the collision
  11515. * @param camera The camera space we are sending rays in
  11516. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11517. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11518. * @returns picking info or null.
  11519. */
  11520. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11521. /**
  11522. * Intersects the sprites with a ray
  11523. * @param ray defines the ray to intersect with
  11524. * @param camera defines the current active camera
  11525. * @param predicate defines a predicate used to select candidate sprites
  11526. * @returns null if no hit or a PickingInfo array
  11527. */
  11528. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11529. /**
  11530. * Renders the list of sprites on screen.
  11531. */
  11532. render(): void;
  11533. }
  11534. /**
  11535. * Class used to manage multiple sprites on the same spritesheet
  11536. * @see http://doc.babylonjs.com/babylon101/sprites
  11537. */
  11538. export class SpriteManager implements ISpriteManager {
  11539. /** defines the manager's name */
  11540. name: string;
  11541. /** Gets the list of sprites */
  11542. sprites: Sprite[];
  11543. /** Gets or sets the rendering group id (0 by default) */
  11544. renderingGroupId: number;
  11545. /** Gets or sets camera layer mask */
  11546. layerMask: number;
  11547. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11548. fogEnabled: boolean;
  11549. /** Gets or sets a boolean indicating if the sprites are pickable */
  11550. isPickable: boolean;
  11551. /** Defines the default width of a cell in the spritesheet */
  11552. cellWidth: number;
  11553. /** Defines the default height of a cell in the spritesheet */
  11554. cellHeight: number;
  11555. /** Associative array from JSON sprite data file */
  11556. private _cellData;
  11557. /** Array of sprite names from JSON sprite data file */
  11558. private _spriteMap;
  11559. /** True when packed cell data from JSON file is ready*/
  11560. private _packedAndReady;
  11561. /**
  11562. * An event triggered when the manager is disposed.
  11563. */
  11564. onDisposeObservable: Observable<SpriteManager>;
  11565. private _onDisposeObserver;
  11566. /**
  11567. * Callback called when the manager is disposed
  11568. */
  11569. onDispose: () => void;
  11570. private _capacity;
  11571. private _fromPacked;
  11572. private _spriteTexture;
  11573. private _epsilon;
  11574. private _scene;
  11575. private _vertexData;
  11576. private _buffer;
  11577. private _vertexBuffers;
  11578. private _indexBuffer;
  11579. private _effectBase;
  11580. private _effectFog;
  11581. /**
  11582. * Gets or sets the spritesheet texture
  11583. */
  11584. texture: Texture;
  11585. /**
  11586. * Creates a new sprite manager
  11587. * @param name defines the manager's name
  11588. * @param imgUrl defines the sprite sheet url
  11589. * @param capacity defines the maximum allowed number of sprites
  11590. * @param cellSize defines the size of a sprite cell
  11591. * @param scene defines the hosting scene
  11592. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11593. * @param samplingMode defines the smapling mode to use with spritesheet
  11594. * @param fromPacked set to false; do not alter
  11595. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11596. */
  11597. constructor(
  11598. /** defines the manager's name */
  11599. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11600. private _makePacked;
  11601. private _appendSpriteVertex;
  11602. /**
  11603. * Intersects the sprites with a ray
  11604. * @param ray defines the ray to intersect with
  11605. * @param camera defines the current active camera
  11606. * @param predicate defines a predicate used to select candidate sprites
  11607. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11608. * @returns null if no hit or a PickingInfo
  11609. */
  11610. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11611. /**
  11612. * Intersects the sprites with a ray
  11613. * @param ray defines the ray to intersect with
  11614. * @param camera defines the current active camera
  11615. * @param predicate defines a predicate used to select candidate sprites
  11616. * @returns null if no hit or a PickingInfo array
  11617. */
  11618. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11619. /**
  11620. * Render all child sprites
  11621. */
  11622. render(): void;
  11623. /**
  11624. * Release associated resources
  11625. */
  11626. dispose(): void;
  11627. }
  11628. }
  11629. declare module BABYLON {
  11630. /**
  11631. * Class used to represent a sprite
  11632. * @see http://doc.babylonjs.com/babylon101/sprites
  11633. */
  11634. export class Sprite {
  11635. /** defines the name */
  11636. name: string;
  11637. /** Gets or sets the current world position */
  11638. position: Vector3;
  11639. /** Gets or sets the main color */
  11640. color: Color4;
  11641. /** Gets or sets the width */
  11642. width: number;
  11643. /** Gets or sets the height */
  11644. height: number;
  11645. /** Gets or sets rotation angle */
  11646. angle: number;
  11647. /** Gets or sets the cell index in the sprite sheet */
  11648. cellIndex: number;
  11649. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11650. cellRef: string;
  11651. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11652. invertU: number;
  11653. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11654. invertV: number;
  11655. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11656. disposeWhenFinishedAnimating: boolean;
  11657. /** Gets the list of attached animations */
  11658. animations: Animation[];
  11659. /** Gets or sets a boolean indicating if the sprite can be picked */
  11660. isPickable: boolean;
  11661. /**
  11662. * Gets or sets the associated action manager
  11663. */
  11664. actionManager: Nullable<ActionManager>;
  11665. private _animationStarted;
  11666. private _loopAnimation;
  11667. private _fromIndex;
  11668. private _toIndex;
  11669. private _delay;
  11670. private _direction;
  11671. private _manager;
  11672. private _time;
  11673. private _onAnimationEnd;
  11674. /**
  11675. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11676. */
  11677. isVisible: boolean;
  11678. /**
  11679. * Gets or sets the sprite size
  11680. */
  11681. size: number;
  11682. /**
  11683. * Creates a new Sprite
  11684. * @param name defines the name
  11685. * @param manager defines the manager
  11686. */
  11687. constructor(
  11688. /** defines the name */
  11689. name: string, manager: ISpriteManager);
  11690. /**
  11691. * Starts an animation
  11692. * @param from defines the initial key
  11693. * @param to defines the end key
  11694. * @param loop defines if the animation must loop
  11695. * @param delay defines the start delay (in ms)
  11696. * @param onAnimationEnd defines a callback to call when animation ends
  11697. */
  11698. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11699. /** Stops current animation (if any) */
  11700. stopAnimation(): void;
  11701. /** @hidden */
  11702. _animate(deltaTime: number): void;
  11703. /** Release associated resources */
  11704. dispose(): void;
  11705. }
  11706. }
  11707. declare module BABYLON {
  11708. /**
  11709. * Information about the result of picking within a scene
  11710. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11711. */
  11712. export class PickingInfo {
  11713. /** @hidden */
  11714. _pickingUnavailable: boolean;
  11715. /**
  11716. * If the pick collided with an object
  11717. */
  11718. hit: boolean;
  11719. /**
  11720. * Distance away where the pick collided
  11721. */
  11722. distance: number;
  11723. /**
  11724. * The location of pick collision
  11725. */
  11726. pickedPoint: Nullable<Vector3>;
  11727. /**
  11728. * The mesh corresponding the the pick collision
  11729. */
  11730. pickedMesh: Nullable<AbstractMesh>;
  11731. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11732. bu: number;
  11733. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11734. bv: number;
  11735. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11736. faceId: number;
  11737. /** Id of the the submesh that was picked */
  11738. subMeshId: number;
  11739. /** If a sprite was picked, this will be the sprite the pick collided with */
  11740. pickedSprite: Nullable<Sprite>;
  11741. /**
  11742. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11743. */
  11744. originMesh: Nullable<AbstractMesh>;
  11745. /**
  11746. * The ray that was used to perform the picking.
  11747. */
  11748. ray: Nullable<Ray>;
  11749. /**
  11750. * Gets the normal correspodning to the face the pick collided with
  11751. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11752. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11753. * @returns The normal correspodning to the face the pick collided with
  11754. */
  11755. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11756. /**
  11757. * Gets the texture coordinates of where the pick occured
  11758. * @returns the vector containing the coordnates of the texture
  11759. */
  11760. getTextureCoordinates(): Nullable<Vector2>;
  11761. }
  11762. }
  11763. declare module BABYLON {
  11764. /**
  11765. * Gather the list of pointer event types as constants.
  11766. */
  11767. export class PointerEventTypes {
  11768. /**
  11769. * 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.
  11770. */
  11771. static readonly POINTERDOWN: number;
  11772. /**
  11773. * The pointerup event is fired when a pointer is no longer active.
  11774. */
  11775. static readonly POINTERUP: number;
  11776. /**
  11777. * The pointermove event is fired when a pointer changes coordinates.
  11778. */
  11779. static readonly POINTERMOVE: number;
  11780. /**
  11781. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11782. */
  11783. static readonly POINTERWHEEL: number;
  11784. /**
  11785. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11786. */
  11787. static readonly POINTERPICK: number;
  11788. /**
  11789. * The pointertap event is fired when a the object has been touched and released without drag.
  11790. */
  11791. static readonly POINTERTAP: number;
  11792. /**
  11793. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11794. */
  11795. static readonly POINTERDOUBLETAP: number;
  11796. }
  11797. /**
  11798. * Base class of pointer info types.
  11799. */
  11800. export class PointerInfoBase {
  11801. /**
  11802. * Defines the type of event (PointerEventTypes)
  11803. */
  11804. type: number;
  11805. /**
  11806. * Defines the related dom event
  11807. */
  11808. event: PointerEvent | MouseWheelEvent;
  11809. /**
  11810. * Instantiates the base class of pointers info.
  11811. * @param type Defines the type of event (PointerEventTypes)
  11812. * @param event Defines the related dom event
  11813. */
  11814. constructor(
  11815. /**
  11816. * Defines the type of event (PointerEventTypes)
  11817. */
  11818. type: number,
  11819. /**
  11820. * Defines the related dom event
  11821. */
  11822. event: PointerEvent | MouseWheelEvent);
  11823. }
  11824. /**
  11825. * This class is used to store pointer related info for the onPrePointerObservable event.
  11826. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11827. */
  11828. export class PointerInfoPre extends PointerInfoBase {
  11829. /**
  11830. * Ray from a pointer if availible (eg. 6dof controller)
  11831. */
  11832. ray: Nullable<Ray>;
  11833. /**
  11834. * Defines the local position of the pointer on the canvas.
  11835. */
  11836. localPosition: Vector2;
  11837. /**
  11838. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11839. */
  11840. skipOnPointerObservable: boolean;
  11841. /**
  11842. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11843. * @param type Defines the type of event (PointerEventTypes)
  11844. * @param event Defines the related dom event
  11845. * @param localX Defines the local x coordinates of the pointer when the event occured
  11846. * @param localY Defines the local y coordinates of the pointer when the event occured
  11847. */
  11848. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11849. }
  11850. /**
  11851. * This type contains all the data related to a pointer event in Babylon.js.
  11852. * 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.
  11853. */
  11854. export class PointerInfo extends PointerInfoBase {
  11855. /**
  11856. * Defines the picking info associated to the info (if any)\
  11857. */
  11858. pickInfo: Nullable<PickingInfo>;
  11859. /**
  11860. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11861. * @param type Defines the type of event (PointerEventTypes)
  11862. * @param event Defines the related dom event
  11863. * @param pickInfo Defines the picking info associated to the info (if any)\
  11864. */
  11865. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11866. /**
  11867. * Defines the picking info associated to the info (if any)\
  11868. */
  11869. pickInfo: Nullable<PickingInfo>);
  11870. }
  11871. /**
  11872. * Data relating to a touch event on the screen.
  11873. */
  11874. export interface PointerTouch {
  11875. /**
  11876. * X coordinate of touch.
  11877. */
  11878. x: number;
  11879. /**
  11880. * Y coordinate of touch.
  11881. */
  11882. y: number;
  11883. /**
  11884. * Id of touch. Unique for each finger.
  11885. */
  11886. pointerId: number;
  11887. /**
  11888. * Event type passed from DOM.
  11889. */
  11890. type: any;
  11891. }
  11892. }
  11893. declare module BABYLON {
  11894. /**
  11895. * Manage the mouse inputs to control the movement of a free camera.
  11896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11897. */
  11898. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11899. /**
  11900. * Define if touch is enabled in the mouse input
  11901. */
  11902. touchEnabled: boolean;
  11903. /**
  11904. * Defines the camera the input is attached to.
  11905. */
  11906. camera: FreeCamera;
  11907. /**
  11908. * Defines the buttons associated with the input to handle camera move.
  11909. */
  11910. buttons: number[];
  11911. /**
  11912. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11913. */
  11914. angularSensibility: number;
  11915. private _pointerInput;
  11916. private _onMouseMove;
  11917. private _observer;
  11918. private previousPosition;
  11919. /**
  11920. * Observable for when a pointer move event occurs containing the move offset
  11921. */
  11922. onPointerMovedObservable: Observable<{
  11923. offsetX: number;
  11924. offsetY: number;
  11925. }>;
  11926. /**
  11927. * @hidden
  11928. * If the camera should be rotated automatically based on pointer movement
  11929. */
  11930. _allowCameraRotation: boolean;
  11931. /**
  11932. * Manage the mouse inputs to control the movement of a free camera.
  11933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11934. * @param touchEnabled Defines if touch is enabled or not
  11935. */
  11936. constructor(
  11937. /**
  11938. * Define if touch is enabled in the mouse input
  11939. */
  11940. touchEnabled?: boolean);
  11941. /**
  11942. * Attach the input controls to a specific dom element to get the input from.
  11943. * @param element Defines the element the controls should be listened from
  11944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11945. */
  11946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11947. /**
  11948. * Called on JS contextmenu event.
  11949. * Override this method to provide functionality.
  11950. */
  11951. protected onContextMenu(evt: PointerEvent): void;
  11952. /**
  11953. * Detach the current controls from the specified dom element.
  11954. * @param element Defines the element to stop listening the inputs from
  11955. */
  11956. detachControl(element: Nullable<HTMLElement>): void;
  11957. /**
  11958. * Gets the class name of the current intput.
  11959. * @returns the class name
  11960. */
  11961. getClassName(): string;
  11962. /**
  11963. * Get the friendly name associated with the input class.
  11964. * @returns the input friendly name
  11965. */
  11966. getSimpleName(): string;
  11967. }
  11968. }
  11969. declare module BABYLON {
  11970. /**
  11971. * Manage the touch inputs to control the movement of a free camera.
  11972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11973. */
  11974. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11975. /**
  11976. * Defines the camera the input is attached to.
  11977. */
  11978. camera: FreeCamera;
  11979. /**
  11980. * Defines the touch sensibility for rotation.
  11981. * The higher the faster.
  11982. */
  11983. touchAngularSensibility: number;
  11984. /**
  11985. * Defines the touch sensibility for move.
  11986. * The higher the faster.
  11987. */
  11988. touchMoveSensibility: number;
  11989. private _offsetX;
  11990. private _offsetY;
  11991. private _pointerPressed;
  11992. private _pointerInput;
  11993. private _observer;
  11994. private _onLostFocus;
  11995. /**
  11996. * Attach the input controls to a specific dom element to get the input from.
  11997. * @param element Defines the element the controls should be listened from
  11998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11999. */
  12000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12001. /**
  12002. * Detach the current controls from the specified dom element.
  12003. * @param element Defines the element to stop listening the inputs from
  12004. */
  12005. detachControl(element: Nullable<HTMLElement>): void;
  12006. /**
  12007. * Update the current camera state depending on the inputs that have been used this frame.
  12008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12009. */
  12010. checkInputs(): void;
  12011. /**
  12012. * Gets the class name of the current intput.
  12013. * @returns the class name
  12014. */
  12015. getClassName(): string;
  12016. /**
  12017. * Get the friendly name associated with the input class.
  12018. * @returns the input friendly name
  12019. */
  12020. getSimpleName(): string;
  12021. }
  12022. }
  12023. declare module BABYLON {
  12024. /**
  12025. * Default Inputs manager for the FreeCamera.
  12026. * It groups all the default supported inputs for ease of use.
  12027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12028. */
  12029. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12030. /**
  12031. * @hidden
  12032. */
  12033. _mouseInput: Nullable<FreeCameraMouseInput>;
  12034. /**
  12035. * Instantiates a new FreeCameraInputsManager.
  12036. * @param camera Defines the camera the inputs belong to
  12037. */
  12038. constructor(camera: FreeCamera);
  12039. /**
  12040. * Add keyboard input support to the input manager.
  12041. * @returns the current input manager
  12042. */
  12043. addKeyboard(): FreeCameraInputsManager;
  12044. /**
  12045. * Add mouse input support to the input manager.
  12046. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12047. * @returns the current input manager
  12048. */
  12049. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12050. /**
  12051. * Removes the mouse input support from the manager
  12052. * @returns the current input manager
  12053. */
  12054. removeMouse(): FreeCameraInputsManager;
  12055. /**
  12056. * Add touch input support to the input manager.
  12057. * @returns the current input manager
  12058. */
  12059. addTouch(): FreeCameraInputsManager;
  12060. /**
  12061. * Remove all attached input methods from a camera
  12062. */
  12063. clear(): void;
  12064. }
  12065. }
  12066. declare module BABYLON {
  12067. /**
  12068. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12069. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12070. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12071. */
  12072. export class FreeCamera extends TargetCamera {
  12073. /**
  12074. * Define the collision ellipsoid of the camera.
  12075. * This is helpful to simulate a camera body like the player body around the camera
  12076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12077. */
  12078. ellipsoid: Vector3;
  12079. /**
  12080. * Define an offset for the position of the ellipsoid around the camera.
  12081. * This can be helpful to determine the center of the body near the gravity center of the body
  12082. * instead of its head.
  12083. */
  12084. ellipsoidOffset: Vector3;
  12085. /**
  12086. * Enable or disable collisions of the camera with the rest of the scene objects.
  12087. */
  12088. checkCollisions: boolean;
  12089. /**
  12090. * Enable or disable gravity on the camera.
  12091. */
  12092. applyGravity: boolean;
  12093. /**
  12094. * Define the input manager associated to the camera.
  12095. */
  12096. inputs: FreeCameraInputsManager;
  12097. /**
  12098. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12099. * Higher values reduce sensitivity.
  12100. */
  12101. /**
  12102. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12103. * Higher values reduce sensitivity.
  12104. */
  12105. angularSensibility: number;
  12106. /**
  12107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12108. */
  12109. keysUp: number[];
  12110. /**
  12111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12112. */
  12113. keysDown: number[];
  12114. /**
  12115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12116. */
  12117. keysLeft: number[];
  12118. /**
  12119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12120. */
  12121. keysRight: number[];
  12122. /**
  12123. * Event raised when the camera collide with a mesh in the scene.
  12124. */
  12125. onCollide: (collidedMesh: AbstractMesh) => void;
  12126. private _collider;
  12127. private _needMoveForGravity;
  12128. private _oldPosition;
  12129. private _diffPosition;
  12130. private _newPosition;
  12131. /** @hidden */
  12132. _localDirection: Vector3;
  12133. /** @hidden */
  12134. _transformedDirection: Vector3;
  12135. /**
  12136. * Instantiates a Free Camera.
  12137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12138. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12140. * @param name Define the name of the camera in the scene
  12141. * @param position Define the start position of the camera in the scene
  12142. * @param scene Define the scene the camera belongs to
  12143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12144. */
  12145. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12146. /**
  12147. * Attached controls to the current camera.
  12148. * @param element Defines the element the controls should be listened from
  12149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12150. */
  12151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12152. /**
  12153. * Detach the current controls from the camera.
  12154. * The camera will stop reacting to inputs.
  12155. * @param element Defines the element to stop listening the inputs from
  12156. */
  12157. detachControl(element: HTMLElement): void;
  12158. private _collisionMask;
  12159. /**
  12160. * Define a collision mask to limit the list of object the camera can collide with
  12161. */
  12162. collisionMask: number;
  12163. /** @hidden */
  12164. _collideWithWorld(displacement: Vector3): void;
  12165. private _onCollisionPositionChange;
  12166. /** @hidden */
  12167. _checkInputs(): void;
  12168. /** @hidden */
  12169. _decideIfNeedsToMove(): boolean;
  12170. /** @hidden */
  12171. _updatePosition(): void;
  12172. /**
  12173. * Destroy the camera and release the current resources hold by it.
  12174. */
  12175. dispose(): void;
  12176. /**
  12177. * Gets the current object class name.
  12178. * @return the class name
  12179. */
  12180. getClassName(): string;
  12181. }
  12182. }
  12183. declare module BABYLON {
  12184. /**
  12185. * Represents a gamepad control stick position
  12186. */
  12187. export class StickValues {
  12188. /**
  12189. * The x component of the control stick
  12190. */
  12191. x: number;
  12192. /**
  12193. * The y component of the control stick
  12194. */
  12195. y: number;
  12196. /**
  12197. * Initializes the gamepad x and y control stick values
  12198. * @param x The x component of the gamepad control stick value
  12199. * @param y The y component of the gamepad control stick value
  12200. */
  12201. constructor(
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number,
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number);
  12210. }
  12211. /**
  12212. * An interface which manages callbacks for gamepad button changes
  12213. */
  12214. export interface GamepadButtonChanges {
  12215. /**
  12216. * Called when a gamepad has been changed
  12217. */
  12218. changed: boolean;
  12219. /**
  12220. * Called when a gamepad press event has been triggered
  12221. */
  12222. pressChanged: boolean;
  12223. /**
  12224. * Called when a touch event has been triggered
  12225. */
  12226. touchChanged: boolean;
  12227. /**
  12228. * Called when a value has changed
  12229. */
  12230. valueChanged: boolean;
  12231. }
  12232. /**
  12233. * Represents a gamepad
  12234. */
  12235. export class Gamepad {
  12236. /**
  12237. * The id of the gamepad
  12238. */
  12239. id: string;
  12240. /**
  12241. * The index of the gamepad
  12242. */
  12243. index: number;
  12244. /**
  12245. * The browser gamepad
  12246. */
  12247. browserGamepad: any;
  12248. /**
  12249. * Specifies what type of gamepad this represents
  12250. */
  12251. type: number;
  12252. private _leftStick;
  12253. private _rightStick;
  12254. /** @hidden */
  12255. _isConnected: boolean;
  12256. private _leftStickAxisX;
  12257. private _leftStickAxisY;
  12258. private _rightStickAxisX;
  12259. private _rightStickAxisY;
  12260. /**
  12261. * Triggered when the left control stick has been changed
  12262. */
  12263. private _onleftstickchanged;
  12264. /**
  12265. * Triggered when the right control stick has been changed
  12266. */
  12267. private _onrightstickchanged;
  12268. /**
  12269. * Represents a gamepad controller
  12270. */
  12271. static GAMEPAD: number;
  12272. /**
  12273. * Represents a generic controller
  12274. */
  12275. static GENERIC: number;
  12276. /**
  12277. * Represents an XBox controller
  12278. */
  12279. static XBOX: number;
  12280. /**
  12281. * Represents a pose-enabled controller
  12282. */
  12283. static POSE_ENABLED: number;
  12284. /**
  12285. * Represents an Dual Shock controller
  12286. */
  12287. static DUALSHOCK: number;
  12288. /**
  12289. * Specifies whether the left control stick should be Y-inverted
  12290. */
  12291. protected _invertLeftStickY: boolean;
  12292. /**
  12293. * Specifies if the gamepad has been connected
  12294. */
  12295. readonly isConnected: boolean;
  12296. /**
  12297. * Initializes the gamepad
  12298. * @param id The id of the gamepad
  12299. * @param index The index of the gamepad
  12300. * @param browserGamepad The browser gamepad
  12301. * @param leftStickX The x component of the left joystick
  12302. * @param leftStickY The y component of the left joystick
  12303. * @param rightStickX The x component of the right joystick
  12304. * @param rightStickY The y component of the right joystick
  12305. */
  12306. constructor(
  12307. /**
  12308. * The id of the gamepad
  12309. */
  12310. id: string,
  12311. /**
  12312. * The index of the gamepad
  12313. */
  12314. index: number,
  12315. /**
  12316. * The browser gamepad
  12317. */
  12318. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12319. /**
  12320. * Callback triggered when the left joystick has changed
  12321. * @param callback
  12322. */
  12323. onleftstickchanged(callback: (values: StickValues) => void): void;
  12324. /**
  12325. * Callback triggered when the right joystick has changed
  12326. * @param callback
  12327. */
  12328. onrightstickchanged(callback: (values: StickValues) => void): void;
  12329. /**
  12330. * Gets the left joystick
  12331. */
  12332. /**
  12333. * Sets the left joystick values
  12334. */
  12335. leftStick: StickValues;
  12336. /**
  12337. * Gets the right joystick
  12338. */
  12339. /**
  12340. * Sets the right joystick value
  12341. */
  12342. rightStick: StickValues;
  12343. /**
  12344. * Updates the gamepad joystick positions
  12345. */
  12346. update(): void;
  12347. /**
  12348. * Disposes the gamepad
  12349. */
  12350. dispose(): void;
  12351. }
  12352. /**
  12353. * Represents a generic gamepad
  12354. */
  12355. export class GenericPad extends Gamepad {
  12356. private _buttons;
  12357. private _onbuttondown;
  12358. private _onbuttonup;
  12359. /**
  12360. * Observable triggered when a button has been pressed
  12361. */
  12362. onButtonDownObservable: Observable<number>;
  12363. /**
  12364. * Observable triggered when a button has been released
  12365. */
  12366. onButtonUpObservable: Observable<number>;
  12367. /**
  12368. * Callback triggered when a button has been pressed
  12369. * @param callback Called when a button has been pressed
  12370. */
  12371. onbuttondown(callback: (buttonPressed: number) => void): void;
  12372. /**
  12373. * Callback triggered when a button has been released
  12374. * @param callback Called when a button has been released
  12375. */
  12376. onbuttonup(callback: (buttonReleased: number) => void): void;
  12377. /**
  12378. * Initializes the generic gamepad
  12379. * @param id The id of the generic gamepad
  12380. * @param index The index of the generic gamepad
  12381. * @param browserGamepad The browser gamepad
  12382. */
  12383. constructor(id: string, index: number, browserGamepad: any);
  12384. private _setButtonValue;
  12385. /**
  12386. * Updates the generic gamepad
  12387. */
  12388. update(): void;
  12389. /**
  12390. * Disposes the generic gamepad
  12391. */
  12392. dispose(): void;
  12393. }
  12394. }
  12395. declare module BABYLON {
  12396. interface Engine {
  12397. /**
  12398. * Creates a raw texture
  12399. * @param data defines the data to store in the texture
  12400. * @param width defines the width of the texture
  12401. * @param height defines the height of the texture
  12402. * @param format defines the format of the data
  12403. * @param generateMipMaps defines if the engine should generate the mip levels
  12404. * @param invertY defines if data must be stored with Y axis inverted
  12405. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12406. * @param compression defines the compression used (null by default)
  12407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12408. * @returns the raw texture inside an InternalTexture
  12409. */
  12410. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12411. /**
  12412. * Update a raw texture
  12413. * @param texture defines the texture to update
  12414. * @param data defines the data to store in the texture
  12415. * @param format defines the format of the data
  12416. * @param invertY defines if data must be stored with Y axis inverted
  12417. */
  12418. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12419. /**
  12420. * Update a raw texture
  12421. * @param texture defines the texture to update
  12422. * @param data defines the data to store in the texture
  12423. * @param format defines the format of the data
  12424. * @param invertY defines if data must be stored with Y axis inverted
  12425. * @param compression defines the compression used (null by default)
  12426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12427. */
  12428. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12429. /**
  12430. * Creates a new raw cube texture
  12431. * @param data defines the array of data to use to create each face
  12432. * @param size defines the size of the textures
  12433. * @param format defines the format of the data
  12434. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12435. * @param generateMipMaps defines if the engine should generate the mip levels
  12436. * @param invertY defines if data must be stored with Y axis inverted
  12437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12438. * @param compression defines the compression used (null by default)
  12439. * @returns the cube texture as an InternalTexture
  12440. */
  12441. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12442. /**
  12443. * Update a raw cube texture
  12444. * @param texture defines the texture to udpdate
  12445. * @param data defines the data to store
  12446. * @param format defines the data format
  12447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12448. * @param invertY defines if data must be stored with Y axis inverted
  12449. */
  12450. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12451. /**
  12452. * Update a raw cube texture
  12453. * @param texture defines the texture to udpdate
  12454. * @param data defines the data to store
  12455. * @param format defines the data format
  12456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12457. * @param invertY defines if data must be stored with Y axis inverted
  12458. * @param compression defines the compression used (null by default)
  12459. */
  12460. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12461. /**
  12462. * Update a raw cube texture
  12463. * @param texture defines the texture to udpdate
  12464. * @param data defines the data to store
  12465. * @param format defines the data format
  12466. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12467. * @param invertY defines if data must be stored with Y axis inverted
  12468. * @param compression defines the compression used (null by default)
  12469. * @param level defines which level of the texture to update
  12470. */
  12471. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12472. /**
  12473. * Creates a new raw cube texture from a specified url
  12474. * @param url defines the url where the data is located
  12475. * @param scene defines the current scene
  12476. * @param size defines the size of the textures
  12477. * @param format defines the format of the data
  12478. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12479. * @param noMipmap defines if the engine should avoid generating the mip levels
  12480. * @param callback defines a callback used to extract texture data from loaded data
  12481. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12482. * @param onLoad defines a callback called when texture is loaded
  12483. * @param onError defines a callback called if there is an error
  12484. * @returns the cube texture as an InternalTexture
  12485. */
  12486. 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;
  12487. /**
  12488. * Creates a new raw cube texture from a specified url
  12489. * @param url defines the url where the data is located
  12490. * @param scene defines the current scene
  12491. * @param size defines the size of the textures
  12492. * @param format defines the format of the data
  12493. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12494. * @param noMipmap defines if the engine should avoid generating the mip levels
  12495. * @param callback defines a callback used to extract texture data from loaded data
  12496. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12497. * @param onLoad defines a callback called when texture is loaded
  12498. * @param onError defines a callback called if there is an error
  12499. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12500. * @param invertY defines if data must be stored with Y axis inverted
  12501. * @returns the cube texture as an InternalTexture
  12502. */
  12503. 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;
  12504. /**
  12505. * Creates a new raw 3D texture
  12506. * @param data defines the data used to create the texture
  12507. * @param width defines the width of the texture
  12508. * @param height defines the height of the texture
  12509. * @param depth defines the depth of the texture
  12510. * @param format defines the format of the texture
  12511. * @param generateMipMaps defines if the engine must generate mip levels
  12512. * @param invertY defines if data must be stored with Y axis inverted
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param compression defines the compressed used (can be null)
  12515. * @param textureType defines the compressed used (can be null)
  12516. * @returns a new raw 3D texture (stored in an InternalTexture)
  12517. */
  12518. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12519. /**
  12520. * Update a raw 3D texture
  12521. * @param texture defines the texture to update
  12522. * @param data defines the data to store
  12523. * @param format defines the data format
  12524. * @param invertY defines if data must be stored with Y axis inverted
  12525. */
  12526. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12527. /**
  12528. * Update a raw 3D texture
  12529. * @param texture defines the texture to update
  12530. * @param data defines the data to store
  12531. * @param format defines the data format
  12532. * @param invertY defines if data must be stored with Y axis inverted
  12533. * @param compression defines the used compression (can be null)
  12534. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12535. */
  12536. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * Raw texture can help creating a texture directly from an array of data.
  12542. * This can be super useful if you either get the data from an uncompressed source or
  12543. * if you wish to create your texture pixel by pixel.
  12544. */
  12545. export class RawTexture extends Texture {
  12546. /**
  12547. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12548. */
  12549. format: number;
  12550. private _engine;
  12551. /**
  12552. * Instantiates a new RawTexture.
  12553. * Raw texture can help creating a texture directly from an array of data.
  12554. * This can be super useful if you either get the data from an uncompressed source or
  12555. * if you wish to create your texture pixel by pixel.
  12556. * @param data define the array of data to use to create the texture
  12557. * @param width define the width of the texture
  12558. * @param height define the height of the texture
  12559. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12560. * @param scene define the scene the texture belongs to
  12561. * @param generateMipMaps define whether mip maps should be generated or not
  12562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12564. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12565. */
  12566. constructor(data: ArrayBufferView, width: number, height: number,
  12567. /**
  12568. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12569. */
  12570. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12571. /**
  12572. * Updates the texture underlying data.
  12573. * @param data Define the new data of the texture
  12574. */
  12575. update(data: ArrayBufferView): void;
  12576. /**
  12577. * Creates a luminance texture from some data.
  12578. * @param data Define the texture data
  12579. * @param width Define the width of the texture
  12580. * @param height Define the height of the texture
  12581. * @param scene Define the scene the texture belongs to
  12582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12585. * @returns the luminance texture
  12586. */
  12587. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12588. /**
  12589. * Creates a luminance alpha texture from some data.
  12590. * @param data Define the texture data
  12591. * @param width Define the width of the texture
  12592. * @param height Define the height of the texture
  12593. * @param scene Define the scene the texture belongs to
  12594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12597. * @returns the luminance alpha texture
  12598. */
  12599. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12600. /**
  12601. * Creates an alpha texture from some data.
  12602. * @param data Define the texture data
  12603. * @param width Define the width of the texture
  12604. * @param height Define the height of the texture
  12605. * @param scene Define the scene the texture belongs to
  12606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12609. * @returns the alpha texture
  12610. */
  12611. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12612. /**
  12613. * Creates a RGB texture from some data.
  12614. * @param data Define the texture data
  12615. * @param width Define the width of the texture
  12616. * @param height Define the height of the texture
  12617. * @param scene Define the scene the texture belongs to
  12618. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12619. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12620. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12621. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12622. * @returns the RGB alpha texture
  12623. */
  12624. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12625. /**
  12626. * Creates a RGBA texture from some data.
  12627. * @param data Define the texture data
  12628. * @param width Define the width of the texture
  12629. * @param height Define the height of the texture
  12630. * @param scene Define the scene the texture belongs to
  12631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12634. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12635. * @returns the RGBA texture
  12636. */
  12637. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12638. /**
  12639. * Creates a R texture from some data.
  12640. * @param data Define the texture data
  12641. * @param width Define the width of the texture
  12642. * @param height Define the height of the texture
  12643. * @param scene Define the scene the texture belongs to
  12644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12647. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12648. * @returns the R texture
  12649. */
  12650. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /**
  12655. * Interface for the size containing width and height
  12656. */
  12657. export interface ISize {
  12658. /**
  12659. * Width
  12660. */
  12661. width: number;
  12662. /**
  12663. * Heighht
  12664. */
  12665. height: number;
  12666. }
  12667. /**
  12668. * Size containing widht and height
  12669. */
  12670. export class Size implements ISize {
  12671. /**
  12672. * Width
  12673. */
  12674. width: number;
  12675. /**
  12676. * Height
  12677. */
  12678. height: number;
  12679. /**
  12680. * Creates a Size object from the given width and height (floats).
  12681. * @param width width of the new size
  12682. * @param height height of the new size
  12683. */
  12684. constructor(width: number, height: number);
  12685. /**
  12686. * Returns a string with the Size width and height
  12687. * @returns a string with the Size width and height
  12688. */
  12689. toString(): string;
  12690. /**
  12691. * "Size"
  12692. * @returns the string "Size"
  12693. */
  12694. getClassName(): string;
  12695. /**
  12696. * Returns the Size hash code.
  12697. * @returns a hash code for a unique width and height
  12698. */
  12699. getHashCode(): number;
  12700. /**
  12701. * Updates the current size from the given one.
  12702. * @param src the given size
  12703. */
  12704. copyFrom(src: Size): void;
  12705. /**
  12706. * Updates in place the current Size from the given floats.
  12707. * @param width width of the new size
  12708. * @param height height of the new size
  12709. * @returns the updated Size.
  12710. */
  12711. copyFromFloats(width: number, height: number): Size;
  12712. /**
  12713. * Updates in place the current Size from the given floats.
  12714. * @param width width to set
  12715. * @param height height to set
  12716. * @returns the updated Size.
  12717. */
  12718. set(width: number, height: number): Size;
  12719. /**
  12720. * Multiplies the width and height by numbers
  12721. * @param w factor to multiple the width by
  12722. * @param h factor to multiple the height by
  12723. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12724. */
  12725. multiplyByFloats(w: number, h: number): Size;
  12726. /**
  12727. * Clones the size
  12728. * @returns a new Size copied from the given one.
  12729. */
  12730. clone(): Size;
  12731. /**
  12732. * True if the current Size and the given one width and height are strictly equal.
  12733. * @param other the other size to compare against
  12734. * @returns True if the current Size and the given one width and height are strictly equal.
  12735. */
  12736. equals(other: Size): boolean;
  12737. /**
  12738. * The surface of the Size : width * height (float).
  12739. */
  12740. readonly surface: number;
  12741. /**
  12742. * Create a new size of zero
  12743. * @returns a new Size set to (0.0, 0.0)
  12744. */
  12745. static Zero(): Size;
  12746. /**
  12747. * Sums the width and height of two sizes
  12748. * @param otherSize size to add to this size
  12749. * @returns a new Size set as the addition result of the current Size and the given one.
  12750. */
  12751. add(otherSize: Size): Size;
  12752. /**
  12753. * Subtracts the width and height of two
  12754. * @param otherSize size to subtract to this size
  12755. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12756. */
  12757. subtract(otherSize: Size): Size;
  12758. /**
  12759. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12760. * @param start starting size to lerp between
  12761. * @param end end size to lerp between
  12762. * @param amount amount to lerp between the start and end values
  12763. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12764. */
  12765. static Lerp(start: Size, end: Size, amount: number): Size;
  12766. }
  12767. }
  12768. declare module BABYLON {
  12769. /**
  12770. * Defines a runtime animation
  12771. */
  12772. export class RuntimeAnimation {
  12773. private _events;
  12774. /**
  12775. * The current frame of the runtime animation
  12776. */
  12777. private _currentFrame;
  12778. /**
  12779. * The animation used by the runtime animation
  12780. */
  12781. private _animation;
  12782. /**
  12783. * The target of the runtime animation
  12784. */
  12785. private _target;
  12786. /**
  12787. * The initiating animatable
  12788. */
  12789. private _host;
  12790. /**
  12791. * The original value of the runtime animation
  12792. */
  12793. private _originalValue;
  12794. /**
  12795. * The original blend value of the runtime animation
  12796. */
  12797. private _originalBlendValue;
  12798. /**
  12799. * The offsets cache of the runtime animation
  12800. */
  12801. private _offsetsCache;
  12802. /**
  12803. * The high limits cache of the runtime animation
  12804. */
  12805. private _highLimitsCache;
  12806. /**
  12807. * Specifies if the runtime animation has been stopped
  12808. */
  12809. private _stopped;
  12810. /**
  12811. * The blending factor of the runtime animation
  12812. */
  12813. private _blendingFactor;
  12814. /**
  12815. * The BabylonJS scene
  12816. */
  12817. private _scene;
  12818. /**
  12819. * The current value of the runtime animation
  12820. */
  12821. private _currentValue;
  12822. /** @hidden */
  12823. _animationState: _IAnimationState;
  12824. /**
  12825. * The active target of the runtime animation
  12826. */
  12827. private _activeTargets;
  12828. private _currentActiveTarget;
  12829. private _directTarget;
  12830. /**
  12831. * The target path of the runtime animation
  12832. */
  12833. private _targetPath;
  12834. /**
  12835. * The weight of the runtime animation
  12836. */
  12837. private _weight;
  12838. /**
  12839. * The ratio offset of the runtime animation
  12840. */
  12841. private _ratioOffset;
  12842. /**
  12843. * The previous delay of the runtime animation
  12844. */
  12845. private _previousDelay;
  12846. /**
  12847. * The previous ratio of the runtime animation
  12848. */
  12849. private _previousRatio;
  12850. private _enableBlending;
  12851. private _keys;
  12852. private _minFrame;
  12853. private _maxFrame;
  12854. private _minValue;
  12855. private _maxValue;
  12856. private _targetIsArray;
  12857. /**
  12858. * Gets the current frame of the runtime animation
  12859. */
  12860. readonly currentFrame: number;
  12861. /**
  12862. * Gets the weight of the runtime animation
  12863. */
  12864. readonly weight: number;
  12865. /**
  12866. * Gets the current value of the runtime animation
  12867. */
  12868. readonly currentValue: any;
  12869. /**
  12870. * Gets the target path of the runtime animation
  12871. */
  12872. readonly targetPath: string;
  12873. /**
  12874. * Gets the actual target of the runtime animation
  12875. */
  12876. readonly target: any;
  12877. /** @hidden */
  12878. _onLoop: () => void;
  12879. /**
  12880. * Create a new RuntimeAnimation object
  12881. * @param target defines the target of the animation
  12882. * @param animation defines the source animation object
  12883. * @param scene defines the hosting scene
  12884. * @param host defines the initiating Animatable
  12885. */
  12886. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12887. private _preparePath;
  12888. /**
  12889. * Gets the animation from the runtime animation
  12890. */
  12891. readonly animation: Animation;
  12892. /**
  12893. * Resets the runtime animation to the beginning
  12894. * @param restoreOriginal defines whether to restore the target property to the original value
  12895. */
  12896. reset(restoreOriginal?: boolean): void;
  12897. /**
  12898. * Specifies if the runtime animation is stopped
  12899. * @returns Boolean specifying if the runtime animation is stopped
  12900. */
  12901. isStopped(): boolean;
  12902. /**
  12903. * Disposes of the runtime animation
  12904. */
  12905. dispose(): void;
  12906. /**
  12907. * Apply the interpolated value to the target
  12908. * @param currentValue defines the value computed by the animation
  12909. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12910. */
  12911. setValue(currentValue: any, weight: number): void;
  12912. private _getOriginalValues;
  12913. private _setValue;
  12914. /**
  12915. * Gets the loop pmode of the runtime animation
  12916. * @returns Loop Mode
  12917. */
  12918. private _getCorrectLoopMode;
  12919. /**
  12920. * Move the current animation to a given frame
  12921. * @param frame defines the frame to move to
  12922. */
  12923. goToFrame(frame: number): void;
  12924. /**
  12925. * @hidden Internal use only
  12926. */
  12927. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12928. /**
  12929. * Execute the current animation
  12930. * @param delay defines the delay to add to the current frame
  12931. * @param from defines the lower bound of the animation range
  12932. * @param to defines the upper bound of the animation range
  12933. * @param loop defines if the current animation must loop
  12934. * @param speedRatio defines the current speed ratio
  12935. * @param weight defines the weight of the animation (default is -1 so no weight)
  12936. * @param onLoop optional callback called when animation loops
  12937. * @returns a boolean indicating if the animation is running
  12938. */
  12939. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12940. }
  12941. }
  12942. declare module BABYLON {
  12943. /**
  12944. * Class used to store an actual running animation
  12945. */
  12946. export class Animatable {
  12947. /** defines the target object */
  12948. target: any;
  12949. /** defines the starting frame number (default is 0) */
  12950. fromFrame: number;
  12951. /** defines the ending frame number (default is 100) */
  12952. toFrame: number;
  12953. /** defines if the animation must loop (default is false) */
  12954. loopAnimation: boolean;
  12955. /** defines a callback to call when animation ends if it is not looping */
  12956. onAnimationEnd?: (() => void) | null | undefined;
  12957. /** defines a callback to call when animation loops */
  12958. onAnimationLoop?: (() => void) | null | undefined;
  12959. private _localDelayOffset;
  12960. private _pausedDelay;
  12961. private _runtimeAnimations;
  12962. private _paused;
  12963. private _scene;
  12964. private _speedRatio;
  12965. private _weight;
  12966. private _syncRoot;
  12967. /**
  12968. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12969. * This will only apply for non looping animation (default is true)
  12970. */
  12971. disposeOnEnd: boolean;
  12972. /**
  12973. * Gets a boolean indicating if the animation has started
  12974. */
  12975. animationStarted: boolean;
  12976. /**
  12977. * Observer raised when the animation ends
  12978. */
  12979. onAnimationEndObservable: Observable<Animatable>;
  12980. /**
  12981. * Observer raised when the animation loops
  12982. */
  12983. onAnimationLoopObservable: Observable<Animatable>;
  12984. /**
  12985. * Gets the root Animatable used to synchronize and normalize animations
  12986. */
  12987. readonly syncRoot: Nullable<Animatable>;
  12988. /**
  12989. * Gets the current frame of the first RuntimeAnimation
  12990. * Used to synchronize Animatables
  12991. */
  12992. readonly masterFrame: number;
  12993. /**
  12994. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12995. */
  12996. weight: number;
  12997. /**
  12998. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12999. */
  13000. speedRatio: number;
  13001. /**
  13002. * Creates a new Animatable
  13003. * @param scene defines the hosting scene
  13004. * @param target defines the target object
  13005. * @param fromFrame defines the starting frame number (default is 0)
  13006. * @param toFrame defines the ending frame number (default is 100)
  13007. * @param loopAnimation defines if the animation must loop (default is false)
  13008. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13009. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13010. * @param animations defines a group of animation to add to the new Animatable
  13011. * @param onAnimationLoop defines a callback to call when animation loops
  13012. */
  13013. constructor(scene: Scene,
  13014. /** defines the target object */
  13015. target: any,
  13016. /** defines the starting frame number (default is 0) */
  13017. fromFrame?: number,
  13018. /** defines the ending frame number (default is 100) */
  13019. toFrame?: number,
  13020. /** defines if the animation must loop (default is false) */
  13021. loopAnimation?: boolean, speedRatio?: number,
  13022. /** defines a callback to call when animation ends if it is not looping */
  13023. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13024. /** defines a callback to call when animation loops */
  13025. onAnimationLoop?: (() => void) | null | undefined);
  13026. /**
  13027. * Synchronize and normalize current Animatable with a source Animatable
  13028. * This is useful when using animation weights and when animations are not of the same length
  13029. * @param root defines the root Animatable to synchronize with
  13030. * @returns the current Animatable
  13031. */
  13032. syncWith(root: Animatable): Animatable;
  13033. /**
  13034. * Gets the list of runtime animations
  13035. * @returns an array of RuntimeAnimation
  13036. */
  13037. getAnimations(): RuntimeAnimation[];
  13038. /**
  13039. * Adds more animations to the current animatable
  13040. * @param target defines the target of the animations
  13041. * @param animations defines the new animations to add
  13042. */
  13043. appendAnimations(target: any, animations: Animation[]): void;
  13044. /**
  13045. * Gets the source animation for a specific property
  13046. * @param property defines the propertyu to look for
  13047. * @returns null or the source animation for the given property
  13048. */
  13049. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13050. /**
  13051. * Gets the runtime animation for a specific property
  13052. * @param property defines the propertyu to look for
  13053. * @returns null or the runtime animation for the given property
  13054. */
  13055. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13056. /**
  13057. * Resets the animatable to its original state
  13058. */
  13059. reset(): void;
  13060. /**
  13061. * Allows the animatable to blend with current running animations
  13062. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13063. * @param blendingSpeed defines the blending speed to use
  13064. */
  13065. enableBlending(blendingSpeed: number): void;
  13066. /**
  13067. * Disable animation blending
  13068. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13069. */
  13070. disableBlending(): void;
  13071. /**
  13072. * Jump directly to a given frame
  13073. * @param frame defines the frame to jump to
  13074. */
  13075. goToFrame(frame: number): void;
  13076. /**
  13077. * Pause the animation
  13078. */
  13079. pause(): void;
  13080. /**
  13081. * Restart the animation
  13082. */
  13083. restart(): void;
  13084. private _raiseOnAnimationEnd;
  13085. /**
  13086. * Stop and delete the current animation
  13087. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13088. * @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)
  13089. */
  13090. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13091. /**
  13092. * Wait asynchronously for the animation to end
  13093. * @returns a promise which will be fullfilled when the animation ends
  13094. */
  13095. waitAsync(): Promise<Animatable>;
  13096. /** @hidden */
  13097. _animate(delay: number): boolean;
  13098. }
  13099. interface Scene {
  13100. /** @hidden */
  13101. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13102. /** @hidden */
  13103. _processLateAnimationBindingsForMatrices(holder: {
  13104. totalWeight: number;
  13105. animations: RuntimeAnimation[];
  13106. originalValue: Matrix;
  13107. }): any;
  13108. /** @hidden */
  13109. _processLateAnimationBindingsForQuaternions(holder: {
  13110. totalWeight: number;
  13111. animations: RuntimeAnimation[];
  13112. originalValue: Quaternion;
  13113. }, refQuaternion: Quaternion): Quaternion;
  13114. /** @hidden */
  13115. _processLateAnimationBindings(): void;
  13116. /**
  13117. * Will start the animation sequence of a given target
  13118. * @param target defines the target
  13119. * @param from defines from which frame should animation start
  13120. * @param to defines until which frame should animation run.
  13121. * @param weight defines the weight to apply to the animation (1.0 by default)
  13122. * @param loop defines if the animation loops
  13123. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13124. * @param onAnimationEnd defines the function to be executed when the animation ends
  13125. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13126. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13127. * @param onAnimationLoop defines the callback to call when an animation loops
  13128. * @returns the animatable object created for this animation
  13129. */
  13130. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13131. /**
  13132. * Will start the animation sequence of a given target
  13133. * @param target defines the target
  13134. * @param from defines from which frame should animation start
  13135. * @param to defines until which frame should animation run.
  13136. * @param loop defines if the animation loops
  13137. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13138. * @param onAnimationEnd defines the function to be executed when the animation ends
  13139. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13140. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13141. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13142. * @param onAnimationLoop defines the callback to call when an animation loops
  13143. * @returns the animatable object created for this animation
  13144. */
  13145. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13146. /**
  13147. * Will start the animation sequence of a given target and its hierarchy
  13148. * @param target defines the target
  13149. * @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.
  13150. * @param from defines from which frame should animation start
  13151. * @param to defines until which frame should animation run.
  13152. * @param loop defines if the animation loops
  13153. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13154. * @param onAnimationEnd defines the function to be executed when the animation ends
  13155. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13156. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13157. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13158. * @param onAnimationLoop defines the callback to call when an animation loops
  13159. * @returns the list of created animatables
  13160. */
  13161. 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[];
  13162. /**
  13163. * Begin a new animation on a given node
  13164. * @param target defines the target where the animation will take place
  13165. * @param animations defines the list of animations to start
  13166. * @param from defines the initial value
  13167. * @param to defines the final value
  13168. * @param loop defines if you want animation to loop (off by default)
  13169. * @param speedRatio defines the speed ratio to apply to all animations
  13170. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the list of created animatables
  13173. */
  13174. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Begin a new animation on a given node and its hierarchy
  13177. * @param target defines the root node where the animation will take place
  13178. * @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.
  13179. * @param animations defines the list of animations to start
  13180. * @param from defines the initial value
  13181. * @param to defines the final value
  13182. * @param loop defines if you want animation to loop (off by default)
  13183. * @param speedRatio defines the speed ratio to apply to all animations
  13184. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13185. * @param onAnimationLoop defines the callback to call when an animation loops
  13186. * @returns the list of animatables created for all nodes
  13187. */
  13188. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13189. /**
  13190. * Gets the animatable associated with a specific target
  13191. * @param target defines the target of the animatable
  13192. * @returns the required animatable if found
  13193. */
  13194. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13195. /**
  13196. * Gets all animatables associated with a given target
  13197. * @param target defines the target to look animatables for
  13198. * @returns an array of Animatables
  13199. */
  13200. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13201. /**
  13202. * Stops and removes all animations that have been applied to the scene
  13203. */
  13204. stopAllAnimations(): void;
  13205. /**
  13206. * Gets the current delta time used by animation engine
  13207. */
  13208. deltaTime: number;
  13209. }
  13210. interface Bone {
  13211. /**
  13212. * Copy an animation range from another bone
  13213. * @param source defines the source bone
  13214. * @param rangeName defines the range name to copy
  13215. * @param frameOffset defines the frame offset
  13216. * @param rescaleAsRequired defines if rescaling must be applied if required
  13217. * @param skelDimensionsRatio defines the scaling ratio
  13218. * @returns true if operation was successful
  13219. */
  13220. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13221. }
  13222. }
  13223. declare module BABYLON {
  13224. /**
  13225. * Class used to override all child animations of a given target
  13226. */
  13227. export class AnimationPropertiesOverride {
  13228. /**
  13229. * Gets or sets a value indicating if animation blending must be used
  13230. */
  13231. enableBlending: boolean;
  13232. /**
  13233. * Gets or sets the blending speed to use when enableBlending is true
  13234. */
  13235. blendingSpeed: number;
  13236. /**
  13237. * Gets or sets the default loop mode to use
  13238. */
  13239. loopMode: number;
  13240. }
  13241. }
  13242. declare module BABYLON {
  13243. /**
  13244. * Class used to handle skinning animations
  13245. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13246. */
  13247. export class Skeleton implements IAnimatable {
  13248. /** defines the skeleton name */
  13249. name: string;
  13250. /** defines the skeleton Id */
  13251. id: string;
  13252. /**
  13253. * Defines the list of child bones
  13254. */
  13255. bones: Bone[];
  13256. /**
  13257. * Defines an estimate of the dimension of the skeleton at rest
  13258. */
  13259. dimensionsAtRest: Vector3;
  13260. /**
  13261. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13262. */
  13263. needInitialSkinMatrix: boolean;
  13264. /**
  13265. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13266. */
  13267. overrideMesh: Nullable<AbstractMesh>;
  13268. /**
  13269. * Gets the list of animations attached to this skeleton
  13270. */
  13271. animations: Array<Animation>;
  13272. private _scene;
  13273. private _isDirty;
  13274. private _transformMatrices;
  13275. private _transformMatrixTexture;
  13276. private _meshesWithPoseMatrix;
  13277. private _animatables;
  13278. private _identity;
  13279. private _synchronizedWithMesh;
  13280. private _ranges;
  13281. private _lastAbsoluteTransformsUpdateId;
  13282. private _canUseTextureForBones;
  13283. private _uniqueId;
  13284. /** @hidden */
  13285. _numBonesWithLinkedTransformNode: number;
  13286. /** @hidden */
  13287. _hasWaitingData: Nullable<boolean>;
  13288. /**
  13289. * Specifies if the skeleton should be serialized
  13290. */
  13291. doNotSerialize: boolean;
  13292. private _useTextureToStoreBoneMatrices;
  13293. /**
  13294. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13295. * Please note that this option is not available if the hardware does not support it
  13296. */
  13297. useTextureToStoreBoneMatrices: boolean;
  13298. private _animationPropertiesOverride;
  13299. /**
  13300. * Gets or sets the animation properties override
  13301. */
  13302. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13303. /**
  13304. * List of inspectable custom properties (used by the Inspector)
  13305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13306. */
  13307. inspectableCustomProperties: IInspectable[];
  13308. /**
  13309. * An observable triggered before computing the skeleton's matrices
  13310. */
  13311. onBeforeComputeObservable: Observable<Skeleton>;
  13312. /**
  13313. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13314. */
  13315. readonly isUsingTextureForMatrices: boolean;
  13316. /**
  13317. * Gets the unique ID of this skeleton
  13318. */
  13319. readonly uniqueId: number;
  13320. /**
  13321. * Creates a new skeleton
  13322. * @param name defines the skeleton name
  13323. * @param id defines the skeleton Id
  13324. * @param scene defines the hosting scene
  13325. */
  13326. constructor(
  13327. /** defines the skeleton name */
  13328. name: string,
  13329. /** defines the skeleton Id */
  13330. id: string, scene: Scene);
  13331. /**
  13332. * Gets the current object class name.
  13333. * @return the class name
  13334. */
  13335. getClassName(): string;
  13336. /**
  13337. * Returns an array containing the root bones
  13338. * @returns an array containing the root bones
  13339. */
  13340. getChildren(): Array<Bone>;
  13341. /**
  13342. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13343. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13344. * @returns a Float32Array containing matrices data
  13345. */
  13346. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13347. /**
  13348. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13349. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13350. * @returns a raw texture containing the data
  13351. */
  13352. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13353. /**
  13354. * Gets the current hosting scene
  13355. * @returns a scene object
  13356. */
  13357. getScene(): Scene;
  13358. /**
  13359. * Gets a string representing the current skeleton data
  13360. * @param fullDetails defines a boolean indicating if we want a verbose version
  13361. * @returns a string representing the current skeleton data
  13362. */
  13363. toString(fullDetails?: boolean): string;
  13364. /**
  13365. * Get bone's index searching by name
  13366. * @param name defines bone's name to search for
  13367. * @return the indice of the bone. Returns -1 if not found
  13368. */
  13369. getBoneIndexByName(name: string): number;
  13370. /**
  13371. * Creater a new animation range
  13372. * @param name defines the name of the range
  13373. * @param from defines the start key
  13374. * @param to defines the end key
  13375. */
  13376. createAnimationRange(name: string, from: number, to: number): void;
  13377. /**
  13378. * Delete a specific animation range
  13379. * @param name defines the name of the range
  13380. * @param deleteFrames defines if frames must be removed as well
  13381. */
  13382. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13383. /**
  13384. * Gets a specific animation range
  13385. * @param name defines the name of the range to look for
  13386. * @returns the requested animation range or null if not found
  13387. */
  13388. getAnimationRange(name: string): Nullable<AnimationRange>;
  13389. /**
  13390. * Gets the list of all animation ranges defined on this skeleton
  13391. * @returns an array
  13392. */
  13393. getAnimationRanges(): Nullable<AnimationRange>[];
  13394. /**
  13395. * Copy animation range from a source skeleton.
  13396. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13397. * @param source defines the source skeleton
  13398. * @param name defines the name of the range to copy
  13399. * @param rescaleAsRequired defines if rescaling must be applied if required
  13400. * @returns true if operation was successful
  13401. */
  13402. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13403. /**
  13404. * Forces the skeleton to go to rest pose
  13405. */
  13406. returnToRest(): void;
  13407. private _getHighestAnimationFrame;
  13408. /**
  13409. * Begin a specific animation range
  13410. * @param name defines the name of the range to start
  13411. * @param loop defines if looping must be turned on (false by default)
  13412. * @param speedRatio defines the speed ratio to apply (1 by default)
  13413. * @param onAnimationEnd defines a callback which will be called when animation will end
  13414. * @returns a new animatable
  13415. */
  13416. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13417. /** @hidden */
  13418. _markAsDirty(): void;
  13419. /** @hidden */
  13420. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13421. /** @hidden */
  13422. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13423. private _computeTransformMatrices;
  13424. /**
  13425. * Build all resources required to render a skeleton
  13426. */
  13427. prepare(): void;
  13428. /**
  13429. * Gets the list of animatables currently running for this skeleton
  13430. * @returns an array of animatables
  13431. */
  13432. getAnimatables(): IAnimatable[];
  13433. /**
  13434. * Clone the current skeleton
  13435. * @param name defines the name of the new skeleton
  13436. * @param id defines the id of the new skeleton
  13437. * @returns the new skeleton
  13438. */
  13439. clone(name: string, id: string): Skeleton;
  13440. /**
  13441. * Enable animation blending for this skeleton
  13442. * @param blendingSpeed defines the blending speed to apply
  13443. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13444. */
  13445. enableBlending(blendingSpeed?: number): void;
  13446. /**
  13447. * Releases all resources associated with the current skeleton
  13448. */
  13449. dispose(): void;
  13450. /**
  13451. * Serialize the skeleton in a JSON object
  13452. * @returns a JSON object
  13453. */
  13454. serialize(): any;
  13455. /**
  13456. * Creates a new skeleton from serialized data
  13457. * @param parsedSkeleton defines the serialized data
  13458. * @param scene defines the hosting scene
  13459. * @returns a new skeleton
  13460. */
  13461. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13462. /**
  13463. * Compute all node absolute transforms
  13464. * @param forceUpdate defines if computation must be done even if cache is up to date
  13465. */
  13466. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13467. /**
  13468. * Gets the root pose matrix
  13469. * @returns a matrix
  13470. */
  13471. getPoseMatrix(): Nullable<Matrix>;
  13472. /**
  13473. * Sorts bones per internal index
  13474. */
  13475. sortBones(): void;
  13476. private _sortBones;
  13477. }
  13478. }
  13479. declare module BABYLON {
  13480. /**
  13481. * Class used to store bone information
  13482. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13483. */
  13484. export class Bone extends Node {
  13485. /**
  13486. * defines the bone name
  13487. */
  13488. name: string;
  13489. private static _tmpVecs;
  13490. private static _tmpQuat;
  13491. private static _tmpMats;
  13492. /**
  13493. * Gets the list of child bones
  13494. */
  13495. children: Bone[];
  13496. /** Gets the animations associated with this bone */
  13497. animations: Animation[];
  13498. /**
  13499. * Gets or sets bone length
  13500. */
  13501. length: number;
  13502. /**
  13503. * @hidden Internal only
  13504. * Set this value to map this bone to a different index in the transform matrices
  13505. * Set this value to -1 to exclude the bone from the transform matrices
  13506. */
  13507. _index: Nullable<number>;
  13508. private _skeleton;
  13509. private _localMatrix;
  13510. private _restPose;
  13511. private _baseMatrix;
  13512. private _absoluteTransform;
  13513. private _invertedAbsoluteTransform;
  13514. private _parent;
  13515. private _scalingDeterminant;
  13516. private _worldTransform;
  13517. private _localScaling;
  13518. private _localRotation;
  13519. private _localPosition;
  13520. private _needToDecompose;
  13521. private _needToCompose;
  13522. /** @hidden */
  13523. _linkedTransformNode: Nullable<TransformNode>;
  13524. /** @hidden */
  13525. _waitingTransformNodeId: Nullable<string>;
  13526. /** @hidden */
  13527. /** @hidden */
  13528. _matrix: Matrix;
  13529. /**
  13530. * Create a new bone
  13531. * @param name defines the bone name
  13532. * @param skeleton defines the parent skeleton
  13533. * @param parentBone defines the parent (can be null if the bone is the root)
  13534. * @param localMatrix defines the local matrix
  13535. * @param restPose defines the rest pose matrix
  13536. * @param baseMatrix defines the base matrix
  13537. * @param index defines index of the bone in the hiearchy
  13538. */
  13539. constructor(
  13540. /**
  13541. * defines the bone name
  13542. */
  13543. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13544. /**
  13545. * Gets the current object class name.
  13546. * @return the class name
  13547. */
  13548. getClassName(): string;
  13549. /**
  13550. * Gets the parent skeleton
  13551. * @returns a skeleton
  13552. */
  13553. getSkeleton(): Skeleton;
  13554. /**
  13555. * Gets parent bone
  13556. * @returns a bone or null if the bone is the root of the bone hierarchy
  13557. */
  13558. getParent(): Nullable<Bone>;
  13559. /**
  13560. * Returns an array containing the root bones
  13561. * @returns an array containing the root bones
  13562. */
  13563. getChildren(): Array<Bone>;
  13564. /**
  13565. * Sets the parent bone
  13566. * @param parent defines the parent (can be null if the bone is the root)
  13567. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13568. */
  13569. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13570. /**
  13571. * Gets the local matrix
  13572. * @returns a matrix
  13573. */
  13574. getLocalMatrix(): Matrix;
  13575. /**
  13576. * Gets the base matrix (initial matrix which remains unchanged)
  13577. * @returns a matrix
  13578. */
  13579. getBaseMatrix(): Matrix;
  13580. /**
  13581. * Gets the rest pose matrix
  13582. * @returns a matrix
  13583. */
  13584. getRestPose(): Matrix;
  13585. /**
  13586. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13587. */
  13588. getWorldMatrix(): Matrix;
  13589. /**
  13590. * Sets the local matrix to rest pose matrix
  13591. */
  13592. returnToRest(): void;
  13593. /**
  13594. * Gets the inverse of the absolute transform matrix.
  13595. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13596. * @returns a matrix
  13597. */
  13598. getInvertedAbsoluteTransform(): Matrix;
  13599. /**
  13600. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13601. * @returns a matrix
  13602. */
  13603. getAbsoluteTransform(): Matrix;
  13604. /**
  13605. * Links with the given transform node.
  13606. * The local matrix of this bone is copied from the transform node every frame.
  13607. * @param transformNode defines the transform node to link to
  13608. */
  13609. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13610. /**
  13611. * Gets the node used to drive the bone's transformation
  13612. * @returns a transform node or null
  13613. */
  13614. getTransformNode(): Nullable<TransformNode>;
  13615. /** Gets or sets current position (in local space) */
  13616. position: Vector3;
  13617. /** Gets or sets current rotation (in local space) */
  13618. rotation: Vector3;
  13619. /** Gets or sets current rotation quaternion (in local space) */
  13620. rotationQuaternion: Quaternion;
  13621. /** Gets or sets current scaling (in local space) */
  13622. scaling: Vector3;
  13623. /**
  13624. * Gets the animation properties override
  13625. */
  13626. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13627. private _decompose;
  13628. private _compose;
  13629. /**
  13630. * Update the base and local matrices
  13631. * @param matrix defines the new base or local matrix
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. * @param updateLocalMatrix defines if the local matrix should be updated
  13634. */
  13635. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13636. /** @hidden */
  13637. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13638. /**
  13639. * Flag the bone as dirty (Forcing it to update everything)
  13640. */
  13641. markAsDirty(): void;
  13642. /** @hidden */
  13643. _markAsDirtyAndCompose(): void;
  13644. private _markAsDirtyAndDecompose;
  13645. /**
  13646. * Translate the bone in local or world space
  13647. * @param vec The amount to translate the bone
  13648. * @param space The space that the translation is in
  13649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13650. */
  13651. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13652. /**
  13653. * Set the postion of the bone in local or world space
  13654. * @param position The position to set the bone
  13655. * @param space The space that the position is in
  13656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13657. */
  13658. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13659. /**
  13660. * Set the absolute position of the bone (world space)
  13661. * @param position The position to set the bone
  13662. * @param mesh The mesh that this bone is attached to
  13663. */
  13664. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13665. /**
  13666. * Scale the bone on the x, y and z axes (in local space)
  13667. * @param x The amount to scale the bone on the x axis
  13668. * @param y The amount to scale the bone on the y axis
  13669. * @param z The amount to scale the bone on the z axis
  13670. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13671. */
  13672. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13673. /**
  13674. * Set the bone scaling in local space
  13675. * @param scale defines the scaling vector
  13676. */
  13677. setScale(scale: Vector3): void;
  13678. /**
  13679. * Gets the current scaling in local space
  13680. * @returns the current scaling vector
  13681. */
  13682. getScale(): Vector3;
  13683. /**
  13684. * Gets the current scaling in local space and stores it in a target vector
  13685. * @param result defines the target vector
  13686. */
  13687. getScaleToRef(result: Vector3): void;
  13688. /**
  13689. * Set the yaw, pitch, and roll of the bone in local or world space
  13690. * @param yaw The rotation of the bone on the y axis
  13691. * @param pitch The rotation of the bone on the x axis
  13692. * @param roll The rotation of the bone on the z axis
  13693. * @param space The space that the axes of rotation are in
  13694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13695. */
  13696. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13697. /**
  13698. * Add a rotation to the bone on an axis in local or world space
  13699. * @param axis The axis to rotate the bone on
  13700. * @param amount The amount to rotate the bone
  13701. * @param space The space that the axis is in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. */
  13704. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13705. /**
  13706. * Set the rotation of the bone to a particular axis angle in local or world space
  13707. * @param axis The axis to rotate the bone on
  13708. * @param angle The angle that the bone should be rotated to
  13709. * @param space The space that the axis is in
  13710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13711. */
  13712. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13713. /**
  13714. * Set the euler rotation of the bone in local of world space
  13715. * @param rotation The euler rotation that the bone should be set to
  13716. * @param space The space that the rotation is in
  13717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13718. */
  13719. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13720. /**
  13721. * Set the quaternion rotation of the bone in local of world space
  13722. * @param quat The quaternion rotation that the bone should be set to
  13723. * @param space The space that the rotation is in
  13724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13725. */
  13726. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13727. /**
  13728. * Set the rotation matrix of the bone in local of world space
  13729. * @param rotMat The rotation matrix that the bone should be set to
  13730. * @param space The space that the rotation is in
  13731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13732. */
  13733. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13734. private _rotateWithMatrix;
  13735. private _getNegativeRotationToRef;
  13736. /**
  13737. * Get the position of the bone in local or world space
  13738. * @param space The space that the returned position is in
  13739. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13740. * @returns The position of the bone
  13741. */
  13742. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13743. /**
  13744. * Copy the position of the bone to a vector3 in local or world space
  13745. * @param space The space that the returned position is in
  13746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13747. * @param result The vector3 to copy the position to
  13748. */
  13749. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13750. /**
  13751. * Get the absolute position of the bone (world space)
  13752. * @param mesh The mesh that this bone is attached to
  13753. * @returns The absolute position of the bone
  13754. */
  13755. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13756. /**
  13757. * Copy the absolute position of the bone (world space) to the result param
  13758. * @param mesh The mesh that this bone is attached to
  13759. * @param result The vector3 to copy the absolute position to
  13760. */
  13761. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13762. /**
  13763. * Compute the absolute transforms of this bone and its children
  13764. */
  13765. computeAbsoluteTransforms(): void;
  13766. /**
  13767. * Get the world direction from an axis that is in the local space of the bone
  13768. * @param localAxis The local direction that is used to compute the world direction
  13769. * @param mesh The mesh that this bone is attached to
  13770. * @returns The world direction
  13771. */
  13772. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13773. /**
  13774. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13775. * @param localAxis The local direction that is used to compute the world direction
  13776. * @param mesh The mesh that this bone is attached to
  13777. * @param result The vector3 that the world direction will be copied to
  13778. */
  13779. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13780. /**
  13781. * Get the euler rotation of the bone in local or world space
  13782. * @param space The space that the rotation should be in
  13783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13784. * @returns The euler rotation
  13785. */
  13786. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13787. /**
  13788. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13789. * @param space The space that the rotation should be in
  13790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13791. * @param result The vector3 that the rotation should be copied to
  13792. */
  13793. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13794. /**
  13795. * Get the quaternion rotation of the bone in either local or world space
  13796. * @param space The space that the rotation should be in
  13797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13798. * @returns The quaternion rotation
  13799. */
  13800. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13801. /**
  13802. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13803. * @param space The space that the rotation should be in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @param result The quaternion that the rotation should be copied to
  13806. */
  13807. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13808. /**
  13809. * Get the rotation matrix of the bone in local or world space
  13810. * @param space The space that the rotation should be in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @returns The rotation matrix
  13813. */
  13814. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13815. /**
  13816. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13817. * @param space The space that the rotation should be in
  13818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13819. * @param result The quaternion that the rotation should be copied to
  13820. */
  13821. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13822. /**
  13823. * Get the world position of a point that is in the local space of the bone
  13824. * @param position The local position
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @returns The world position
  13827. */
  13828. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13829. /**
  13830. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13831. * @param position The local position
  13832. * @param mesh The mesh that this bone is attached to
  13833. * @param result The vector3 that the world position should be copied to
  13834. */
  13835. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13836. /**
  13837. * Get the local position of a point that is in world space
  13838. * @param position The world position
  13839. * @param mesh The mesh that this bone is attached to
  13840. * @returns The local position
  13841. */
  13842. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13843. /**
  13844. * Get the local position of a point that is in world space and copy it to the result param
  13845. * @param position The world position
  13846. * @param mesh The mesh that this bone is attached to
  13847. * @param result The vector3 that the local position should be copied to
  13848. */
  13849. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13850. }
  13851. }
  13852. declare module BABYLON {
  13853. /**
  13854. * 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.
  13855. * @see https://doc.babylonjs.com/how_to/transformnode
  13856. */
  13857. export class TransformNode extends Node {
  13858. /**
  13859. * Object will not rotate to face the camera
  13860. */
  13861. static BILLBOARDMODE_NONE: number;
  13862. /**
  13863. * Object will rotate to face the camera but only on the x axis
  13864. */
  13865. static BILLBOARDMODE_X: number;
  13866. /**
  13867. * Object will rotate to face the camera but only on the y axis
  13868. */
  13869. static BILLBOARDMODE_Y: number;
  13870. /**
  13871. * Object will rotate to face the camera but only on the z axis
  13872. */
  13873. static BILLBOARDMODE_Z: number;
  13874. /**
  13875. * Object will rotate to face the camera
  13876. */
  13877. static BILLBOARDMODE_ALL: number;
  13878. /**
  13879. * Object will rotate to face the camera's position instead of orientation
  13880. */
  13881. static BILLBOARDMODE_USE_POSITION: number;
  13882. private _forward;
  13883. private _forwardInverted;
  13884. private _up;
  13885. private _right;
  13886. private _rightInverted;
  13887. private _position;
  13888. private _rotation;
  13889. private _rotationQuaternion;
  13890. protected _scaling: Vector3;
  13891. protected _isDirty: boolean;
  13892. private _transformToBoneReferal;
  13893. private _isAbsoluteSynced;
  13894. private _billboardMode;
  13895. /**
  13896. * Gets or sets the billboard mode. Default is 0.
  13897. *
  13898. * | Value | Type | Description |
  13899. * | --- | --- | --- |
  13900. * | 0 | BILLBOARDMODE_NONE | |
  13901. * | 1 | BILLBOARDMODE_X | |
  13902. * | 2 | BILLBOARDMODE_Y | |
  13903. * | 4 | BILLBOARDMODE_Z | |
  13904. * | 7 | BILLBOARDMODE_ALL | |
  13905. *
  13906. */
  13907. billboardMode: number;
  13908. private _preserveParentRotationForBillboard;
  13909. /**
  13910. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13911. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13912. */
  13913. preserveParentRotationForBillboard: boolean;
  13914. /**
  13915. * 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
  13916. */
  13917. scalingDeterminant: number;
  13918. private _infiniteDistance;
  13919. /**
  13920. * Gets or sets the distance of the object to max, often used by skybox
  13921. */
  13922. infiniteDistance: boolean;
  13923. /**
  13924. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13925. * By default the system will update normals to compensate
  13926. */
  13927. ignoreNonUniformScaling: boolean;
  13928. /**
  13929. * 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
  13930. */
  13931. reIntegrateRotationIntoRotationQuaternion: boolean;
  13932. /** @hidden */
  13933. _poseMatrix: Nullable<Matrix>;
  13934. /** @hidden */
  13935. _localMatrix: Matrix;
  13936. private _usePivotMatrix;
  13937. private _absolutePosition;
  13938. private _absoluteScaling;
  13939. private _absoluteRotationQuaternion;
  13940. private _pivotMatrix;
  13941. private _pivotMatrixInverse;
  13942. protected _postMultiplyPivotMatrix: boolean;
  13943. protected _isWorldMatrixFrozen: boolean;
  13944. /** @hidden */
  13945. _indexInSceneTransformNodesArray: number;
  13946. /**
  13947. * An event triggered after the world matrix is updated
  13948. */
  13949. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13950. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13951. /**
  13952. * Gets a string identifying the name of the class
  13953. * @returns "TransformNode" string
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13958. */
  13959. position: Vector3;
  13960. /**
  13961. * 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)).
  13962. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13963. */
  13964. rotation: Vector3;
  13965. /**
  13966. * 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)).
  13967. */
  13968. scaling: Vector3;
  13969. /**
  13970. * 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).
  13971. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13972. */
  13973. rotationQuaternion: Nullable<Quaternion>;
  13974. /**
  13975. * The forward direction of that transform in world space.
  13976. */
  13977. readonly forward: Vector3;
  13978. /**
  13979. * The up direction of that transform in world space.
  13980. */
  13981. readonly up: Vector3;
  13982. /**
  13983. * The right direction of that transform in world space.
  13984. */
  13985. readonly right: Vector3;
  13986. /**
  13987. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13988. * @param matrix the matrix to copy the pose from
  13989. * @returns this TransformNode.
  13990. */
  13991. updatePoseMatrix(matrix: Matrix): TransformNode;
  13992. /**
  13993. * Returns the mesh Pose matrix.
  13994. * @returns the pose matrix
  13995. */
  13996. getPoseMatrix(): Matrix;
  13997. /** @hidden */
  13998. _isSynchronized(): boolean;
  13999. /** @hidden */
  14000. _initCache(): void;
  14001. /**
  14002. * Flag the transform node as dirty (Forcing it to update everything)
  14003. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14004. * @returns this transform node
  14005. */
  14006. markAsDirty(property: string): TransformNode;
  14007. /**
  14008. * Returns the current mesh absolute position.
  14009. * Returns a Vector3.
  14010. */
  14011. readonly absolutePosition: Vector3;
  14012. /**
  14013. * Returns the current mesh absolute scaling.
  14014. * Returns a Vector3.
  14015. */
  14016. readonly absoluteScaling: Vector3;
  14017. /**
  14018. * Returns the current mesh absolute rotation.
  14019. * Returns a Quaternion.
  14020. */
  14021. readonly absoluteRotationQuaternion: Quaternion;
  14022. /**
  14023. * Sets a new matrix to apply before all other transformation
  14024. * @param matrix defines the transform matrix
  14025. * @returns the current TransformNode
  14026. */
  14027. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14028. /**
  14029. * Sets a new pivot matrix to the current node
  14030. * @param matrix defines the new pivot matrix to use
  14031. * @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
  14032. * @returns the current TransformNode
  14033. */
  14034. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14035. /**
  14036. * Returns the mesh pivot matrix.
  14037. * Default : Identity.
  14038. * @returns the matrix
  14039. */
  14040. getPivotMatrix(): Matrix;
  14041. /**
  14042. * Instantiate (when possible) or clone that node with its hierarchy
  14043. * @param newParent defines the new parent to use for the instance (or clone)
  14044. * @returns an instance (or a clone) of the current node with its hiearchy
  14045. */
  14046. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14047. /**
  14048. * Prevents the World matrix to be computed any longer
  14049. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14050. * @returns the TransformNode.
  14051. */
  14052. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14053. /**
  14054. * Allows back the World matrix computation.
  14055. * @returns the TransformNode.
  14056. */
  14057. unfreezeWorldMatrix(): this;
  14058. /**
  14059. * True if the World matrix has been frozen.
  14060. */
  14061. readonly isWorldMatrixFrozen: boolean;
  14062. /**
  14063. * Retuns the mesh absolute position in the World.
  14064. * @returns a Vector3.
  14065. */
  14066. getAbsolutePosition(): Vector3;
  14067. /**
  14068. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14069. * @param absolutePosition the absolute position to set
  14070. * @returns the TransformNode.
  14071. */
  14072. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14073. /**
  14074. * Sets the mesh position in its local space.
  14075. * @param vector3 the position to set in localspace
  14076. * @returns the TransformNode.
  14077. */
  14078. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14079. /**
  14080. * Returns the mesh position in the local space from the current World matrix values.
  14081. * @returns a new Vector3.
  14082. */
  14083. getPositionExpressedInLocalSpace(): Vector3;
  14084. /**
  14085. * Translates the mesh along the passed Vector3 in its local space.
  14086. * @param vector3 the distance to translate in localspace
  14087. * @returns the TransformNode.
  14088. */
  14089. locallyTranslate(vector3: Vector3): TransformNode;
  14090. private static _lookAtVectorCache;
  14091. /**
  14092. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14093. * @param targetPoint the position (must be in same space as current mesh) to look at
  14094. * @param yawCor optional yaw (y-axis) correction in radians
  14095. * @param pitchCor optional pitch (x-axis) correction in radians
  14096. * @param rollCor optional roll (z-axis) correction in radians
  14097. * @param space the choosen space of the target
  14098. * @returns the TransformNode.
  14099. */
  14100. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14101. /**
  14102. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14103. * This Vector3 is expressed in the World space.
  14104. * @param localAxis axis to rotate
  14105. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14106. */
  14107. getDirection(localAxis: Vector3): Vector3;
  14108. /**
  14109. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14110. * localAxis is expressed in the mesh local space.
  14111. * result is computed in the Wordl space from the mesh World matrix.
  14112. * @param localAxis axis to rotate
  14113. * @param result the resulting transformnode
  14114. * @returns this TransformNode.
  14115. */
  14116. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14117. /**
  14118. * Sets this transform node rotation to the given local axis.
  14119. * @param localAxis the axis in local space
  14120. * @param yawCor optional yaw (y-axis) correction in radians
  14121. * @param pitchCor optional pitch (x-axis) correction in radians
  14122. * @param rollCor optional roll (z-axis) correction in radians
  14123. * @returns this TransformNode
  14124. */
  14125. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14126. /**
  14127. * Sets a new pivot point to the current node
  14128. * @param point defines the new pivot point to use
  14129. * @param space defines if the point is in world or local space (local by default)
  14130. * @returns the current TransformNode
  14131. */
  14132. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14133. /**
  14134. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14135. * @returns the pivot point
  14136. */
  14137. getPivotPoint(): Vector3;
  14138. /**
  14139. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14140. * @param result the vector3 to store the result
  14141. * @returns this TransformNode.
  14142. */
  14143. getPivotPointToRef(result: Vector3): TransformNode;
  14144. /**
  14145. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14146. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14147. */
  14148. getAbsolutePivotPoint(): Vector3;
  14149. /**
  14150. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14151. * @param result vector3 to store the result
  14152. * @returns this TransformNode.
  14153. */
  14154. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14155. /**
  14156. * Defines the passed node as the parent of the current node.
  14157. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14158. * @see https://doc.babylonjs.com/how_to/parenting
  14159. * @param node the node ot set as the parent
  14160. * @returns this TransformNode.
  14161. */
  14162. setParent(node: Nullable<Node>): TransformNode;
  14163. private _nonUniformScaling;
  14164. /**
  14165. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14166. */
  14167. readonly nonUniformScaling: boolean;
  14168. /** @hidden */
  14169. _updateNonUniformScalingState(value: boolean): boolean;
  14170. /**
  14171. * Attach the current TransformNode to another TransformNode associated with a bone
  14172. * @param bone Bone affecting the TransformNode
  14173. * @param affectedTransformNode TransformNode associated with the bone
  14174. * @returns this object
  14175. */
  14176. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14177. /**
  14178. * Detach the transform node if its associated with a bone
  14179. * @returns this object
  14180. */
  14181. detachFromBone(): TransformNode;
  14182. private static _rotationAxisCache;
  14183. /**
  14184. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14185. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14186. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14187. * The passed axis is also normalized.
  14188. * @param axis the axis to rotate around
  14189. * @param amount the amount to rotate in radians
  14190. * @param space Space to rotate in (Default: local)
  14191. * @returns the TransformNode.
  14192. */
  14193. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14194. /**
  14195. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14196. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14197. * The passed axis is also normalized. .
  14198. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14199. * @param point the point to rotate around
  14200. * @param axis the axis to rotate around
  14201. * @param amount the amount to rotate in radians
  14202. * @returns the TransformNode
  14203. */
  14204. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14205. /**
  14206. * Translates the mesh along the axis vector for the passed distance in the given space.
  14207. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14208. * @param axis the axis to translate in
  14209. * @param distance the distance to translate
  14210. * @param space Space to rotate in (Default: local)
  14211. * @returns the TransformNode.
  14212. */
  14213. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14214. /**
  14215. * Adds a rotation step to the mesh current rotation.
  14216. * x, y, z are Euler angles expressed in radians.
  14217. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14218. * This means this rotation is made in the mesh local space only.
  14219. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14220. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14221. * ```javascript
  14222. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14223. * ```
  14224. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14225. * 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.
  14226. * @param x Rotation to add
  14227. * @param y Rotation to add
  14228. * @param z Rotation to add
  14229. * @returns the TransformNode.
  14230. */
  14231. addRotation(x: number, y: number, z: number): TransformNode;
  14232. /**
  14233. * @hidden
  14234. */
  14235. protected _getEffectiveParent(): Nullable<Node>;
  14236. /**
  14237. * Computes the world matrix of the node
  14238. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14239. * @returns the world matrix
  14240. */
  14241. computeWorldMatrix(force?: boolean): Matrix;
  14242. protected _afterComputeWorldMatrix(): void;
  14243. /**
  14244. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14245. * @param func callback function to add
  14246. *
  14247. * @returns the TransformNode.
  14248. */
  14249. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14250. /**
  14251. * Removes a registered callback function.
  14252. * @param func callback function to remove
  14253. * @returns the TransformNode.
  14254. */
  14255. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14256. /**
  14257. * Gets the position of the current mesh in camera space
  14258. * @param camera defines the camera to use
  14259. * @returns a position
  14260. */
  14261. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14262. /**
  14263. * Returns the distance from the mesh to the active camera
  14264. * @param camera defines the camera to use
  14265. * @returns the distance
  14266. */
  14267. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14268. /**
  14269. * Clone the current transform node
  14270. * @param name Name of the new clone
  14271. * @param newParent New parent for the clone
  14272. * @param doNotCloneChildren Do not clone children hierarchy
  14273. * @returns the new transform node
  14274. */
  14275. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14276. /**
  14277. * Serializes the objects information.
  14278. * @param currentSerializationObject defines the object to serialize in
  14279. * @returns the serialized object
  14280. */
  14281. serialize(currentSerializationObject?: any): any;
  14282. /**
  14283. * Returns a new TransformNode object parsed from the source provided.
  14284. * @param parsedTransformNode is the source.
  14285. * @param scene the scne the object belongs to
  14286. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14287. * @returns a new TransformNode object parsed from the source provided.
  14288. */
  14289. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14290. /**
  14291. * Get all child-transformNodes of this node
  14292. * @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
  14293. * @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
  14294. * @returns an array of TransformNode
  14295. */
  14296. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14297. /**
  14298. * Releases resources associated with this transform node.
  14299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14301. */
  14302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14303. /**
  14304. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14305. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14306. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14307. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14308. * @returns the current mesh
  14309. */
  14310. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14311. private _syncAbsoluteScalingAndRotation;
  14312. }
  14313. }
  14314. declare module BABYLON {
  14315. /**
  14316. * Defines the types of pose enabled controllers that are supported
  14317. */
  14318. export enum PoseEnabledControllerType {
  14319. /**
  14320. * HTC Vive
  14321. */
  14322. VIVE = 0,
  14323. /**
  14324. * Oculus Rift
  14325. */
  14326. OCULUS = 1,
  14327. /**
  14328. * Windows mixed reality
  14329. */
  14330. WINDOWS = 2,
  14331. /**
  14332. * Samsung gear VR
  14333. */
  14334. GEAR_VR = 3,
  14335. /**
  14336. * Google Daydream
  14337. */
  14338. DAYDREAM = 4,
  14339. /**
  14340. * Generic
  14341. */
  14342. GENERIC = 5
  14343. }
  14344. /**
  14345. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14346. */
  14347. export interface MutableGamepadButton {
  14348. /**
  14349. * Value of the button/trigger
  14350. */
  14351. value: number;
  14352. /**
  14353. * If the button/trigger is currently touched
  14354. */
  14355. touched: boolean;
  14356. /**
  14357. * If the button/trigger is currently pressed
  14358. */
  14359. pressed: boolean;
  14360. }
  14361. /**
  14362. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14363. * @hidden
  14364. */
  14365. export interface ExtendedGamepadButton extends GamepadButton {
  14366. /**
  14367. * If the button/trigger is currently pressed
  14368. */
  14369. readonly pressed: boolean;
  14370. /**
  14371. * If the button/trigger is currently touched
  14372. */
  14373. readonly touched: boolean;
  14374. /**
  14375. * Value of the button/trigger
  14376. */
  14377. readonly value: number;
  14378. }
  14379. /** @hidden */
  14380. export interface _GamePadFactory {
  14381. /**
  14382. * Returns wether or not the current gamepad can be created for this type of controller.
  14383. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14384. * @returns true if it can be created, otherwise false
  14385. */
  14386. canCreate(gamepadInfo: any): boolean;
  14387. /**
  14388. * Creates a new instance of the Gamepad.
  14389. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14390. * @returns the new gamepad instance
  14391. */
  14392. create(gamepadInfo: any): Gamepad;
  14393. }
  14394. /**
  14395. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14396. */
  14397. export class PoseEnabledControllerHelper {
  14398. /** @hidden */
  14399. static _ControllerFactories: _GamePadFactory[];
  14400. /** @hidden */
  14401. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14402. /**
  14403. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14404. * @param vrGamepad the gamepad to initialized
  14405. * @returns a vr controller of the type the gamepad identified as
  14406. */
  14407. static InitiateController(vrGamepad: any): Gamepad;
  14408. }
  14409. /**
  14410. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14411. */
  14412. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14413. /**
  14414. * If the controller is used in a webXR session
  14415. */
  14416. isXR: boolean;
  14417. private _deviceRoomPosition;
  14418. private _deviceRoomRotationQuaternion;
  14419. /**
  14420. * The device position in babylon space
  14421. */
  14422. devicePosition: Vector3;
  14423. /**
  14424. * The device rotation in babylon space
  14425. */
  14426. deviceRotationQuaternion: Quaternion;
  14427. /**
  14428. * The scale factor of the device in babylon space
  14429. */
  14430. deviceScaleFactor: number;
  14431. /**
  14432. * (Likely devicePosition should be used instead) The device position in its room space
  14433. */
  14434. position: Vector3;
  14435. /**
  14436. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14437. */
  14438. rotationQuaternion: Quaternion;
  14439. /**
  14440. * The type of controller (Eg. Windows mixed reality)
  14441. */
  14442. controllerType: PoseEnabledControllerType;
  14443. protected _calculatedPosition: Vector3;
  14444. private _calculatedRotation;
  14445. /**
  14446. * The raw pose from the device
  14447. */
  14448. rawPose: DevicePose;
  14449. private _trackPosition;
  14450. private _maxRotationDistFromHeadset;
  14451. private _draggedRoomRotation;
  14452. /**
  14453. * @hidden
  14454. */
  14455. _disableTrackPosition(fixedPosition: Vector3): void;
  14456. /**
  14457. * Internal, the mesh attached to the controller
  14458. * @hidden
  14459. */
  14460. _mesh: Nullable<AbstractMesh>;
  14461. private _poseControlledCamera;
  14462. private _leftHandSystemQuaternion;
  14463. /**
  14464. * Internal, matrix used to convert room space to babylon space
  14465. * @hidden
  14466. */
  14467. _deviceToWorld: Matrix;
  14468. /**
  14469. * Node to be used when casting a ray from the controller
  14470. * @hidden
  14471. */
  14472. _pointingPoseNode: Nullable<TransformNode>;
  14473. /**
  14474. * Name of the child mesh that can be used to cast a ray from the controller
  14475. */
  14476. static readonly POINTING_POSE: string;
  14477. /**
  14478. * Creates a new PoseEnabledController from a gamepad
  14479. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14480. */
  14481. constructor(browserGamepad: any);
  14482. private _workingMatrix;
  14483. /**
  14484. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14485. */
  14486. update(): void;
  14487. /**
  14488. * Updates only the pose device and mesh without doing any button event checking
  14489. */
  14490. protected _updatePoseAndMesh(): void;
  14491. /**
  14492. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14493. * @param poseData raw pose fromthe device
  14494. */
  14495. updateFromDevice(poseData: DevicePose): void;
  14496. /**
  14497. * @hidden
  14498. */
  14499. _meshAttachedObservable: Observable<AbstractMesh>;
  14500. /**
  14501. * Attaches a mesh to the controller
  14502. * @param mesh the mesh to be attached
  14503. */
  14504. attachToMesh(mesh: AbstractMesh): void;
  14505. /**
  14506. * Attaches the controllers mesh to a camera
  14507. * @param camera the camera the mesh should be attached to
  14508. */
  14509. attachToPoseControlledCamera(camera: TargetCamera): void;
  14510. /**
  14511. * Disposes of the controller
  14512. */
  14513. dispose(): void;
  14514. /**
  14515. * The mesh that is attached to the controller
  14516. */
  14517. readonly mesh: Nullable<AbstractMesh>;
  14518. /**
  14519. * Gets the ray of the controller in the direction the controller is pointing
  14520. * @param length the length the resulting ray should be
  14521. * @returns a ray in the direction the controller is pointing
  14522. */
  14523. getForwardRay(length?: number): Ray;
  14524. }
  14525. }
  14526. declare module BABYLON {
  14527. /**
  14528. * Defines the WebVRController object that represents controllers tracked in 3D space
  14529. */
  14530. export abstract class WebVRController extends PoseEnabledController {
  14531. /**
  14532. * Internal, the default controller model for the controller
  14533. */
  14534. protected _defaultModel: Nullable<AbstractMesh>;
  14535. /**
  14536. * Fired when the trigger state has changed
  14537. */
  14538. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14539. /**
  14540. * Fired when the main button state has changed
  14541. */
  14542. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14543. /**
  14544. * Fired when the secondary button state has changed
  14545. */
  14546. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14547. /**
  14548. * Fired when the pad state has changed
  14549. */
  14550. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14551. /**
  14552. * Fired when controllers stick values have changed
  14553. */
  14554. onPadValuesChangedObservable: Observable<StickValues>;
  14555. /**
  14556. * Array of button availible on the controller
  14557. */
  14558. protected _buttons: Array<MutableGamepadButton>;
  14559. private _onButtonStateChange;
  14560. /**
  14561. * Fired when a controller button's state has changed
  14562. * @param callback the callback containing the button that was modified
  14563. */
  14564. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14565. /**
  14566. * X and Y axis corresponding to the controllers joystick
  14567. */
  14568. pad: StickValues;
  14569. /**
  14570. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14571. */
  14572. hand: string;
  14573. /**
  14574. * The default controller model for the controller
  14575. */
  14576. readonly defaultModel: Nullable<AbstractMesh>;
  14577. /**
  14578. * Creates a new WebVRController from a gamepad
  14579. * @param vrGamepad the gamepad that the WebVRController should be created from
  14580. */
  14581. constructor(vrGamepad: any);
  14582. /**
  14583. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14584. */
  14585. update(): void;
  14586. /**
  14587. * Function to be called when a button is modified
  14588. */
  14589. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14590. /**
  14591. * Loads a mesh and attaches it to the controller
  14592. * @param scene the scene the mesh should be added to
  14593. * @param meshLoaded callback for when the mesh has been loaded
  14594. */
  14595. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14596. private _setButtonValue;
  14597. private _changes;
  14598. private _checkChanges;
  14599. /**
  14600. * Disposes of th webVRCOntroller
  14601. */
  14602. dispose(): void;
  14603. }
  14604. }
  14605. declare module BABYLON {
  14606. /**
  14607. * The HemisphericLight simulates the ambient environment light,
  14608. * so the passed direction is the light reflection direction, not the incoming direction.
  14609. */
  14610. export class HemisphericLight extends Light {
  14611. /**
  14612. * The groundColor is the light in the opposite direction to the one specified during creation.
  14613. * 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.
  14614. */
  14615. groundColor: Color3;
  14616. /**
  14617. * The light reflection direction, not the incoming direction.
  14618. */
  14619. direction: Vector3;
  14620. /**
  14621. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14622. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14623. * The HemisphericLight can't cast shadows.
  14624. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14625. * @param name The friendly name of the light
  14626. * @param direction The direction of the light reflection
  14627. * @param scene The scene the light belongs to
  14628. */
  14629. constructor(name: string, direction: Vector3, scene: Scene);
  14630. protected _buildUniformLayout(): void;
  14631. /**
  14632. * Returns the string "HemisphericLight".
  14633. * @return The class name
  14634. */
  14635. getClassName(): string;
  14636. /**
  14637. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14638. * Returns the updated direction.
  14639. * @param target The target the direction should point to
  14640. * @return The computed direction
  14641. */
  14642. setDirectionToTarget(target: Vector3): Vector3;
  14643. /**
  14644. * Returns the shadow generator associated to the light.
  14645. * @returns Always null for hemispheric lights because it does not support shadows.
  14646. */
  14647. getShadowGenerator(): Nullable<IShadowGenerator>;
  14648. /**
  14649. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14650. * @param effect The effect to update
  14651. * @param lightIndex The index of the light in the effect to update
  14652. * @returns The hemispheric light
  14653. */
  14654. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14655. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14656. /**
  14657. * Computes the world matrix of the node
  14658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14659. * @param useWasUpdatedFlag defines a reserved property
  14660. * @returns the world matrix
  14661. */
  14662. computeWorldMatrix(): Matrix;
  14663. /**
  14664. * Returns the integer 3.
  14665. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14666. */
  14667. getTypeID(): number;
  14668. /**
  14669. * Prepares the list of defines specific to the light type.
  14670. * @param defines the list of defines
  14671. * @param lightIndex defines the index of the light for the effect
  14672. */
  14673. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14674. }
  14675. }
  14676. declare module BABYLON {
  14677. /** @hidden */
  14678. export var vrMultiviewToSingleviewPixelShader: {
  14679. name: string;
  14680. shader: string;
  14681. };
  14682. }
  14683. declare module BABYLON {
  14684. /**
  14685. * Renders to multiple views with a single draw call
  14686. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14687. */
  14688. export class MultiviewRenderTarget extends RenderTargetTexture {
  14689. /**
  14690. * Creates a multiview render target
  14691. * @param scene scene used with the render target
  14692. * @param size the size of the render target (used for each view)
  14693. */
  14694. constructor(scene: Scene, size?: number | {
  14695. width: number;
  14696. height: number;
  14697. } | {
  14698. ratio: number;
  14699. });
  14700. /**
  14701. * @hidden
  14702. * @param faceIndex the face index, if its a cube texture
  14703. */
  14704. _bindFrameBuffer(faceIndex?: number): void;
  14705. /**
  14706. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14707. * @returns the view count
  14708. */
  14709. getViewCount(): number;
  14710. }
  14711. }
  14712. declare module BABYLON {
  14713. /**
  14714. * Represents a camera frustum
  14715. */
  14716. export class Frustum {
  14717. /**
  14718. * Gets the planes representing the frustum
  14719. * @param transform matrix to be applied to the returned planes
  14720. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14721. */
  14722. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14723. /**
  14724. * Gets the near frustum plane transformed by the transform matrix
  14725. * @param transform transformation matrix to be applied to the resulting frustum plane
  14726. * @param frustumPlane the resuling frustum plane
  14727. */
  14728. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14729. /**
  14730. * Gets the far frustum plane transformed by the transform matrix
  14731. * @param transform transformation matrix to be applied to the resulting frustum plane
  14732. * @param frustumPlane the resuling frustum plane
  14733. */
  14734. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14735. /**
  14736. * Gets the left frustum plane transformed by the transform matrix
  14737. * @param transform transformation matrix to be applied to the resulting frustum plane
  14738. * @param frustumPlane the resuling frustum plane
  14739. */
  14740. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14741. /**
  14742. * Gets the right frustum plane transformed by the transform matrix
  14743. * @param transform transformation matrix to be applied to the resulting frustum plane
  14744. * @param frustumPlane the resuling frustum plane
  14745. */
  14746. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14747. /**
  14748. * Gets the top frustum plane transformed by the transform matrix
  14749. * @param transform transformation matrix to be applied to the resulting frustum plane
  14750. * @param frustumPlane the resuling frustum plane
  14751. */
  14752. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14753. /**
  14754. * Gets the bottom frustum plane transformed by the transform matrix
  14755. * @param transform transformation matrix to be applied to the resulting frustum plane
  14756. * @param frustumPlane the resuling frustum plane
  14757. */
  14758. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14759. /**
  14760. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14761. * @param transform transformation matrix to be applied to the resulting frustum planes
  14762. * @param frustumPlanes the resuling frustum planes
  14763. */
  14764. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14765. }
  14766. }
  14767. declare module BABYLON {
  14768. interface Engine {
  14769. /**
  14770. * Creates a new multiview render target
  14771. * @param width defines the width of the texture
  14772. * @param height defines the height of the texture
  14773. * @returns the created multiview texture
  14774. */
  14775. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14776. /**
  14777. * Binds a multiview framebuffer to be drawn to
  14778. * @param multiviewTexture texture to bind
  14779. */
  14780. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14781. }
  14782. interface Camera {
  14783. /**
  14784. * @hidden
  14785. * 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)
  14786. */
  14787. _useMultiviewToSingleView: boolean;
  14788. /**
  14789. * @hidden
  14790. * 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)
  14791. */
  14792. _multiviewTexture: Nullable<RenderTargetTexture>;
  14793. /**
  14794. * @hidden
  14795. * ensures the multiview texture of the camera exists and has the specified width/height
  14796. * @param width height to set on the multiview texture
  14797. * @param height width to set on the multiview texture
  14798. */
  14799. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14800. }
  14801. interface Scene {
  14802. /** @hidden */
  14803. _transformMatrixR: Matrix;
  14804. /** @hidden */
  14805. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14806. /** @hidden */
  14807. _createMultiviewUbo(): void;
  14808. /** @hidden */
  14809. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14810. /** @hidden */
  14811. _renderMultiviewToSingleView(camera: Camera): void;
  14812. }
  14813. }
  14814. declare module BABYLON {
  14815. /**
  14816. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14817. * This will not be used for webXR as it supports displaying texture arrays directly
  14818. */
  14819. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14820. /**
  14821. * Initializes a VRMultiviewToSingleview
  14822. * @param name name of the post process
  14823. * @param camera camera to be applied to
  14824. * @param scaleFactor scaling factor to the size of the output texture
  14825. */
  14826. constructor(name: string, camera: Camera, scaleFactor: number);
  14827. }
  14828. }
  14829. declare module BABYLON {
  14830. interface Engine {
  14831. /** @hidden */
  14832. _vrDisplay: any;
  14833. /** @hidden */
  14834. _vrSupported: boolean;
  14835. /** @hidden */
  14836. _oldSize: Size;
  14837. /** @hidden */
  14838. _oldHardwareScaleFactor: number;
  14839. /** @hidden */
  14840. _vrExclusivePointerMode: boolean;
  14841. /** @hidden */
  14842. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14843. /** @hidden */
  14844. _onVRDisplayPointerRestricted: () => void;
  14845. /** @hidden */
  14846. _onVRDisplayPointerUnrestricted: () => void;
  14847. /** @hidden */
  14848. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14849. /** @hidden */
  14850. _onVrDisplayDisconnect: Nullable<() => void>;
  14851. /** @hidden */
  14852. _onVrDisplayPresentChange: Nullable<() => void>;
  14853. /**
  14854. * Observable signaled when VR display mode changes
  14855. */
  14856. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14857. /**
  14858. * Observable signaled when VR request present is complete
  14859. */
  14860. onVRRequestPresentComplete: Observable<boolean>;
  14861. /**
  14862. * Observable signaled when VR request present starts
  14863. */
  14864. onVRRequestPresentStart: Observable<Engine>;
  14865. /**
  14866. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14867. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14868. */
  14869. isInVRExclusivePointerMode: boolean;
  14870. /**
  14871. * Gets a boolean indicating if a webVR device was detected
  14872. * @returns true if a webVR device was detected
  14873. */
  14874. isVRDevicePresent(): boolean;
  14875. /**
  14876. * Gets the current webVR device
  14877. * @returns the current webVR device (or null)
  14878. */
  14879. getVRDevice(): any;
  14880. /**
  14881. * Initializes a webVR display and starts listening to display change events
  14882. * The onVRDisplayChangedObservable will be notified upon these changes
  14883. * @returns A promise containing a VRDisplay and if vr is supported
  14884. */
  14885. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14886. /** @hidden */
  14887. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14888. /**
  14889. * Call this function to switch to webVR mode
  14890. * Will do nothing if webVR is not supported or if there is no webVR device
  14891. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14892. */
  14893. enableVR(): void;
  14894. /** @hidden */
  14895. _onVRFullScreenTriggered(): void;
  14896. }
  14897. }
  14898. declare module BABYLON {
  14899. /**
  14900. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14901. * IMPORTANT!! The data is right-hand data.
  14902. * @export
  14903. * @interface DevicePose
  14904. */
  14905. export interface DevicePose {
  14906. /**
  14907. * The position of the device, values in array are [x,y,z].
  14908. */
  14909. readonly position: Nullable<Float32Array>;
  14910. /**
  14911. * The linearVelocity of the device, values in array are [x,y,z].
  14912. */
  14913. readonly linearVelocity: Nullable<Float32Array>;
  14914. /**
  14915. * The linearAcceleration of the device, values in array are [x,y,z].
  14916. */
  14917. readonly linearAcceleration: Nullable<Float32Array>;
  14918. /**
  14919. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14920. */
  14921. readonly orientation: Nullable<Float32Array>;
  14922. /**
  14923. * The angularVelocity of the device, values in array are [x,y,z].
  14924. */
  14925. readonly angularVelocity: Nullable<Float32Array>;
  14926. /**
  14927. * The angularAcceleration of the device, values in array are [x,y,z].
  14928. */
  14929. readonly angularAcceleration: Nullable<Float32Array>;
  14930. }
  14931. /**
  14932. * Interface representing a pose controlled object in Babylon.
  14933. * A pose controlled object has both regular pose values as well as pose values
  14934. * from an external device such as a VR head mounted display
  14935. */
  14936. export interface PoseControlled {
  14937. /**
  14938. * The position of the object in babylon space.
  14939. */
  14940. position: Vector3;
  14941. /**
  14942. * The rotation quaternion of the object in babylon space.
  14943. */
  14944. rotationQuaternion: Quaternion;
  14945. /**
  14946. * The position of the device in babylon space.
  14947. */
  14948. devicePosition?: Vector3;
  14949. /**
  14950. * The rotation quaternion of the device in babylon space.
  14951. */
  14952. deviceRotationQuaternion: Quaternion;
  14953. /**
  14954. * The raw pose coming from the device.
  14955. */
  14956. rawPose: Nullable<DevicePose>;
  14957. /**
  14958. * The scale of the device to be used when translating from device space to babylon space.
  14959. */
  14960. deviceScaleFactor: number;
  14961. /**
  14962. * Updates the poseControlled values based on the input device pose.
  14963. * @param poseData the pose data to update the object with
  14964. */
  14965. updateFromDevice(poseData: DevicePose): void;
  14966. }
  14967. /**
  14968. * Set of options to customize the webVRCamera
  14969. */
  14970. export interface WebVROptions {
  14971. /**
  14972. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14973. */
  14974. trackPosition?: boolean;
  14975. /**
  14976. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14977. */
  14978. positionScale?: number;
  14979. /**
  14980. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14981. */
  14982. displayName?: string;
  14983. /**
  14984. * Should the native controller meshes be initialized. (default: true)
  14985. */
  14986. controllerMeshes?: boolean;
  14987. /**
  14988. * Creating a default HemiLight only on controllers. (default: true)
  14989. */
  14990. defaultLightingOnControllers?: boolean;
  14991. /**
  14992. * If you don't want to use the default VR button of the helper. (default: false)
  14993. */
  14994. useCustomVRButton?: boolean;
  14995. /**
  14996. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14997. */
  14998. customVRButton?: HTMLButtonElement;
  14999. /**
  15000. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15001. */
  15002. rayLength?: number;
  15003. /**
  15004. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15005. */
  15006. defaultHeight?: number;
  15007. /**
  15008. * If multiview should be used if availible (default: false)
  15009. */
  15010. useMultiview?: boolean;
  15011. }
  15012. /**
  15013. * This represents a WebVR camera.
  15014. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15015. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15016. */
  15017. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15018. private webVROptions;
  15019. /**
  15020. * @hidden
  15021. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15022. */
  15023. _vrDevice: any;
  15024. /**
  15025. * The rawPose of the vrDevice.
  15026. */
  15027. rawPose: Nullable<DevicePose>;
  15028. private _onVREnabled;
  15029. private _specsVersion;
  15030. private _attached;
  15031. private _frameData;
  15032. protected _descendants: Array<Node>;
  15033. private _deviceRoomPosition;
  15034. /** @hidden */
  15035. _deviceRoomRotationQuaternion: Quaternion;
  15036. private _standingMatrix;
  15037. /**
  15038. * Represents device position in babylon space.
  15039. */
  15040. devicePosition: Vector3;
  15041. /**
  15042. * Represents device rotation in babylon space.
  15043. */
  15044. deviceRotationQuaternion: Quaternion;
  15045. /**
  15046. * The scale of the device to be used when translating from device space to babylon space.
  15047. */
  15048. deviceScaleFactor: number;
  15049. private _deviceToWorld;
  15050. private _worldToDevice;
  15051. /**
  15052. * References to the webVR controllers for the vrDevice.
  15053. */
  15054. controllers: Array<WebVRController>;
  15055. /**
  15056. * Emits an event when a controller is attached.
  15057. */
  15058. onControllersAttachedObservable: Observable<WebVRController[]>;
  15059. /**
  15060. * Emits an event when a controller's mesh has been loaded;
  15061. */
  15062. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15063. /**
  15064. * Emits an event when the HMD's pose has been updated.
  15065. */
  15066. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15067. private _poseSet;
  15068. /**
  15069. * If the rig cameras be used as parent instead of this camera.
  15070. */
  15071. rigParenting: boolean;
  15072. private _lightOnControllers;
  15073. private _defaultHeight?;
  15074. /**
  15075. * Instantiates a WebVRFreeCamera.
  15076. * @param name The name of the WebVRFreeCamera
  15077. * @param position The starting anchor position for the camera
  15078. * @param scene The scene the camera belongs to
  15079. * @param webVROptions a set of customizable options for the webVRCamera
  15080. */
  15081. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15082. /**
  15083. * Gets the device distance from the ground in meters.
  15084. * @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.
  15085. */
  15086. deviceDistanceToRoomGround(): number;
  15087. /**
  15088. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15089. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15090. */
  15091. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15092. /**
  15093. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15094. * @returns A promise with a boolean set to if the standing matrix is supported.
  15095. */
  15096. useStandingMatrixAsync(): Promise<boolean>;
  15097. /**
  15098. * Disposes the camera
  15099. */
  15100. dispose(): void;
  15101. /**
  15102. * Gets a vrController by name.
  15103. * @param name The name of the controller to retreive
  15104. * @returns the controller matching the name specified or null if not found
  15105. */
  15106. getControllerByName(name: string): Nullable<WebVRController>;
  15107. private _leftController;
  15108. /**
  15109. * The controller corresponding to the users left hand.
  15110. */
  15111. readonly leftController: Nullable<WebVRController>;
  15112. private _rightController;
  15113. /**
  15114. * The controller corresponding to the users right hand.
  15115. */
  15116. readonly rightController: Nullable<WebVRController>;
  15117. /**
  15118. * Casts a ray forward from the vrCamera's gaze.
  15119. * @param length Length of the ray (default: 100)
  15120. * @returns the ray corresponding to the gaze
  15121. */
  15122. getForwardRay(length?: number): Ray;
  15123. /**
  15124. * @hidden
  15125. * Updates the camera based on device's frame data
  15126. */
  15127. _checkInputs(): void;
  15128. /**
  15129. * Updates the poseControlled values based on the input device pose.
  15130. * @param poseData Pose coming from the device
  15131. */
  15132. updateFromDevice(poseData: DevicePose): void;
  15133. private _htmlElementAttached;
  15134. private _detachIfAttached;
  15135. /**
  15136. * WebVR's attach control will start broadcasting frames to the device.
  15137. * Note that in certain browsers (chrome for example) this function must be called
  15138. * within a user-interaction callback. Example:
  15139. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15140. *
  15141. * @param element html element to attach the vrDevice to
  15142. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15143. */
  15144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15145. /**
  15146. * Detaches the camera from the html element and disables VR
  15147. *
  15148. * @param element html element to detach from
  15149. */
  15150. detachControl(element: HTMLElement): void;
  15151. /**
  15152. * @returns the name of this class
  15153. */
  15154. getClassName(): string;
  15155. /**
  15156. * Calls resetPose on the vrDisplay
  15157. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15158. */
  15159. resetToCurrentRotation(): void;
  15160. /**
  15161. * @hidden
  15162. * Updates the rig cameras (left and right eye)
  15163. */
  15164. _updateRigCameras(): void;
  15165. private _workingVector;
  15166. private _oneVector;
  15167. private _workingMatrix;
  15168. private updateCacheCalled;
  15169. private _correctPositionIfNotTrackPosition;
  15170. /**
  15171. * @hidden
  15172. * Updates the cached values of the camera
  15173. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15174. */
  15175. _updateCache(ignoreParentClass?: boolean): void;
  15176. /**
  15177. * @hidden
  15178. * Get current device position in babylon world
  15179. */
  15180. _computeDevicePosition(): void;
  15181. /**
  15182. * Updates the current device position and rotation in the babylon world
  15183. */
  15184. update(): void;
  15185. /**
  15186. * @hidden
  15187. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15188. * @returns an identity matrix
  15189. */
  15190. _getViewMatrix(): Matrix;
  15191. private _tmpMatrix;
  15192. /**
  15193. * This function is called by the two RIG cameras.
  15194. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15195. * @hidden
  15196. */
  15197. _getWebVRViewMatrix(): Matrix;
  15198. /** @hidden */
  15199. _getWebVRProjectionMatrix(): Matrix;
  15200. private _onGamepadConnectedObserver;
  15201. private _onGamepadDisconnectedObserver;
  15202. private _updateCacheWhenTrackingDisabledObserver;
  15203. /**
  15204. * Initializes the controllers and their meshes
  15205. */
  15206. initControllers(): void;
  15207. }
  15208. }
  15209. declare module BABYLON {
  15210. /**
  15211. * Size options for a post process
  15212. */
  15213. export type PostProcessOptions = {
  15214. width: number;
  15215. height: number;
  15216. };
  15217. /**
  15218. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15219. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15220. */
  15221. export class PostProcess {
  15222. /** Name of the PostProcess. */
  15223. name: string;
  15224. /**
  15225. * Gets or sets the unique id of the post process
  15226. */
  15227. uniqueId: number;
  15228. /**
  15229. * Width of the texture to apply the post process on
  15230. */
  15231. width: number;
  15232. /**
  15233. * Height of the texture to apply the post process on
  15234. */
  15235. height: number;
  15236. /**
  15237. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15238. * @hidden
  15239. */
  15240. _outputTexture: Nullable<InternalTexture>;
  15241. /**
  15242. * Sampling mode used by the shader
  15243. * See https://doc.babylonjs.com/classes/3.1/texture
  15244. */
  15245. renderTargetSamplingMode: number;
  15246. /**
  15247. * Clear color to use when screen clearing
  15248. */
  15249. clearColor: Color4;
  15250. /**
  15251. * If the buffer needs to be cleared before applying the post process. (default: true)
  15252. * Should be set to false if shader will overwrite all previous pixels.
  15253. */
  15254. autoClear: boolean;
  15255. /**
  15256. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15257. */
  15258. alphaMode: number;
  15259. /**
  15260. * Sets the setAlphaBlendConstants of the babylon engine
  15261. */
  15262. alphaConstants: Color4;
  15263. /**
  15264. * Animations to be used for the post processing
  15265. */
  15266. animations: Animation[];
  15267. /**
  15268. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15269. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15270. */
  15271. enablePixelPerfectMode: boolean;
  15272. /**
  15273. * Force the postprocess to be applied without taking in account viewport
  15274. */
  15275. forceFullscreenViewport: boolean;
  15276. /**
  15277. * List of inspectable custom properties (used by the Inspector)
  15278. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15279. */
  15280. inspectableCustomProperties: IInspectable[];
  15281. /**
  15282. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15283. *
  15284. * | Value | Type | Description |
  15285. * | ----- | ----------------------------------- | ----------- |
  15286. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15287. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15288. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15289. *
  15290. */
  15291. scaleMode: number;
  15292. /**
  15293. * Force textures to be a power of two (default: false)
  15294. */
  15295. alwaysForcePOT: boolean;
  15296. private _samples;
  15297. /**
  15298. * Number of sample textures (default: 1)
  15299. */
  15300. samples: number;
  15301. /**
  15302. * Modify the scale of the post process to be the same as the viewport (default: false)
  15303. */
  15304. adaptScaleToCurrentViewport: boolean;
  15305. private _camera;
  15306. private _scene;
  15307. private _engine;
  15308. private _options;
  15309. private _reusable;
  15310. private _textureType;
  15311. /**
  15312. * Smart array of input and output textures for the post process.
  15313. * @hidden
  15314. */
  15315. _textures: SmartArray<InternalTexture>;
  15316. /**
  15317. * The index in _textures that corresponds to the output texture.
  15318. * @hidden
  15319. */
  15320. _currentRenderTextureInd: number;
  15321. private _effect;
  15322. private _samplers;
  15323. private _fragmentUrl;
  15324. private _vertexUrl;
  15325. private _parameters;
  15326. private _scaleRatio;
  15327. protected _indexParameters: any;
  15328. private _shareOutputWithPostProcess;
  15329. private _texelSize;
  15330. private _forcedOutputTexture;
  15331. /**
  15332. * Returns the fragment url or shader name used in the post process.
  15333. * @returns the fragment url or name in the shader store.
  15334. */
  15335. getEffectName(): string;
  15336. /**
  15337. * An event triggered when the postprocess is activated.
  15338. */
  15339. onActivateObservable: Observable<Camera>;
  15340. private _onActivateObserver;
  15341. /**
  15342. * A function that is added to the onActivateObservable
  15343. */
  15344. onActivate: Nullable<(camera: Camera) => void>;
  15345. /**
  15346. * An event triggered when the postprocess changes its size.
  15347. */
  15348. onSizeChangedObservable: Observable<PostProcess>;
  15349. private _onSizeChangedObserver;
  15350. /**
  15351. * A function that is added to the onSizeChangedObservable
  15352. */
  15353. onSizeChanged: (postProcess: PostProcess) => void;
  15354. /**
  15355. * An event triggered when the postprocess applies its effect.
  15356. */
  15357. onApplyObservable: Observable<Effect>;
  15358. private _onApplyObserver;
  15359. /**
  15360. * A function that is added to the onApplyObservable
  15361. */
  15362. onApply: (effect: Effect) => void;
  15363. /**
  15364. * An event triggered before rendering the postprocess
  15365. */
  15366. onBeforeRenderObservable: Observable<Effect>;
  15367. private _onBeforeRenderObserver;
  15368. /**
  15369. * A function that is added to the onBeforeRenderObservable
  15370. */
  15371. onBeforeRender: (effect: Effect) => void;
  15372. /**
  15373. * An event triggered after rendering the postprocess
  15374. */
  15375. onAfterRenderObservable: Observable<Effect>;
  15376. private _onAfterRenderObserver;
  15377. /**
  15378. * A function that is added to the onAfterRenderObservable
  15379. */
  15380. onAfterRender: (efect: Effect) => void;
  15381. /**
  15382. * 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
  15383. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15384. */
  15385. inputTexture: InternalTexture;
  15386. /**
  15387. * Gets the camera which post process is applied to.
  15388. * @returns The camera the post process is applied to.
  15389. */
  15390. getCamera(): Camera;
  15391. /**
  15392. * Gets the texel size of the postprocess.
  15393. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15394. */
  15395. readonly texelSize: Vector2;
  15396. /**
  15397. * Creates a new instance PostProcess
  15398. * @param name The name of the PostProcess.
  15399. * @param fragmentUrl The url of the fragment shader to be used.
  15400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15403. * @param camera The camera to apply the render pass to.
  15404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15405. * @param engine The engine which the post process will be applied. (default: current engine)
  15406. * @param reusable If the post process can be reused on the same frame. (default: false)
  15407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15408. * @param textureType Type of textures used when performing the post process. (default: 0)
  15409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15410. * @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
  15411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15412. */
  15413. constructor(
  15414. /** Name of the PostProcess. */
  15415. 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);
  15416. /**
  15417. * Gets a string idenfifying the name of the class
  15418. * @returns "PostProcess" string
  15419. */
  15420. getClassName(): string;
  15421. /**
  15422. * Gets the engine which this post process belongs to.
  15423. * @returns The engine the post process was enabled with.
  15424. */
  15425. getEngine(): Engine;
  15426. /**
  15427. * The effect that is created when initializing the post process.
  15428. * @returns The created effect corresponding the the postprocess.
  15429. */
  15430. getEffect(): Effect;
  15431. /**
  15432. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15433. * @param postProcess The post process to share the output with.
  15434. * @returns This post process.
  15435. */
  15436. shareOutputWith(postProcess: PostProcess): PostProcess;
  15437. /**
  15438. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15439. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15440. */
  15441. useOwnOutput(): void;
  15442. /**
  15443. * Updates the effect with the current post process compile time values and recompiles the shader.
  15444. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15445. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15446. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15447. * @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
  15448. * @param onCompiled Called when the shader has been compiled.
  15449. * @param onError Called if there is an error when compiling a shader.
  15450. */
  15451. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15452. /**
  15453. * The post process is reusable if it can be used multiple times within one frame.
  15454. * @returns If the post process is reusable
  15455. */
  15456. isReusable(): boolean;
  15457. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15458. markTextureDirty(): void;
  15459. /**
  15460. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15461. * 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.
  15462. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15463. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15464. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15465. * @returns The target texture that was bound to be written to.
  15466. */
  15467. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15468. /**
  15469. * If the post process is supported.
  15470. */
  15471. readonly isSupported: boolean;
  15472. /**
  15473. * The aspect ratio of the output texture.
  15474. */
  15475. readonly aspectRatio: number;
  15476. /**
  15477. * Get a value indicating if the post-process is ready to be used
  15478. * @returns true if the post-process is ready (shader is compiled)
  15479. */
  15480. isReady(): boolean;
  15481. /**
  15482. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15483. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15484. */
  15485. apply(): Nullable<Effect>;
  15486. private _disposeTextures;
  15487. /**
  15488. * Disposes the post process.
  15489. * @param camera The camera to dispose the post process on.
  15490. */
  15491. dispose(camera?: Camera): void;
  15492. }
  15493. }
  15494. declare module BABYLON {
  15495. /** @hidden */
  15496. export var kernelBlurVaryingDeclaration: {
  15497. name: string;
  15498. shader: string;
  15499. };
  15500. }
  15501. declare module BABYLON {
  15502. /** @hidden */
  15503. export var kernelBlurFragment: {
  15504. name: string;
  15505. shader: string;
  15506. };
  15507. }
  15508. declare module BABYLON {
  15509. /** @hidden */
  15510. export var kernelBlurFragment2: {
  15511. name: string;
  15512. shader: string;
  15513. };
  15514. }
  15515. declare module BABYLON {
  15516. /** @hidden */
  15517. export var kernelBlurPixelShader: {
  15518. name: string;
  15519. shader: string;
  15520. };
  15521. }
  15522. declare module BABYLON {
  15523. /** @hidden */
  15524. export var kernelBlurVertex: {
  15525. name: string;
  15526. shader: string;
  15527. };
  15528. }
  15529. declare module BABYLON {
  15530. /** @hidden */
  15531. export var kernelBlurVertexShader: {
  15532. name: string;
  15533. shader: string;
  15534. };
  15535. }
  15536. declare module BABYLON {
  15537. /**
  15538. * The Blur Post Process which blurs an image based on a kernel and direction.
  15539. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15540. */
  15541. export class BlurPostProcess extends PostProcess {
  15542. /** The direction in which to blur the image. */
  15543. direction: Vector2;
  15544. private blockCompilation;
  15545. protected _kernel: number;
  15546. protected _idealKernel: number;
  15547. protected _packedFloat: boolean;
  15548. private _staticDefines;
  15549. /**
  15550. * Sets the length in pixels of the blur sample region
  15551. */
  15552. /**
  15553. * Gets the length in pixels of the blur sample region
  15554. */
  15555. kernel: number;
  15556. /**
  15557. * Sets wether or not the blur needs to unpack/repack floats
  15558. */
  15559. /**
  15560. * Gets wether or not the blur is unpacking/repacking floats
  15561. */
  15562. packedFloat: boolean;
  15563. /**
  15564. * Creates a new instance BlurPostProcess
  15565. * @param name The name of the effect.
  15566. * @param direction The direction in which to blur the image.
  15567. * @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.
  15568. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15569. * @param camera The camera to apply the render pass to.
  15570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15571. * @param engine The engine which the post process will be applied. (default: current engine)
  15572. * @param reusable If the post process can be reused on the same frame. (default: false)
  15573. * @param textureType Type of textures used when performing the post process. (default: 0)
  15574. * @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)
  15575. */
  15576. constructor(name: string,
  15577. /** The direction in which to blur the image. */
  15578. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15579. /**
  15580. * Updates the effect with the current post process compile time values and recompiles the shader.
  15581. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15582. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15583. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15584. * @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
  15585. * @param onCompiled Called when the shader has been compiled.
  15586. * @param onError Called if there is an error when compiling a shader.
  15587. */
  15588. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15589. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15590. /**
  15591. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15592. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15593. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15594. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15595. * The gaps between physical kernels are compensated for in the weighting of the samples
  15596. * @param idealKernel Ideal blur kernel.
  15597. * @return Nearest best kernel.
  15598. */
  15599. protected _nearestBestKernel(idealKernel: number): number;
  15600. /**
  15601. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15602. * @param x The point on the Gaussian distribution to sample.
  15603. * @return the value of the Gaussian function at x.
  15604. */
  15605. protected _gaussianWeight(x: number): number;
  15606. /**
  15607. * Generates a string that can be used as a floating point number in GLSL.
  15608. * @param x Value to print.
  15609. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15610. * @return GLSL float string.
  15611. */
  15612. protected _glslFloat(x: number, decimalFigures?: number): string;
  15613. }
  15614. }
  15615. declare module BABYLON {
  15616. /**
  15617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15619. * You can then easily use it as a reflectionTexture on a flat surface.
  15620. * In case the surface is not a plane, please consider relying on reflection probes.
  15621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15622. */
  15623. export class MirrorTexture extends RenderTargetTexture {
  15624. private scene;
  15625. /**
  15626. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15627. * 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.
  15628. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15629. */
  15630. mirrorPlane: Plane;
  15631. /**
  15632. * Define the blur ratio used to blur the reflection if needed.
  15633. */
  15634. blurRatio: number;
  15635. /**
  15636. * Define the adaptive blur kernel used to blur the reflection if needed.
  15637. * This will autocompute the closest best match for the `blurKernel`
  15638. */
  15639. adaptiveBlurKernel: number;
  15640. /**
  15641. * Define the blur kernel used to blur the reflection if needed.
  15642. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15643. */
  15644. blurKernel: number;
  15645. /**
  15646. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15647. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15648. */
  15649. blurKernelX: number;
  15650. /**
  15651. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15652. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15653. */
  15654. blurKernelY: number;
  15655. private _autoComputeBlurKernel;
  15656. protected _onRatioRescale(): void;
  15657. private _updateGammaSpace;
  15658. private _imageProcessingConfigChangeObserver;
  15659. private _transformMatrix;
  15660. private _mirrorMatrix;
  15661. private _savedViewMatrix;
  15662. private _blurX;
  15663. private _blurY;
  15664. private _adaptiveBlurKernel;
  15665. private _blurKernelX;
  15666. private _blurKernelY;
  15667. private _blurRatio;
  15668. /**
  15669. * Instantiates a Mirror Texture.
  15670. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15671. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15672. * You can then easily use it as a reflectionTexture on a flat surface.
  15673. * In case the surface is not a plane, please consider relying on reflection probes.
  15674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15675. * @param name
  15676. * @param size
  15677. * @param scene
  15678. * @param generateMipMaps
  15679. * @param type
  15680. * @param samplingMode
  15681. * @param generateDepthBuffer
  15682. */
  15683. constructor(name: string, size: number | {
  15684. width: number;
  15685. height: number;
  15686. } | {
  15687. ratio: number;
  15688. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15689. private _preparePostProcesses;
  15690. /**
  15691. * Clone the mirror texture.
  15692. * @returns the cloned texture
  15693. */
  15694. clone(): MirrorTexture;
  15695. /**
  15696. * Serialize the texture to a JSON representation you could use in Parse later on
  15697. * @returns the serialized JSON representation
  15698. */
  15699. serialize(): any;
  15700. /**
  15701. * Dispose the texture and release its associated resources.
  15702. */
  15703. dispose(): void;
  15704. }
  15705. }
  15706. declare module BABYLON {
  15707. /**
  15708. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15709. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15710. */
  15711. export class Texture extends BaseTexture {
  15712. /**
  15713. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15714. */
  15715. static SerializeBuffers: boolean;
  15716. /** @hidden */
  15717. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15718. /** @hidden */
  15719. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15720. /** @hidden */
  15721. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15722. /** nearest is mag = nearest and min = nearest and mip = linear */
  15723. static readonly NEAREST_SAMPLINGMODE: number;
  15724. /** nearest is mag = nearest and min = nearest and mip = linear */
  15725. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15726. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15727. static readonly BILINEAR_SAMPLINGMODE: number;
  15728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15729. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15730. /** Trilinear is mag = linear and min = linear and mip = linear */
  15731. static readonly TRILINEAR_SAMPLINGMODE: number;
  15732. /** Trilinear is mag = linear and min = linear and mip = linear */
  15733. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15734. /** mag = nearest and min = nearest and mip = nearest */
  15735. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15736. /** mag = nearest and min = linear and mip = nearest */
  15737. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15738. /** mag = nearest and min = linear and mip = linear */
  15739. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15740. /** mag = nearest and min = linear and mip = none */
  15741. static readonly NEAREST_LINEAR: number;
  15742. /** mag = nearest and min = nearest and mip = none */
  15743. static readonly NEAREST_NEAREST: number;
  15744. /** mag = linear and min = nearest and mip = nearest */
  15745. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15746. /** mag = linear and min = nearest and mip = linear */
  15747. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15748. /** mag = linear and min = linear and mip = none */
  15749. static readonly LINEAR_LINEAR: number;
  15750. /** mag = linear and min = nearest and mip = none */
  15751. static readonly LINEAR_NEAREST: number;
  15752. /** Explicit coordinates mode */
  15753. static readonly EXPLICIT_MODE: number;
  15754. /** Spherical coordinates mode */
  15755. static readonly SPHERICAL_MODE: number;
  15756. /** Planar coordinates mode */
  15757. static readonly PLANAR_MODE: number;
  15758. /** Cubic coordinates mode */
  15759. static readonly CUBIC_MODE: number;
  15760. /** Projection coordinates mode */
  15761. static readonly PROJECTION_MODE: number;
  15762. /** Inverse Cubic coordinates mode */
  15763. static readonly SKYBOX_MODE: number;
  15764. /** Inverse Cubic coordinates mode */
  15765. static readonly INVCUBIC_MODE: number;
  15766. /** Equirectangular coordinates mode */
  15767. static readonly EQUIRECTANGULAR_MODE: number;
  15768. /** Equirectangular Fixed coordinates mode */
  15769. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15770. /** Equirectangular Fixed Mirrored coordinates mode */
  15771. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15772. /** Texture is not repeating outside of 0..1 UVs */
  15773. static readonly CLAMP_ADDRESSMODE: number;
  15774. /** Texture is repeating outside of 0..1 UVs */
  15775. static readonly WRAP_ADDRESSMODE: number;
  15776. /** Texture is repeating and mirrored */
  15777. static readonly MIRROR_ADDRESSMODE: number;
  15778. /**
  15779. * 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
  15780. */
  15781. static UseSerializedUrlIfAny: boolean;
  15782. /**
  15783. * Define the url of the texture.
  15784. */
  15785. url: Nullable<string>;
  15786. /**
  15787. * Define an offset on the texture to offset the u coordinates of the UVs
  15788. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15789. */
  15790. uOffset: number;
  15791. /**
  15792. * Define an offset on the texture to offset the v coordinates of the UVs
  15793. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15794. */
  15795. vOffset: number;
  15796. /**
  15797. * Define an offset on the texture to scale the u coordinates of the UVs
  15798. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15799. */
  15800. uScale: number;
  15801. /**
  15802. * Define an offset on the texture to scale the v coordinates of the UVs
  15803. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15804. */
  15805. vScale: number;
  15806. /**
  15807. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15808. * @see http://doc.babylonjs.com/how_to/more_materials
  15809. */
  15810. uAng: number;
  15811. /**
  15812. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15813. * @see http://doc.babylonjs.com/how_to/more_materials
  15814. */
  15815. vAng: number;
  15816. /**
  15817. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15818. * @see http://doc.babylonjs.com/how_to/more_materials
  15819. */
  15820. wAng: number;
  15821. /**
  15822. * Defines the center of rotation (U)
  15823. */
  15824. uRotationCenter: number;
  15825. /**
  15826. * Defines the center of rotation (V)
  15827. */
  15828. vRotationCenter: number;
  15829. /**
  15830. * Defines the center of rotation (W)
  15831. */
  15832. wRotationCenter: number;
  15833. /**
  15834. * Are mip maps generated for this texture or not.
  15835. */
  15836. readonly noMipmap: boolean;
  15837. /**
  15838. * List of inspectable custom properties (used by the Inspector)
  15839. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15840. */
  15841. inspectableCustomProperties: Nullable<IInspectable[]>;
  15842. private _noMipmap;
  15843. /** @hidden */
  15844. _invertY: boolean;
  15845. private _rowGenerationMatrix;
  15846. private _cachedTextureMatrix;
  15847. private _projectionModeMatrix;
  15848. private _t0;
  15849. private _t1;
  15850. private _t2;
  15851. private _cachedUOffset;
  15852. private _cachedVOffset;
  15853. private _cachedUScale;
  15854. private _cachedVScale;
  15855. private _cachedUAng;
  15856. private _cachedVAng;
  15857. private _cachedWAng;
  15858. private _cachedProjectionMatrixId;
  15859. private _cachedCoordinatesMode;
  15860. /** @hidden */
  15861. protected _initialSamplingMode: number;
  15862. /** @hidden */
  15863. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15864. private _deleteBuffer;
  15865. protected _format: Nullable<number>;
  15866. private _delayedOnLoad;
  15867. private _delayedOnError;
  15868. /**
  15869. * Observable triggered once the texture has been loaded.
  15870. */
  15871. onLoadObservable: Observable<Texture>;
  15872. protected _isBlocking: boolean;
  15873. /**
  15874. * Is the texture preventing material to render while loading.
  15875. * If false, a default texture will be used instead of the loading one during the preparation step.
  15876. */
  15877. isBlocking: boolean;
  15878. /**
  15879. * Get the current sampling mode associated with the texture.
  15880. */
  15881. readonly samplingMode: number;
  15882. /**
  15883. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15884. */
  15885. readonly invertY: boolean;
  15886. /**
  15887. * Instantiates a new texture.
  15888. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15889. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15890. * @param url define the url of the picture to load as a texture
  15891. * @param scene define the scene or engine the texture will belong to
  15892. * @param noMipmap define if the texture will require mip maps or not
  15893. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15894. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15895. * @param onLoad define a callback triggered when the texture has been loaded
  15896. * @param onError define a callback triggered when an error occurred during the loading session
  15897. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15898. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15899. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15900. */
  15901. 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);
  15902. /**
  15903. * Update the url (and optional buffer) of this texture if url was null during construction.
  15904. * @param url the url of the texture
  15905. * @param buffer the buffer of the texture (defaults to null)
  15906. * @param onLoad callback called when the texture is loaded (defaults to null)
  15907. */
  15908. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15909. /**
  15910. * Finish the loading sequence of a texture flagged as delayed load.
  15911. * @hidden
  15912. */
  15913. delayLoad(): void;
  15914. private _prepareRowForTextureGeneration;
  15915. /**
  15916. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15917. * @returns the transform matrix of the texture.
  15918. */
  15919. getTextureMatrix(): Matrix;
  15920. /**
  15921. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15922. * @returns The reflection texture transform
  15923. */
  15924. getReflectionTextureMatrix(): Matrix;
  15925. /**
  15926. * Clones the texture.
  15927. * @returns the cloned texture
  15928. */
  15929. clone(): Texture;
  15930. /**
  15931. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15932. * @returns The JSON representation of the texture
  15933. */
  15934. serialize(): any;
  15935. /**
  15936. * Get the current class name of the texture useful for serialization or dynamic coding.
  15937. * @returns "Texture"
  15938. */
  15939. getClassName(): string;
  15940. /**
  15941. * Dispose the texture and release its associated resources.
  15942. */
  15943. dispose(): void;
  15944. /**
  15945. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15946. * @param parsedTexture Define the JSON representation of the texture
  15947. * @param scene Define the scene the parsed texture should be instantiated in
  15948. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15949. * @returns The parsed texture if successful
  15950. */
  15951. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15952. /**
  15953. * Creates a texture from its base 64 representation.
  15954. * @param data Define the base64 payload without the data: prefix
  15955. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15956. * @param scene Define the scene the texture should belong to
  15957. * @param noMipmap Forces the texture to not create mip map information if true
  15958. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15959. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15960. * @param onLoad define a callback triggered when the texture has been loaded
  15961. * @param onError define a callback triggered when an error occurred during the loading session
  15962. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15963. * @returns the created texture
  15964. */
  15965. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15966. /**
  15967. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15968. * @param data Define the base64 payload without the data: prefix
  15969. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15970. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15971. * @param scene Define the scene the texture should belong to
  15972. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15973. * @param noMipmap Forces the texture to not create mip map information if true
  15974. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15975. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15976. * @param onLoad define a callback triggered when the texture has been loaded
  15977. * @param onError define a callback triggered when an error occurred during the loading session
  15978. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15979. * @returns the created texture
  15980. */
  15981. 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;
  15982. }
  15983. }
  15984. declare module BABYLON {
  15985. /**
  15986. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15987. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15988. */
  15989. export class PostProcessManager {
  15990. private _scene;
  15991. private _indexBuffer;
  15992. private _vertexBuffers;
  15993. /**
  15994. * Creates a new instance PostProcess
  15995. * @param scene The scene that the post process is associated with.
  15996. */
  15997. constructor(scene: Scene);
  15998. private _prepareBuffers;
  15999. private _buildIndexBuffer;
  16000. /**
  16001. * Rebuilds the vertex buffers of the manager.
  16002. * @hidden
  16003. */
  16004. _rebuild(): void;
  16005. /**
  16006. * Prepares a frame to be run through a post process.
  16007. * @param sourceTexture The input texture to the post procesess. (default: null)
  16008. * @param postProcesses An array of post processes to be run. (default: null)
  16009. * @returns True if the post processes were able to be run.
  16010. * @hidden
  16011. */
  16012. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16013. /**
  16014. * Manually render a set of post processes to a texture.
  16015. * @param postProcesses An array of post processes to be run.
  16016. * @param targetTexture The target texture to render to.
  16017. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16018. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16019. * @param lodLevel defines which lod of the texture to render to
  16020. */
  16021. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16022. /**
  16023. * Finalize the result of the output of the postprocesses.
  16024. * @param doNotPresent If true the result will not be displayed to the screen.
  16025. * @param targetTexture The target texture to render to.
  16026. * @param faceIndex The index of the face to bind the target texture to.
  16027. * @param postProcesses The array of post processes to render.
  16028. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16029. * @hidden
  16030. */
  16031. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16032. /**
  16033. * Disposes of the post process manager.
  16034. */
  16035. dispose(): void;
  16036. }
  16037. }
  16038. declare module BABYLON {
  16039. /** Interface used by value gradients (color, factor, ...) */
  16040. export interface IValueGradient {
  16041. /**
  16042. * Gets or sets the gradient value (between 0 and 1)
  16043. */
  16044. gradient: number;
  16045. }
  16046. /** Class used to store color4 gradient */
  16047. export class ColorGradient implements IValueGradient {
  16048. /**
  16049. * Gets or sets the gradient value (between 0 and 1)
  16050. */
  16051. gradient: number;
  16052. /**
  16053. * Gets or sets first associated color
  16054. */
  16055. color1: Color4;
  16056. /**
  16057. * Gets or sets second associated color
  16058. */
  16059. color2?: Color4;
  16060. /**
  16061. * Will get a color picked randomly between color1 and color2.
  16062. * If color2 is undefined then color1 will be used
  16063. * @param result defines the target Color4 to store the result in
  16064. */
  16065. getColorToRef(result: Color4): void;
  16066. }
  16067. /** Class used to store color 3 gradient */
  16068. export class Color3Gradient implements IValueGradient {
  16069. /**
  16070. * Gets or sets the gradient value (between 0 and 1)
  16071. */
  16072. gradient: number;
  16073. /**
  16074. * Gets or sets the associated color
  16075. */
  16076. color: Color3;
  16077. }
  16078. /** Class used to store factor gradient */
  16079. export class FactorGradient implements IValueGradient {
  16080. /**
  16081. * Gets or sets the gradient value (between 0 and 1)
  16082. */
  16083. gradient: number;
  16084. /**
  16085. * Gets or sets first associated factor
  16086. */
  16087. factor1: number;
  16088. /**
  16089. * Gets or sets second associated factor
  16090. */
  16091. factor2?: number;
  16092. /**
  16093. * Will get a number picked randomly between factor1 and factor2.
  16094. * If factor2 is undefined then factor1 will be used
  16095. * @returns the picked number
  16096. */
  16097. getFactor(): number;
  16098. }
  16099. /**
  16100. * Helper used to simplify some generic gradient tasks
  16101. */
  16102. export class GradientHelper {
  16103. /**
  16104. * Gets the current gradient from an array of IValueGradient
  16105. * @param ratio defines the current ratio to get
  16106. * @param gradients defines the array of IValueGradient
  16107. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16108. */
  16109. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16110. }
  16111. }
  16112. declare module BABYLON {
  16113. interface ThinEngine {
  16114. /**
  16115. * Creates a dynamic texture
  16116. * @param width defines the width of the texture
  16117. * @param height defines the height of the texture
  16118. * @param generateMipMaps defines if the engine should generate the mip levels
  16119. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16120. * @returns the dynamic texture inside an InternalTexture
  16121. */
  16122. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16123. /**
  16124. * Update the content of a dynamic texture
  16125. * @param texture defines the texture to update
  16126. * @param canvas defines the canvas containing the source
  16127. * @param invertY defines if data must be stored with Y axis inverted
  16128. * @param premulAlpha defines if alpha is stored as premultiplied
  16129. * @param format defines the format of the data
  16130. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16131. */
  16132. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16133. }
  16134. }
  16135. declare module BABYLON {
  16136. /**
  16137. * A class extending Texture allowing drawing on a texture
  16138. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16139. */
  16140. export class DynamicTexture extends Texture {
  16141. private _generateMipMaps;
  16142. private _canvas;
  16143. private _context;
  16144. private _engine;
  16145. /**
  16146. * Creates a DynamicTexture
  16147. * @param name defines the name of the texture
  16148. * @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
  16149. * @param scene defines the scene where you want the texture
  16150. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16151. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16152. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16153. */
  16154. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16155. /**
  16156. * Get the current class name of the texture useful for serialization or dynamic coding.
  16157. * @returns "DynamicTexture"
  16158. */
  16159. getClassName(): string;
  16160. /**
  16161. * Gets the current state of canRescale
  16162. */
  16163. readonly canRescale: boolean;
  16164. private _recreate;
  16165. /**
  16166. * Scales the texture
  16167. * @param ratio the scale factor to apply to both width and height
  16168. */
  16169. scale(ratio: number): void;
  16170. /**
  16171. * Resizes the texture
  16172. * @param width the new width
  16173. * @param height the new height
  16174. */
  16175. scaleTo(width: number, height: number): void;
  16176. /**
  16177. * Gets the context of the canvas used by the texture
  16178. * @returns the canvas context of the dynamic texture
  16179. */
  16180. getContext(): CanvasRenderingContext2D;
  16181. /**
  16182. * Clears the texture
  16183. */
  16184. clear(): void;
  16185. /**
  16186. * Updates the texture
  16187. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16188. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16189. */
  16190. update(invertY?: boolean, premulAlpha?: boolean): void;
  16191. /**
  16192. * Draws text onto the texture
  16193. * @param text defines the text to be drawn
  16194. * @param x defines the placement of the text from the left
  16195. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16196. * @param font defines the font to be used with font-style, font-size, font-name
  16197. * @param color defines the color used for the text
  16198. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16199. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16200. * @param update defines whether texture is immediately update (default is true)
  16201. */
  16202. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16203. /**
  16204. * Clones the texture
  16205. * @returns the clone of the texture.
  16206. */
  16207. clone(): DynamicTexture;
  16208. /**
  16209. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16210. * @returns a serialized dynamic texture object
  16211. */
  16212. serialize(): any;
  16213. /** @hidden */
  16214. _rebuild(): void;
  16215. }
  16216. }
  16217. declare module BABYLON {
  16218. interface AbstractScene {
  16219. /**
  16220. * The list of procedural textures added to the scene
  16221. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16222. */
  16223. proceduralTextures: Array<ProceduralTexture>;
  16224. }
  16225. /**
  16226. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16227. * in a given scene.
  16228. */
  16229. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16230. /**
  16231. * The component name helpfull to identify the component in the list of scene components.
  16232. */
  16233. readonly name: string;
  16234. /**
  16235. * The scene the component belongs to.
  16236. */
  16237. scene: Scene;
  16238. /**
  16239. * Creates a new instance of the component for the given scene
  16240. * @param scene Defines the scene to register the component in
  16241. */
  16242. constructor(scene: Scene);
  16243. /**
  16244. * Registers the component in a given scene
  16245. */
  16246. register(): void;
  16247. /**
  16248. * Rebuilds the elements related to this component in case of
  16249. * context lost for instance.
  16250. */
  16251. rebuild(): void;
  16252. /**
  16253. * Disposes the component and the associated ressources.
  16254. */
  16255. dispose(): void;
  16256. private _beforeClear;
  16257. }
  16258. }
  16259. declare module BABYLON {
  16260. interface ThinEngine {
  16261. /**
  16262. * Creates a new render target cube texture
  16263. * @param size defines the size of the texture
  16264. * @param options defines the options used to create the texture
  16265. * @returns a new render target cube texture stored in an InternalTexture
  16266. */
  16267. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16268. }
  16269. }
  16270. declare module BABYLON {
  16271. /** @hidden */
  16272. export var proceduralVertexShader: {
  16273. name: string;
  16274. shader: string;
  16275. };
  16276. }
  16277. declare module BABYLON {
  16278. /**
  16279. * 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.
  16280. * This is the base class of any Procedural texture and contains most of the shareable code.
  16281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16282. */
  16283. export class ProceduralTexture extends Texture {
  16284. isCube: boolean;
  16285. /**
  16286. * Define if the texture is enabled or not (disabled texture will not render)
  16287. */
  16288. isEnabled: boolean;
  16289. /**
  16290. * Define if the texture must be cleared before rendering (default is true)
  16291. */
  16292. autoClear: boolean;
  16293. /**
  16294. * Callback called when the texture is generated
  16295. */
  16296. onGenerated: () => void;
  16297. /**
  16298. * Event raised when the texture is generated
  16299. */
  16300. onGeneratedObservable: Observable<ProceduralTexture>;
  16301. /** @hidden */
  16302. _generateMipMaps: boolean;
  16303. /** @hidden **/
  16304. _effect: Effect;
  16305. /** @hidden */
  16306. _textures: {
  16307. [key: string]: Texture;
  16308. };
  16309. private _size;
  16310. private _currentRefreshId;
  16311. private _refreshRate;
  16312. private _vertexBuffers;
  16313. private _indexBuffer;
  16314. private _uniforms;
  16315. private _samplers;
  16316. private _fragment;
  16317. private _floats;
  16318. private _ints;
  16319. private _floatsArrays;
  16320. private _colors3;
  16321. private _colors4;
  16322. private _vectors2;
  16323. private _vectors3;
  16324. private _matrices;
  16325. private _fallbackTexture;
  16326. private _fallbackTextureUsed;
  16327. private _engine;
  16328. private _cachedDefines;
  16329. private _contentUpdateId;
  16330. private _contentData;
  16331. /**
  16332. * Instantiates a new procedural texture.
  16333. * 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.
  16334. * This is the base class of any Procedural texture and contains most of the shareable code.
  16335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16336. * @param name Define the name of the texture
  16337. * @param size Define the size of the texture to create
  16338. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16339. * @param scene Define the scene the texture belongs to
  16340. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16341. * @param generateMipMaps Define if the texture should creates mip maps or not
  16342. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16343. */
  16344. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16345. /**
  16346. * The effect that is created when initializing the post process.
  16347. * @returns The created effect corresponding the the postprocess.
  16348. */
  16349. getEffect(): Effect;
  16350. /**
  16351. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16352. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16353. */
  16354. getContent(): Nullable<ArrayBufferView>;
  16355. private _createIndexBuffer;
  16356. /** @hidden */
  16357. _rebuild(): void;
  16358. /**
  16359. * Resets the texture in order to recreate its associated resources.
  16360. * This can be called in case of context loss
  16361. */
  16362. reset(): void;
  16363. protected _getDefines(): string;
  16364. /**
  16365. * Is the texture ready to be used ? (rendered at least once)
  16366. * @returns true if ready, otherwise, false.
  16367. */
  16368. isReady(): boolean;
  16369. /**
  16370. * Resets the refresh counter of the texture and start bak from scratch.
  16371. * Could be useful to regenerate the texture if it is setup to render only once.
  16372. */
  16373. resetRefreshCounter(): void;
  16374. /**
  16375. * Set the fragment shader to use in order to render the texture.
  16376. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16377. */
  16378. setFragment(fragment: any): void;
  16379. /**
  16380. * Define the refresh rate of the texture or the rendering frequency.
  16381. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16382. */
  16383. refreshRate: number;
  16384. /** @hidden */
  16385. _shouldRender(): boolean;
  16386. /**
  16387. * Get the size the texture is rendering at.
  16388. * @returns the size (texture is always squared)
  16389. */
  16390. getRenderSize(): number;
  16391. /**
  16392. * Resize the texture to new value.
  16393. * @param size Define the new size the texture should have
  16394. * @param generateMipMaps Define whether the new texture should create mip maps
  16395. */
  16396. resize(size: number, generateMipMaps: boolean): void;
  16397. private _checkUniform;
  16398. /**
  16399. * Set a texture in the shader program used to render.
  16400. * @param name Define the name of the uniform samplers as defined in the shader
  16401. * @param texture Define the texture to bind to this sampler
  16402. * @return the texture itself allowing "fluent" like uniform updates
  16403. */
  16404. setTexture(name: string, texture: Texture): ProceduralTexture;
  16405. /**
  16406. * Set a float in the shader.
  16407. * @param name Define the name of the uniform as defined in the shader
  16408. * @param value Define the value to give to the uniform
  16409. * @return the texture itself allowing "fluent" like uniform updates
  16410. */
  16411. setFloat(name: string, value: number): ProceduralTexture;
  16412. /**
  16413. * Set a int in the shader.
  16414. * @param name Define the name of the uniform as defined in the shader
  16415. * @param value Define the value to give to the uniform
  16416. * @return the texture itself allowing "fluent" like uniform updates
  16417. */
  16418. setInt(name: string, value: number): ProceduralTexture;
  16419. /**
  16420. * Set an array of floats in the shader.
  16421. * @param name Define the name of the uniform as defined in the shader
  16422. * @param value Define the value to give to the uniform
  16423. * @return the texture itself allowing "fluent" like uniform updates
  16424. */
  16425. setFloats(name: string, value: number[]): ProceduralTexture;
  16426. /**
  16427. * Set a vec3 in the shader from a Color3.
  16428. * @param name Define the name of the uniform as defined in the shader
  16429. * @param value Define the value to give to the uniform
  16430. * @return the texture itself allowing "fluent" like uniform updates
  16431. */
  16432. setColor3(name: string, value: Color3): ProceduralTexture;
  16433. /**
  16434. * Set a vec4 in the shader from a Color4.
  16435. * @param name Define the name of the uniform as defined in the shader
  16436. * @param value Define the value to give to the uniform
  16437. * @return the texture itself allowing "fluent" like uniform updates
  16438. */
  16439. setColor4(name: string, value: Color4): ProceduralTexture;
  16440. /**
  16441. * Set a vec2 in the shader from a Vector2.
  16442. * @param name Define the name of the uniform as defined in the shader
  16443. * @param value Define the value to give to the uniform
  16444. * @return the texture itself allowing "fluent" like uniform updates
  16445. */
  16446. setVector2(name: string, value: Vector2): ProceduralTexture;
  16447. /**
  16448. * Set a vec3 in the shader from a Vector3.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the texture itself allowing "fluent" like uniform updates
  16452. */
  16453. setVector3(name: string, value: Vector3): ProceduralTexture;
  16454. /**
  16455. * Set a mat4 in the shader from a MAtrix.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the texture itself allowing "fluent" like uniform updates
  16459. */
  16460. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16461. /**
  16462. * Render the texture to its associated render target.
  16463. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16464. */
  16465. render(useCameraPostProcess?: boolean): void;
  16466. /**
  16467. * Clone the texture.
  16468. * @returns the cloned texture
  16469. */
  16470. clone(): ProceduralTexture;
  16471. /**
  16472. * Dispose the texture and release its asoociated resources.
  16473. */
  16474. dispose(): void;
  16475. }
  16476. }
  16477. declare module BABYLON {
  16478. /**
  16479. * This represents the base class for particle system in Babylon.
  16480. * 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.
  16481. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16482. * @example https://doc.babylonjs.com/babylon101/particles
  16483. */
  16484. export class BaseParticleSystem {
  16485. /**
  16486. * Source color is added to the destination color without alpha affecting the result
  16487. */
  16488. static BLENDMODE_ONEONE: number;
  16489. /**
  16490. * Blend current color and particle color using particle’s alpha
  16491. */
  16492. static BLENDMODE_STANDARD: number;
  16493. /**
  16494. * Add current color and particle color multiplied by particle’s alpha
  16495. */
  16496. static BLENDMODE_ADD: number;
  16497. /**
  16498. * Multiply current color with particle color
  16499. */
  16500. static BLENDMODE_MULTIPLY: number;
  16501. /**
  16502. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16503. */
  16504. static BLENDMODE_MULTIPLYADD: number;
  16505. /**
  16506. * List of animations used by the particle system.
  16507. */
  16508. animations: Animation[];
  16509. /**
  16510. * The id of the Particle system.
  16511. */
  16512. id: string;
  16513. /**
  16514. * The friendly name of the Particle system.
  16515. */
  16516. name: string;
  16517. /**
  16518. * The rendering group used by the Particle system to chose when to render.
  16519. */
  16520. renderingGroupId: number;
  16521. /**
  16522. * The emitter represents the Mesh or position we are attaching the particle system to.
  16523. */
  16524. emitter: Nullable<AbstractMesh | Vector3>;
  16525. /**
  16526. * The maximum number of particles to emit per frame
  16527. */
  16528. emitRate: number;
  16529. /**
  16530. * If you want to launch only a few particles at once, that can be done, as well.
  16531. */
  16532. manualEmitCount: number;
  16533. /**
  16534. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16535. */
  16536. updateSpeed: number;
  16537. /**
  16538. * The amount of time the particle system is running (depends of the overall update speed).
  16539. */
  16540. targetStopDuration: number;
  16541. /**
  16542. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16543. */
  16544. disposeOnStop: boolean;
  16545. /**
  16546. * Minimum power of emitting particles.
  16547. */
  16548. minEmitPower: number;
  16549. /**
  16550. * Maximum power of emitting particles.
  16551. */
  16552. maxEmitPower: number;
  16553. /**
  16554. * Minimum life time of emitting particles.
  16555. */
  16556. minLifeTime: number;
  16557. /**
  16558. * Maximum life time of emitting particles.
  16559. */
  16560. maxLifeTime: number;
  16561. /**
  16562. * Minimum Size of emitting particles.
  16563. */
  16564. minSize: number;
  16565. /**
  16566. * Maximum Size of emitting particles.
  16567. */
  16568. maxSize: number;
  16569. /**
  16570. * Minimum scale of emitting particles on X axis.
  16571. */
  16572. minScaleX: number;
  16573. /**
  16574. * Maximum scale of emitting particles on X axis.
  16575. */
  16576. maxScaleX: number;
  16577. /**
  16578. * Minimum scale of emitting particles on Y axis.
  16579. */
  16580. minScaleY: number;
  16581. /**
  16582. * Maximum scale of emitting particles on Y axis.
  16583. */
  16584. maxScaleY: number;
  16585. /**
  16586. * Gets or sets the minimal initial rotation in radians.
  16587. */
  16588. minInitialRotation: number;
  16589. /**
  16590. * Gets or sets the maximal initial rotation in radians.
  16591. */
  16592. maxInitialRotation: number;
  16593. /**
  16594. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16595. */
  16596. minAngularSpeed: number;
  16597. /**
  16598. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16599. */
  16600. maxAngularSpeed: number;
  16601. /**
  16602. * The texture used to render each particle. (this can be a spritesheet)
  16603. */
  16604. particleTexture: Nullable<Texture>;
  16605. /**
  16606. * The layer mask we are rendering the particles through.
  16607. */
  16608. layerMask: number;
  16609. /**
  16610. * This can help using your own shader to render the particle system.
  16611. * The according effect will be created
  16612. */
  16613. customShader: any;
  16614. /**
  16615. * By default particle system starts as soon as they are created. This prevents the
  16616. * automatic start to happen and let you decide when to start emitting particles.
  16617. */
  16618. preventAutoStart: boolean;
  16619. private _noiseTexture;
  16620. /**
  16621. * Gets or sets a texture used to add random noise to particle positions
  16622. */
  16623. noiseTexture: Nullable<ProceduralTexture>;
  16624. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16625. noiseStrength: Vector3;
  16626. /**
  16627. * Callback triggered when the particle animation is ending.
  16628. */
  16629. onAnimationEnd: Nullable<() => void>;
  16630. /**
  16631. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16632. */
  16633. blendMode: number;
  16634. /**
  16635. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16636. * to override the particles.
  16637. */
  16638. forceDepthWrite: boolean;
  16639. /** 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 */
  16640. preWarmCycles: number;
  16641. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16642. preWarmStepOffset: number;
  16643. /**
  16644. * 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)
  16645. */
  16646. spriteCellChangeSpeed: number;
  16647. /**
  16648. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16649. */
  16650. startSpriteCellID: number;
  16651. /**
  16652. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16653. */
  16654. endSpriteCellID: number;
  16655. /**
  16656. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16657. */
  16658. spriteCellWidth: number;
  16659. /**
  16660. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16661. */
  16662. spriteCellHeight: number;
  16663. /**
  16664. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16665. */
  16666. spriteRandomStartCell: boolean;
  16667. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16668. translationPivot: Vector2;
  16669. /** @hidden */
  16670. protected _isAnimationSheetEnabled: boolean;
  16671. /**
  16672. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16673. */
  16674. beginAnimationOnStart: boolean;
  16675. /**
  16676. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16677. */
  16678. beginAnimationFrom: number;
  16679. /**
  16680. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16681. */
  16682. beginAnimationTo: number;
  16683. /**
  16684. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16685. */
  16686. beginAnimationLoop: boolean;
  16687. /**
  16688. * Gets or sets a world offset applied to all particles
  16689. */
  16690. worldOffset: Vector3;
  16691. /**
  16692. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16693. */
  16694. isAnimationSheetEnabled: boolean;
  16695. /**
  16696. * Get hosting scene
  16697. * @returns the scene
  16698. */
  16699. getScene(): Scene;
  16700. /**
  16701. * You can use gravity if you want to give an orientation to your particles.
  16702. */
  16703. gravity: Vector3;
  16704. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16705. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16706. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16707. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16708. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16709. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16710. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16711. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16712. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16713. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16714. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16715. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16716. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16717. /**
  16718. * Defines the delay in milliseconds before starting the system (0 by default)
  16719. */
  16720. startDelay: number;
  16721. /**
  16722. * Gets the current list of drag gradients.
  16723. * You must use addDragGradient and removeDragGradient to udpate this list
  16724. * @returns the list of drag gradients
  16725. */
  16726. getDragGradients(): Nullable<Array<FactorGradient>>;
  16727. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16728. limitVelocityDamping: number;
  16729. /**
  16730. * Gets the current list of limit velocity gradients.
  16731. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16732. * @returns the list of limit velocity gradients
  16733. */
  16734. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16735. /**
  16736. * Gets the current list of color gradients.
  16737. * You must use addColorGradient and removeColorGradient to udpate this list
  16738. * @returns the list of color gradients
  16739. */
  16740. getColorGradients(): Nullable<Array<ColorGradient>>;
  16741. /**
  16742. * Gets the current list of size gradients.
  16743. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16744. * @returns the list of size gradients
  16745. */
  16746. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16747. /**
  16748. * Gets the current list of color remap gradients.
  16749. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16750. * @returns the list of color remap gradients
  16751. */
  16752. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16753. /**
  16754. * Gets the current list of alpha remap gradients.
  16755. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16756. * @returns the list of alpha remap gradients
  16757. */
  16758. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16759. /**
  16760. * Gets the current list of life time gradients.
  16761. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16762. * @returns the list of life time gradients
  16763. */
  16764. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16765. /**
  16766. * Gets the current list of angular speed gradients.
  16767. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16768. * @returns the list of angular speed gradients
  16769. */
  16770. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Gets the current list of velocity gradients.
  16773. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16774. * @returns the list of velocity gradients
  16775. */
  16776. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16777. /**
  16778. * Gets the current list of start size gradients.
  16779. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16780. * @returns the list of start size gradients
  16781. */
  16782. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16783. /**
  16784. * Gets the current list of emit rate gradients.
  16785. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16786. * @returns the list of emit rate gradients
  16787. */
  16788. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16789. /**
  16790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16791. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16792. */
  16793. direction1: Vector3;
  16794. /**
  16795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16797. */
  16798. direction2: Vector3;
  16799. /**
  16800. * 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.
  16801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16802. */
  16803. minEmitBox: Vector3;
  16804. /**
  16805. * 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.
  16806. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16807. */
  16808. maxEmitBox: Vector3;
  16809. /**
  16810. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16811. */
  16812. color1: Color4;
  16813. /**
  16814. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16815. */
  16816. color2: Color4;
  16817. /**
  16818. * Color the particle will have at the end of its lifetime
  16819. */
  16820. colorDead: Color4;
  16821. /**
  16822. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16823. */
  16824. textureMask: Color4;
  16825. /**
  16826. * The particle emitter type defines the emitter used by the particle system.
  16827. * It can be for example box, sphere, or cone...
  16828. */
  16829. particleEmitterType: IParticleEmitterType;
  16830. /** @hidden */
  16831. _isSubEmitter: boolean;
  16832. /**
  16833. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16834. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16835. */
  16836. billboardMode: number;
  16837. protected _isBillboardBased: boolean;
  16838. /**
  16839. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16840. */
  16841. isBillboardBased: boolean;
  16842. /**
  16843. * The scene the particle system belongs to.
  16844. */
  16845. protected _scene: Scene;
  16846. /**
  16847. * Local cache of defines for image processing.
  16848. */
  16849. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16850. /**
  16851. * Default configuration related to image processing available in the standard Material.
  16852. */
  16853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16854. /**
  16855. * Gets the image processing configuration used either in this material.
  16856. */
  16857. /**
  16858. * Sets the Default image processing configuration used either in the this material.
  16859. *
  16860. * If sets to null, the scene one is in use.
  16861. */
  16862. imageProcessingConfiguration: ImageProcessingConfiguration;
  16863. /**
  16864. * Attaches a new image processing configuration to the Standard Material.
  16865. * @param configuration
  16866. */
  16867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16868. /** @hidden */
  16869. protected _reset(): void;
  16870. /** @hidden */
  16871. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16872. /**
  16873. * Instantiates a particle system.
  16874. * 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.
  16875. * @param name The name of the particle system
  16876. */
  16877. constructor(name: string);
  16878. /**
  16879. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16880. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16881. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16882. * @returns the emitter
  16883. */
  16884. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16885. /**
  16886. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16887. * @param radius The radius of the hemisphere to emit from
  16888. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16889. * @returns the emitter
  16890. */
  16891. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16892. /**
  16893. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16894. * @param radius The radius of the sphere to emit from
  16895. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16896. * @returns the emitter
  16897. */
  16898. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16899. /**
  16900. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16901. * @param radius The radius of the sphere to emit from
  16902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16904. * @returns the emitter
  16905. */
  16906. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16907. /**
  16908. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16909. * @param radius The radius of the emission cylinder
  16910. * @param height The height of the emission cylinder
  16911. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16912. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16913. * @returns the emitter
  16914. */
  16915. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16916. /**
  16917. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16918. * @param radius The radius of the cylinder to emit from
  16919. * @param height The height of the emission cylinder
  16920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16921. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16922. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16923. * @returns the emitter
  16924. */
  16925. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16926. /**
  16927. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16928. * @param radius The radius of the cone to emit from
  16929. * @param angle The base angle of the cone
  16930. * @returns the emitter
  16931. */
  16932. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16933. /**
  16934. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16935. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16936. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16937. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16938. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16939. * @returns the emitter
  16940. */
  16941. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16942. }
  16943. }
  16944. declare module BABYLON {
  16945. /**
  16946. * Type of sub emitter
  16947. */
  16948. export enum SubEmitterType {
  16949. /**
  16950. * Attached to the particle over it's lifetime
  16951. */
  16952. ATTACHED = 0,
  16953. /**
  16954. * Created when the particle dies
  16955. */
  16956. END = 1
  16957. }
  16958. /**
  16959. * Sub emitter class used to emit particles from an existing particle
  16960. */
  16961. export class SubEmitter {
  16962. /**
  16963. * the particle system to be used by the sub emitter
  16964. */
  16965. particleSystem: ParticleSystem;
  16966. /**
  16967. * Type of the submitter (Default: END)
  16968. */
  16969. type: SubEmitterType;
  16970. /**
  16971. * 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)
  16972. * Note: This only is supported when using an emitter of type Mesh
  16973. */
  16974. inheritDirection: boolean;
  16975. /**
  16976. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16977. */
  16978. inheritedVelocityAmount: number;
  16979. /**
  16980. * Creates a sub emitter
  16981. * @param particleSystem the particle system to be used by the sub emitter
  16982. */
  16983. constructor(
  16984. /**
  16985. * the particle system to be used by the sub emitter
  16986. */
  16987. particleSystem: ParticleSystem);
  16988. /**
  16989. * Clones the sub emitter
  16990. * @returns the cloned sub emitter
  16991. */
  16992. clone(): SubEmitter;
  16993. /**
  16994. * Serialize current object to a JSON object
  16995. * @returns the serialized object
  16996. */
  16997. serialize(): any;
  16998. /** @hidden */
  16999. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17000. /**
  17001. * Creates a new SubEmitter from a serialized JSON version
  17002. * @param serializationObject defines the JSON object to read from
  17003. * @param scene defines the hosting scene
  17004. * @param rootUrl defines the rootUrl for data loading
  17005. * @returns a new SubEmitter
  17006. */
  17007. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17008. /** Release associated resources */
  17009. dispose(): void;
  17010. }
  17011. }
  17012. declare module BABYLON {
  17013. /** @hidden */
  17014. export var clipPlaneFragmentDeclaration: {
  17015. name: string;
  17016. shader: string;
  17017. };
  17018. }
  17019. declare module BABYLON {
  17020. /** @hidden */
  17021. export var imageProcessingDeclaration: {
  17022. name: string;
  17023. shader: string;
  17024. };
  17025. }
  17026. declare module BABYLON {
  17027. /** @hidden */
  17028. export var imageProcessingFunctions: {
  17029. name: string;
  17030. shader: string;
  17031. };
  17032. }
  17033. declare module BABYLON {
  17034. /** @hidden */
  17035. export var clipPlaneFragment: {
  17036. name: string;
  17037. shader: string;
  17038. };
  17039. }
  17040. declare module BABYLON {
  17041. /** @hidden */
  17042. export var particlesPixelShader: {
  17043. name: string;
  17044. shader: string;
  17045. };
  17046. }
  17047. declare module BABYLON {
  17048. /** @hidden */
  17049. export var clipPlaneVertexDeclaration: {
  17050. name: string;
  17051. shader: string;
  17052. };
  17053. }
  17054. declare module BABYLON {
  17055. /** @hidden */
  17056. export var clipPlaneVertex: {
  17057. name: string;
  17058. shader: string;
  17059. };
  17060. }
  17061. declare module BABYLON {
  17062. /** @hidden */
  17063. export var particlesVertexShader: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module BABYLON {
  17069. /**
  17070. * This represents a particle system in Babylon.
  17071. * 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.
  17072. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17073. * @example https://doc.babylonjs.com/babylon101/particles
  17074. */
  17075. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17076. /**
  17077. * Billboard mode will only apply to Y axis
  17078. */
  17079. static readonly BILLBOARDMODE_Y: number;
  17080. /**
  17081. * Billboard mode will apply to all axes
  17082. */
  17083. static readonly BILLBOARDMODE_ALL: number;
  17084. /**
  17085. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17086. */
  17087. static readonly BILLBOARDMODE_STRETCHED: number;
  17088. /**
  17089. * This function can be defined to provide custom update for active particles.
  17090. * This function will be called instead of regular update (age, position, color, etc.).
  17091. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17092. */
  17093. updateFunction: (particles: Particle[]) => void;
  17094. private _emitterWorldMatrix;
  17095. /**
  17096. * This function can be defined to specify initial direction for every new particle.
  17097. * It by default use the emitterType defined function
  17098. */
  17099. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17100. /**
  17101. * This function can be defined to specify initial position for every new particle.
  17102. * It by default use the emitterType defined function
  17103. */
  17104. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17105. /**
  17106. * @hidden
  17107. */
  17108. _inheritedVelocityOffset: Vector3;
  17109. /**
  17110. * An event triggered when the system is disposed
  17111. */
  17112. onDisposeObservable: Observable<ParticleSystem>;
  17113. private _onDisposeObserver;
  17114. /**
  17115. * Sets a callback that will be triggered when the system is disposed
  17116. */
  17117. onDispose: () => void;
  17118. private _particles;
  17119. private _epsilon;
  17120. private _capacity;
  17121. private _stockParticles;
  17122. private _newPartsExcess;
  17123. private _vertexData;
  17124. private _vertexBuffer;
  17125. private _vertexBuffers;
  17126. private _spriteBuffer;
  17127. private _indexBuffer;
  17128. private _effect;
  17129. private _customEffect;
  17130. private _cachedDefines;
  17131. private _scaledColorStep;
  17132. private _colorDiff;
  17133. private _scaledDirection;
  17134. private _scaledGravity;
  17135. private _currentRenderId;
  17136. private _alive;
  17137. private _useInstancing;
  17138. private _started;
  17139. private _stopped;
  17140. private _actualFrame;
  17141. private _scaledUpdateSpeed;
  17142. private _vertexBufferSize;
  17143. /** @hidden */
  17144. _currentEmitRateGradient: Nullable<FactorGradient>;
  17145. /** @hidden */
  17146. _currentEmitRate1: number;
  17147. /** @hidden */
  17148. _currentEmitRate2: number;
  17149. /** @hidden */
  17150. _currentStartSizeGradient: Nullable<FactorGradient>;
  17151. /** @hidden */
  17152. _currentStartSize1: number;
  17153. /** @hidden */
  17154. _currentStartSize2: number;
  17155. private readonly _rawTextureWidth;
  17156. private _rampGradientsTexture;
  17157. private _useRampGradients;
  17158. /** Gets or sets a boolean indicating that ramp gradients must be used
  17159. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17160. */
  17161. useRampGradients: boolean;
  17162. /**
  17163. * 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.
  17164. * 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: [])
  17165. */
  17166. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17167. private _subEmitters;
  17168. /**
  17169. * @hidden
  17170. * If the particle systems emitter should be disposed when the particle system is disposed
  17171. */
  17172. _disposeEmitterOnDispose: boolean;
  17173. /**
  17174. * The current active Sub-systems, this property is used by the root particle system only.
  17175. */
  17176. activeSubSystems: Array<ParticleSystem>;
  17177. private _rootParticleSystem;
  17178. /**
  17179. * Gets the current list of active particles
  17180. */
  17181. readonly particles: Particle[];
  17182. /**
  17183. * Returns the string "ParticleSystem"
  17184. * @returns a string containing the class name
  17185. */
  17186. getClassName(): string;
  17187. /**
  17188. * Instantiates a particle system.
  17189. * 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.
  17190. * @param name The name of the particle system
  17191. * @param capacity The max number of particles alive at the same time
  17192. * @param scene The scene the particle system belongs to
  17193. * @param customEffect a custom effect used to change the way particles are rendered by default
  17194. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17195. * @param epsilon Offset used to render the particles
  17196. */
  17197. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17198. private _addFactorGradient;
  17199. private _removeFactorGradient;
  17200. /**
  17201. * Adds a new life time gradient
  17202. * @param gradient defines the gradient to use (between 0 and 1)
  17203. * @param factor defines the life time factor to affect to the specified gradient
  17204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17205. * @returns the current particle system
  17206. */
  17207. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17208. /**
  17209. * Remove a specific life time gradient
  17210. * @param gradient defines the gradient to remove
  17211. * @returns the current particle system
  17212. */
  17213. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17214. /**
  17215. * Adds a new size gradient
  17216. * @param gradient defines the gradient to use (between 0 and 1)
  17217. * @param factor defines the size factor to affect to the specified gradient
  17218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17219. * @returns the current particle system
  17220. */
  17221. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17222. /**
  17223. * Remove a specific size gradient
  17224. * @param gradient defines the gradient to remove
  17225. * @returns the current particle system
  17226. */
  17227. removeSizeGradient(gradient: number): IParticleSystem;
  17228. /**
  17229. * Adds a new color remap gradient
  17230. * @param gradient defines the gradient to use (between 0 and 1)
  17231. * @param min defines the color remap minimal range
  17232. * @param max defines the color remap maximal range
  17233. * @returns the current particle system
  17234. */
  17235. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17236. /**
  17237. * Remove a specific color remap gradient
  17238. * @param gradient defines the gradient to remove
  17239. * @returns the current particle system
  17240. */
  17241. removeColorRemapGradient(gradient: number): IParticleSystem;
  17242. /**
  17243. * Adds a new alpha remap gradient
  17244. * @param gradient defines the gradient to use (between 0 and 1)
  17245. * @param min defines the alpha remap minimal range
  17246. * @param max defines the alpha remap maximal range
  17247. * @returns the current particle system
  17248. */
  17249. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17250. /**
  17251. * Remove a specific alpha remap gradient
  17252. * @param gradient defines the gradient to remove
  17253. * @returns the current particle system
  17254. */
  17255. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17256. /**
  17257. * Adds a new angular speed gradient
  17258. * @param gradient defines the gradient to use (between 0 and 1)
  17259. * @param factor defines the angular speed to affect to the specified gradient
  17260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17261. * @returns the current particle system
  17262. */
  17263. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17264. /**
  17265. * Remove a specific angular speed gradient
  17266. * @param gradient defines the gradient to remove
  17267. * @returns the current particle system
  17268. */
  17269. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17270. /**
  17271. * Adds a new velocity gradient
  17272. * @param gradient defines the gradient to use (between 0 and 1)
  17273. * @param factor defines the velocity to affect to the specified gradient
  17274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17275. * @returns the current particle system
  17276. */
  17277. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17278. /**
  17279. * Remove a specific velocity gradient
  17280. * @param gradient defines the gradient to remove
  17281. * @returns the current particle system
  17282. */
  17283. removeVelocityGradient(gradient: number): IParticleSystem;
  17284. /**
  17285. * Adds a new limit velocity gradient
  17286. * @param gradient defines the gradient to use (between 0 and 1)
  17287. * @param factor defines the limit velocity value to affect to the specified gradient
  17288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17289. * @returns the current particle system
  17290. */
  17291. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17292. /**
  17293. * Remove a specific limit velocity gradient
  17294. * @param gradient defines the gradient to remove
  17295. * @returns the current particle system
  17296. */
  17297. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17298. /**
  17299. * Adds a new drag gradient
  17300. * @param gradient defines the gradient to use (between 0 and 1)
  17301. * @param factor defines the drag value to affect to the specified gradient
  17302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17303. * @returns the current particle system
  17304. */
  17305. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17306. /**
  17307. * Remove a specific drag gradient
  17308. * @param gradient defines the gradient to remove
  17309. * @returns the current particle system
  17310. */
  17311. removeDragGradient(gradient: number): IParticleSystem;
  17312. /**
  17313. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17314. * @param gradient defines the gradient to use (between 0 and 1)
  17315. * @param factor defines the emit rate value to affect to the specified gradient
  17316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17317. * @returns the current particle system
  17318. */
  17319. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17320. /**
  17321. * Remove a specific emit rate gradient
  17322. * @param gradient defines the gradient to remove
  17323. * @returns the current particle system
  17324. */
  17325. removeEmitRateGradient(gradient: number): IParticleSystem;
  17326. /**
  17327. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17328. * @param gradient defines the gradient to use (between 0 and 1)
  17329. * @param factor defines the start size value to affect to the specified gradient
  17330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17331. * @returns the current particle system
  17332. */
  17333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17334. /**
  17335. * Remove a specific start size gradient
  17336. * @param gradient defines the gradient to remove
  17337. * @returns the current particle system
  17338. */
  17339. removeStartSizeGradient(gradient: number): IParticleSystem;
  17340. private _createRampGradientTexture;
  17341. /**
  17342. * Gets the current list of ramp gradients.
  17343. * You must use addRampGradient and removeRampGradient to udpate this list
  17344. * @returns the list of ramp gradients
  17345. */
  17346. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17347. /**
  17348. * Adds a new ramp gradient used to remap particle colors
  17349. * @param gradient defines the gradient to use (between 0 and 1)
  17350. * @param color defines the color to affect to the specified gradient
  17351. * @returns the current particle system
  17352. */
  17353. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17354. /**
  17355. * Remove a specific ramp gradient
  17356. * @param gradient defines the gradient to remove
  17357. * @returns the current particle system
  17358. */
  17359. removeRampGradient(gradient: number): ParticleSystem;
  17360. /**
  17361. * Adds a new color gradient
  17362. * @param gradient defines the gradient to use (between 0 and 1)
  17363. * @param color1 defines the color to affect to the specified gradient
  17364. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17365. * @returns this particle system
  17366. */
  17367. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17368. /**
  17369. * Remove a specific color gradient
  17370. * @param gradient defines the gradient to remove
  17371. * @returns this particle system
  17372. */
  17373. removeColorGradient(gradient: number): IParticleSystem;
  17374. private _fetchR;
  17375. protected _reset(): void;
  17376. private _resetEffect;
  17377. private _createVertexBuffers;
  17378. private _createIndexBuffer;
  17379. /**
  17380. * Gets the maximum number of particles active at the same time.
  17381. * @returns The max number of active particles.
  17382. */
  17383. getCapacity(): number;
  17384. /**
  17385. * Gets whether there are still active particles in the system.
  17386. * @returns True if it is alive, otherwise false.
  17387. */
  17388. isAlive(): boolean;
  17389. /**
  17390. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17391. * @returns True if it has been started, otherwise false.
  17392. */
  17393. isStarted(): boolean;
  17394. private _prepareSubEmitterInternalArray;
  17395. /**
  17396. * Starts the particle system and begins to emit
  17397. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17398. */
  17399. start(delay?: number): void;
  17400. /**
  17401. * Stops the particle system.
  17402. * @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.
  17403. */
  17404. stop(stopSubEmitters?: boolean): void;
  17405. /**
  17406. * Remove all active particles
  17407. */
  17408. reset(): void;
  17409. /**
  17410. * @hidden (for internal use only)
  17411. */
  17412. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17413. /**
  17414. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17415. * Its lifetime will start back at 0.
  17416. */
  17417. recycleParticle: (particle: Particle) => void;
  17418. private _stopSubEmitters;
  17419. private _createParticle;
  17420. private _removeFromRoot;
  17421. private _emitFromParticle;
  17422. private _update;
  17423. /** @hidden */
  17424. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17425. /** @hidden */
  17426. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17427. /** @hidden */
  17428. private _getEffect;
  17429. /**
  17430. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17431. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17432. */
  17433. animate(preWarmOnly?: boolean): void;
  17434. private _appendParticleVertices;
  17435. /**
  17436. * Rebuilds the particle system.
  17437. */
  17438. rebuild(): void;
  17439. /**
  17440. * Is this system ready to be used/rendered
  17441. * @return true if the system is ready
  17442. */
  17443. isReady(): boolean;
  17444. private _render;
  17445. /**
  17446. * Renders the particle system in its current state.
  17447. * @returns the current number of particles
  17448. */
  17449. render(): number;
  17450. /**
  17451. * Disposes the particle system and free the associated resources
  17452. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17453. */
  17454. dispose(disposeTexture?: boolean): void;
  17455. /**
  17456. * Clones the particle system.
  17457. * @param name The name of the cloned object
  17458. * @param newEmitter The new emitter to use
  17459. * @returns the cloned particle system
  17460. */
  17461. clone(name: string, newEmitter: any): ParticleSystem;
  17462. /**
  17463. * Serializes the particle system to a JSON object.
  17464. * @returns the JSON object
  17465. */
  17466. serialize(): any;
  17467. /** @hidden */
  17468. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17469. /** @hidden */
  17470. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17471. /**
  17472. * Parses a JSON object to create a particle system.
  17473. * @param parsedParticleSystem The JSON object to parse
  17474. * @param scene The scene to create the particle system in
  17475. * @param rootUrl The root url to use to load external dependencies like texture
  17476. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17477. * @returns the Parsed particle system
  17478. */
  17479. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17480. }
  17481. }
  17482. declare module BABYLON {
  17483. /**
  17484. * A particle represents one of the element emitted by a particle system.
  17485. * This is mainly define by its coordinates, direction, velocity and age.
  17486. */
  17487. export class Particle {
  17488. /**
  17489. * The particle system the particle belongs to.
  17490. */
  17491. particleSystem: ParticleSystem;
  17492. private static _Count;
  17493. /**
  17494. * Unique ID of the particle
  17495. */
  17496. id: number;
  17497. /**
  17498. * The world position of the particle in the scene.
  17499. */
  17500. position: Vector3;
  17501. /**
  17502. * The world direction of the particle in the scene.
  17503. */
  17504. direction: Vector3;
  17505. /**
  17506. * The color of the particle.
  17507. */
  17508. color: Color4;
  17509. /**
  17510. * The color change of the particle per step.
  17511. */
  17512. colorStep: Color4;
  17513. /**
  17514. * Defines how long will the life of the particle be.
  17515. */
  17516. lifeTime: number;
  17517. /**
  17518. * The current age of the particle.
  17519. */
  17520. age: number;
  17521. /**
  17522. * The current size of the particle.
  17523. */
  17524. size: number;
  17525. /**
  17526. * The current scale of the particle.
  17527. */
  17528. scale: Vector2;
  17529. /**
  17530. * The current angle of the particle.
  17531. */
  17532. angle: number;
  17533. /**
  17534. * Defines how fast is the angle changing.
  17535. */
  17536. angularSpeed: number;
  17537. /**
  17538. * Defines the cell index used by the particle to be rendered from a sprite.
  17539. */
  17540. cellIndex: number;
  17541. /**
  17542. * The information required to support color remapping
  17543. */
  17544. remapData: Vector4;
  17545. /** @hidden */
  17546. _randomCellOffset?: number;
  17547. /** @hidden */
  17548. _initialDirection: Nullable<Vector3>;
  17549. /** @hidden */
  17550. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17551. /** @hidden */
  17552. _initialStartSpriteCellID: number;
  17553. /** @hidden */
  17554. _initialEndSpriteCellID: number;
  17555. /** @hidden */
  17556. _currentColorGradient: Nullable<ColorGradient>;
  17557. /** @hidden */
  17558. _currentColor1: Color4;
  17559. /** @hidden */
  17560. _currentColor2: Color4;
  17561. /** @hidden */
  17562. _currentSizeGradient: Nullable<FactorGradient>;
  17563. /** @hidden */
  17564. _currentSize1: number;
  17565. /** @hidden */
  17566. _currentSize2: number;
  17567. /** @hidden */
  17568. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17569. /** @hidden */
  17570. _currentAngularSpeed1: number;
  17571. /** @hidden */
  17572. _currentAngularSpeed2: number;
  17573. /** @hidden */
  17574. _currentVelocityGradient: Nullable<FactorGradient>;
  17575. /** @hidden */
  17576. _currentVelocity1: number;
  17577. /** @hidden */
  17578. _currentVelocity2: number;
  17579. /** @hidden */
  17580. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17581. /** @hidden */
  17582. _currentLimitVelocity1: number;
  17583. /** @hidden */
  17584. _currentLimitVelocity2: number;
  17585. /** @hidden */
  17586. _currentDragGradient: Nullable<FactorGradient>;
  17587. /** @hidden */
  17588. _currentDrag1: number;
  17589. /** @hidden */
  17590. _currentDrag2: number;
  17591. /** @hidden */
  17592. _randomNoiseCoordinates1: Vector3;
  17593. /** @hidden */
  17594. _randomNoiseCoordinates2: Vector3;
  17595. /**
  17596. * Creates a new instance Particle
  17597. * @param particleSystem the particle system the particle belongs to
  17598. */
  17599. constructor(
  17600. /**
  17601. * The particle system the particle belongs to.
  17602. */
  17603. particleSystem: ParticleSystem);
  17604. private updateCellInfoFromSystem;
  17605. /**
  17606. * Defines how the sprite cell index is updated for the particle
  17607. */
  17608. updateCellIndex(): void;
  17609. /** @hidden */
  17610. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17611. /** @hidden */
  17612. _inheritParticleInfoToSubEmitters(): void;
  17613. /** @hidden */
  17614. _reset(): void;
  17615. /**
  17616. * Copy the properties of particle to another one.
  17617. * @param other the particle to copy the information to.
  17618. */
  17619. copyTo(other: Particle): void;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * Particle emitter represents a volume emitting particles.
  17625. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17626. */
  17627. export interface IParticleEmitterType {
  17628. /**
  17629. * Called by the particle System when the direction is computed for the created particle.
  17630. * @param worldMatrix is the world matrix of the particle system
  17631. * @param directionToUpdate is the direction vector to update with the result
  17632. * @param particle is the particle we are computed the direction for
  17633. */
  17634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17635. /**
  17636. * Called by the particle System when the position is computed for the created particle.
  17637. * @param worldMatrix is the world matrix of the particle system
  17638. * @param positionToUpdate is the position vector to update with the result
  17639. * @param particle is the particle we are computed the position for
  17640. */
  17641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17642. /**
  17643. * Clones the current emitter and returns a copy of it
  17644. * @returns the new emitter
  17645. */
  17646. clone(): IParticleEmitterType;
  17647. /**
  17648. * Called by the GPUParticleSystem to setup the update shader
  17649. * @param effect defines the update shader
  17650. */
  17651. applyToShader(effect: Effect): void;
  17652. /**
  17653. * Returns a string to use to update the GPU particles update shader
  17654. * @returns the effect defines string
  17655. */
  17656. getEffectDefines(): string;
  17657. /**
  17658. * Returns a string representing the class name
  17659. * @returns a string containing the class name
  17660. */
  17661. getClassName(): string;
  17662. /**
  17663. * Serializes the particle system to a JSON object.
  17664. * @returns the JSON object
  17665. */
  17666. serialize(): any;
  17667. /**
  17668. * Parse properties from a JSON object
  17669. * @param serializationObject defines the JSON object
  17670. */
  17671. parse(serializationObject: any): void;
  17672. }
  17673. }
  17674. declare module BABYLON {
  17675. /**
  17676. * Particle emitter emitting particles from the inside of a box.
  17677. * It emits the particles randomly between 2 given directions.
  17678. */
  17679. export class BoxParticleEmitter implements IParticleEmitterType {
  17680. /**
  17681. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17682. */
  17683. direction1: Vector3;
  17684. /**
  17685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17686. */
  17687. direction2: Vector3;
  17688. /**
  17689. * 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.
  17690. */
  17691. minEmitBox: Vector3;
  17692. /**
  17693. * 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.
  17694. */
  17695. maxEmitBox: Vector3;
  17696. /**
  17697. * Creates a new instance BoxParticleEmitter
  17698. */
  17699. constructor();
  17700. /**
  17701. * Called by the particle System when the direction is computed for the created particle.
  17702. * @param worldMatrix is the world matrix of the particle system
  17703. * @param directionToUpdate is the direction vector to update with the result
  17704. * @param particle is the particle we are computed the direction for
  17705. */
  17706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17707. /**
  17708. * Called by the particle System when the position is computed for the created particle.
  17709. * @param worldMatrix is the world matrix of the particle system
  17710. * @param positionToUpdate is the position vector to update with the result
  17711. * @param particle is the particle we are computed the position for
  17712. */
  17713. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17714. /**
  17715. * Clones the current emitter and returns a copy of it
  17716. * @returns the new emitter
  17717. */
  17718. clone(): BoxParticleEmitter;
  17719. /**
  17720. * Called by the GPUParticleSystem to setup the update shader
  17721. * @param effect defines the update shader
  17722. */
  17723. applyToShader(effect: Effect): void;
  17724. /**
  17725. * Returns a string to use to update the GPU particles update shader
  17726. * @returns a string containng the defines string
  17727. */
  17728. getEffectDefines(): string;
  17729. /**
  17730. * Returns the string "BoxParticleEmitter"
  17731. * @returns a string containing the class name
  17732. */
  17733. getClassName(): string;
  17734. /**
  17735. * Serializes the particle system to a JSON object.
  17736. * @returns the JSON object
  17737. */
  17738. serialize(): any;
  17739. /**
  17740. * Parse properties from a JSON object
  17741. * @param serializationObject defines the JSON object
  17742. */
  17743. parse(serializationObject: any): void;
  17744. }
  17745. }
  17746. declare module BABYLON {
  17747. /**
  17748. * Particle emitter emitting particles from the inside of a cone.
  17749. * It emits the particles alongside the cone volume from the base to the particle.
  17750. * The emission direction might be randomized.
  17751. */
  17752. export class ConeParticleEmitter implements IParticleEmitterType {
  17753. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17754. directionRandomizer: number;
  17755. private _radius;
  17756. private _angle;
  17757. private _height;
  17758. /**
  17759. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17760. */
  17761. radiusRange: number;
  17762. /**
  17763. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17764. */
  17765. heightRange: number;
  17766. /**
  17767. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17768. */
  17769. emitFromSpawnPointOnly: boolean;
  17770. /**
  17771. * Gets or sets the radius of the emission cone
  17772. */
  17773. radius: number;
  17774. /**
  17775. * Gets or sets the angle of the emission cone
  17776. */
  17777. angle: number;
  17778. private _buildHeight;
  17779. /**
  17780. * Creates a new instance ConeParticleEmitter
  17781. * @param radius the radius of the emission cone (1 by default)
  17782. * @param angle the cone base angle (PI by default)
  17783. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17784. */
  17785. constructor(radius?: number, angle?: number,
  17786. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17787. directionRandomizer?: number);
  17788. /**
  17789. * Called by the particle System when the direction is computed for the created particle.
  17790. * @param worldMatrix is the world matrix of the particle system
  17791. * @param directionToUpdate is the direction vector to update with the result
  17792. * @param particle is the particle we are computed the direction for
  17793. */
  17794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17795. /**
  17796. * Called by the particle System when the position is computed for the created particle.
  17797. * @param worldMatrix is the world matrix of the particle system
  17798. * @param positionToUpdate is the position vector to update with the result
  17799. * @param particle is the particle we are computed the position for
  17800. */
  17801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17802. /**
  17803. * Clones the current emitter and returns a copy of it
  17804. * @returns the new emitter
  17805. */
  17806. clone(): ConeParticleEmitter;
  17807. /**
  17808. * Called by the GPUParticleSystem to setup the update shader
  17809. * @param effect defines the update shader
  17810. */
  17811. applyToShader(effect: Effect): void;
  17812. /**
  17813. * Returns a string to use to update the GPU particles update shader
  17814. * @returns a string containng the defines string
  17815. */
  17816. getEffectDefines(): string;
  17817. /**
  17818. * Returns the string "ConeParticleEmitter"
  17819. * @returns a string containing the class name
  17820. */
  17821. getClassName(): string;
  17822. /**
  17823. * Serializes the particle system to a JSON object.
  17824. * @returns the JSON object
  17825. */
  17826. serialize(): any;
  17827. /**
  17828. * Parse properties from a JSON object
  17829. * @param serializationObject defines the JSON object
  17830. */
  17831. parse(serializationObject: any): void;
  17832. }
  17833. }
  17834. declare module BABYLON {
  17835. /**
  17836. * Particle emitter emitting particles from the inside of a cylinder.
  17837. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17838. */
  17839. export class CylinderParticleEmitter implements IParticleEmitterType {
  17840. /**
  17841. * The radius of the emission cylinder.
  17842. */
  17843. radius: number;
  17844. /**
  17845. * The height of the emission cylinder.
  17846. */
  17847. height: number;
  17848. /**
  17849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17850. */
  17851. radiusRange: number;
  17852. /**
  17853. * How much to randomize the particle direction [0-1].
  17854. */
  17855. directionRandomizer: number;
  17856. /**
  17857. * Creates a new instance CylinderParticleEmitter
  17858. * @param radius the radius of the emission cylinder (1 by default)
  17859. * @param height the height of the emission cylinder (1 by default)
  17860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17861. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17862. */
  17863. constructor(
  17864. /**
  17865. * The radius of the emission cylinder.
  17866. */
  17867. radius?: number,
  17868. /**
  17869. * The height of the emission cylinder.
  17870. */
  17871. height?: number,
  17872. /**
  17873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17874. */
  17875. radiusRange?: number,
  17876. /**
  17877. * How much to randomize the particle direction [0-1].
  17878. */
  17879. directionRandomizer?: number);
  17880. /**
  17881. * Called by the particle System when the direction is computed for the created particle.
  17882. * @param worldMatrix is the world matrix of the particle system
  17883. * @param directionToUpdate is the direction vector to update with the result
  17884. * @param particle is the particle we are computed the direction for
  17885. */
  17886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17887. /**
  17888. * Called by the particle System when the position is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param positionToUpdate is the position vector to update with the result
  17891. * @param particle is the particle we are computed the position for
  17892. */
  17893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): CylinderParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "CylinderParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. /**
  17926. * Particle emitter emitting particles from the inside of a cylinder.
  17927. * It emits the particles randomly between two vectors.
  17928. */
  17929. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17930. /**
  17931. * The min limit of the emission direction.
  17932. */
  17933. direction1: Vector3;
  17934. /**
  17935. * The max limit of the emission direction.
  17936. */
  17937. direction2: Vector3;
  17938. /**
  17939. * Creates a new instance CylinderDirectedParticleEmitter
  17940. * @param radius the radius of the emission cylinder (1 by default)
  17941. * @param height the height of the emission cylinder (1 by default)
  17942. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17943. * @param direction1 the min limit of the emission direction (up vector by default)
  17944. * @param direction2 the max limit of the emission direction (up vector by default)
  17945. */
  17946. constructor(radius?: number, height?: number, radiusRange?: number,
  17947. /**
  17948. * The min limit of the emission direction.
  17949. */
  17950. direction1?: Vector3,
  17951. /**
  17952. * The max limit of the emission direction.
  17953. */
  17954. direction2?: Vector3);
  17955. /**
  17956. * Called by the particle System when the direction is computed for the created particle.
  17957. * @param worldMatrix is the world matrix of the particle system
  17958. * @param directionToUpdate is the direction vector to update with the result
  17959. * @param particle is the particle we are computed the direction for
  17960. */
  17961. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17962. /**
  17963. * Clones the current emitter and returns a copy of it
  17964. * @returns the new emitter
  17965. */
  17966. clone(): CylinderDirectedParticleEmitter;
  17967. /**
  17968. * Called by the GPUParticleSystem to setup the update shader
  17969. * @param effect defines the update shader
  17970. */
  17971. applyToShader(effect: Effect): void;
  17972. /**
  17973. * Returns a string to use to update the GPU particles update shader
  17974. * @returns a string containng the defines string
  17975. */
  17976. getEffectDefines(): string;
  17977. /**
  17978. * Returns the string "CylinderDirectedParticleEmitter"
  17979. * @returns a string containing the class name
  17980. */
  17981. getClassName(): string;
  17982. /**
  17983. * Serializes the particle system to a JSON object.
  17984. * @returns the JSON object
  17985. */
  17986. serialize(): any;
  17987. /**
  17988. * Parse properties from a JSON object
  17989. * @param serializationObject defines the JSON object
  17990. */
  17991. parse(serializationObject: any): void;
  17992. }
  17993. }
  17994. declare module BABYLON {
  17995. /**
  17996. * Particle emitter emitting particles from the inside of a hemisphere.
  17997. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17998. */
  17999. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18000. /**
  18001. * The radius of the emission hemisphere.
  18002. */
  18003. radius: number;
  18004. /**
  18005. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18006. */
  18007. radiusRange: number;
  18008. /**
  18009. * How much to randomize the particle direction [0-1].
  18010. */
  18011. directionRandomizer: number;
  18012. /**
  18013. * Creates a new instance HemisphericParticleEmitter
  18014. * @param radius the radius of the emission hemisphere (1 by default)
  18015. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18016. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18017. */
  18018. constructor(
  18019. /**
  18020. * The radius of the emission hemisphere.
  18021. */
  18022. radius?: number,
  18023. /**
  18024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18025. */
  18026. radiusRange?: number,
  18027. /**
  18028. * How much to randomize the particle direction [0-1].
  18029. */
  18030. directionRandomizer?: number);
  18031. /**
  18032. * Called by the particle System when the direction is computed for the created particle.
  18033. * @param worldMatrix is the world matrix of the particle system
  18034. * @param directionToUpdate is the direction vector to update with the result
  18035. * @param particle is the particle we are computed the direction for
  18036. */
  18037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18038. /**
  18039. * Called by the particle System when the position is computed for the created particle.
  18040. * @param worldMatrix is the world matrix of the particle system
  18041. * @param positionToUpdate is the position vector to update with the result
  18042. * @param particle is the particle we are computed the position for
  18043. */
  18044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18045. /**
  18046. * Clones the current emitter and returns a copy of it
  18047. * @returns the new emitter
  18048. */
  18049. clone(): HemisphericParticleEmitter;
  18050. /**
  18051. * Called by the GPUParticleSystem to setup the update shader
  18052. * @param effect defines the update shader
  18053. */
  18054. applyToShader(effect: Effect): void;
  18055. /**
  18056. * Returns a string to use to update the GPU particles update shader
  18057. * @returns a string containng the defines string
  18058. */
  18059. getEffectDefines(): string;
  18060. /**
  18061. * Returns the string "HemisphericParticleEmitter"
  18062. * @returns a string containing the class name
  18063. */
  18064. getClassName(): string;
  18065. /**
  18066. * Serializes the particle system to a JSON object.
  18067. * @returns the JSON object
  18068. */
  18069. serialize(): any;
  18070. /**
  18071. * Parse properties from a JSON object
  18072. * @param serializationObject defines the JSON object
  18073. */
  18074. parse(serializationObject: any): void;
  18075. }
  18076. }
  18077. declare module BABYLON {
  18078. /**
  18079. * Particle emitter emitting particles from a point.
  18080. * It emits the particles randomly between 2 given directions.
  18081. */
  18082. export class PointParticleEmitter implements IParticleEmitterType {
  18083. /**
  18084. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18085. */
  18086. direction1: Vector3;
  18087. /**
  18088. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18089. */
  18090. direction2: Vector3;
  18091. /**
  18092. * Creates a new instance PointParticleEmitter
  18093. */
  18094. constructor();
  18095. /**
  18096. * Called by the particle System when the direction is computed for the created particle.
  18097. * @param worldMatrix is the world matrix of the particle system
  18098. * @param directionToUpdate is the direction vector to update with the result
  18099. * @param particle is the particle we are computed the direction for
  18100. */
  18101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18102. /**
  18103. * Called by the particle System when the position is computed for the created particle.
  18104. * @param worldMatrix is the world matrix of the particle system
  18105. * @param positionToUpdate is the position vector to update with the result
  18106. * @param particle is the particle we are computed the position for
  18107. */
  18108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18109. /**
  18110. * Clones the current emitter and returns a copy of it
  18111. * @returns the new emitter
  18112. */
  18113. clone(): PointParticleEmitter;
  18114. /**
  18115. * Called by the GPUParticleSystem to setup the update shader
  18116. * @param effect defines the update shader
  18117. */
  18118. applyToShader(effect: Effect): void;
  18119. /**
  18120. * Returns a string to use to update the GPU particles update shader
  18121. * @returns a string containng the defines string
  18122. */
  18123. getEffectDefines(): string;
  18124. /**
  18125. * Returns the string "PointParticleEmitter"
  18126. * @returns a string containing the class name
  18127. */
  18128. getClassName(): string;
  18129. /**
  18130. * Serializes the particle system to a JSON object.
  18131. * @returns the JSON object
  18132. */
  18133. serialize(): any;
  18134. /**
  18135. * Parse properties from a JSON object
  18136. * @param serializationObject defines the JSON object
  18137. */
  18138. parse(serializationObject: any): void;
  18139. }
  18140. }
  18141. declare module BABYLON {
  18142. /**
  18143. * Particle emitter emitting particles from the inside of a sphere.
  18144. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18145. */
  18146. export class SphereParticleEmitter implements IParticleEmitterType {
  18147. /**
  18148. * The radius of the emission sphere.
  18149. */
  18150. radius: number;
  18151. /**
  18152. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18153. */
  18154. radiusRange: number;
  18155. /**
  18156. * How much to randomize the particle direction [0-1].
  18157. */
  18158. directionRandomizer: number;
  18159. /**
  18160. * Creates a new instance SphereParticleEmitter
  18161. * @param radius the radius of the emission sphere (1 by default)
  18162. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18163. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18164. */
  18165. constructor(
  18166. /**
  18167. * The radius of the emission sphere.
  18168. */
  18169. radius?: number,
  18170. /**
  18171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18172. */
  18173. radiusRange?: number,
  18174. /**
  18175. * How much to randomize the particle direction [0-1].
  18176. */
  18177. directionRandomizer?: number);
  18178. /**
  18179. * Called by the particle System when the direction is computed for the created particle.
  18180. * @param worldMatrix is the world matrix of the particle system
  18181. * @param directionToUpdate is the direction vector to update with the result
  18182. * @param particle is the particle we are computed the direction for
  18183. */
  18184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18185. /**
  18186. * Called by the particle System when the position is computed for the created particle.
  18187. * @param worldMatrix is the world matrix of the particle system
  18188. * @param positionToUpdate is the position vector to update with the result
  18189. * @param particle is the particle we are computed the position for
  18190. */
  18191. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18192. /**
  18193. * Clones the current emitter and returns a copy of it
  18194. * @returns the new emitter
  18195. */
  18196. clone(): SphereParticleEmitter;
  18197. /**
  18198. * Called by the GPUParticleSystem to setup the update shader
  18199. * @param effect defines the update shader
  18200. */
  18201. applyToShader(effect: Effect): void;
  18202. /**
  18203. * Returns a string to use to update the GPU particles update shader
  18204. * @returns a string containng the defines string
  18205. */
  18206. getEffectDefines(): string;
  18207. /**
  18208. * Returns the string "SphereParticleEmitter"
  18209. * @returns a string containing the class name
  18210. */
  18211. getClassName(): string;
  18212. /**
  18213. * Serializes the particle system to a JSON object.
  18214. * @returns the JSON object
  18215. */
  18216. serialize(): any;
  18217. /**
  18218. * Parse properties from a JSON object
  18219. * @param serializationObject defines the JSON object
  18220. */
  18221. parse(serializationObject: any): void;
  18222. }
  18223. /**
  18224. * Particle emitter emitting particles from the inside of a sphere.
  18225. * It emits the particles randomly between two vectors.
  18226. */
  18227. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18228. /**
  18229. * The min limit of the emission direction.
  18230. */
  18231. direction1: Vector3;
  18232. /**
  18233. * The max limit of the emission direction.
  18234. */
  18235. direction2: Vector3;
  18236. /**
  18237. * Creates a new instance SphereDirectedParticleEmitter
  18238. * @param radius the radius of the emission sphere (1 by default)
  18239. * @param direction1 the min limit of the emission direction (up vector by default)
  18240. * @param direction2 the max limit of the emission direction (up vector by default)
  18241. */
  18242. constructor(radius?: number,
  18243. /**
  18244. * The min limit of the emission direction.
  18245. */
  18246. direction1?: Vector3,
  18247. /**
  18248. * The max limit of the emission direction.
  18249. */
  18250. direction2?: Vector3);
  18251. /**
  18252. * Called by the particle System when the direction is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param directionToUpdate is the direction vector to update with the result
  18255. * @param particle is the particle we are computed the direction for
  18256. */
  18257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): SphereDirectedParticleEmitter;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns a string containng the defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns the string "SphereDirectedParticleEmitter"
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * Interface representing a particle system in Babylon.js.
  18293. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18294. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18295. */
  18296. export interface IParticleSystem {
  18297. /**
  18298. * List of animations used by the particle system.
  18299. */
  18300. animations: Animation[];
  18301. /**
  18302. * The id of the Particle system.
  18303. */
  18304. id: string;
  18305. /**
  18306. * The name of the Particle system.
  18307. */
  18308. name: string;
  18309. /**
  18310. * The emitter represents the Mesh or position we are attaching the particle system to.
  18311. */
  18312. emitter: Nullable<AbstractMesh | Vector3>;
  18313. /**
  18314. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18315. */
  18316. isBillboardBased: boolean;
  18317. /**
  18318. * The rendering group used by the Particle system to chose when to render.
  18319. */
  18320. renderingGroupId: number;
  18321. /**
  18322. * The layer mask we are rendering the particles through.
  18323. */
  18324. layerMask: number;
  18325. /**
  18326. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18327. */
  18328. updateSpeed: number;
  18329. /**
  18330. * The amount of time the particle system is running (depends of the overall update speed).
  18331. */
  18332. targetStopDuration: number;
  18333. /**
  18334. * The texture used to render each particle. (this can be a spritesheet)
  18335. */
  18336. particleTexture: Nullable<Texture>;
  18337. /**
  18338. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18339. */
  18340. blendMode: number;
  18341. /**
  18342. * Minimum life time of emitting particles.
  18343. */
  18344. minLifeTime: number;
  18345. /**
  18346. * Maximum life time of emitting particles.
  18347. */
  18348. maxLifeTime: number;
  18349. /**
  18350. * Minimum Size of emitting particles.
  18351. */
  18352. minSize: number;
  18353. /**
  18354. * Maximum Size of emitting particles.
  18355. */
  18356. maxSize: number;
  18357. /**
  18358. * Minimum scale of emitting particles on X axis.
  18359. */
  18360. minScaleX: number;
  18361. /**
  18362. * Maximum scale of emitting particles on X axis.
  18363. */
  18364. maxScaleX: number;
  18365. /**
  18366. * Minimum scale of emitting particles on Y axis.
  18367. */
  18368. minScaleY: number;
  18369. /**
  18370. * Maximum scale of emitting particles on Y axis.
  18371. */
  18372. maxScaleY: number;
  18373. /**
  18374. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18375. */
  18376. color1: Color4;
  18377. /**
  18378. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18379. */
  18380. color2: Color4;
  18381. /**
  18382. * Color the particle will have at the end of its lifetime.
  18383. */
  18384. colorDead: Color4;
  18385. /**
  18386. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18387. */
  18388. emitRate: number;
  18389. /**
  18390. * You can use gravity if you want to give an orientation to your particles.
  18391. */
  18392. gravity: Vector3;
  18393. /**
  18394. * Minimum power of emitting particles.
  18395. */
  18396. minEmitPower: number;
  18397. /**
  18398. * Maximum power of emitting particles.
  18399. */
  18400. maxEmitPower: number;
  18401. /**
  18402. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18403. */
  18404. minAngularSpeed: number;
  18405. /**
  18406. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18407. */
  18408. maxAngularSpeed: number;
  18409. /**
  18410. * Gets or sets the minimal initial rotation in radians.
  18411. */
  18412. minInitialRotation: number;
  18413. /**
  18414. * Gets or sets the maximal initial rotation in radians.
  18415. */
  18416. maxInitialRotation: number;
  18417. /**
  18418. * The particle emitter type defines the emitter used by the particle system.
  18419. * It can be for example box, sphere, or cone...
  18420. */
  18421. particleEmitterType: Nullable<IParticleEmitterType>;
  18422. /**
  18423. * Defines the delay in milliseconds before starting the system (0 by default)
  18424. */
  18425. startDelay: number;
  18426. /**
  18427. * 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
  18428. */
  18429. preWarmCycles: number;
  18430. /**
  18431. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18432. */
  18433. preWarmStepOffset: number;
  18434. /**
  18435. * 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)
  18436. */
  18437. spriteCellChangeSpeed: number;
  18438. /**
  18439. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18440. */
  18441. startSpriteCellID: number;
  18442. /**
  18443. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18444. */
  18445. endSpriteCellID: number;
  18446. /**
  18447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18448. */
  18449. spriteCellWidth: number;
  18450. /**
  18451. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18452. */
  18453. spriteCellHeight: number;
  18454. /**
  18455. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18456. */
  18457. spriteRandomStartCell: boolean;
  18458. /**
  18459. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18460. */
  18461. isAnimationSheetEnabled: boolean;
  18462. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18463. translationPivot: Vector2;
  18464. /**
  18465. * Gets or sets a texture used to add random noise to particle positions
  18466. */
  18467. noiseTexture: Nullable<BaseTexture>;
  18468. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18469. noiseStrength: Vector3;
  18470. /**
  18471. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18472. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18473. */
  18474. billboardMode: number;
  18475. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18476. limitVelocityDamping: number;
  18477. /**
  18478. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18479. */
  18480. beginAnimationOnStart: boolean;
  18481. /**
  18482. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18483. */
  18484. beginAnimationFrom: number;
  18485. /**
  18486. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18487. */
  18488. beginAnimationTo: number;
  18489. /**
  18490. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18491. */
  18492. beginAnimationLoop: boolean;
  18493. /**
  18494. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18495. */
  18496. disposeOnStop: boolean;
  18497. /**
  18498. * Gets the maximum number of particles active at the same time.
  18499. * @returns The max number of active particles.
  18500. */
  18501. getCapacity(): number;
  18502. /**
  18503. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18504. * @returns True if it has been started, otherwise false.
  18505. */
  18506. isStarted(): boolean;
  18507. /**
  18508. * Animates the particle system for this frame.
  18509. */
  18510. animate(): void;
  18511. /**
  18512. * Renders the particle system in its current state.
  18513. * @returns the current number of particles
  18514. */
  18515. render(): number;
  18516. /**
  18517. * Dispose the particle system and frees its associated resources.
  18518. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18519. */
  18520. dispose(disposeTexture?: boolean): void;
  18521. /**
  18522. * Clones the particle system.
  18523. * @param name The name of the cloned object
  18524. * @param newEmitter The new emitter to use
  18525. * @returns the cloned particle system
  18526. */
  18527. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18528. /**
  18529. * Serializes the particle system to a JSON object.
  18530. * @returns the JSON object
  18531. */
  18532. serialize(): any;
  18533. /**
  18534. * Rebuild the particle system
  18535. */
  18536. rebuild(): void;
  18537. /**
  18538. * Starts the particle system and begins to emit
  18539. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18540. */
  18541. start(delay?: number): void;
  18542. /**
  18543. * Stops the particle system.
  18544. */
  18545. stop(): void;
  18546. /**
  18547. * Remove all active particles
  18548. */
  18549. reset(): void;
  18550. /**
  18551. * Is this system ready to be used/rendered
  18552. * @return true if the system is ready
  18553. */
  18554. isReady(): boolean;
  18555. /**
  18556. * Adds a new color gradient
  18557. * @param gradient defines the gradient to use (between 0 and 1)
  18558. * @param color1 defines the color to affect to the specified gradient
  18559. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18560. * @returns the current particle system
  18561. */
  18562. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18563. /**
  18564. * Remove a specific color gradient
  18565. * @param gradient defines the gradient to remove
  18566. * @returns the current particle system
  18567. */
  18568. removeColorGradient(gradient: number): IParticleSystem;
  18569. /**
  18570. * Adds a new size gradient
  18571. * @param gradient defines the gradient to use (between 0 and 1)
  18572. * @param factor defines the size factor to affect to the specified gradient
  18573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18574. * @returns the current particle system
  18575. */
  18576. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18577. /**
  18578. * Remove a specific size gradient
  18579. * @param gradient defines the gradient to remove
  18580. * @returns the current particle system
  18581. */
  18582. removeSizeGradient(gradient: number): IParticleSystem;
  18583. /**
  18584. * Gets the current list of color gradients.
  18585. * You must use addColorGradient and removeColorGradient to udpate this list
  18586. * @returns the list of color gradients
  18587. */
  18588. getColorGradients(): Nullable<Array<ColorGradient>>;
  18589. /**
  18590. * Gets the current list of size gradients.
  18591. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18592. * @returns the list of size gradients
  18593. */
  18594. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18595. /**
  18596. * Gets the current list of angular speed gradients.
  18597. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18598. * @returns the list of angular speed gradients
  18599. */
  18600. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18601. /**
  18602. * Adds a new angular speed gradient
  18603. * @param gradient defines the gradient to use (between 0 and 1)
  18604. * @param factor defines the angular speed to affect to the specified gradient
  18605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18606. * @returns the current particle system
  18607. */
  18608. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18609. /**
  18610. * Remove a specific angular speed gradient
  18611. * @param gradient defines the gradient to remove
  18612. * @returns the current particle system
  18613. */
  18614. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18615. /**
  18616. * Gets the current list of velocity gradients.
  18617. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18618. * @returns the list of velocity gradients
  18619. */
  18620. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18621. /**
  18622. * Adds a new velocity gradient
  18623. * @param gradient defines the gradient to use (between 0 and 1)
  18624. * @param factor defines the velocity to affect to the specified gradient
  18625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18626. * @returns the current particle system
  18627. */
  18628. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18629. /**
  18630. * Remove a specific velocity gradient
  18631. * @param gradient defines the gradient to remove
  18632. * @returns the current particle system
  18633. */
  18634. removeVelocityGradient(gradient: number): IParticleSystem;
  18635. /**
  18636. * Gets the current list of limit velocity gradients.
  18637. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18638. * @returns the list of limit velocity gradients
  18639. */
  18640. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18641. /**
  18642. * Adds a new limit velocity gradient
  18643. * @param gradient defines the gradient to use (between 0 and 1)
  18644. * @param factor defines the limit velocity to affect to the specified gradient
  18645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18646. * @returns the current particle system
  18647. */
  18648. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18649. /**
  18650. * Remove a specific limit velocity gradient
  18651. * @param gradient defines the gradient to remove
  18652. * @returns the current particle system
  18653. */
  18654. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18655. /**
  18656. * Adds a new drag gradient
  18657. * @param gradient defines the gradient to use (between 0 and 1)
  18658. * @param factor defines the drag to affect to the specified gradient
  18659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18660. * @returns the current particle system
  18661. */
  18662. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18663. /**
  18664. * Remove a specific drag gradient
  18665. * @param gradient defines the gradient to remove
  18666. * @returns the current particle system
  18667. */
  18668. removeDragGradient(gradient: number): IParticleSystem;
  18669. /**
  18670. * Gets the current list of drag gradients.
  18671. * You must use addDragGradient and removeDragGradient to udpate this list
  18672. * @returns the list of drag gradients
  18673. */
  18674. getDragGradients(): Nullable<Array<FactorGradient>>;
  18675. /**
  18676. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18677. * @param gradient defines the gradient to use (between 0 and 1)
  18678. * @param factor defines the emit rate to affect to the specified gradient
  18679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18680. * @returns the current particle system
  18681. */
  18682. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18683. /**
  18684. * Remove a specific emit rate gradient
  18685. * @param gradient defines the gradient to remove
  18686. * @returns the current particle system
  18687. */
  18688. removeEmitRateGradient(gradient: number): IParticleSystem;
  18689. /**
  18690. * Gets the current list of emit rate gradients.
  18691. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18692. * @returns the list of emit rate gradients
  18693. */
  18694. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18695. /**
  18696. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param factor defines the start size to affect to the specified gradient
  18699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18700. * @returns the current particle system
  18701. */
  18702. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18703. /**
  18704. * Remove a specific start size gradient
  18705. * @param gradient defines the gradient to remove
  18706. * @returns the current particle system
  18707. */
  18708. removeStartSizeGradient(gradient: number): IParticleSystem;
  18709. /**
  18710. * Gets the current list of start size gradients.
  18711. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18712. * @returns the list of start size gradients
  18713. */
  18714. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18715. /**
  18716. * Adds a new life time gradient
  18717. * @param gradient defines the gradient to use (between 0 and 1)
  18718. * @param factor defines the life time factor to affect to the specified gradient
  18719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18720. * @returns the current particle system
  18721. */
  18722. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18723. /**
  18724. * Remove a specific life time gradient
  18725. * @param gradient defines the gradient to remove
  18726. * @returns the current particle system
  18727. */
  18728. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18729. /**
  18730. * Gets the current list of life time gradients.
  18731. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18732. * @returns the list of life time gradients
  18733. */
  18734. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18735. /**
  18736. * Gets the current list of color gradients.
  18737. * You must use addColorGradient and removeColorGradient to udpate this list
  18738. * @returns the list of color gradients
  18739. */
  18740. getColorGradients(): Nullable<Array<ColorGradient>>;
  18741. /**
  18742. * Adds a new ramp gradient used to remap particle colors
  18743. * @param gradient defines the gradient to use (between 0 and 1)
  18744. * @param color defines the color to affect to the specified gradient
  18745. * @returns the current particle system
  18746. */
  18747. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18748. /**
  18749. * Gets the current list of ramp gradients.
  18750. * You must use addRampGradient and removeRampGradient to udpate this list
  18751. * @returns the list of ramp gradients
  18752. */
  18753. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18754. /** Gets or sets a boolean indicating that ramp gradients must be used
  18755. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18756. */
  18757. useRampGradients: boolean;
  18758. /**
  18759. * Adds a new color remap gradient
  18760. * @param gradient defines the gradient to use (between 0 and 1)
  18761. * @param min defines the color remap minimal range
  18762. * @param max defines the color remap maximal range
  18763. * @returns the current particle system
  18764. */
  18765. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18766. /**
  18767. * Gets the current list of color remap gradients.
  18768. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18769. * @returns the list of color remap gradients
  18770. */
  18771. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18772. /**
  18773. * Adds a new alpha remap gradient
  18774. * @param gradient defines the gradient to use (between 0 and 1)
  18775. * @param min defines the alpha remap minimal range
  18776. * @param max defines the alpha remap maximal range
  18777. * @returns the current particle system
  18778. */
  18779. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18780. /**
  18781. * Gets the current list of alpha remap gradients.
  18782. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18783. * @returns the list of alpha remap gradients
  18784. */
  18785. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18786. /**
  18787. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18788. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18789. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18790. * @returns the emitter
  18791. */
  18792. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18793. /**
  18794. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18795. * @param radius The radius of the hemisphere to emit from
  18796. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18797. * @returns the emitter
  18798. */
  18799. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18800. /**
  18801. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18802. * @param radius The radius of the sphere to emit from
  18803. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18804. * @returns the emitter
  18805. */
  18806. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18807. /**
  18808. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18809. * @param radius The radius of the sphere to emit from
  18810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18812. * @returns the emitter
  18813. */
  18814. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18815. /**
  18816. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18817. * @param radius The radius of the emission cylinder
  18818. * @param height The height of the emission cylinder
  18819. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18820. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18821. * @returns the emitter
  18822. */
  18823. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18824. /**
  18825. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18826. * @param radius The radius of the cylinder to emit from
  18827. * @param height The height of the emission cylinder
  18828. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18829. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18830. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18831. * @returns the emitter
  18832. */
  18833. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18834. /**
  18835. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18836. * @param radius The radius of the cone to emit from
  18837. * @param angle The base angle of the cone
  18838. * @returns the emitter
  18839. */
  18840. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18841. /**
  18842. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18845. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18846. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18847. * @returns the emitter
  18848. */
  18849. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18850. /**
  18851. * Get hosting scene
  18852. * @returns the scene
  18853. */
  18854. getScene(): Scene;
  18855. }
  18856. }
  18857. declare module BABYLON {
  18858. /**
  18859. * Creates an instance based on a source mesh.
  18860. */
  18861. export class InstancedMesh extends AbstractMesh {
  18862. private _sourceMesh;
  18863. private _currentLOD;
  18864. /** @hidden */
  18865. _indexInSourceMeshInstanceArray: number;
  18866. constructor(name: string, source: Mesh);
  18867. /**
  18868. * Returns the string "InstancedMesh".
  18869. */
  18870. getClassName(): string;
  18871. /** Gets the list of lights affecting that mesh */
  18872. readonly lightSources: Light[];
  18873. _resyncLightSources(): void;
  18874. _resyncLighSource(light: Light): void;
  18875. _removeLightSource(light: Light, dispose: boolean): void;
  18876. /**
  18877. * If the source mesh receives shadows
  18878. */
  18879. readonly receiveShadows: boolean;
  18880. /**
  18881. * The material of the source mesh
  18882. */
  18883. readonly material: Nullable<Material>;
  18884. /**
  18885. * Visibility of the source mesh
  18886. */
  18887. readonly visibility: number;
  18888. /**
  18889. * Skeleton of the source mesh
  18890. */
  18891. readonly skeleton: Nullable<Skeleton>;
  18892. /**
  18893. * Rendering ground id of the source mesh
  18894. */
  18895. renderingGroupId: number;
  18896. /**
  18897. * Returns the total number of vertices (integer).
  18898. */
  18899. getTotalVertices(): number;
  18900. /**
  18901. * Returns a positive integer : the total number of indices in this mesh geometry.
  18902. * @returns the numner of indices or zero if the mesh has no geometry.
  18903. */
  18904. getTotalIndices(): number;
  18905. /**
  18906. * The source mesh of the instance
  18907. */
  18908. readonly sourceMesh: Mesh;
  18909. /**
  18910. * Is this node ready to be used/rendered
  18911. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18912. * @return {boolean} is it ready
  18913. */
  18914. isReady(completeCheck?: boolean): boolean;
  18915. /**
  18916. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18917. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18918. * @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.
  18919. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18920. */
  18921. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18922. /**
  18923. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18924. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18925. * The `data` are either a numeric array either a Float32Array.
  18926. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18927. * 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).
  18928. * Note that a new underlying VertexBuffer object is created each call.
  18929. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18930. *
  18931. * Possible `kind` values :
  18932. * - VertexBuffer.PositionKind
  18933. * - VertexBuffer.UVKind
  18934. * - VertexBuffer.UV2Kind
  18935. * - VertexBuffer.UV3Kind
  18936. * - VertexBuffer.UV4Kind
  18937. * - VertexBuffer.UV5Kind
  18938. * - VertexBuffer.UV6Kind
  18939. * - VertexBuffer.ColorKind
  18940. * - VertexBuffer.MatricesIndicesKind
  18941. * - VertexBuffer.MatricesIndicesExtraKind
  18942. * - VertexBuffer.MatricesWeightsKind
  18943. * - VertexBuffer.MatricesWeightsExtraKind
  18944. *
  18945. * Returns the Mesh.
  18946. */
  18947. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18948. /**
  18949. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18950. * If the mesh has no geometry, it is simply returned as it is.
  18951. * The `data` are either a numeric array either a Float32Array.
  18952. * No new underlying VertexBuffer object is created.
  18953. * 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.
  18954. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18955. *
  18956. * Possible `kind` values :
  18957. * - VertexBuffer.PositionKind
  18958. * - VertexBuffer.UVKind
  18959. * - VertexBuffer.UV2Kind
  18960. * - VertexBuffer.UV3Kind
  18961. * - VertexBuffer.UV4Kind
  18962. * - VertexBuffer.UV5Kind
  18963. * - VertexBuffer.UV6Kind
  18964. * - VertexBuffer.ColorKind
  18965. * - VertexBuffer.MatricesIndicesKind
  18966. * - VertexBuffer.MatricesIndicesExtraKind
  18967. * - VertexBuffer.MatricesWeightsKind
  18968. * - VertexBuffer.MatricesWeightsExtraKind
  18969. *
  18970. * Returns the Mesh.
  18971. */
  18972. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18973. /**
  18974. * Sets the mesh indices.
  18975. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18976. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18977. * This method creates a new index buffer each call.
  18978. * Returns the Mesh.
  18979. */
  18980. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18981. /**
  18982. * Boolean : True if the mesh owns the requested kind of data.
  18983. */
  18984. isVerticesDataPresent(kind: string): boolean;
  18985. /**
  18986. * Returns an array of indices (IndicesArray).
  18987. */
  18988. getIndices(): Nullable<IndicesArray>;
  18989. readonly _positions: Nullable<Vector3[]>;
  18990. /**
  18991. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18992. * This means the mesh underlying bounding box and sphere are recomputed.
  18993. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18994. * @returns the current mesh
  18995. */
  18996. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18997. /** @hidden */
  18998. _preActivate(): InstancedMesh;
  18999. /** @hidden */
  19000. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19001. /** @hidden */
  19002. _postActivate(): void;
  19003. getWorldMatrix(): Matrix;
  19004. readonly isAnInstance: boolean;
  19005. /**
  19006. * Returns the current associated LOD AbstractMesh.
  19007. */
  19008. getLOD(camera: Camera): AbstractMesh;
  19009. /** @hidden */
  19010. _syncSubMeshes(): InstancedMesh;
  19011. /** @hidden */
  19012. _generatePointsArray(): boolean;
  19013. /**
  19014. * Creates a new InstancedMesh from the current mesh.
  19015. * - name (string) : the cloned mesh name
  19016. * - newParent (optional Node) : the optional Node to parent the clone to.
  19017. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19018. *
  19019. * Returns the clone.
  19020. */
  19021. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19022. /**
  19023. * Disposes the InstancedMesh.
  19024. * Returns nothing.
  19025. */
  19026. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19027. }
  19028. }
  19029. declare module BABYLON {
  19030. /**
  19031. * Defines the options associated with the creation of a shader material.
  19032. */
  19033. export interface IShaderMaterialOptions {
  19034. /**
  19035. * Does the material work in alpha blend mode
  19036. */
  19037. needAlphaBlending: boolean;
  19038. /**
  19039. * Does the material work in alpha test mode
  19040. */
  19041. needAlphaTesting: boolean;
  19042. /**
  19043. * The list of attribute names used in the shader
  19044. */
  19045. attributes: string[];
  19046. /**
  19047. * The list of unifrom names used in the shader
  19048. */
  19049. uniforms: string[];
  19050. /**
  19051. * The list of UBO names used in the shader
  19052. */
  19053. uniformBuffers: string[];
  19054. /**
  19055. * The list of sampler names used in the shader
  19056. */
  19057. samplers: string[];
  19058. /**
  19059. * The list of defines used in the shader
  19060. */
  19061. defines: string[];
  19062. }
  19063. /**
  19064. * 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.
  19065. *
  19066. * This returned material effects how the mesh will look based on the code in the shaders.
  19067. *
  19068. * @see http://doc.babylonjs.com/how_to/shader_material
  19069. */
  19070. export class ShaderMaterial extends Material {
  19071. private _shaderPath;
  19072. private _options;
  19073. private _textures;
  19074. private _textureArrays;
  19075. private _floats;
  19076. private _ints;
  19077. private _floatsArrays;
  19078. private _colors3;
  19079. private _colors3Arrays;
  19080. private _colors4;
  19081. private _colors4Arrays;
  19082. private _vectors2;
  19083. private _vectors3;
  19084. private _vectors4;
  19085. private _matrices;
  19086. private _matrices3x3;
  19087. private _matrices2x2;
  19088. private _vectors2Arrays;
  19089. private _vectors3Arrays;
  19090. private _vectors4Arrays;
  19091. private _cachedWorldViewMatrix;
  19092. private _cachedWorldViewProjectionMatrix;
  19093. private _renderId;
  19094. /**
  19095. * Instantiate a new shader material.
  19096. * 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.
  19097. * This returned material effects how the mesh will look based on the code in the shaders.
  19098. * @see http://doc.babylonjs.com/how_to/shader_material
  19099. * @param name Define the name of the material in the scene
  19100. * @param scene Define the scene the material belongs to
  19101. * @param shaderPath Defines the route to the shader code in one of three ways:
  19102. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19103. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19104. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19105. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19106. * @param options Define the options used to create the shader
  19107. */
  19108. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19109. /**
  19110. * Gets the options used to compile the shader.
  19111. * They can be modified to trigger a new compilation
  19112. */
  19113. readonly options: IShaderMaterialOptions;
  19114. /**
  19115. * Gets the current class name of the material e.g. "ShaderMaterial"
  19116. * Mainly use in serialization.
  19117. * @returns the class name
  19118. */
  19119. getClassName(): string;
  19120. /**
  19121. * Specifies if the material will require alpha blending
  19122. * @returns a boolean specifying if alpha blending is needed
  19123. */
  19124. needAlphaBlending(): boolean;
  19125. /**
  19126. * Specifies if this material should be rendered in alpha test mode
  19127. * @returns a boolean specifying if an alpha test is needed.
  19128. */
  19129. needAlphaTesting(): boolean;
  19130. private _checkUniform;
  19131. /**
  19132. * Set a texture in the shader.
  19133. * @param name Define the name of the uniform samplers as defined in the shader
  19134. * @param texture Define the texture to bind to this sampler
  19135. * @return the material itself allowing "fluent" like uniform updates
  19136. */
  19137. setTexture(name: string, texture: Texture): ShaderMaterial;
  19138. /**
  19139. * Set a texture array in the shader.
  19140. * @param name Define the name of the uniform sampler array as defined in the shader
  19141. * @param textures Define the list of textures to bind to this sampler
  19142. * @return the material itself allowing "fluent" like uniform updates
  19143. */
  19144. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19145. /**
  19146. * Set a float in the shader.
  19147. * @param name Define the name of the uniform as defined in the shader
  19148. * @param value Define the value to give to the uniform
  19149. * @return the material itself allowing "fluent" like uniform updates
  19150. */
  19151. setFloat(name: string, value: number): ShaderMaterial;
  19152. /**
  19153. * Set a int in the shader.
  19154. * @param name Define the name of the uniform as defined in the shader
  19155. * @param value Define the value to give to the uniform
  19156. * @return the material itself allowing "fluent" like uniform updates
  19157. */
  19158. setInt(name: string, value: number): ShaderMaterial;
  19159. /**
  19160. * Set an array of floats in the shader.
  19161. * @param name Define the name of the uniform as defined in the shader
  19162. * @param value Define the value to give to the uniform
  19163. * @return the material itself allowing "fluent" like uniform updates
  19164. */
  19165. setFloats(name: string, value: number[]): ShaderMaterial;
  19166. /**
  19167. * Set a vec3 in the shader from a Color3.
  19168. * @param name Define the name of the uniform as defined in the shader
  19169. * @param value Define the value to give to the uniform
  19170. * @return the material itself allowing "fluent" like uniform updates
  19171. */
  19172. setColor3(name: string, value: Color3): ShaderMaterial;
  19173. /**
  19174. * Set a vec3 array in the shader from a Color3 array.
  19175. * @param name Define the name of the uniform as defined in the shader
  19176. * @param value Define the value to give to the uniform
  19177. * @return the material itself allowing "fluent" like uniform updates
  19178. */
  19179. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19180. /**
  19181. * Set a vec4 in the shader from a Color4.
  19182. * @param name Define the name of the uniform as defined in the shader
  19183. * @param value Define the value to give to the uniform
  19184. * @return the material itself allowing "fluent" like uniform updates
  19185. */
  19186. setColor4(name: string, value: Color4): ShaderMaterial;
  19187. /**
  19188. * Set a vec4 array in the shader from a Color4 array.
  19189. * @param name Define the name of the uniform as defined in the shader
  19190. * @param value Define the value to give to the uniform
  19191. * @return the material itself allowing "fluent" like uniform updates
  19192. */
  19193. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19194. /**
  19195. * Set a vec2 in the shader from a Vector2.
  19196. * @param name Define the name of the uniform as defined in the shader
  19197. * @param value Define the value to give to the uniform
  19198. * @return the material itself allowing "fluent" like uniform updates
  19199. */
  19200. setVector2(name: string, value: Vector2): ShaderMaterial;
  19201. /**
  19202. * Set a vec3 in the shader from a Vector3.
  19203. * @param name Define the name of the uniform as defined in the shader
  19204. * @param value Define the value to give to the uniform
  19205. * @return the material itself allowing "fluent" like uniform updates
  19206. */
  19207. setVector3(name: string, value: Vector3): ShaderMaterial;
  19208. /**
  19209. * Set a vec4 in the shader from a Vector4.
  19210. * @param name Define the name of the uniform as defined in the shader
  19211. * @param value Define the value to give to the uniform
  19212. * @return the material itself allowing "fluent" like uniform updates
  19213. */
  19214. setVector4(name: string, value: Vector4): ShaderMaterial;
  19215. /**
  19216. * Set a mat4 in the shader from a Matrix.
  19217. * @param name Define the name of the uniform as defined in the shader
  19218. * @param value Define the value to give to the uniform
  19219. * @return the material itself allowing "fluent" like uniform updates
  19220. */
  19221. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19222. /**
  19223. * Set a mat3 in the shader from a Float32Array.
  19224. * @param name Define the name of the uniform as defined in the shader
  19225. * @param value Define the value to give to the uniform
  19226. * @return the material itself allowing "fluent" like uniform updates
  19227. */
  19228. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19229. /**
  19230. * Set a mat2 in the shader from a Float32Array.
  19231. * @param name Define the name of the uniform as defined in the shader
  19232. * @param value Define the value to give to the uniform
  19233. * @return the material itself allowing "fluent" like uniform updates
  19234. */
  19235. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19236. /**
  19237. * Set a vec2 array in the shader from a number array.
  19238. * @param name Define the name of the uniform as defined in the shader
  19239. * @param value Define the value to give to the uniform
  19240. * @return the material itself allowing "fluent" like uniform updates
  19241. */
  19242. setArray2(name: string, value: number[]): ShaderMaterial;
  19243. /**
  19244. * Set a vec3 array in the shader from a number array.
  19245. * @param name Define the name of the uniform as defined in the shader
  19246. * @param value Define the value to give to the uniform
  19247. * @return the material itself allowing "fluent" like uniform updates
  19248. */
  19249. setArray3(name: string, value: number[]): ShaderMaterial;
  19250. /**
  19251. * Set a vec4 array in the shader from a number array.
  19252. * @param name Define the name of the uniform as defined in the shader
  19253. * @param value Define the value to give to the uniform
  19254. * @return the material itself allowing "fluent" like uniform updates
  19255. */
  19256. setArray4(name: string, value: number[]): ShaderMaterial;
  19257. private _checkCache;
  19258. /**
  19259. * Specifies that the submesh is ready to be used
  19260. * @param mesh defines the mesh to check
  19261. * @param subMesh defines which submesh to check
  19262. * @param useInstances specifies that instances should be used
  19263. * @returns a boolean indicating that the submesh is ready or not
  19264. */
  19265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19266. /**
  19267. * Checks if the material is ready to render the requested mesh
  19268. * @param mesh Define the mesh to render
  19269. * @param useInstances Define whether or not the material is used with instances
  19270. * @returns true if ready, otherwise false
  19271. */
  19272. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19273. /**
  19274. * Binds the world matrix to the material
  19275. * @param world defines the world transformation matrix
  19276. */
  19277. bindOnlyWorldMatrix(world: Matrix): void;
  19278. /**
  19279. * Binds the material to the mesh
  19280. * @param world defines the world transformation matrix
  19281. * @param mesh defines the mesh to bind the material to
  19282. */
  19283. bind(world: Matrix, mesh?: Mesh): void;
  19284. /**
  19285. * Gets the active textures from the material
  19286. * @returns an array of textures
  19287. */
  19288. getActiveTextures(): BaseTexture[];
  19289. /**
  19290. * Specifies if the material uses a texture
  19291. * @param texture defines the texture to check against the material
  19292. * @returns a boolean specifying if the material uses the texture
  19293. */
  19294. hasTexture(texture: BaseTexture): boolean;
  19295. /**
  19296. * Makes a duplicate of the material, and gives it a new name
  19297. * @param name defines the new name for the duplicated material
  19298. * @returns the cloned material
  19299. */
  19300. clone(name: string): ShaderMaterial;
  19301. /**
  19302. * Disposes the material
  19303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19305. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19306. */
  19307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19308. /**
  19309. * Serializes this material in a JSON representation
  19310. * @returns the serialized material object
  19311. */
  19312. serialize(): any;
  19313. /**
  19314. * Creates a shader material from parsed shader material data
  19315. * @param source defines the JSON represnetation of the material
  19316. * @param scene defines the hosting scene
  19317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19318. * @returns a new material
  19319. */
  19320. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19321. }
  19322. }
  19323. declare module BABYLON {
  19324. /** @hidden */
  19325. export var colorPixelShader: {
  19326. name: string;
  19327. shader: string;
  19328. };
  19329. }
  19330. declare module BABYLON {
  19331. /** @hidden */
  19332. export var colorVertexShader: {
  19333. name: string;
  19334. shader: string;
  19335. };
  19336. }
  19337. declare module BABYLON {
  19338. /**
  19339. * Line mesh
  19340. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19341. */
  19342. export class LinesMesh extends Mesh {
  19343. /**
  19344. * If vertex color should be applied to the mesh
  19345. */
  19346. readonly useVertexColor?: boolean | undefined;
  19347. /**
  19348. * If vertex alpha should be applied to the mesh
  19349. */
  19350. readonly useVertexAlpha?: boolean | undefined;
  19351. /**
  19352. * Color of the line (Default: White)
  19353. */
  19354. color: Color3;
  19355. /**
  19356. * Alpha of the line (Default: 1)
  19357. */
  19358. alpha: number;
  19359. /**
  19360. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19361. * This margin is expressed in world space coordinates, so its value may vary.
  19362. * Default value is 0.1
  19363. */
  19364. intersectionThreshold: number;
  19365. private _colorShader;
  19366. private color4;
  19367. /**
  19368. * Creates a new LinesMesh
  19369. * @param name defines the name
  19370. * @param scene defines the hosting scene
  19371. * @param parent defines the parent mesh if any
  19372. * @param source defines the optional source LinesMesh used to clone data from
  19373. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19374. * When false, achieved by calling a clone(), also passing False.
  19375. * This will make creation of children, recursive.
  19376. * @param useVertexColor defines if this LinesMesh supports vertex color
  19377. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19378. */
  19379. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19380. /**
  19381. * If vertex color should be applied to the mesh
  19382. */
  19383. useVertexColor?: boolean | undefined,
  19384. /**
  19385. * If vertex alpha should be applied to the mesh
  19386. */
  19387. useVertexAlpha?: boolean | undefined);
  19388. private _addClipPlaneDefine;
  19389. private _removeClipPlaneDefine;
  19390. isReady(): boolean;
  19391. /**
  19392. * Returns the string "LineMesh"
  19393. */
  19394. getClassName(): string;
  19395. /**
  19396. * @hidden
  19397. */
  19398. /**
  19399. * @hidden
  19400. */
  19401. material: Material;
  19402. /**
  19403. * @hidden
  19404. */
  19405. readonly checkCollisions: boolean;
  19406. /** @hidden */
  19407. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19408. /** @hidden */
  19409. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19410. /**
  19411. * Disposes of the line mesh
  19412. * @param doNotRecurse If children should be disposed
  19413. */
  19414. dispose(doNotRecurse?: boolean): void;
  19415. /**
  19416. * Returns a new LineMesh object cloned from the current one.
  19417. */
  19418. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19419. /**
  19420. * Creates a new InstancedLinesMesh object from the mesh model.
  19421. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19422. * @param name defines the name of the new instance
  19423. * @returns a new InstancedLinesMesh
  19424. */
  19425. createInstance(name: string): InstancedLinesMesh;
  19426. }
  19427. /**
  19428. * Creates an instance based on a source LinesMesh
  19429. */
  19430. export class InstancedLinesMesh extends InstancedMesh {
  19431. /**
  19432. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19433. * This margin is expressed in world space coordinates, so its value may vary.
  19434. * Initilized with the intersectionThreshold value of the source LinesMesh
  19435. */
  19436. intersectionThreshold: number;
  19437. constructor(name: string, source: LinesMesh);
  19438. /**
  19439. * Returns the string "InstancedLinesMesh".
  19440. */
  19441. getClassName(): string;
  19442. }
  19443. }
  19444. declare module BABYLON {
  19445. /** @hidden */
  19446. export var linePixelShader: {
  19447. name: string;
  19448. shader: string;
  19449. };
  19450. }
  19451. declare module BABYLON {
  19452. /** @hidden */
  19453. export var lineVertexShader: {
  19454. name: string;
  19455. shader: string;
  19456. };
  19457. }
  19458. declare module BABYLON {
  19459. interface AbstractMesh {
  19460. /**
  19461. * Gets the edgesRenderer associated with the mesh
  19462. */
  19463. edgesRenderer: Nullable<EdgesRenderer>;
  19464. }
  19465. interface LinesMesh {
  19466. /**
  19467. * Enables the edge rendering mode on the mesh.
  19468. * This mode makes the mesh edges visible
  19469. * @param epsilon defines the maximal distance between two angles to detect a face
  19470. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19471. * @returns the currentAbstractMesh
  19472. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19473. */
  19474. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19475. }
  19476. interface InstancedLinesMesh {
  19477. /**
  19478. * Enables the edge rendering mode on the mesh.
  19479. * This mode makes the mesh edges visible
  19480. * @param epsilon defines the maximal distance between two angles to detect a face
  19481. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19482. * @returns the current InstancedLinesMesh
  19483. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19484. */
  19485. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19486. }
  19487. /**
  19488. * Defines the minimum contract an Edges renderer should follow.
  19489. */
  19490. export interface IEdgesRenderer extends IDisposable {
  19491. /**
  19492. * Gets or sets a boolean indicating if the edgesRenderer is active
  19493. */
  19494. isEnabled: boolean;
  19495. /**
  19496. * Renders the edges of the attached mesh,
  19497. */
  19498. render(): void;
  19499. /**
  19500. * Checks wether or not the edges renderer is ready to render.
  19501. * @return true if ready, otherwise false.
  19502. */
  19503. isReady(): boolean;
  19504. }
  19505. /**
  19506. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19507. */
  19508. export class EdgesRenderer implements IEdgesRenderer {
  19509. /**
  19510. * Define the size of the edges with an orthographic camera
  19511. */
  19512. edgesWidthScalerForOrthographic: number;
  19513. /**
  19514. * Define the size of the edges with a perspective camera
  19515. */
  19516. edgesWidthScalerForPerspective: number;
  19517. protected _source: AbstractMesh;
  19518. protected _linesPositions: number[];
  19519. protected _linesNormals: number[];
  19520. protected _linesIndices: number[];
  19521. protected _epsilon: number;
  19522. protected _indicesCount: number;
  19523. protected _lineShader: ShaderMaterial;
  19524. protected _ib: DataBuffer;
  19525. protected _buffers: {
  19526. [key: string]: Nullable<VertexBuffer>;
  19527. };
  19528. protected _checkVerticesInsteadOfIndices: boolean;
  19529. private _meshRebuildObserver;
  19530. private _meshDisposeObserver;
  19531. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19532. isEnabled: boolean;
  19533. /**
  19534. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19535. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19536. * @param source Mesh used to create edges
  19537. * @param epsilon sum of angles in adjacency to check for edge
  19538. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19539. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19540. */
  19541. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19542. protected _prepareRessources(): void;
  19543. /** @hidden */
  19544. _rebuild(): void;
  19545. /**
  19546. * Releases the required resources for the edges renderer
  19547. */
  19548. dispose(): void;
  19549. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19550. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19551. /**
  19552. * Checks if the pair of p0 and p1 is en edge
  19553. * @param faceIndex
  19554. * @param edge
  19555. * @param faceNormals
  19556. * @param p0
  19557. * @param p1
  19558. * @private
  19559. */
  19560. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19561. /**
  19562. * push line into the position, normal and index buffer
  19563. * @protected
  19564. */
  19565. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19566. /**
  19567. * Generates lines edges from adjacencjes
  19568. * @private
  19569. */
  19570. _generateEdgesLines(): void;
  19571. /**
  19572. * Checks wether or not the edges renderer is ready to render.
  19573. * @return true if ready, otherwise false.
  19574. */
  19575. isReady(): boolean;
  19576. /**
  19577. * Renders the edges of the attached mesh,
  19578. */
  19579. render(): void;
  19580. }
  19581. /**
  19582. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19583. */
  19584. export class LineEdgesRenderer extends EdgesRenderer {
  19585. /**
  19586. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19587. * @param source LineMesh used to generate edges
  19588. * @param epsilon not important (specified angle for edge detection)
  19589. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19590. */
  19591. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19592. /**
  19593. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19594. */
  19595. _generateEdgesLines(): void;
  19596. }
  19597. }
  19598. declare module BABYLON {
  19599. /**
  19600. * This represents the object necessary to create a rendering group.
  19601. * This is exclusively used and created by the rendering manager.
  19602. * To modify the behavior, you use the available helpers in your scene or meshes.
  19603. * @hidden
  19604. */
  19605. export class RenderingGroup {
  19606. index: number;
  19607. private static _zeroVector;
  19608. private _scene;
  19609. private _opaqueSubMeshes;
  19610. private _transparentSubMeshes;
  19611. private _alphaTestSubMeshes;
  19612. private _depthOnlySubMeshes;
  19613. private _particleSystems;
  19614. private _spriteManagers;
  19615. private _opaqueSortCompareFn;
  19616. private _alphaTestSortCompareFn;
  19617. private _transparentSortCompareFn;
  19618. private _renderOpaque;
  19619. private _renderAlphaTest;
  19620. private _renderTransparent;
  19621. /** @hidden */
  19622. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19623. onBeforeTransparentRendering: () => void;
  19624. /**
  19625. * Set the opaque sort comparison function.
  19626. * If null the sub meshes will be render in the order they were created
  19627. */
  19628. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19629. /**
  19630. * Set the alpha test sort comparison function.
  19631. * If null the sub meshes will be render in the order they were created
  19632. */
  19633. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19634. /**
  19635. * Set the transparent sort comparison function.
  19636. * If null the sub meshes will be render in the order they were created
  19637. */
  19638. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19639. /**
  19640. * Creates a new rendering group.
  19641. * @param index The rendering group index
  19642. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19643. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19644. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19645. */
  19646. 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>);
  19647. /**
  19648. * Render all the sub meshes contained in the group.
  19649. * @param customRenderFunction Used to override the default render behaviour of the group.
  19650. * @returns true if rendered some submeshes.
  19651. */
  19652. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19653. /**
  19654. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19655. * @param subMeshes The submeshes to render
  19656. */
  19657. private renderOpaqueSorted;
  19658. /**
  19659. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19660. * @param subMeshes The submeshes to render
  19661. */
  19662. private renderAlphaTestSorted;
  19663. /**
  19664. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19665. * @param subMeshes The submeshes to render
  19666. */
  19667. private renderTransparentSorted;
  19668. /**
  19669. * Renders the submeshes in a specified order.
  19670. * @param subMeshes The submeshes to sort before render
  19671. * @param sortCompareFn The comparison function use to sort
  19672. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19673. * @param transparent Specifies to activate blending if true
  19674. */
  19675. private static renderSorted;
  19676. /**
  19677. * Renders the submeshes in the order they were dispatched (no sort applied).
  19678. * @param subMeshes The submeshes to render
  19679. */
  19680. private static renderUnsorted;
  19681. /**
  19682. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19683. * are rendered back to front if in the same alpha index.
  19684. *
  19685. * @param a The first submesh
  19686. * @param b The second submesh
  19687. * @returns The result of the comparison
  19688. */
  19689. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19690. /**
  19691. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19692. * are rendered back to front.
  19693. *
  19694. * @param a The first submesh
  19695. * @param b The second submesh
  19696. * @returns The result of the comparison
  19697. */
  19698. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19699. /**
  19700. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19701. * are rendered front to back (prevent overdraw).
  19702. *
  19703. * @param a The first submesh
  19704. * @param b The second submesh
  19705. * @returns The result of the comparison
  19706. */
  19707. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19708. /**
  19709. * Resets the different lists of submeshes to prepare a new frame.
  19710. */
  19711. prepare(): void;
  19712. dispose(): void;
  19713. /**
  19714. * Inserts the submesh in its correct queue depending on its material.
  19715. * @param subMesh The submesh to dispatch
  19716. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19717. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19718. */
  19719. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19720. dispatchSprites(spriteManager: ISpriteManager): void;
  19721. dispatchParticles(particleSystem: IParticleSystem): void;
  19722. private _renderParticles;
  19723. private _renderSprites;
  19724. }
  19725. }
  19726. declare module BABYLON {
  19727. /**
  19728. * Interface describing the different options available in the rendering manager
  19729. * regarding Auto Clear between groups.
  19730. */
  19731. export interface IRenderingManagerAutoClearSetup {
  19732. /**
  19733. * Defines whether or not autoclear is enable.
  19734. */
  19735. autoClear: boolean;
  19736. /**
  19737. * Defines whether or not to autoclear the depth buffer.
  19738. */
  19739. depth: boolean;
  19740. /**
  19741. * Defines whether or not to autoclear the stencil buffer.
  19742. */
  19743. stencil: boolean;
  19744. }
  19745. /**
  19746. * This class is used by the onRenderingGroupObservable
  19747. */
  19748. export class RenderingGroupInfo {
  19749. /**
  19750. * The Scene that being rendered
  19751. */
  19752. scene: Scene;
  19753. /**
  19754. * The camera currently used for the rendering pass
  19755. */
  19756. camera: Nullable<Camera>;
  19757. /**
  19758. * The ID of the renderingGroup being processed
  19759. */
  19760. renderingGroupId: number;
  19761. }
  19762. /**
  19763. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19764. * It is enable to manage the different groups as well as the different necessary sort functions.
  19765. * This should not be used directly aside of the few static configurations
  19766. */
  19767. export class RenderingManager {
  19768. /**
  19769. * The max id used for rendering groups (not included)
  19770. */
  19771. static MAX_RENDERINGGROUPS: number;
  19772. /**
  19773. * The min id used for rendering groups (included)
  19774. */
  19775. static MIN_RENDERINGGROUPS: number;
  19776. /**
  19777. * Used to globally prevent autoclearing scenes.
  19778. */
  19779. static AUTOCLEAR: boolean;
  19780. /**
  19781. * @hidden
  19782. */
  19783. _useSceneAutoClearSetup: boolean;
  19784. private _scene;
  19785. private _renderingGroups;
  19786. private _depthStencilBufferAlreadyCleaned;
  19787. private _autoClearDepthStencil;
  19788. private _customOpaqueSortCompareFn;
  19789. private _customAlphaTestSortCompareFn;
  19790. private _customTransparentSortCompareFn;
  19791. private _renderingGroupInfo;
  19792. /**
  19793. * Instantiates a new rendering group for a particular scene
  19794. * @param scene Defines the scene the groups belongs to
  19795. */
  19796. constructor(scene: Scene);
  19797. private _clearDepthStencilBuffer;
  19798. /**
  19799. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19800. * @hidden
  19801. */
  19802. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19803. /**
  19804. * Resets the different information of the group to prepare a new frame
  19805. * @hidden
  19806. */
  19807. reset(): void;
  19808. /**
  19809. * Dispose and release the group and its associated resources.
  19810. * @hidden
  19811. */
  19812. dispose(): void;
  19813. /**
  19814. * Clear the info related to rendering groups preventing retention points during dispose.
  19815. */
  19816. freeRenderingGroups(): void;
  19817. private _prepareRenderingGroup;
  19818. /**
  19819. * Add a sprite manager to the rendering manager in order to render it this frame.
  19820. * @param spriteManager Define the sprite manager to render
  19821. */
  19822. dispatchSprites(spriteManager: ISpriteManager): void;
  19823. /**
  19824. * Add a particle system to the rendering manager in order to render it this frame.
  19825. * @param particleSystem Define the particle system to render
  19826. */
  19827. dispatchParticles(particleSystem: IParticleSystem): void;
  19828. /**
  19829. * Add a submesh to the manager in order to render it this frame
  19830. * @param subMesh The submesh to dispatch
  19831. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19832. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19833. */
  19834. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19835. /**
  19836. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19837. * This allowed control for front to back rendering or reversly depending of the special needs.
  19838. *
  19839. * @param renderingGroupId The rendering group id corresponding to its index
  19840. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19841. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19842. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19843. */
  19844. 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;
  19845. /**
  19846. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19847. *
  19848. * @param renderingGroupId The rendering group id corresponding to its index
  19849. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19850. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19851. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19852. */
  19853. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19854. /**
  19855. * Gets the current auto clear configuration for one rendering group of the rendering
  19856. * manager.
  19857. * @param index the rendering group index to get the information for
  19858. * @returns The auto clear setup for the requested rendering group
  19859. */
  19860. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19861. }
  19862. }
  19863. declare module BABYLON {
  19864. /**
  19865. * This Helps creating a texture that will be created from a camera in your scene.
  19866. * It is basically a dynamic texture that could be used to create special effects for instance.
  19867. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19868. */
  19869. export class RenderTargetTexture extends Texture {
  19870. isCube: boolean;
  19871. /**
  19872. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19873. */
  19874. static readonly REFRESHRATE_RENDER_ONCE: number;
  19875. /**
  19876. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19877. */
  19878. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19879. /**
  19880. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19881. * the central point of your effect and can save a lot of performances.
  19882. */
  19883. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19884. /**
  19885. * Use this predicate to dynamically define the list of mesh you want to render.
  19886. * If set, the renderList property will be overwritten.
  19887. */
  19888. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19889. private _renderList;
  19890. /**
  19891. * Use this list to define the list of mesh you want to render.
  19892. */
  19893. renderList: Nullable<Array<AbstractMesh>>;
  19894. private _hookArray;
  19895. /**
  19896. * Define if particles should be rendered in your texture.
  19897. */
  19898. renderParticles: boolean;
  19899. /**
  19900. * Define if sprites should be rendered in your texture.
  19901. */
  19902. renderSprites: boolean;
  19903. /**
  19904. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19905. */
  19906. coordinatesMode: number;
  19907. /**
  19908. * Define the camera used to render the texture.
  19909. */
  19910. activeCamera: Nullable<Camera>;
  19911. /**
  19912. * Override the render function of the texture with your own one.
  19913. */
  19914. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19915. /**
  19916. * Define if camera post processes should be use while rendering the texture.
  19917. */
  19918. useCameraPostProcesses: boolean;
  19919. /**
  19920. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19921. */
  19922. ignoreCameraViewport: boolean;
  19923. private _postProcessManager;
  19924. private _postProcesses;
  19925. private _resizeObserver;
  19926. /**
  19927. * An event triggered when the texture is unbind.
  19928. */
  19929. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19930. /**
  19931. * An event triggered when the texture is unbind.
  19932. */
  19933. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19934. private _onAfterUnbindObserver;
  19935. /**
  19936. * Set a after unbind callback in the texture.
  19937. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19938. */
  19939. onAfterUnbind: () => void;
  19940. /**
  19941. * An event triggered before rendering the texture
  19942. */
  19943. onBeforeRenderObservable: Observable<number>;
  19944. private _onBeforeRenderObserver;
  19945. /**
  19946. * Set a before render callback in the texture.
  19947. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19948. */
  19949. onBeforeRender: (faceIndex: number) => void;
  19950. /**
  19951. * An event triggered after rendering the texture
  19952. */
  19953. onAfterRenderObservable: Observable<number>;
  19954. private _onAfterRenderObserver;
  19955. /**
  19956. * Set a after render callback in the texture.
  19957. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19958. */
  19959. onAfterRender: (faceIndex: number) => void;
  19960. /**
  19961. * An event triggered after the texture clear
  19962. */
  19963. onClearObservable: Observable<Engine>;
  19964. private _onClearObserver;
  19965. /**
  19966. * Set a clear callback in the texture.
  19967. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19968. */
  19969. onClear: (Engine: Engine) => void;
  19970. /**
  19971. * An event triggered when the texture is resized.
  19972. */
  19973. onResizeObservable: Observable<RenderTargetTexture>;
  19974. /**
  19975. * Define the clear color of the Render Target if it should be different from the scene.
  19976. */
  19977. clearColor: Color4;
  19978. protected _size: number | {
  19979. width: number;
  19980. height: number;
  19981. };
  19982. protected _initialSizeParameter: number | {
  19983. width: number;
  19984. height: number;
  19985. } | {
  19986. ratio: number;
  19987. };
  19988. protected _sizeRatio: Nullable<number>;
  19989. /** @hidden */
  19990. _generateMipMaps: boolean;
  19991. protected _renderingManager: RenderingManager;
  19992. /** @hidden */
  19993. _waitingRenderList: string[];
  19994. protected _doNotChangeAspectRatio: boolean;
  19995. protected _currentRefreshId: number;
  19996. protected _refreshRate: number;
  19997. protected _textureMatrix: Matrix;
  19998. protected _samples: number;
  19999. protected _renderTargetOptions: RenderTargetCreationOptions;
  20000. /**
  20001. * Gets render target creation options that were used.
  20002. */
  20003. readonly renderTargetOptions: RenderTargetCreationOptions;
  20004. protected _engine: Engine;
  20005. protected _onRatioRescale(): void;
  20006. /**
  20007. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20008. * It must define where the camera used to render the texture is set
  20009. */
  20010. boundingBoxPosition: Vector3;
  20011. private _boundingBoxSize;
  20012. /**
  20013. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20014. * When defined, the cubemap will switch to local mode
  20015. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20016. * @example https://www.babylonjs-playground.com/#RNASML
  20017. */
  20018. boundingBoxSize: Vector3;
  20019. /**
  20020. * In case the RTT has been created with a depth texture, get the associated
  20021. * depth texture.
  20022. * Otherwise, return null.
  20023. */
  20024. depthStencilTexture: Nullable<InternalTexture>;
  20025. /**
  20026. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20027. * or used a shadow, depth texture...
  20028. * @param name The friendly name of the texture
  20029. * @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)
  20030. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20031. * @param generateMipMaps True if mip maps need to be generated after render.
  20032. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20033. * @param type The type of the buffer in the RTT (int, half float, float...)
  20034. * @param isCube True if a cube texture needs to be created
  20035. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20036. * @param generateDepthBuffer True to generate a depth buffer
  20037. * @param generateStencilBuffer True to generate a stencil buffer
  20038. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20039. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20040. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20041. */
  20042. constructor(name: string, size: number | {
  20043. width: number;
  20044. height: number;
  20045. } | {
  20046. ratio: number;
  20047. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20048. /**
  20049. * Creates a depth stencil texture.
  20050. * This is only available in WebGL 2 or with the depth texture extension available.
  20051. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20052. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20053. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20054. */
  20055. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20056. private _processSizeParameter;
  20057. /**
  20058. * Define the number of samples to use in case of MSAA.
  20059. * It defaults to one meaning no MSAA has been enabled.
  20060. */
  20061. samples: number;
  20062. /**
  20063. * Resets the refresh counter of the texture and start bak from scratch.
  20064. * Could be useful to regenerate the texture if it is setup to render only once.
  20065. */
  20066. resetRefreshCounter(): void;
  20067. /**
  20068. * Define the refresh rate of the texture or the rendering frequency.
  20069. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20070. */
  20071. refreshRate: number;
  20072. /**
  20073. * Adds a post process to the render target rendering passes.
  20074. * @param postProcess define the post process to add
  20075. */
  20076. addPostProcess(postProcess: PostProcess): void;
  20077. /**
  20078. * Clear all the post processes attached to the render target
  20079. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20080. */
  20081. clearPostProcesses(dispose?: boolean): void;
  20082. /**
  20083. * Remove one of the post process from the list of attached post processes to the texture
  20084. * @param postProcess define the post process to remove from the list
  20085. */
  20086. removePostProcess(postProcess: PostProcess): void;
  20087. /** @hidden */
  20088. _shouldRender(): boolean;
  20089. /**
  20090. * Gets the actual render size of the texture.
  20091. * @returns the width of the render size
  20092. */
  20093. getRenderSize(): number;
  20094. /**
  20095. * Gets the actual render width of the texture.
  20096. * @returns the width of the render size
  20097. */
  20098. getRenderWidth(): number;
  20099. /**
  20100. * Gets the actual render height of the texture.
  20101. * @returns the height of the render size
  20102. */
  20103. getRenderHeight(): number;
  20104. /**
  20105. * Get if the texture can be rescaled or not.
  20106. */
  20107. readonly canRescale: boolean;
  20108. /**
  20109. * Resize the texture using a ratio.
  20110. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20111. */
  20112. scale(ratio: number): void;
  20113. /**
  20114. * Get the texture reflection matrix used to rotate/transform the reflection.
  20115. * @returns the reflection matrix
  20116. */
  20117. getReflectionTextureMatrix(): Matrix;
  20118. /**
  20119. * Resize the texture to a new desired size.
  20120. * Be carrefull as it will recreate all the data in the new texture.
  20121. * @param size Define the new size. It can be:
  20122. * - a number for squared texture,
  20123. * - an object containing { width: number, height: number }
  20124. * - or an object containing a ratio { ratio: number }
  20125. */
  20126. resize(size: number | {
  20127. width: number;
  20128. height: number;
  20129. } | {
  20130. ratio: number;
  20131. }): void;
  20132. /**
  20133. * Renders all the objects from the render list into the texture.
  20134. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20135. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20136. */
  20137. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20138. private _bestReflectionRenderTargetDimension;
  20139. /**
  20140. * @hidden
  20141. * @param faceIndex face index to bind to if this is a cubetexture
  20142. */
  20143. _bindFrameBuffer(faceIndex?: number): void;
  20144. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20145. private renderToTarget;
  20146. /**
  20147. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20148. * This allowed control for front to back rendering or reversly depending of the special needs.
  20149. *
  20150. * @param renderingGroupId The rendering group id corresponding to its index
  20151. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20152. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20153. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20154. */
  20155. 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;
  20156. /**
  20157. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20158. *
  20159. * @param renderingGroupId The rendering group id corresponding to its index
  20160. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20161. */
  20162. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20163. /**
  20164. * Clones the texture.
  20165. * @returns the cloned texture
  20166. */
  20167. clone(): RenderTargetTexture;
  20168. /**
  20169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20170. * @returns The JSON representation of the texture
  20171. */
  20172. serialize(): any;
  20173. /**
  20174. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20175. */
  20176. disposeFramebufferObjects(): void;
  20177. /**
  20178. * Dispose the texture and release its associated resources.
  20179. */
  20180. dispose(): void;
  20181. /** @hidden */
  20182. _rebuild(): void;
  20183. /**
  20184. * Clear the info related to rendering groups preventing retention point in material dispose.
  20185. */
  20186. freeRenderingGroups(): void;
  20187. /**
  20188. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20189. * @returns the view count
  20190. */
  20191. getViewCount(): number;
  20192. }
  20193. }
  20194. declare module BABYLON {
  20195. /**
  20196. * Base class for the main features of a material in Babylon.js
  20197. */
  20198. export class Material implements IAnimatable {
  20199. /**
  20200. * Returns the triangle fill mode
  20201. */
  20202. static readonly TriangleFillMode: number;
  20203. /**
  20204. * Returns the wireframe mode
  20205. */
  20206. static readonly WireFrameFillMode: number;
  20207. /**
  20208. * Returns the point fill mode
  20209. */
  20210. static readonly PointFillMode: number;
  20211. /**
  20212. * Returns the point list draw mode
  20213. */
  20214. static readonly PointListDrawMode: number;
  20215. /**
  20216. * Returns the line list draw mode
  20217. */
  20218. static readonly LineListDrawMode: number;
  20219. /**
  20220. * Returns the line loop draw mode
  20221. */
  20222. static readonly LineLoopDrawMode: number;
  20223. /**
  20224. * Returns the line strip draw mode
  20225. */
  20226. static readonly LineStripDrawMode: number;
  20227. /**
  20228. * Returns the triangle strip draw mode
  20229. */
  20230. static readonly TriangleStripDrawMode: number;
  20231. /**
  20232. * Returns the triangle fan draw mode
  20233. */
  20234. static readonly TriangleFanDrawMode: number;
  20235. /**
  20236. * Stores the clock-wise side orientation
  20237. */
  20238. static readonly ClockWiseSideOrientation: number;
  20239. /**
  20240. * Stores the counter clock-wise side orientation
  20241. */
  20242. static readonly CounterClockWiseSideOrientation: number;
  20243. /**
  20244. * The dirty texture flag value
  20245. */
  20246. static readonly TextureDirtyFlag: number;
  20247. /**
  20248. * The dirty light flag value
  20249. */
  20250. static readonly LightDirtyFlag: number;
  20251. /**
  20252. * The dirty fresnel flag value
  20253. */
  20254. static readonly FresnelDirtyFlag: number;
  20255. /**
  20256. * The dirty attribute flag value
  20257. */
  20258. static readonly AttributesDirtyFlag: number;
  20259. /**
  20260. * The dirty misc flag value
  20261. */
  20262. static readonly MiscDirtyFlag: number;
  20263. /**
  20264. * The all dirty flag value
  20265. */
  20266. static readonly AllDirtyFlag: number;
  20267. /**
  20268. * The ID of the material
  20269. */
  20270. id: string;
  20271. /**
  20272. * Gets or sets the unique id of the material
  20273. */
  20274. uniqueId: number;
  20275. /**
  20276. * The name of the material
  20277. */
  20278. name: string;
  20279. /**
  20280. * Gets or sets user defined metadata
  20281. */
  20282. metadata: any;
  20283. /**
  20284. * For internal use only. Please do not use.
  20285. */
  20286. reservedDataStore: any;
  20287. /**
  20288. * Specifies if the ready state should be checked on each call
  20289. */
  20290. checkReadyOnEveryCall: boolean;
  20291. /**
  20292. * Specifies if the ready state should be checked once
  20293. */
  20294. checkReadyOnlyOnce: boolean;
  20295. /**
  20296. * The state of the material
  20297. */
  20298. state: string;
  20299. /**
  20300. * The alpha value of the material
  20301. */
  20302. protected _alpha: number;
  20303. /**
  20304. * List of inspectable custom properties (used by the Inspector)
  20305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20306. */
  20307. inspectableCustomProperties: IInspectable[];
  20308. /**
  20309. * Sets the alpha value of the material
  20310. */
  20311. /**
  20312. * Gets the alpha value of the material
  20313. */
  20314. alpha: number;
  20315. /**
  20316. * Specifies if back face culling is enabled
  20317. */
  20318. protected _backFaceCulling: boolean;
  20319. /**
  20320. * Sets the back-face culling state
  20321. */
  20322. /**
  20323. * Gets the back-face culling state
  20324. */
  20325. backFaceCulling: boolean;
  20326. /**
  20327. * Stores the value for side orientation
  20328. */
  20329. sideOrientation: number;
  20330. /**
  20331. * Callback triggered when the material is compiled
  20332. */
  20333. onCompiled: Nullable<(effect: Effect) => void>;
  20334. /**
  20335. * Callback triggered when an error occurs
  20336. */
  20337. onError: Nullable<(effect: Effect, errors: string) => void>;
  20338. /**
  20339. * Callback triggered to get the render target textures
  20340. */
  20341. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20342. /**
  20343. * Gets a boolean indicating that current material needs to register RTT
  20344. */
  20345. readonly hasRenderTargetTextures: boolean;
  20346. /**
  20347. * Specifies if the material should be serialized
  20348. */
  20349. doNotSerialize: boolean;
  20350. /**
  20351. * @hidden
  20352. */
  20353. _storeEffectOnSubMeshes: boolean;
  20354. /**
  20355. * Stores the animations for the material
  20356. */
  20357. animations: Nullable<Array<Animation>>;
  20358. /**
  20359. * An event triggered when the material is disposed
  20360. */
  20361. onDisposeObservable: Observable<Material>;
  20362. /**
  20363. * An observer which watches for dispose events
  20364. */
  20365. private _onDisposeObserver;
  20366. private _onUnBindObservable;
  20367. /**
  20368. * Called during a dispose event
  20369. */
  20370. onDispose: () => void;
  20371. private _onBindObservable;
  20372. /**
  20373. * An event triggered when the material is bound
  20374. */
  20375. readonly onBindObservable: Observable<AbstractMesh>;
  20376. /**
  20377. * An observer which watches for bind events
  20378. */
  20379. private _onBindObserver;
  20380. /**
  20381. * Called during a bind event
  20382. */
  20383. onBind: (Mesh: AbstractMesh) => void;
  20384. /**
  20385. * An event triggered when the material is unbound
  20386. */
  20387. readonly onUnBindObservable: Observable<Material>;
  20388. /**
  20389. * Stores the value of the alpha mode
  20390. */
  20391. private _alphaMode;
  20392. /**
  20393. * Sets the value of the alpha mode.
  20394. *
  20395. * | Value | Type | Description |
  20396. * | --- | --- | --- |
  20397. * | 0 | ALPHA_DISABLE | |
  20398. * | 1 | ALPHA_ADD | |
  20399. * | 2 | ALPHA_COMBINE | |
  20400. * | 3 | ALPHA_SUBTRACT | |
  20401. * | 4 | ALPHA_MULTIPLY | |
  20402. * | 5 | ALPHA_MAXIMIZED | |
  20403. * | 6 | ALPHA_ONEONE | |
  20404. * | 7 | ALPHA_PREMULTIPLIED | |
  20405. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20406. * | 9 | ALPHA_INTERPOLATE | |
  20407. * | 10 | ALPHA_SCREENMODE | |
  20408. *
  20409. */
  20410. /**
  20411. * Gets the value of the alpha mode
  20412. */
  20413. alphaMode: number;
  20414. /**
  20415. * Stores the state of the need depth pre-pass value
  20416. */
  20417. private _needDepthPrePass;
  20418. /**
  20419. * Sets the need depth pre-pass value
  20420. */
  20421. /**
  20422. * Gets the depth pre-pass value
  20423. */
  20424. needDepthPrePass: boolean;
  20425. /**
  20426. * Specifies if depth writing should be disabled
  20427. */
  20428. disableDepthWrite: boolean;
  20429. /**
  20430. * Specifies if depth writing should be forced
  20431. */
  20432. forceDepthWrite: boolean;
  20433. /**
  20434. * Specifies if there should be a separate pass for culling
  20435. */
  20436. separateCullingPass: boolean;
  20437. /**
  20438. * Stores the state specifing if fog should be enabled
  20439. */
  20440. private _fogEnabled;
  20441. /**
  20442. * Sets the state for enabling fog
  20443. */
  20444. /**
  20445. * Gets the value of the fog enabled state
  20446. */
  20447. fogEnabled: boolean;
  20448. /**
  20449. * Stores the size of points
  20450. */
  20451. pointSize: number;
  20452. /**
  20453. * Stores the z offset value
  20454. */
  20455. zOffset: number;
  20456. /**
  20457. * Gets a value specifying if wireframe mode is enabled
  20458. */
  20459. /**
  20460. * Sets the state of wireframe mode
  20461. */
  20462. wireframe: boolean;
  20463. /**
  20464. * Gets the value specifying if point clouds are enabled
  20465. */
  20466. /**
  20467. * Sets the state of point cloud mode
  20468. */
  20469. pointsCloud: boolean;
  20470. /**
  20471. * Gets the material fill mode
  20472. */
  20473. /**
  20474. * Sets the material fill mode
  20475. */
  20476. fillMode: number;
  20477. /**
  20478. * @hidden
  20479. * Stores the effects for the material
  20480. */
  20481. _effect: Nullable<Effect>;
  20482. /**
  20483. * @hidden
  20484. * Specifies if the material was previously ready
  20485. */
  20486. _wasPreviouslyReady: boolean;
  20487. /**
  20488. * Specifies if uniform buffers should be used
  20489. */
  20490. private _useUBO;
  20491. /**
  20492. * Stores a reference to the scene
  20493. */
  20494. private _scene;
  20495. /**
  20496. * Stores the fill mode state
  20497. */
  20498. private _fillMode;
  20499. /**
  20500. * Specifies if the depth write state should be cached
  20501. */
  20502. private _cachedDepthWriteState;
  20503. /**
  20504. * Stores the uniform buffer
  20505. */
  20506. protected _uniformBuffer: UniformBuffer;
  20507. /** @hidden */
  20508. _indexInSceneMaterialArray: number;
  20509. /** @hidden */
  20510. meshMap: Nullable<{
  20511. [id: string]: AbstractMesh | undefined;
  20512. }>;
  20513. /**
  20514. * Creates a material instance
  20515. * @param name defines the name of the material
  20516. * @param scene defines the scene to reference
  20517. * @param doNotAdd specifies if the material should be added to the scene
  20518. */
  20519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20520. /**
  20521. * Returns a string representation of the current material
  20522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20523. * @returns a string with material information
  20524. */
  20525. toString(fullDetails?: boolean): string;
  20526. /**
  20527. * Gets the class name of the material
  20528. * @returns a string with the class name of the material
  20529. */
  20530. getClassName(): string;
  20531. /**
  20532. * Specifies if updates for the material been locked
  20533. */
  20534. readonly isFrozen: boolean;
  20535. /**
  20536. * Locks updates for the material
  20537. */
  20538. freeze(): void;
  20539. /**
  20540. * Unlocks updates for the material
  20541. */
  20542. unfreeze(): void;
  20543. /**
  20544. * Specifies if the material is ready to be used
  20545. * @param mesh defines the mesh to check
  20546. * @param useInstances specifies if instances should be used
  20547. * @returns a boolean indicating if the material is ready to be used
  20548. */
  20549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20550. /**
  20551. * Specifies that the submesh is ready to be used
  20552. * @param mesh defines the mesh to check
  20553. * @param subMesh defines which submesh to check
  20554. * @param useInstances specifies that instances should be used
  20555. * @returns a boolean indicating that the submesh is ready or not
  20556. */
  20557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20558. /**
  20559. * Returns the material effect
  20560. * @returns the effect associated with the material
  20561. */
  20562. getEffect(): Nullable<Effect>;
  20563. /**
  20564. * Returns the current scene
  20565. * @returns a Scene
  20566. */
  20567. getScene(): Scene;
  20568. /**
  20569. * Specifies if the material will require alpha blending
  20570. * @returns a boolean specifying if alpha blending is needed
  20571. */
  20572. needAlphaBlending(): boolean;
  20573. /**
  20574. * Specifies if the mesh will require alpha blending
  20575. * @param mesh defines the mesh to check
  20576. * @returns a boolean specifying if alpha blending is needed for the mesh
  20577. */
  20578. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20579. /**
  20580. * Specifies if this material should be rendered in alpha test mode
  20581. * @returns a boolean specifying if an alpha test is needed.
  20582. */
  20583. needAlphaTesting(): boolean;
  20584. /**
  20585. * Gets the texture used for the alpha test
  20586. * @returns the texture to use for alpha testing
  20587. */
  20588. getAlphaTestTexture(): Nullable<BaseTexture>;
  20589. /**
  20590. * Marks the material to indicate that it needs to be re-calculated
  20591. */
  20592. markDirty(): void;
  20593. /** @hidden */
  20594. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20595. /**
  20596. * Binds the material to the mesh
  20597. * @param world defines the world transformation matrix
  20598. * @param mesh defines the mesh to bind the material to
  20599. */
  20600. bind(world: Matrix, mesh?: Mesh): void;
  20601. /**
  20602. * Binds the submesh to the material
  20603. * @param world defines the world transformation matrix
  20604. * @param mesh defines the mesh containing the submesh
  20605. * @param subMesh defines the submesh to bind the material to
  20606. */
  20607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20608. /**
  20609. * Binds the world matrix to the material
  20610. * @param world defines the world transformation matrix
  20611. */
  20612. bindOnlyWorldMatrix(world: Matrix): void;
  20613. /**
  20614. * Binds the scene's uniform buffer to the effect.
  20615. * @param effect defines the effect to bind to the scene uniform buffer
  20616. * @param sceneUbo defines the uniform buffer storing scene data
  20617. */
  20618. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20619. /**
  20620. * Binds the view matrix to the effect
  20621. * @param effect defines the effect to bind the view matrix to
  20622. */
  20623. bindView(effect: Effect): void;
  20624. /**
  20625. * Binds the view projection matrix to the effect
  20626. * @param effect defines the effect to bind the view projection matrix to
  20627. */
  20628. bindViewProjection(effect: Effect): void;
  20629. /**
  20630. * Specifies if material alpha testing should be turned on for the mesh
  20631. * @param mesh defines the mesh to check
  20632. */
  20633. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20634. /**
  20635. * Processes to execute after binding the material to a mesh
  20636. * @param mesh defines the rendered mesh
  20637. */
  20638. protected _afterBind(mesh?: Mesh): void;
  20639. /**
  20640. * Unbinds the material from the mesh
  20641. */
  20642. unbind(): void;
  20643. /**
  20644. * Gets the active textures from the material
  20645. * @returns an array of textures
  20646. */
  20647. getActiveTextures(): BaseTexture[];
  20648. /**
  20649. * Specifies if the material uses a texture
  20650. * @param texture defines the texture to check against the material
  20651. * @returns a boolean specifying if the material uses the texture
  20652. */
  20653. hasTexture(texture: BaseTexture): boolean;
  20654. /**
  20655. * Makes a duplicate of the material, and gives it a new name
  20656. * @param name defines the new name for the duplicated material
  20657. * @returns the cloned material
  20658. */
  20659. clone(name: string): Nullable<Material>;
  20660. /**
  20661. * Gets the meshes bound to the material
  20662. * @returns an array of meshes bound to the material
  20663. */
  20664. getBindedMeshes(): AbstractMesh[];
  20665. /**
  20666. * Force shader compilation
  20667. * @param mesh defines the mesh associated with this material
  20668. * @param onCompiled defines a function to execute once the material is compiled
  20669. * @param options defines the options to configure the compilation
  20670. */
  20671. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20672. clipPlane: boolean;
  20673. }>): void;
  20674. /**
  20675. * Force shader compilation
  20676. * @param mesh defines the mesh that will use this material
  20677. * @param options defines additional options for compiling the shaders
  20678. * @returns a promise that resolves when the compilation completes
  20679. */
  20680. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20681. clipPlane: boolean;
  20682. }>): Promise<void>;
  20683. private static readonly _AllDirtyCallBack;
  20684. private static readonly _ImageProcessingDirtyCallBack;
  20685. private static readonly _TextureDirtyCallBack;
  20686. private static readonly _FresnelDirtyCallBack;
  20687. private static readonly _MiscDirtyCallBack;
  20688. private static readonly _LightsDirtyCallBack;
  20689. private static readonly _AttributeDirtyCallBack;
  20690. private static _FresnelAndMiscDirtyCallBack;
  20691. private static _TextureAndMiscDirtyCallBack;
  20692. private static readonly _DirtyCallbackArray;
  20693. private static readonly _RunDirtyCallBacks;
  20694. /**
  20695. * Marks a define in the material to indicate that it needs to be re-computed
  20696. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20697. */
  20698. markAsDirty(flag: number): void;
  20699. /**
  20700. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20701. * @param func defines a function which checks material defines against the submeshes
  20702. */
  20703. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20704. /**
  20705. * Indicates that we need to re-calculated for all submeshes
  20706. */
  20707. protected _markAllSubMeshesAsAllDirty(): void;
  20708. /**
  20709. * Indicates that image processing needs to be re-calculated for all submeshes
  20710. */
  20711. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20712. /**
  20713. * Indicates that textures need to be re-calculated for all submeshes
  20714. */
  20715. protected _markAllSubMeshesAsTexturesDirty(): void;
  20716. /**
  20717. * Indicates that fresnel needs to be re-calculated for all submeshes
  20718. */
  20719. protected _markAllSubMeshesAsFresnelDirty(): void;
  20720. /**
  20721. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20722. */
  20723. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20724. /**
  20725. * Indicates that lights need to be re-calculated for all submeshes
  20726. */
  20727. protected _markAllSubMeshesAsLightsDirty(): void;
  20728. /**
  20729. * Indicates that attributes need to be re-calculated for all submeshes
  20730. */
  20731. protected _markAllSubMeshesAsAttributesDirty(): void;
  20732. /**
  20733. * Indicates that misc needs to be re-calculated for all submeshes
  20734. */
  20735. protected _markAllSubMeshesAsMiscDirty(): void;
  20736. /**
  20737. * Indicates that textures and misc need to be re-calculated for all submeshes
  20738. */
  20739. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20740. /**
  20741. * Disposes the material
  20742. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20743. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20744. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20745. */
  20746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20747. /** @hidden */
  20748. private releaseVertexArrayObject;
  20749. /**
  20750. * Serializes this material
  20751. * @returns the serialized material object
  20752. */
  20753. serialize(): any;
  20754. /**
  20755. * Creates a material from parsed material data
  20756. * @param parsedMaterial defines parsed material data
  20757. * @param scene defines the hosting scene
  20758. * @param rootUrl defines the root URL to use to load textures
  20759. * @returns a new material
  20760. */
  20761. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20762. }
  20763. }
  20764. declare module BABYLON {
  20765. /**
  20766. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20767. * separate meshes. This can be use to improve performances.
  20768. * @see http://doc.babylonjs.com/how_to/multi_materials
  20769. */
  20770. export class MultiMaterial extends Material {
  20771. private _subMaterials;
  20772. /**
  20773. * Gets or Sets the list of Materials used within the multi material.
  20774. * They need to be ordered according to the submeshes order in the associated mesh
  20775. */
  20776. subMaterials: Nullable<Material>[];
  20777. /**
  20778. * Function used to align with Node.getChildren()
  20779. * @returns the list of Materials used within the multi material
  20780. */
  20781. getChildren(): Nullable<Material>[];
  20782. /**
  20783. * Instantiates a new Multi Material
  20784. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20785. * separate meshes. This can be use to improve performances.
  20786. * @see http://doc.babylonjs.com/how_to/multi_materials
  20787. * @param name Define the name in the scene
  20788. * @param scene Define the scene the material belongs to
  20789. */
  20790. constructor(name: string, scene: Scene);
  20791. private _hookArray;
  20792. /**
  20793. * Get one of the submaterial by its index in the submaterials array
  20794. * @param index The index to look the sub material at
  20795. * @returns The Material if the index has been defined
  20796. */
  20797. getSubMaterial(index: number): Nullable<Material>;
  20798. /**
  20799. * Get the list of active textures for the whole sub materials list.
  20800. * @returns All the textures that will be used during the rendering
  20801. */
  20802. getActiveTextures(): BaseTexture[];
  20803. /**
  20804. * Gets the current class name of the material e.g. "MultiMaterial"
  20805. * Mainly use in serialization.
  20806. * @returns the class name
  20807. */
  20808. getClassName(): string;
  20809. /**
  20810. * Checks if the material is ready to render the requested sub mesh
  20811. * @param mesh Define the mesh the submesh belongs to
  20812. * @param subMesh Define the sub mesh to look readyness for
  20813. * @param useInstances Define whether or not the material is used with instances
  20814. * @returns true if ready, otherwise false
  20815. */
  20816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20817. /**
  20818. * Clones the current material and its related sub materials
  20819. * @param name Define the name of the newly cloned material
  20820. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20821. * @returns the cloned material
  20822. */
  20823. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20824. /**
  20825. * Serializes the materials into a JSON representation.
  20826. * @returns the JSON representation
  20827. */
  20828. serialize(): any;
  20829. /**
  20830. * Dispose the material and release its associated resources
  20831. * @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)
  20832. * @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)
  20833. * @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)
  20834. */
  20835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20836. /**
  20837. * Creates a MultiMaterial from parsed MultiMaterial data.
  20838. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20839. * @param scene defines the hosting scene
  20840. * @returns a new MultiMaterial
  20841. */
  20842. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20843. }
  20844. }
  20845. declare module BABYLON {
  20846. /**
  20847. * Base class for submeshes
  20848. */
  20849. export class BaseSubMesh {
  20850. /** @hidden */
  20851. _materialDefines: Nullable<MaterialDefines>;
  20852. /** @hidden */
  20853. _materialEffect: Nullable<Effect>;
  20854. /**
  20855. * Gets associated effect
  20856. */
  20857. readonly effect: Nullable<Effect>;
  20858. /**
  20859. * Sets associated effect (effect used to render this submesh)
  20860. * @param effect defines the effect to associate with
  20861. * @param defines defines the set of defines used to compile this effect
  20862. */
  20863. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20864. }
  20865. /**
  20866. * Defines a subdivision inside a mesh
  20867. */
  20868. export class SubMesh extends BaseSubMesh implements ICullable {
  20869. /** the material index to use */
  20870. materialIndex: number;
  20871. /** vertex index start */
  20872. verticesStart: number;
  20873. /** vertices count */
  20874. verticesCount: number;
  20875. /** index start */
  20876. indexStart: number;
  20877. /** indices count */
  20878. indexCount: number;
  20879. /** @hidden */
  20880. _linesIndexCount: number;
  20881. private _mesh;
  20882. private _renderingMesh;
  20883. private _boundingInfo;
  20884. private _linesIndexBuffer;
  20885. /** @hidden */
  20886. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20887. /** @hidden */
  20888. _trianglePlanes: Plane[];
  20889. /** @hidden */
  20890. _lastColliderTransformMatrix: Nullable<Matrix>;
  20891. /** @hidden */
  20892. _renderId: number;
  20893. /** @hidden */
  20894. _alphaIndex: number;
  20895. /** @hidden */
  20896. _distanceToCamera: number;
  20897. /** @hidden */
  20898. _id: number;
  20899. private _currentMaterial;
  20900. /**
  20901. * Add a new submesh to a mesh
  20902. * @param materialIndex defines the material index to use
  20903. * @param verticesStart defines vertex index start
  20904. * @param verticesCount defines vertices count
  20905. * @param indexStart defines index start
  20906. * @param indexCount defines indices count
  20907. * @param mesh defines the parent mesh
  20908. * @param renderingMesh defines an optional rendering mesh
  20909. * @param createBoundingBox defines if bounding box should be created for this submesh
  20910. * @returns the new submesh
  20911. */
  20912. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20913. /**
  20914. * Creates a new submesh
  20915. * @param materialIndex defines the material index to use
  20916. * @param verticesStart defines vertex index start
  20917. * @param verticesCount defines vertices count
  20918. * @param indexStart defines index start
  20919. * @param indexCount defines indices count
  20920. * @param mesh defines the parent mesh
  20921. * @param renderingMesh defines an optional rendering mesh
  20922. * @param createBoundingBox defines if bounding box should be created for this submesh
  20923. */
  20924. constructor(
  20925. /** the material index to use */
  20926. materialIndex: number,
  20927. /** vertex index start */
  20928. verticesStart: number,
  20929. /** vertices count */
  20930. verticesCount: number,
  20931. /** index start */
  20932. indexStart: number,
  20933. /** indices count */
  20934. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20935. /**
  20936. * Returns true if this submesh covers the entire parent mesh
  20937. * @ignorenaming
  20938. */
  20939. readonly IsGlobal: boolean;
  20940. /**
  20941. * Returns the submesh BoudingInfo object
  20942. * @returns current bounding info (or mesh's one if the submesh is global)
  20943. */
  20944. getBoundingInfo(): BoundingInfo;
  20945. /**
  20946. * Sets the submesh BoundingInfo
  20947. * @param boundingInfo defines the new bounding info to use
  20948. * @returns the SubMesh
  20949. */
  20950. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20951. /**
  20952. * Returns the mesh of the current submesh
  20953. * @return the parent mesh
  20954. */
  20955. getMesh(): AbstractMesh;
  20956. /**
  20957. * Returns the rendering mesh of the submesh
  20958. * @returns the rendering mesh (could be different from parent mesh)
  20959. */
  20960. getRenderingMesh(): Mesh;
  20961. /**
  20962. * Returns the submesh material
  20963. * @returns null or the current material
  20964. */
  20965. getMaterial(): Nullable<Material>;
  20966. /**
  20967. * Sets a new updated BoundingInfo object to the submesh
  20968. * @param data defines an optional position array to use to determine the bounding info
  20969. * @returns the SubMesh
  20970. */
  20971. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20972. /** @hidden */
  20973. _checkCollision(collider: Collider): boolean;
  20974. /**
  20975. * Updates the submesh BoundingInfo
  20976. * @param world defines the world matrix to use to update the bounding info
  20977. * @returns the submesh
  20978. */
  20979. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20980. /**
  20981. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20982. * @param frustumPlanes defines the frustum planes
  20983. * @returns true if the submesh is intersecting with the frustum
  20984. */
  20985. isInFrustum(frustumPlanes: Plane[]): boolean;
  20986. /**
  20987. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20988. * @param frustumPlanes defines the frustum planes
  20989. * @returns true if the submesh is inside the frustum
  20990. */
  20991. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20992. /**
  20993. * Renders the submesh
  20994. * @param enableAlphaMode defines if alpha needs to be used
  20995. * @returns the submesh
  20996. */
  20997. render(enableAlphaMode: boolean): SubMesh;
  20998. /**
  20999. * @hidden
  21000. */
  21001. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21002. /**
  21003. * Checks if the submesh intersects with a ray
  21004. * @param ray defines the ray to test
  21005. * @returns true is the passed ray intersects the submesh bounding box
  21006. */
  21007. canIntersects(ray: Ray): boolean;
  21008. /**
  21009. * Intersects current submesh with a ray
  21010. * @param ray defines the ray to test
  21011. * @param positions defines mesh's positions array
  21012. * @param indices defines mesh's indices array
  21013. * @param fastCheck defines if only bounding info should be used
  21014. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21015. * @returns intersection info or null if no intersection
  21016. */
  21017. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21018. /** @hidden */
  21019. private _intersectLines;
  21020. /** @hidden */
  21021. private _intersectUnIndexedLines;
  21022. /** @hidden */
  21023. private _intersectTriangles;
  21024. /** @hidden */
  21025. private _intersectUnIndexedTriangles;
  21026. /** @hidden */
  21027. _rebuild(): void;
  21028. /**
  21029. * Creates a new submesh from the passed mesh
  21030. * @param newMesh defines the new hosting mesh
  21031. * @param newRenderingMesh defines an optional rendering mesh
  21032. * @returns the new submesh
  21033. */
  21034. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21035. /**
  21036. * Release associated resources
  21037. */
  21038. dispose(): void;
  21039. /**
  21040. * Gets the class name
  21041. * @returns the string "SubMesh".
  21042. */
  21043. getClassName(): string;
  21044. /**
  21045. * Creates a new submesh from indices data
  21046. * @param materialIndex the index of the main mesh material
  21047. * @param startIndex the index where to start the copy in the mesh indices array
  21048. * @param indexCount the number of indices to copy then from the startIndex
  21049. * @param mesh the main mesh to create the submesh from
  21050. * @param renderingMesh the optional rendering mesh
  21051. * @returns a new submesh
  21052. */
  21053. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21054. }
  21055. }
  21056. declare module BABYLON {
  21057. /**
  21058. * Class used to represent data loading progression
  21059. */
  21060. export class SceneLoaderFlags {
  21061. private static _ForceFullSceneLoadingForIncremental;
  21062. private static _ShowLoadingScreen;
  21063. private static _CleanBoneMatrixWeights;
  21064. private static _loggingLevel;
  21065. /**
  21066. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21067. */
  21068. static ForceFullSceneLoadingForIncremental: boolean;
  21069. /**
  21070. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21071. */
  21072. static ShowLoadingScreen: boolean;
  21073. /**
  21074. * Defines the current logging level (while loading the scene)
  21075. * @ignorenaming
  21076. */
  21077. static loggingLevel: number;
  21078. /**
  21079. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21080. */
  21081. static CleanBoneMatrixWeights: boolean;
  21082. }
  21083. }
  21084. declare module BABYLON {
  21085. /**
  21086. * Class used to store geometry data (vertex buffers + index buffer)
  21087. */
  21088. export class Geometry implements IGetSetVerticesData {
  21089. /**
  21090. * Gets or sets the ID of the geometry
  21091. */
  21092. id: string;
  21093. /**
  21094. * Gets or sets the unique ID of the geometry
  21095. */
  21096. uniqueId: number;
  21097. /**
  21098. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21099. */
  21100. delayLoadState: number;
  21101. /**
  21102. * Gets the file containing the data to load when running in delay load state
  21103. */
  21104. delayLoadingFile: Nullable<string>;
  21105. /**
  21106. * Callback called when the geometry is updated
  21107. */
  21108. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21109. private _scene;
  21110. private _engine;
  21111. private _meshes;
  21112. private _totalVertices;
  21113. /** @hidden */
  21114. _indices: IndicesArray;
  21115. /** @hidden */
  21116. _vertexBuffers: {
  21117. [key: string]: VertexBuffer;
  21118. };
  21119. private _isDisposed;
  21120. private _extend;
  21121. private _boundingBias;
  21122. /** @hidden */
  21123. _delayInfo: Array<string>;
  21124. private _indexBuffer;
  21125. private _indexBufferIsUpdatable;
  21126. /** @hidden */
  21127. _boundingInfo: Nullable<BoundingInfo>;
  21128. /** @hidden */
  21129. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21130. /** @hidden */
  21131. _softwareSkinningFrameId: number;
  21132. private _vertexArrayObjects;
  21133. private _updatable;
  21134. /** @hidden */
  21135. _positions: Nullable<Vector3[]>;
  21136. /**
  21137. * 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
  21138. */
  21139. /**
  21140. * 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
  21141. */
  21142. boundingBias: Vector2;
  21143. /**
  21144. * Static function used to attach a new empty geometry to a mesh
  21145. * @param mesh defines the mesh to attach the geometry to
  21146. * @returns the new Geometry
  21147. */
  21148. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21149. /**
  21150. * Creates a new geometry
  21151. * @param id defines the unique ID
  21152. * @param scene defines the hosting scene
  21153. * @param vertexData defines the VertexData used to get geometry data
  21154. * @param updatable defines if geometry must be updatable (false by default)
  21155. * @param mesh defines the mesh that will be associated with the geometry
  21156. */
  21157. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21158. /**
  21159. * Gets the current extend of the geometry
  21160. */
  21161. readonly extend: {
  21162. minimum: Vector3;
  21163. maximum: Vector3;
  21164. };
  21165. /**
  21166. * Gets the hosting scene
  21167. * @returns the hosting Scene
  21168. */
  21169. getScene(): Scene;
  21170. /**
  21171. * Gets the hosting engine
  21172. * @returns the hosting Engine
  21173. */
  21174. getEngine(): Engine;
  21175. /**
  21176. * Defines if the geometry is ready to use
  21177. * @returns true if the geometry is ready to be used
  21178. */
  21179. isReady(): boolean;
  21180. /**
  21181. * Gets a value indicating that the geometry should not be serialized
  21182. */
  21183. readonly doNotSerialize: boolean;
  21184. /** @hidden */
  21185. _rebuild(): void;
  21186. /**
  21187. * Affects all geometry data in one call
  21188. * @param vertexData defines the geometry data
  21189. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21190. */
  21191. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21192. /**
  21193. * Set specific vertex data
  21194. * @param kind defines the data kind (Position, normal, etc...)
  21195. * @param data defines the vertex data to use
  21196. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21197. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21198. */
  21199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21200. /**
  21201. * Removes a specific vertex data
  21202. * @param kind defines the data kind (Position, normal, etc...)
  21203. */
  21204. removeVerticesData(kind: string): void;
  21205. /**
  21206. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21207. * @param buffer defines the vertex buffer to use
  21208. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21209. */
  21210. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21211. /**
  21212. * Update a specific vertex buffer
  21213. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21214. * It will do nothing if the buffer is not updatable
  21215. * @param kind defines the data kind (Position, normal, etc...)
  21216. * @param data defines the data to use
  21217. * @param offset defines the offset in the target buffer where to store the data
  21218. * @param useBytes set to true if the offset is in bytes
  21219. */
  21220. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21221. /**
  21222. * Update a specific vertex buffer
  21223. * This function will create a new buffer if the current one is not updatable
  21224. * @param kind defines the data kind (Position, normal, etc...)
  21225. * @param data defines the data to use
  21226. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21227. */
  21228. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21229. private _updateBoundingInfo;
  21230. /** @hidden */
  21231. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21232. /**
  21233. * Gets total number of vertices
  21234. * @returns the total number of vertices
  21235. */
  21236. getTotalVertices(): number;
  21237. /**
  21238. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21239. * @param kind defines the data kind (Position, normal, etc...)
  21240. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21242. * @returns a float array containing vertex data
  21243. */
  21244. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21245. /**
  21246. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21247. * @param kind defines the data kind (Position, normal, etc...)
  21248. * @returns true if the vertex buffer with the specified kind is updatable
  21249. */
  21250. isVertexBufferUpdatable(kind: string): boolean;
  21251. /**
  21252. * Gets a specific vertex buffer
  21253. * @param kind defines the data kind (Position, normal, etc...)
  21254. * @returns a VertexBuffer
  21255. */
  21256. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21257. /**
  21258. * Returns all vertex buffers
  21259. * @return an object holding all vertex buffers indexed by kind
  21260. */
  21261. getVertexBuffers(): Nullable<{
  21262. [key: string]: VertexBuffer;
  21263. }>;
  21264. /**
  21265. * Gets a boolean indicating if specific vertex buffer is present
  21266. * @param kind defines the data kind (Position, normal, etc...)
  21267. * @returns true if data is present
  21268. */
  21269. isVerticesDataPresent(kind: string): boolean;
  21270. /**
  21271. * Gets a list of all attached data kinds (Position, normal, etc...)
  21272. * @returns a list of string containing all kinds
  21273. */
  21274. getVerticesDataKinds(): string[];
  21275. /**
  21276. * Update index buffer
  21277. * @param indices defines the indices to store in the index buffer
  21278. * @param offset defines the offset in the target buffer where to store the data
  21279. * @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)
  21280. */
  21281. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21282. /**
  21283. * Creates a new index buffer
  21284. * @param indices defines the indices to store in the index buffer
  21285. * @param totalVertices defines the total number of vertices (could be null)
  21286. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21287. */
  21288. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21289. /**
  21290. * Return the total number of indices
  21291. * @returns the total number of indices
  21292. */
  21293. getTotalIndices(): number;
  21294. /**
  21295. * Gets the index buffer array
  21296. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21297. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21298. * @returns the index buffer array
  21299. */
  21300. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21301. /**
  21302. * Gets the index buffer
  21303. * @return the index buffer
  21304. */
  21305. getIndexBuffer(): Nullable<DataBuffer>;
  21306. /** @hidden */
  21307. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21308. /**
  21309. * Release the associated resources for a specific mesh
  21310. * @param mesh defines the source mesh
  21311. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21312. */
  21313. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21314. /**
  21315. * Apply current geometry to a given mesh
  21316. * @param mesh defines the mesh to apply geometry to
  21317. */
  21318. applyToMesh(mesh: Mesh): void;
  21319. private _updateExtend;
  21320. private _applyToMesh;
  21321. private notifyUpdate;
  21322. /**
  21323. * Load the geometry if it was flagged as delay loaded
  21324. * @param scene defines the hosting scene
  21325. * @param onLoaded defines a callback called when the geometry is loaded
  21326. */
  21327. load(scene: Scene, onLoaded?: () => void): void;
  21328. private _queueLoad;
  21329. /**
  21330. * Invert the geometry to move from a right handed system to a left handed one.
  21331. */
  21332. toLeftHanded(): void;
  21333. /** @hidden */
  21334. _resetPointsArrayCache(): void;
  21335. /** @hidden */
  21336. _generatePointsArray(): boolean;
  21337. /**
  21338. * Gets a value indicating if the geometry is disposed
  21339. * @returns true if the geometry was disposed
  21340. */
  21341. isDisposed(): boolean;
  21342. private _disposeVertexArrayObjects;
  21343. /**
  21344. * Free all associated resources
  21345. */
  21346. dispose(): void;
  21347. /**
  21348. * Clone the current geometry into a new geometry
  21349. * @param id defines the unique ID of the new geometry
  21350. * @returns a new geometry object
  21351. */
  21352. copy(id: string): Geometry;
  21353. /**
  21354. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21355. * @return a JSON representation of the current geometry data (without the vertices data)
  21356. */
  21357. serialize(): any;
  21358. private toNumberArray;
  21359. /**
  21360. * Serialize all vertices data into a JSON oject
  21361. * @returns a JSON representation of the current geometry data
  21362. */
  21363. serializeVerticeData(): any;
  21364. /**
  21365. * Extracts a clone of a mesh geometry
  21366. * @param mesh defines the source mesh
  21367. * @param id defines the unique ID of the new geometry object
  21368. * @returns the new geometry object
  21369. */
  21370. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21371. /**
  21372. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21373. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21374. * Be aware Math.random() could cause collisions, but:
  21375. * "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"
  21376. * @returns a string containing a new GUID
  21377. */
  21378. static RandomId(): string;
  21379. /** @hidden */
  21380. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21381. private static _CleanMatricesWeights;
  21382. /**
  21383. * Create a new geometry from persisted data (Using .babylon file format)
  21384. * @param parsedVertexData defines the persisted data
  21385. * @param scene defines the hosting scene
  21386. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21387. * @returns the new geometry object
  21388. */
  21389. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21390. }
  21391. }
  21392. declare module BABYLON {
  21393. /**
  21394. * Define an interface for all classes that will get and set the data on vertices
  21395. */
  21396. export interface IGetSetVerticesData {
  21397. /**
  21398. * Gets a boolean indicating if specific vertex data is present
  21399. * @param kind defines the vertex data kind to use
  21400. * @returns true is data kind is present
  21401. */
  21402. isVerticesDataPresent(kind: string): boolean;
  21403. /**
  21404. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21405. * @param kind defines the data kind (Position, normal, etc...)
  21406. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21407. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21408. * @returns a float array containing vertex data
  21409. */
  21410. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21411. /**
  21412. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21413. * @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.
  21414. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21415. * @returns the indices array or an empty array if the mesh has no geometry
  21416. */
  21417. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21418. /**
  21419. * Set specific vertex data
  21420. * @param kind defines the data kind (Position, normal, etc...)
  21421. * @param data defines the vertex data to use
  21422. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21423. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21424. */
  21425. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21426. /**
  21427. * Update a specific associated vertex buffer
  21428. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21429. * - VertexBuffer.PositionKind
  21430. * - VertexBuffer.UVKind
  21431. * - VertexBuffer.UV2Kind
  21432. * - VertexBuffer.UV3Kind
  21433. * - VertexBuffer.UV4Kind
  21434. * - VertexBuffer.UV5Kind
  21435. * - VertexBuffer.UV6Kind
  21436. * - VertexBuffer.ColorKind
  21437. * - VertexBuffer.MatricesIndicesKind
  21438. * - VertexBuffer.MatricesIndicesExtraKind
  21439. * - VertexBuffer.MatricesWeightsKind
  21440. * - VertexBuffer.MatricesWeightsExtraKind
  21441. * @param data defines the data source
  21442. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21443. * @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)
  21444. */
  21445. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21446. /**
  21447. * Creates a new index buffer
  21448. * @param indices defines the indices to store in the index buffer
  21449. * @param totalVertices defines the total number of vertices (could be null)
  21450. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21451. */
  21452. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21453. }
  21454. /**
  21455. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21456. */
  21457. export class VertexData {
  21458. /**
  21459. * Mesh side orientation : usually the external or front surface
  21460. */
  21461. static readonly FRONTSIDE: number;
  21462. /**
  21463. * Mesh side orientation : usually the internal or back surface
  21464. */
  21465. static readonly BACKSIDE: number;
  21466. /**
  21467. * Mesh side orientation : both internal and external or front and back surfaces
  21468. */
  21469. static readonly DOUBLESIDE: number;
  21470. /**
  21471. * Mesh side orientation : by default, `FRONTSIDE`
  21472. */
  21473. static readonly DEFAULTSIDE: number;
  21474. /**
  21475. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21476. */
  21477. positions: Nullable<FloatArray>;
  21478. /**
  21479. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21480. */
  21481. normals: Nullable<FloatArray>;
  21482. /**
  21483. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21484. */
  21485. tangents: Nullable<FloatArray>;
  21486. /**
  21487. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21488. */
  21489. uvs: Nullable<FloatArray>;
  21490. /**
  21491. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21492. */
  21493. uvs2: Nullable<FloatArray>;
  21494. /**
  21495. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21496. */
  21497. uvs3: Nullable<FloatArray>;
  21498. /**
  21499. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21500. */
  21501. uvs4: Nullable<FloatArray>;
  21502. /**
  21503. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21504. */
  21505. uvs5: Nullable<FloatArray>;
  21506. /**
  21507. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21508. */
  21509. uvs6: Nullable<FloatArray>;
  21510. /**
  21511. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21512. */
  21513. colors: Nullable<FloatArray>;
  21514. /**
  21515. * 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).
  21516. */
  21517. matricesIndices: Nullable<FloatArray>;
  21518. /**
  21519. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21520. */
  21521. matricesWeights: Nullable<FloatArray>;
  21522. /**
  21523. * An array extending the number of possible indices
  21524. */
  21525. matricesIndicesExtra: Nullable<FloatArray>;
  21526. /**
  21527. * An array extending the number of possible weights when the number of indices is extended
  21528. */
  21529. matricesWeightsExtra: Nullable<FloatArray>;
  21530. /**
  21531. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21532. */
  21533. indices: Nullable<IndicesArray>;
  21534. /**
  21535. * Uses the passed data array to set the set the values for the specified kind of data
  21536. * @param data a linear array of floating numbers
  21537. * @param kind the type of data that is being set, eg positions, colors etc
  21538. */
  21539. set(data: FloatArray, kind: string): void;
  21540. /**
  21541. * Associates the vertexData to the passed Mesh.
  21542. * Sets it as updatable or not (default `false`)
  21543. * @param mesh the mesh the vertexData is applied to
  21544. * @param updatable when used and having the value true allows new data to update the vertexData
  21545. * @returns the VertexData
  21546. */
  21547. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21548. /**
  21549. * Associates the vertexData to the passed Geometry.
  21550. * Sets it as updatable or not (default `false`)
  21551. * @param geometry the geometry the vertexData is applied to
  21552. * @param updatable when used and having the value true allows new data to update the vertexData
  21553. * @returns VertexData
  21554. */
  21555. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21556. /**
  21557. * Updates the associated mesh
  21558. * @param mesh the mesh to be updated
  21559. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21560. * @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
  21561. * @returns VertexData
  21562. */
  21563. updateMesh(mesh: Mesh): VertexData;
  21564. /**
  21565. * Updates the associated geometry
  21566. * @param geometry the geometry to be updated
  21567. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21568. * @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
  21569. * @returns VertexData.
  21570. */
  21571. updateGeometry(geometry: Geometry): VertexData;
  21572. private _applyTo;
  21573. private _update;
  21574. /**
  21575. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21576. * @param matrix the transforming matrix
  21577. * @returns the VertexData
  21578. */
  21579. transform(matrix: Matrix): VertexData;
  21580. /**
  21581. * Merges the passed VertexData into the current one
  21582. * @param other the VertexData to be merged into the current one
  21583. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21584. * @returns the modified VertexData
  21585. */
  21586. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21587. private _mergeElement;
  21588. private _validate;
  21589. /**
  21590. * Serializes the VertexData
  21591. * @returns a serialized object
  21592. */
  21593. serialize(): any;
  21594. /**
  21595. * Extracts the vertexData from a mesh
  21596. * @param mesh the mesh from which to extract the VertexData
  21597. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21598. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21599. * @returns the object VertexData associated to the passed mesh
  21600. */
  21601. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21602. /**
  21603. * Extracts the vertexData from the geometry
  21604. * @param geometry the geometry from which to extract the VertexData
  21605. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21606. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21607. * @returns the object VertexData associated to the passed mesh
  21608. */
  21609. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21610. private static _ExtractFrom;
  21611. /**
  21612. * Creates the VertexData for a Ribbon
  21613. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21614. * * pathArray array of paths, each of which an array of successive Vector3
  21615. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21616. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21617. * * 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
  21618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21619. * * 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)
  21620. * * 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)
  21621. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21622. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21623. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21624. * @returns the VertexData of the ribbon
  21625. */
  21626. static CreateRibbon(options: {
  21627. pathArray: Vector3[][];
  21628. closeArray?: boolean;
  21629. closePath?: boolean;
  21630. offset?: number;
  21631. sideOrientation?: number;
  21632. frontUVs?: Vector4;
  21633. backUVs?: Vector4;
  21634. invertUV?: boolean;
  21635. uvs?: Vector2[];
  21636. colors?: Color4[];
  21637. }): VertexData;
  21638. /**
  21639. * Creates the VertexData for a box
  21640. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21641. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21642. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21643. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21644. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21645. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21646. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21648. * * 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)
  21649. * * 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)
  21650. * @returns the VertexData of the box
  21651. */
  21652. static CreateBox(options: {
  21653. size?: number;
  21654. width?: number;
  21655. height?: number;
  21656. depth?: number;
  21657. faceUV?: Vector4[];
  21658. faceColors?: Color4[];
  21659. sideOrientation?: number;
  21660. frontUVs?: Vector4;
  21661. backUVs?: Vector4;
  21662. }): VertexData;
  21663. /**
  21664. * Creates the VertexData for a tiled box
  21665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21666. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21667. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21668. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21669. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21670. * @returns the VertexData of the box
  21671. */
  21672. static CreateTiledBox(options: {
  21673. pattern?: number;
  21674. width?: number;
  21675. height?: number;
  21676. depth?: number;
  21677. tileSize?: number;
  21678. tileWidth?: number;
  21679. tileHeight?: number;
  21680. alignHorizontal?: number;
  21681. alignVertical?: number;
  21682. faceUV?: Vector4[];
  21683. faceColors?: Color4[];
  21684. sideOrientation?: number;
  21685. }): VertexData;
  21686. /**
  21687. * Creates the VertexData for a tiled plane
  21688. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21689. * * pattern a limited pattern arrangement depending on the number
  21690. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21691. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21692. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21694. * * 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)
  21695. * * 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)
  21696. * @returns the VertexData of the tiled plane
  21697. */
  21698. static CreateTiledPlane(options: {
  21699. pattern?: number;
  21700. tileSize?: number;
  21701. tileWidth?: number;
  21702. tileHeight?: number;
  21703. size?: number;
  21704. width?: number;
  21705. height?: number;
  21706. alignHorizontal?: number;
  21707. alignVertical?: number;
  21708. sideOrientation?: number;
  21709. frontUVs?: Vector4;
  21710. backUVs?: Vector4;
  21711. }): VertexData;
  21712. /**
  21713. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21714. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21715. * * segments sets the number of horizontal strips optional, default 32
  21716. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21717. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21718. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21719. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21720. * * 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
  21721. * * 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
  21722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21723. * * 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)
  21724. * * 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)
  21725. * @returns the VertexData of the ellipsoid
  21726. */
  21727. static CreateSphere(options: {
  21728. segments?: number;
  21729. diameter?: number;
  21730. diameterX?: number;
  21731. diameterY?: number;
  21732. diameterZ?: number;
  21733. arc?: number;
  21734. slice?: number;
  21735. sideOrientation?: number;
  21736. frontUVs?: Vector4;
  21737. backUVs?: Vector4;
  21738. }): VertexData;
  21739. /**
  21740. * Creates the VertexData for a cylinder, cone or prism
  21741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21742. * * height sets the height (y direction) of the cylinder, optional, default 2
  21743. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21744. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21745. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21746. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21747. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21748. * * 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
  21749. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21750. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21751. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21752. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21754. * * 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)
  21755. * * 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)
  21756. * @returns the VertexData of the cylinder, cone or prism
  21757. */
  21758. static CreateCylinder(options: {
  21759. height?: number;
  21760. diameterTop?: number;
  21761. diameterBottom?: number;
  21762. diameter?: number;
  21763. tessellation?: number;
  21764. subdivisions?: number;
  21765. arc?: number;
  21766. faceColors?: Color4[];
  21767. faceUV?: Vector4[];
  21768. hasRings?: boolean;
  21769. enclose?: boolean;
  21770. sideOrientation?: number;
  21771. frontUVs?: Vector4;
  21772. backUVs?: Vector4;
  21773. }): VertexData;
  21774. /**
  21775. * Creates the VertexData for a torus
  21776. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21777. * * diameter the diameter of the torus, optional default 1
  21778. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21779. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21781. * * 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)
  21782. * * 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)
  21783. * @returns the VertexData of the torus
  21784. */
  21785. static CreateTorus(options: {
  21786. diameter?: number;
  21787. thickness?: number;
  21788. tessellation?: number;
  21789. sideOrientation?: number;
  21790. frontUVs?: Vector4;
  21791. backUVs?: Vector4;
  21792. }): VertexData;
  21793. /**
  21794. * Creates the VertexData of the LineSystem
  21795. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21796. * - lines an array of lines, each line being an array of successive Vector3
  21797. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21798. * @returns the VertexData of the LineSystem
  21799. */
  21800. static CreateLineSystem(options: {
  21801. lines: Vector3[][];
  21802. colors?: Nullable<Color4[][]>;
  21803. }): VertexData;
  21804. /**
  21805. * Create the VertexData for a DashedLines
  21806. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21807. * - points an array successive Vector3
  21808. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21809. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21810. * - dashNb the intended total number of dashes, optional, default 200
  21811. * @returns the VertexData for the DashedLines
  21812. */
  21813. static CreateDashedLines(options: {
  21814. points: Vector3[];
  21815. dashSize?: number;
  21816. gapSize?: number;
  21817. dashNb?: number;
  21818. }): VertexData;
  21819. /**
  21820. * Creates the VertexData for a Ground
  21821. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21822. * - width the width (x direction) of the ground, optional, default 1
  21823. * - height the height (z direction) of the ground, optional, default 1
  21824. * - subdivisions the number of subdivisions per side, optional, default 1
  21825. * @returns the VertexData of the Ground
  21826. */
  21827. static CreateGround(options: {
  21828. width?: number;
  21829. height?: number;
  21830. subdivisions?: number;
  21831. subdivisionsX?: number;
  21832. subdivisionsY?: number;
  21833. }): VertexData;
  21834. /**
  21835. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21836. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21837. * * xmin the ground minimum X coordinate, optional, default -1
  21838. * * zmin the ground minimum Z coordinate, optional, default -1
  21839. * * xmax the ground maximum X coordinate, optional, default 1
  21840. * * zmax the ground maximum Z coordinate, optional, default 1
  21841. * * 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}
  21842. * * 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}
  21843. * @returns the VertexData of the TiledGround
  21844. */
  21845. static CreateTiledGround(options: {
  21846. xmin: number;
  21847. zmin: number;
  21848. xmax: number;
  21849. zmax: number;
  21850. subdivisions?: {
  21851. w: number;
  21852. h: number;
  21853. };
  21854. precision?: {
  21855. w: number;
  21856. h: number;
  21857. };
  21858. }): VertexData;
  21859. /**
  21860. * Creates the VertexData of the Ground designed from a heightmap
  21861. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21862. * * width the width (x direction) of the ground
  21863. * * height the height (z direction) of the ground
  21864. * * subdivisions the number of subdivisions per side
  21865. * * minHeight the minimum altitude on the ground, optional, default 0
  21866. * * maxHeight the maximum altitude on the ground, optional default 1
  21867. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21868. * * buffer the array holding the image color data
  21869. * * bufferWidth the width of image
  21870. * * bufferHeight the height of image
  21871. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21872. * @returns the VertexData of the Ground designed from a heightmap
  21873. */
  21874. static CreateGroundFromHeightMap(options: {
  21875. width: number;
  21876. height: number;
  21877. subdivisions: number;
  21878. minHeight: number;
  21879. maxHeight: number;
  21880. colorFilter: Color3;
  21881. buffer: Uint8Array;
  21882. bufferWidth: number;
  21883. bufferHeight: number;
  21884. alphaFilter: number;
  21885. }): VertexData;
  21886. /**
  21887. * Creates the VertexData for a Plane
  21888. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21889. * * size sets the width and height of the plane to the value of size, optional default 1
  21890. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21891. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21893. * * 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)
  21894. * * 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)
  21895. * @returns the VertexData of the box
  21896. */
  21897. static CreatePlane(options: {
  21898. size?: number;
  21899. width?: number;
  21900. height?: number;
  21901. sideOrientation?: number;
  21902. frontUVs?: Vector4;
  21903. backUVs?: Vector4;
  21904. }): VertexData;
  21905. /**
  21906. * Creates the VertexData of the Disc or regular Polygon
  21907. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21908. * * radius the radius of the disc, optional default 0.5
  21909. * * tessellation the number of polygon sides, optional, default 64
  21910. * * 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
  21911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21912. * * 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)
  21913. * * 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)
  21914. * @returns the VertexData of the box
  21915. */
  21916. static CreateDisc(options: {
  21917. radius?: number;
  21918. tessellation?: number;
  21919. arc?: number;
  21920. sideOrientation?: number;
  21921. frontUVs?: Vector4;
  21922. backUVs?: Vector4;
  21923. }): VertexData;
  21924. /**
  21925. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21926. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21927. * @param polygon a mesh built from polygonTriangulation.build()
  21928. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21929. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21930. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21931. * @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)
  21932. * @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)
  21933. * @returns the VertexData of the Polygon
  21934. */
  21935. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21936. /**
  21937. * Creates the VertexData of the IcoSphere
  21938. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21939. * * radius the radius of the IcoSphere, optional default 1
  21940. * * radiusX allows stretching in the x direction, optional, default radius
  21941. * * radiusY allows stretching in the y direction, optional, default radius
  21942. * * radiusZ allows stretching in the z direction, optional, default radius
  21943. * * flat when true creates a flat shaded mesh, optional, default true
  21944. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21946. * * 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)
  21947. * * 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)
  21948. * @returns the VertexData of the IcoSphere
  21949. */
  21950. static CreateIcoSphere(options: {
  21951. radius?: number;
  21952. radiusX?: number;
  21953. radiusY?: number;
  21954. radiusZ?: number;
  21955. flat?: boolean;
  21956. subdivisions?: number;
  21957. sideOrientation?: number;
  21958. frontUVs?: Vector4;
  21959. backUVs?: Vector4;
  21960. }): VertexData;
  21961. /**
  21962. * Creates the VertexData for a Polyhedron
  21963. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21964. * * type provided types are:
  21965. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21966. * * 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)
  21967. * * size the size of the IcoSphere, optional default 1
  21968. * * sizeX allows stretching in the x direction, optional, default size
  21969. * * sizeY allows stretching in the y direction, optional, default size
  21970. * * sizeZ allows stretching in the z direction, optional, default size
  21971. * * 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
  21972. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21973. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21974. * * flat when true creates a flat shaded mesh, optional, default true
  21975. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21976. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21977. * * 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)
  21978. * * 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)
  21979. * @returns the VertexData of the Polyhedron
  21980. */
  21981. static CreatePolyhedron(options: {
  21982. type?: number;
  21983. size?: number;
  21984. sizeX?: number;
  21985. sizeY?: number;
  21986. sizeZ?: number;
  21987. custom?: any;
  21988. faceUV?: Vector4[];
  21989. faceColors?: Color4[];
  21990. flat?: boolean;
  21991. sideOrientation?: number;
  21992. frontUVs?: Vector4;
  21993. backUVs?: Vector4;
  21994. }): VertexData;
  21995. /**
  21996. * Creates the VertexData for a TorusKnot
  21997. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21998. * * radius the radius of the torus knot, optional, default 2
  21999. * * tube the thickness of the tube, optional, default 0.5
  22000. * * radialSegments the number of sides on each tube segments, optional, default 32
  22001. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22002. * * p the number of windings around the z axis, optional, default 2
  22003. * * q the number of windings around the x axis, optional, default 3
  22004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22005. * * 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)
  22006. * * 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)
  22007. * @returns the VertexData of the Torus Knot
  22008. */
  22009. static CreateTorusKnot(options: {
  22010. radius?: number;
  22011. tube?: number;
  22012. radialSegments?: number;
  22013. tubularSegments?: number;
  22014. p?: number;
  22015. q?: number;
  22016. sideOrientation?: number;
  22017. frontUVs?: Vector4;
  22018. backUVs?: Vector4;
  22019. }): VertexData;
  22020. /**
  22021. * Compute normals for given positions and indices
  22022. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22023. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22024. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22025. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22026. * * facetNormals : optional array of facet normals (vector3)
  22027. * * facetPositions : optional array of facet positions (vector3)
  22028. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22029. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22030. * * bInfo : optional bounding info, required for facetPartitioning computation
  22031. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22032. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22033. * * useRightHandedSystem: optional boolean to for right handed system computation
  22034. * * depthSort : optional boolean to enable the facet depth sort computation
  22035. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22036. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22037. */
  22038. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22039. facetNormals?: any;
  22040. facetPositions?: any;
  22041. facetPartitioning?: any;
  22042. ratio?: number;
  22043. bInfo?: any;
  22044. bbSize?: Vector3;
  22045. subDiv?: any;
  22046. useRightHandedSystem?: boolean;
  22047. depthSort?: boolean;
  22048. distanceTo?: Vector3;
  22049. depthSortedFacets?: any;
  22050. }): void;
  22051. /** @hidden */
  22052. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22053. /**
  22054. * Applies VertexData created from the imported parameters to the geometry
  22055. * @param parsedVertexData the parsed data from an imported file
  22056. * @param geometry the geometry to apply the VertexData to
  22057. */
  22058. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22059. }
  22060. }
  22061. declare module BABYLON {
  22062. /**
  22063. * Defines a target to use with MorphTargetManager
  22064. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22065. */
  22066. export class MorphTarget implements IAnimatable {
  22067. /** defines the name of the target */
  22068. name: string;
  22069. /**
  22070. * Gets or sets the list of animations
  22071. */
  22072. animations: Animation[];
  22073. private _scene;
  22074. private _positions;
  22075. private _normals;
  22076. private _tangents;
  22077. private _uvs;
  22078. private _influence;
  22079. /**
  22080. * Observable raised when the influence changes
  22081. */
  22082. onInfluenceChanged: Observable<boolean>;
  22083. /** @hidden */
  22084. _onDataLayoutChanged: Observable<void>;
  22085. /**
  22086. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22087. */
  22088. influence: number;
  22089. /**
  22090. * Gets or sets the id of the morph Target
  22091. */
  22092. id: string;
  22093. private _animationPropertiesOverride;
  22094. /**
  22095. * Gets or sets the animation properties override
  22096. */
  22097. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22098. /**
  22099. * Creates a new MorphTarget
  22100. * @param name defines the name of the target
  22101. * @param influence defines the influence to use
  22102. * @param scene defines the scene the morphtarget belongs to
  22103. */
  22104. constructor(
  22105. /** defines the name of the target */
  22106. name: string, influence?: number, scene?: Nullable<Scene>);
  22107. /**
  22108. * Gets a boolean defining if the target contains position data
  22109. */
  22110. readonly hasPositions: boolean;
  22111. /**
  22112. * Gets a boolean defining if the target contains normal data
  22113. */
  22114. readonly hasNormals: boolean;
  22115. /**
  22116. * Gets a boolean defining if the target contains tangent data
  22117. */
  22118. readonly hasTangents: boolean;
  22119. /**
  22120. * Gets a boolean defining if the target contains texture coordinates data
  22121. */
  22122. readonly hasUVs: boolean;
  22123. /**
  22124. * Affects position data to this target
  22125. * @param data defines the position data to use
  22126. */
  22127. setPositions(data: Nullable<FloatArray>): void;
  22128. /**
  22129. * Gets the position data stored in this target
  22130. * @returns a FloatArray containing the position data (or null if not present)
  22131. */
  22132. getPositions(): Nullable<FloatArray>;
  22133. /**
  22134. * Affects normal data to this target
  22135. * @param data defines the normal data to use
  22136. */
  22137. setNormals(data: Nullable<FloatArray>): void;
  22138. /**
  22139. * Gets the normal data stored in this target
  22140. * @returns a FloatArray containing the normal data (or null if not present)
  22141. */
  22142. getNormals(): Nullable<FloatArray>;
  22143. /**
  22144. * Affects tangent data to this target
  22145. * @param data defines the tangent data to use
  22146. */
  22147. setTangents(data: Nullable<FloatArray>): void;
  22148. /**
  22149. * Gets the tangent data stored in this target
  22150. * @returns a FloatArray containing the tangent data (or null if not present)
  22151. */
  22152. getTangents(): Nullable<FloatArray>;
  22153. /**
  22154. * Affects texture coordinates data to this target
  22155. * @param data defines the texture coordinates data to use
  22156. */
  22157. setUVs(data: Nullable<FloatArray>): void;
  22158. /**
  22159. * Gets the texture coordinates data stored in this target
  22160. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22161. */
  22162. getUVs(): Nullable<FloatArray>;
  22163. /**
  22164. * Serializes the current target into a Serialization object
  22165. * @returns the serialized object
  22166. */
  22167. serialize(): any;
  22168. /**
  22169. * Returns the string "MorphTarget"
  22170. * @returns "MorphTarget"
  22171. */
  22172. getClassName(): string;
  22173. /**
  22174. * Creates a new target from serialized data
  22175. * @param serializationObject defines the serialized data to use
  22176. * @returns a new MorphTarget
  22177. */
  22178. static Parse(serializationObject: any): MorphTarget;
  22179. /**
  22180. * Creates a MorphTarget from mesh data
  22181. * @param mesh defines the source mesh
  22182. * @param name defines the name to use for the new target
  22183. * @param influence defines the influence to attach to the target
  22184. * @returns a new MorphTarget
  22185. */
  22186. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22187. }
  22188. }
  22189. declare module BABYLON {
  22190. /**
  22191. * This class is used to deform meshes using morphing between different targets
  22192. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22193. */
  22194. export class MorphTargetManager {
  22195. private _targets;
  22196. private _targetInfluenceChangedObservers;
  22197. private _targetDataLayoutChangedObservers;
  22198. private _activeTargets;
  22199. private _scene;
  22200. private _influences;
  22201. private _supportsNormals;
  22202. private _supportsTangents;
  22203. private _supportsUVs;
  22204. private _vertexCount;
  22205. private _uniqueId;
  22206. private _tempInfluences;
  22207. /**
  22208. * Gets or sets a boolean indicating if normals must be morphed
  22209. */
  22210. enableNormalMorphing: boolean;
  22211. /**
  22212. * Gets or sets a boolean indicating if tangents must be morphed
  22213. */
  22214. enableTangentMorphing: boolean;
  22215. /**
  22216. * Gets or sets a boolean indicating if UV must be morphed
  22217. */
  22218. enableUVMorphing: boolean;
  22219. /**
  22220. * Creates a new MorphTargetManager
  22221. * @param scene defines the current scene
  22222. */
  22223. constructor(scene?: Nullable<Scene>);
  22224. /**
  22225. * Gets the unique ID of this manager
  22226. */
  22227. readonly uniqueId: number;
  22228. /**
  22229. * Gets the number of vertices handled by this manager
  22230. */
  22231. readonly vertexCount: number;
  22232. /**
  22233. * Gets a boolean indicating if this manager supports morphing of normals
  22234. */
  22235. readonly supportsNormals: boolean;
  22236. /**
  22237. * Gets a boolean indicating if this manager supports morphing of tangents
  22238. */
  22239. readonly supportsTangents: boolean;
  22240. /**
  22241. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22242. */
  22243. readonly supportsUVs: boolean;
  22244. /**
  22245. * Gets the number of targets stored in this manager
  22246. */
  22247. readonly numTargets: number;
  22248. /**
  22249. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22250. */
  22251. readonly numInfluencers: number;
  22252. /**
  22253. * Gets the list of influences (one per target)
  22254. */
  22255. readonly influences: Float32Array;
  22256. /**
  22257. * Gets the active target at specified index. An active target is a target with an influence > 0
  22258. * @param index defines the index to check
  22259. * @returns the requested target
  22260. */
  22261. getActiveTarget(index: number): MorphTarget;
  22262. /**
  22263. * Gets the target at specified index
  22264. * @param index defines the index to check
  22265. * @returns the requested target
  22266. */
  22267. getTarget(index: number): MorphTarget;
  22268. /**
  22269. * Add a new target to this manager
  22270. * @param target defines the target to add
  22271. */
  22272. addTarget(target: MorphTarget): void;
  22273. /**
  22274. * Removes a target from the manager
  22275. * @param target defines the target to remove
  22276. */
  22277. removeTarget(target: MorphTarget): void;
  22278. /**
  22279. * Serializes the current manager into a Serialization object
  22280. * @returns the serialized object
  22281. */
  22282. serialize(): any;
  22283. private _syncActiveTargets;
  22284. /**
  22285. * Syncrhonize the targets with all the meshes using this morph target manager
  22286. */
  22287. synchronize(): void;
  22288. /**
  22289. * Creates a new MorphTargetManager from serialized data
  22290. * @param serializationObject defines the serialized data
  22291. * @param scene defines the hosting scene
  22292. * @returns the new MorphTargetManager
  22293. */
  22294. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22295. }
  22296. }
  22297. declare module BABYLON {
  22298. /**
  22299. * Class used to represent a specific level of detail of a mesh
  22300. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22301. */
  22302. export class MeshLODLevel {
  22303. /** Defines the distance where this level should start being displayed */
  22304. distance: number;
  22305. /** Defines the mesh to use to render this level */
  22306. mesh: Nullable<Mesh>;
  22307. /**
  22308. * Creates a new LOD level
  22309. * @param distance defines the distance where this level should star being displayed
  22310. * @param mesh defines the mesh to use to render this level
  22311. */
  22312. constructor(
  22313. /** Defines the distance where this level should start being displayed */
  22314. distance: number,
  22315. /** Defines the mesh to use to render this level */
  22316. mesh: Nullable<Mesh>);
  22317. }
  22318. }
  22319. declare module BABYLON {
  22320. /**
  22321. * Mesh representing the gorund
  22322. */
  22323. export class GroundMesh extends Mesh {
  22324. /** If octree should be generated */
  22325. generateOctree: boolean;
  22326. private _heightQuads;
  22327. /** @hidden */
  22328. _subdivisionsX: number;
  22329. /** @hidden */
  22330. _subdivisionsY: number;
  22331. /** @hidden */
  22332. _width: number;
  22333. /** @hidden */
  22334. _height: number;
  22335. /** @hidden */
  22336. _minX: number;
  22337. /** @hidden */
  22338. _maxX: number;
  22339. /** @hidden */
  22340. _minZ: number;
  22341. /** @hidden */
  22342. _maxZ: number;
  22343. constructor(name: string, scene: Scene);
  22344. /**
  22345. * "GroundMesh"
  22346. * @returns "GroundMesh"
  22347. */
  22348. getClassName(): string;
  22349. /**
  22350. * The minimum of x and y subdivisions
  22351. */
  22352. readonly subdivisions: number;
  22353. /**
  22354. * X subdivisions
  22355. */
  22356. readonly subdivisionsX: number;
  22357. /**
  22358. * Y subdivisions
  22359. */
  22360. readonly subdivisionsY: number;
  22361. /**
  22362. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22363. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22364. * @param chunksCount the number of subdivisions for x and y
  22365. * @param octreeBlocksSize (Default: 32)
  22366. */
  22367. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22368. /**
  22369. * Returns a height (y) value in the Worl system :
  22370. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22371. * @param x x coordinate
  22372. * @param z z coordinate
  22373. * @returns the ground y position if (x, z) are outside the ground surface.
  22374. */
  22375. getHeightAtCoordinates(x: number, z: number): number;
  22376. /**
  22377. * Returns a normalized vector (Vector3) orthogonal to the ground
  22378. * at the ground coordinates (x, z) expressed in the World system.
  22379. * @param x x coordinate
  22380. * @param z z coordinate
  22381. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22382. */
  22383. getNormalAtCoordinates(x: number, z: number): Vector3;
  22384. /**
  22385. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22386. * at the ground coordinates (x, z) expressed in the World system.
  22387. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22388. * @param x x coordinate
  22389. * @param z z coordinate
  22390. * @param ref vector to store the result
  22391. * @returns the GroundMesh.
  22392. */
  22393. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22394. /**
  22395. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22396. * if the ground has been updated.
  22397. * This can be used in the render loop.
  22398. * @returns the GroundMesh.
  22399. */
  22400. updateCoordinateHeights(): GroundMesh;
  22401. private _getFacetAt;
  22402. private _initHeightQuads;
  22403. private _computeHeightQuads;
  22404. /**
  22405. * Serializes this ground mesh
  22406. * @param serializationObject object to write serialization to
  22407. */
  22408. serialize(serializationObject: any): void;
  22409. /**
  22410. * Parses a serialized ground mesh
  22411. * @param parsedMesh the serialized mesh
  22412. * @param scene the scene to create the ground mesh in
  22413. * @returns the created ground mesh
  22414. */
  22415. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22416. }
  22417. }
  22418. declare module BABYLON {
  22419. /**
  22420. * Interface for Physics-Joint data
  22421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22422. */
  22423. export interface PhysicsJointData {
  22424. /**
  22425. * The main pivot of the joint
  22426. */
  22427. mainPivot?: Vector3;
  22428. /**
  22429. * The connected pivot of the joint
  22430. */
  22431. connectedPivot?: Vector3;
  22432. /**
  22433. * The main axis of the joint
  22434. */
  22435. mainAxis?: Vector3;
  22436. /**
  22437. * The connected axis of the joint
  22438. */
  22439. connectedAxis?: Vector3;
  22440. /**
  22441. * The collision of the joint
  22442. */
  22443. collision?: boolean;
  22444. /**
  22445. * Native Oimo/Cannon/Energy data
  22446. */
  22447. nativeParams?: any;
  22448. }
  22449. /**
  22450. * This is a holder class for the physics joint created by the physics plugin
  22451. * It holds a set of functions to control the underlying joint
  22452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22453. */
  22454. export class PhysicsJoint {
  22455. /**
  22456. * The type of the physics joint
  22457. */
  22458. type: number;
  22459. /**
  22460. * The data for the physics joint
  22461. */
  22462. jointData: PhysicsJointData;
  22463. private _physicsJoint;
  22464. protected _physicsPlugin: IPhysicsEnginePlugin;
  22465. /**
  22466. * Initializes the physics joint
  22467. * @param type The type of the physics joint
  22468. * @param jointData The data for the physics joint
  22469. */
  22470. constructor(
  22471. /**
  22472. * The type of the physics joint
  22473. */
  22474. type: number,
  22475. /**
  22476. * The data for the physics joint
  22477. */
  22478. jointData: PhysicsJointData);
  22479. /**
  22480. * Gets the physics joint
  22481. */
  22482. /**
  22483. * Sets the physics joint
  22484. */
  22485. physicsJoint: any;
  22486. /**
  22487. * Sets the physics plugin
  22488. */
  22489. physicsPlugin: IPhysicsEnginePlugin;
  22490. /**
  22491. * Execute a function that is physics-plugin specific.
  22492. * @param {Function} func the function that will be executed.
  22493. * It accepts two parameters: the physics world and the physics joint
  22494. */
  22495. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22496. /**
  22497. * Distance-Joint type
  22498. */
  22499. static DistanceJoint: number;
  22500. /**
  22501. * Hinge-Joint type
  22502. */
  22503. static HingeJoint: number;
  22504. /**
  22505. * Ball-and-Socket joint type
  22506. */
  22507. static BallAndSocketJoint: number;
  22508. /**
  22509. * Wheel-Joint type
  22510. */
  22511. static WheelJoint: number;
  22512. /**
  22513. * Slider-Joint type
  22514. */
  22515. static SliderJoint: number;
  22516. /**
  22517. * Prismatic-Joint type
  22518. */
  22519. static PrismaticJoint: number;
  22520. /**
  22521. * Universal-Joint type
  22522. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22523. */
  22524. static UniversalJoint: number;
  22525. /**
  22526. * Hinge-Joint 2 type
  22527. */
  22528. static Hinge2Joint: number;
  22529. /**
  22530. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22531. */
  22532. static PointToPointJoint: number;
  22533. /**
  22534. * Spring-Joint type
  22535. */
  22536. static SpringJoint: number;
  22537. /**
  22538. * Lock-Joint type
  22539. */
  22540. static LockJoint: number;
  22541. }
  22542. /**
  22543. * A class representing a physics distance joint
  22544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22545. */
  22546. export class DistanceJoint extends PhysicsJoint {
  22547. /**
  22548. *
  22549. * @param jointData The data for the Distance-Joint
  22550. */
  22551. constructor(jointData: DistanceJointData);
  22552. /**
  22553. * Update the predefined distance.
  22554. * @param maxDistance The maximum preferred distance
  22555. * @param minDistance The minimum preferred distance
  22556. */
  22557. updateDistance(maxDistance: number, minDistance?: number): void;
  22558. }
  22559. /**
  22560. * Represents a Motor-Enabled Joint
  22561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22562. */
  22563. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22564. /**
  22565. * Initializes the Motor-Enabled Joint
  22566. * @param type The type of the joint
  22567. * @param jointData The physica joint data for the joint
  22568. */
  22569. constructor(type: number, jointData: PhysicsJointData);
  22570. /**
  22571. * Set the motor values.
  22572. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22573. * @param force the force to apply
  22574. * @param maxForce max force for this motor.
  22575. */
  22576. setMotor(force?: number, maxForce?: number): void;
  22577. /**
  22578. * Set the motor's limits.
  22579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22580. * @param upperLimit The upper limit of the motor
  22581. * @param lowerLimit The lower limit of the motor
  22582. */
  22583. setLimit(upperLimit: number, lowerLimit?: number): void;
  22584. }
  22585. /**
  22586. * This class represents a single physics Hinge-Joint
  22587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22588. */
  22589. export class HingeJoint extends MotorEnabledJoint {
  22590. /**
  22591. * Initializes the Hinge-Joint
  22592. * @param jointData The joint data for the Hinge-Joint
  22593. */
  22594. constructor(jointData: PhysicsJointData);
  22595. /**
  22596. * Set the motor values.
  22597. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22598. * @param {number} force the force to apply
  22599. * @param {number} maxForce max force for this motor.
  22600. */
  22601. setMotor(force?: number, maxForce?: number): void;
  22602. /**
  22603. * Set the motor's limits.
  22604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22605. * @param upperLimit The upper limit of the motor
  22606. * @param lowerLimit The lower limit of the motor
  22607. */
  22608. setLimit(upperLimit: number, lowerLimit?: number): void;
  22609. }
  22610. /**
  22611. * This class represents a dual hinge physics joint (same as wheel joint)
  22612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22613. */
  22614. export class Hinge2Joint extends MotorEnabledJoint {
  22615. /**
  22616. * Initializes the Hinge2-Joint
  22617. * @param jointData The joint data for the Hinge2-Joint
  22618. */
  22619. constructor(jointData: PhysicsJointData);
  22620. /**
  22621. * Set the motor values.
  22622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22623. * @param {number} targetSpeed the speed the motor is to reach
  22624. * @param {number} maxForce max force for this motor.
  22625. * @param {motorIndex} the motor's index, 0 or 1.
  22626. */
  22627. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22628. /**
  22629. * Set the motor limits.
  22630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22631. * @param {number} upperLimit the upper limit
  22632. * @param {number} lowerLimit lower limit
  22633. * @param {motorIndex} the motor's index, 0 or 1.
  22634. */
  22635. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22636. }
  22637. /**
  22638. * Interface for a motor enabled joint
  22639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22640. */
  22641. export interface IMotorEnabledJoint {
  22642. /**
  22643. * Physics joint
  22644. */
  22645. physicsJoint: any;
  22646. /**
  22647. * Sets the motor of the motor-enabled joint
  22648. * @param force The force of the motor
  22649. * @param maxForce The maximum force of the motor
  22650. * @param motorIndex The index of the motor
  22651. */
  22652. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22653. /**
  22654. * Sets the limit of the motor
  22655. * @param upperLimit The upper limit of the motor
  22656. * @param lowerLimit The lower limit of the motor
  22657. * @param motorIndex The index of the motor
  22658. */
  22659. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22660. }
  22661. /**
  22662. * Joint data for a Distance-Joint
  22663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22664. */
  22665. export interface DistanceJointData extends PhysicsJointData {
  22666. /**
  22667. * Max distance the 2 joint objects can be apart
  22668. */
  22669. maxDistance: number;
  22670. }
  22671. /**
  22672. * Joint data from a spring joint
  22673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22674. */
  22675. export interface SpringJointData extends PhysicsJointData {
  22676. /**
  22677. * Length of the spring
  22678. */
  22679. length: number;
  22680. /**
  22681. * Stiffness of the spring
  22682. */
  22683. stiffness: number;
  22684. /**
  22685. * Damping of the spring
  22686. */
  22687. damping: number;
  22688. /** this callback will be called when applying the force to the impostors. */
  22689. forceApplicationCallback: () => void;
  22690. }
  22691. }
  22692. declare module BABYLON {
  22693. /**
  22694. * Holds the data for the raycast result
  22695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22696. */
  22697. export class PhysicsRaycastResult {
  22698. private _hasHit;
  22699. private _hitDistance;
  22700. private _hitNormalWorld;
  22701. private _hitPointWorld;
  22702. private _rayFromWorld;
  22703. private _rayToWorld;
  22704. /**
  22705. * Gets if there was a hit
  22706. */
  22707. readonly hasHit: boolean;
  22708. /**
  22709. * Gets the distance from the hit
  22710. */
  22711. readonly hitDistance: number;
  22712. /**
  22713. * Gets the hit normal/direction in the world
  22714. */
  22715. readonly hitNormalWorld: Vector3;
  22716. /**
  22717. * Gets the hit point in the world
  22718. */
  22719. readonly hitPointWorld: Vector3;
  22720. /**
  22721. * Gets the ray "start point" of the ray in the world
  22722. */
  22723. readonly rayFromWorld: Vector3;
  22724. /**
  22725. * Gets the ray "end point" of the ray in the world
  22726. */
  22727. readonly rayToWorld: Vector3;
  22728. /**
  22729. * Sets the hit data (normal & point in world space)
  22730. * @param hitNormalWorld defines the normal in world space
  22731. * @param hitPointWorld defines the point in world space
  22732. */
  22733. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22734. /**
  22735. * Sets the distance from the start point to the hit point
  22736. * @param distance
  22737. */
  22738. setHitDistance(distance: number): void;
  22739. /**
  22740. * Calculates the distance manually
  22741. */
  22742. calculateHitDistance(): void;
  22743. /**
  22744. * Resets all the values to default
  22745. * @param from The from point on world space
  22746. * @param to The to point on world space
  22747. */
  22748. reset(from?: Vector3, to?: Vector3): void;
  22749. }
  22750. /**
  22751. * Interface for the size containing width and height
  22752. */
  22753. interface IXYZ {
  22754. /**
  22755. * X
  22756. */
  22757. x: number;
  22758. /**
  22759. * Y
  22760. */
  22761. y: number;
  22762. /**
  22763. * Z
  22764. */
  22765. z: number;
  22766. }
  22767. }
  22768. declare module BABYLON {
  22769. /**
  22770. * Interface used to describe a physics joint
  22771. */
  22772. export interface PhysicsImpostorJoint {
  22773. /** Defines the main impostor to which the joint is linked */
  22774. mainImpostor: PhysicsImpostor;
  22775. /** Defines the impostor that is connected to the main impostor using this joint */
  22776. connectedImpostor: PhysicsImpostor;
  22777. /** Defines the joint itself */
  22778. joint: PhysicsJoint;
  22779. }
  22780. /** @hidden */
  22781. export interface IPhysicsEnginePlugin {
  22782. world: any;
  22783. name: string;
  22784. setGravity(gravity: Vector3): void;
  22785. setTimeStep(timeStep: number): void;
  22786. getTimeStep(): number;
  22787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22788. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22789. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22790. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22791. removePhysicsBody(impostor: PhysicsImpostor): void;
  22792. generateJoint(joint: PhysicsImpostorJoint): void;
  22793. removeJoint(joint: PhysicsImpostorJoint): void;
  22794. isSupported(): boolean;
  22795. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22797. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22798. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22799. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22800. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22802. getBodyMass(impostor: PhysicsImpostor): number;
  22803. getBodyFriction(impostor: PhysicsImpostor): number;
  22804. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22805. getBodyRestitution(impostor: PhysicsImpostor): number;
  22806. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22807. getBodyPressure?(impostor: PhysicsImpostor): number;
  22808. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22809. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22810. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22811. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22812. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22813. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22814. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22815. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22816. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22817. sleepBody(impostor: PhysicsImpostor): void;
  22818. wakeUpBody(impostor: PhysicsImpostor): void;
  22819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22820. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22821. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22822. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22823. getRadius(impostor: PhysicsImpostor): number;
  22824. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22825. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22826. dispose(): void;
  22827. }
  22828. /**
  22829. * Interface used to define a physics engine
  22830. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22831. */
  22832. export interface IPhysicsEngine {
  22833. /**
  22834. * Gets the gravity vector used by the simulation
  22835. */
  22836. gravity: Vector3;
  22837. /**
  22838. * Sets the gravity vector used by the simulation
  22839. * @param gravity defines the gravity vector to use
  22840. */
  22841. setGravity(gravity: Vector3): void;
  22842. /**
  22843. * Set the time step of the physics engine.
  22844. * Default is 1/60.
  22845. * To slow it down, enter 1/600 for example.
  22846. * To speed it up, 1/30
  22847. * @param newTimeStep the new timestep to apply to this world.
  22848. */
  22849. setTimeStep(newTimeStep: number): void;
  22850. /**
  22851. * Get the time step of the physics engine.
  22852. * @returns the current time step
  22853. */
  22854. getTimeStep(): number;
  22855. /**
  22856. * Release all resources
  22857. */
  22858. dispose(): void;
  22859. /**
  22860. * Gets the name of the current physics plugin
  22861. * @returns the name of the plugin
  22862. */
  22863. getPhysicsPluginName(): string;
  22864. /**
  22865. * Adding a new impostor for the impostor tracking.
  22866. * This will be done by the impostor itself.
  22867. * @param impostor the impostor to add
  22868. */
  22869. addImpostor(impostor: PhysicsImpostor): void;
  22870. /**
  22871. * Remove an impostor from the engine.
  22872. * This impostor and its mesh will not longer be updated by the physics engine.
  22873. * @param impostor the impostor to remove
  22874. */
  22875. removeImpostor(impostor: PhysicsImpostor): void;
  22876. /**
  22877. * Add a joint to the physics engine
  22878. * @param mainImpostor defines the main impostor to which the joint is added.
  22879. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22880. * @param joint defines the joint that will connect both impostors.
  22881. */
  22882. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22883. /**
  22884. * Removes a joint from the simulation
  22885. * @param mainImpostor defines the impostor used with the joint
  22886. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22887. * @param joint defines the joint to remove
  22888. */
  22889. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22890. /**
  22891. * Gets the current plugin used to run the simulation
  22892. * @returns current plugin
  22893. */
  22894. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22895. /**
  22896. * Gets the list of physic impostors
  22897. * @returns an array of PhysicsImpostor
  22898. */
  22899. getImpostors(): Array<PhysicsImpostor>;
  22900. /**
  22901. * Gets the impostor for a physics enabled object
  22902. * @param object defines the object impersonated by the impostor
  22903. * @returns the PhysicsImpostor or null if not found
  22904. */
  22905. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22906. /**
  22907. * Gets the impostor for a physics body object
  22908. * @param body defines physics body used by the impostor
  22909. * @returns the PhysicsImpostor or null if not found
  22910. */
  22911. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22912. /**
  22913. * Does a raycast in the physics world
  22914. * @param from when should the ray start?
  22915. * @param to when should the ray end?
  22916. * @returns PhysicsRaycastResult
  22917. */
  22918. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22919. /**
  22920. * Called by the scene. No need to call it.
  22921. * @param delta defines the timespam between frames
  22922. */
  22923. _step(delta: number): void;
  22924. }
  22925. }
  22926. declare module BABYLON {
  22927. /**
  22928. * The interface for the physics imposter parameters
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export interface PhysicsImpostorParameters {
  22932. /**
  22933. * The mass of the physics imposter
  22934. */
  22935. mass: number;
  22936. /**
  22937. * The friction of the physics imposter
  22938. */
  22939. friction?: number;
  22940. /**
  22941. * The coefficient of restitution of the physics imposter
  22942. */
  22943. restitution?: number;
  22944. /**
  22945. * The native options of the physics imposter
  22946. */
  22947. nativeOptions?: any;
  22948. /**
  22949. * Specifies if the parent should be ignored
  22950. */
  22951. ignoreParent?: boolean;
  22952. /**
  22953. * Specifies if bi-directional transformations should be disabled
  22954. */
  22955. disableBidirectionalTransformation?: boolean;
  22956. /**
  22957. * The pressure inside the physics imposter, soft object only
  22958. */
  22959. pressure?: number;
  22960. /**
  22961. * The stiffness the physics imposter, soft object only
  22962. */
  22963. stiffness?: number;
  22964. /**
  22965. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22966. */
  22967. velocityIterations?: number;
  22968. /**
  22969. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22970. */
  22971. positionIterations?: number;
  22972. /**
  22973. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22974. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22975. * Add to fix multiple points
  22976. */
  22977. fixedPoints?: number;
  22978. /**
  22979. * The collision margin around a soft object
  22980. */
  22981. margin?: number;
  22982. /**
  22983. * The collision margin around a soft object
  22984. */
  22985. damping?: number;
  22986. /**
  22987. * The path for a rope based on an extrusion
  22988. */
  22989. path?: any;
  22990. /**
  22991. * The shape of an extrusion used for a rope based on an extrusion
  22992. */
  22993. shape?: any;
  22994. }
  22995. /**
  22996. * Interface for a physics-enabled object
  22997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22998. */
  22999. export interface IPhysicsEnabledObject {
  23000. /**
  23001. * The position of the physics-enabled object
  23002. */
  23003. position: Vector3;
  23004. /**
  23005. * The rotation of the physics-enabled object
  23006. */
  23007. rotationQuaternion: Nullable<Quaternion>;
  23008. /**
  23009. * The scale of the physics-enabled object
  23010. */
  23011. scaling: Vector3;
  23012. /**
  23013. * The rotation of the physics-enabled object
  23014. */
  23015. rotation?: Vector3;
  23016. /**
  23017. * The parent of the physics-enabled object
  23018. */
  23019. parent?: any;
  23020. /**
  23021. * The bounding info of the physics-enabled object
  23022. * @returns The bounding info of the physics-enabled object
  23023. */
  23024. getBoundingInfo(): BoundingInfo;
  23025. /**
  23026. * Computes the world matrix
  23027. * @param force Specifies if the world matrix should be computed by force
  23028. * @returns A world matrix
  23029. */
  23030. computeWorldMatrix(force: boolean): Matrix;
  23031. /**
  23032. * Gets the world matrix
  23033. * @returns A world matrix
  23034. */
  23035. getWorldMatrix?(): Matrix;
  23036. /**
  23037. * Gets the child meshes
  23038. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23039. * @returns An array of abstract meshes
  23040. */
  23041. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23042. /**
  23043. * Gets the vertex data
  23044. * @param kind The type of vertex data
  23045. * @returns A nullable array of numbers, or a float32 array
  23046. */
  23047. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23048. /**
  23049. * Gets the indices from the mesh
  23050. * @returns A nullable array of index arrays
  23051. */
  23052. getIndices?(): Nullable<IndicesArray>;
  23053. /**
  23054. * Gets the scene from the mesh
  23055. * @returns the indices array or null
  23056. */
  23057. getScene?(): Scene;
  23058. /**
  23059. * Gets the absolute position from the mesh
  23060. * @returns the absolute position
  23061. */
  23062. getAbsolutePosition(): Vector3;
  23063. /**
  23064. * Gets the absolute pivot point from the mesh
  23065. * @returns the absolute pivot point
  23066. */
  23067. getAbsolutePivotPoint(): Vector3;
  23068. /**
  23069. * Rotates the mesh
  23070. * @param axis The axis of rotation
  23071. * @param amount The amount of rotation
  23072. * @param space The space of the rotation
  23073. * @returns The rotation transform node
  23074. */
  23075. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23076. /**
  23077. * Translates the mesh
  23078. * @param axis The axis of translation
  23079. * @param distance The distance of translation
  23080. * @param space The space of the translation
  23081. * @returns The transform node
  23082. */
  23083. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23084. /**
  23085. * Sets the absolute position of the mesh
  23086. * @param absolutePosition The absolute position of the mesh
  23087. * @returns The transform node
  23088. */
  23089. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23090. /**
  23091. * Gets the class name of the mesh
  23092. * @returns The class name
  23093. */
  23094. getClassName(): string;
  23095. }
  23096. /**
  23097. * Represents a physics imposter
  23098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23099. */
  23100. export class PhysicsImpostor {
  23101. /**
  23102. * The physics-enabled object used as the physics imposter
  23103. */
  23104. object: IPhysicsEnabledObject;
  23105. /**
  23106. * The type of the physics imposter
  23107. */
  23108. type: number;
  23109. private _options;
  23110. private _scene?;
  23111. /**
  23112. * The default object size of the imposter
  23113. */
  23114. static DEFAULT_OBJECT_SIZE: Vector3;
  23115. /**
  23116. * The identity quaternion of the imposter
  23117. */
  23118. static IDENTITY_QUATERNION: Quaternion;
  23119. /** @hidden */
  23120. _pluginData: any;
  23121. private _physicsEngine;
  23122. private _physicsBody;
  23123. private _bodyUpdateRequired;
  23124. private _onBeforePhysicsStepCallbacks;
  23125. private _onAfterPhysicsStepCallbacks;
  23126. /** @hidden */
  23127. _onPhysicsCollideCallbacks: Array<{
  23128. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23129. otherImpostors: Array<PhysicsImpostor>;
  23130. }>;
  23131. private _deltaPosition;
  23132. private _deltaRotation;
  23133. private _deltaRotationConjugated;
  23134. /** @hidden */
  23135. _isFromLine: boolean;
  23136. private _parent;
  23137. private _isDisposed;
  23138. private static _tmpVecs;
  23139. private static _tmpQuat;
  23140. /**
  23141. * Specifies if the physics imposter is disposed
  23142. */
  23143. readonly isDisposed: boolean;
  23144. /**
  23145. * Gets the mass of the physics imposter
  23146. */
  23147. mass: number;
  23148. /**
  23149. * Gets the coefficient of friction
  23150. */
  23151. /**
  23152. * Sets the coefficient of friction
  23153. */
  23154. friction: number;
  23155. /**
  23156. * Gets the coefficient of restitution
  23157. */
  23158. /**
  23159. * Sets the coefficient of restitution
  23160. */
  23161. restitution: number;
  23162. /**
  23163. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23164. */
  23165. /**
  23166. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23167. */
  23168. pressure: number;
  23169. /**
  23170. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23171. */
  23172. /**
  23173. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23174. */
  23175. stiffness: number;
  23176. /**
  23177. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23178. */
  23179. /**
  23180. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23181. */
  23182. velocityIterations: number;
  23183. /**
  23184. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23185. */
  23186. /**
  23187. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23188. */
  23189. positionIterations: number;
  23190. /**
  23191. * The unique id of the physics imposter
  23192. * set by the physics engine when adding this impostor to the array
  23193. */
  23194. uniqueId: number;
  23195. /**
  23196. * @hidden
  23197. */
  23198. soft: boolean;
  23199. /**
  23200. * @hidden
  23201. */
  23202. segments: number;
  23203. private _joints;
  23204. /**
  23205. * Initializes the physics imposter
  23206. * @param object The physics-enabled object used as the physics imposter
  23207. * @param type The type of the physics imposter
  23208. * @param _options The options for the physics imposter
  23209. * @param _scene The Babylon scene
  23210. */
  23211. constructor(
  23212. /**
  23213. * The physics-enabled object used as the physics imposter
  23214. */
  23215. object: IPhysicsEnabledObject,
  23216. /**
  23217. * The type of the physics imposter
  23218. */
  23219. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23220. /**
  23221. * This function will completly initialize this impostor.
  23222. * It will create a new body - but only if this mesh has no parent.
  23223. * If it has, this impostor will not be used other than to define the impostor
  23224. * of the child mesh.
  23225. * @hidden
  23226. */
  23227. _init(): void;
  23228. private _getPhysicsParent;
  23229. /**
  23230. * Should a new body be generated.
  23231. * @returns boolean specifying if body initialization is required
  23232. */
  23233. isBodyInitRequired(): boolean;
  23234. /**
  23235. * Sets the updated scaling
  23236. * @param updated Specifies if the scaling is updated
  23237. */
  23238. setScalingUpdated(): void;
  23239. /**
  23240. * Force a regeneration of this or the parent's impostor's body.
  23241. * Use under cautious - This will remove all joints already implemented.
  23242. */
  23243. forceUpdate(): void;
  23244. /**
  23245. * Gets the body that holds this impostor. Either its own, or its parent.
  23246. */
  23247. /**
  23248. * Set the physics body. Used mainly by the physics engine/plugin
  23249. */
  23250. physicsBody: any;
  23251. /**
  23252. * Get the parent of the physics imposter
  23253. * @returns Physics imposter or null
  23254. */
  23255. /**
  23256. * Sets the parent of the physics imposter
  23257. */
  23258. parent: Nullable<PhysicsImpostor>;
  23259. /**
  23260. * Resets the update flags
  23261. */
  23262. resetUpdateFlags(): void;
  23263. /**
  23264. * Gets the object extend size
  23265. * @returns the object extend size
  23266. */
  23267. getObjectExtendSize(): Vector3;
  23268. /**
  23269. * Gets the object center
  23270. * @returns The object center
  23271. */
  23272. getObjectCenter(): Vector3;
  23273. /**
  23274. * Get a specific parametes from the options parameter
  23275. * @param paramName The object parameter name
  23276. * @returns The object parameter
  23277. */
  23278. getParam(paramName: string): any;
  23279. /**
  23280. * Sets a specific parameter in the options given to the physics plugin
  23281. * @param paramName The parameter name
  23282. * @param value The value of the parameter
  23283. */
  23284. setParam(paramName: string, value: number): void;
  23285. /**
  23286. * Specifically change the body's mass option. Won't recreate the physics body object
  23287. * @param mass The mass of the physics imposter
  23288. */
  23289. setMass(mass: number): void;
  23290. /**
  23291. * Gets the linear velocity
  23292. * @returns linear velocity or null
  23293. */
  23294. getLinearVelocity(): Nullable<Vector3>;
  23295. /**
  23296. * Sets the linear velocity
  23297. * @param velocity linear velocity or null
  23298. */
  23299. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23300. /**
  23301. * Gets the angular velocity
  23302. * @returns angular velocity or null
  23303. */
  23304. getAngularVelocity(): Nullable<Vector3>;
  23305. /**
  23306. * Sets the angular velocity
  23307. * @param velocity The velocity or null
  23308. */
  23309. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23310. /**
  23311. * Execute a function with the physics plugin native code
  23312. * Provide a function the will have two variables - the world object and the physics body object
  23313. * @param func The function to execute with the physics plugin native code
  23314. */
  23315. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23316. /**
  23317. * Register a function that will be executed before the physics world is stepping forward
  23318. * @param func The function to execute before the physics world is stepped forward
  23319. */
  23320. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23321. /**
  23322. * Unregister a function that will be executed before the physics world is stepping forward
  23323. * @param func The function to execute before the physics world is stepped forward
  23324. */
  23325. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23326. /**
  23327. * Register a function that will be executed after the physics step
  23328. * @param func The function to execute after physics step
  23329. */
  23330. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23331. /**
  23332. * Unregisters a function that will be executed after the physics step
  23333. * @param func The function to execute after physics step
  23334. */
  23335. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23336. /**
  23337. * register a function that will be executed when this impostor collides against a different body
  23338. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23339. * @param func Callback that is executed on collision
  23340. */
  23341. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23342. /**
  23343. * Unregisters the physics imposter on contact
  23344. * @param collideAgainst The physics object to collide against
  23345. * @param func Callback to execute on collision
  23346. */
  23347. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23348. private _tmpQuat;
  23349. private _tmpQuat2;
  23350. /**
  23351. * Get the parent rotation
  23352. * @returns The parent rotation
  23353. */
  23354. getParentsRotation(): Quaternion;
  23355. /**
  23356. * this function is executed by the physics engine.
  23357. */
  23358. beforeStep: () => void;
  23359. /**
  23360. * this function is executed by the physics engine
  23361. */
  23362. afterStep: () => void;
  23363. /**
  23364. * Legacy collision detection event support
  23365. */
  23366. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23367. /**
  23368. * event and body object due to cannon's event-based architecture.
  23369. */
  23370. onCollide: (e: {
  23371. body: any;
  23372. }) => void;
  23373. /**
  23374. * Apply a force
  23375. * @param force The force to apply
  23376. * @param contactPoint The contact point for the force
  23377. * @returns The physics imposter
  23378. */
  23379. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23380. /**
  23381. * Apply an impulse
  23382. * @param force The impulse force
  23383. * @param contactPoint The contact point for the impulse force
  23384. * @returns The physics imposter
  23385. */
  23386. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23387. /**
  23388. * A help function to create a joint
  23389. * @param otherImpostor A physics imposter used to create a joint
  23390. * @param jointType The type of joint
  23391. * @param jointData The data for the joint
  23392. * @returns The physics imposter
  23393. */
  23394. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23395. /**
  23396. * Add a joint to this impostor with a different impostor
  23397. * @param otherImpostor A physics imposter used to add a joint
  23398. * @param joint The joint to add
  23399. * @returns The physics imposter
  23400. */
  23401. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23402. /**
  23403. * Add an anchor to a cloth impostor
  23404. * @param otherImpostor rigid impostor to anchor to
  23405. * @param width ratio across width from 0 to 1
  23406. * @param height ratio up height from 0 to 1
  23407. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23408. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23409. * @returns impostor the soft imposter
  23410. */
  23411. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23412. /**
  23413. * Add a hook to a rope impostor
  23414. * @param otherImpostor rigid impostor to anchor to
  23415. * @param length ratio across rope from 0 to 1
  23416. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23418. * @returns impostor the rope imposter
  23419. */
  23420. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23421. /**
  23422. * Will keep this body still, in a sleep mode.
  23423. * @returns the physics imposter
  23424. */
  23425. sleep(): PhysicsImpostor;
  23426. /**
  23427. * Wake the body up.
  23428. * @returns The physics imposter
  23429. */
  23430. wakeUp(): PhysicsImpostor;
  23431. /**
  23432. * Clones the physics imposter
  23433. * @param newObject The physics imposter clones to this physics-enabled object
  23434. * @returns A nullable physics imposter
  23435. */
  23436. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23437. /**
  23438. * Disposes the physics imposter
  23439. */
  23440. dispose(): void;
  23441. /**
  23442. * Sets the delta position
  23443. * @param position The delta position amount
  23444. */
  23445. setDeltaPosition(position: Vector3): void;
  23446. /**
  23447. * Sets the delta rotation
  23448. * @param rotation The delta rotation amount
  23449. */
  23450. setDeltaRotation(rotation: Quaternion): void;
  23451. /**
  23452. * Gets the box size of the physics imposter and stores the result in the input parameter
  23453. * @param result Stores the box size
  23454. * @returns The physics imposter
  23455. */
  23456. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23457. /**
  23458. * Gets the radius of the physics imposter
  23459. * @returns Radius of the physics imposter
  23460. */
  23461. getRadius(): number;
  23462. /**
  23463. * Sync a bone with this impostor
  23464. * @param bone The bone to sync to the impostor.
  23465. * @param boneMesh The mesh that the bone is influencing.
  23466. * @param jointPivot The pivot of the joint / bone in local space.
  23467. * @param distToJoint Optional distance from the impostor to the joint.
  23468. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23469. */
  23470. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23471. /**
  23472. * Sync impostor to a bone
  23473. * @param bone The bone that the impostor will be synced to.
  23474. * @param boneMesh The mesh that the bone is influencing.
  23475. * @param jointPivot The pivot of the joint / bone in local space.
  23476. * @param distToJoint Optional distance from the impostor to the joint.
  23477. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23478. * @param boneAxis Optional vector3 axis the bone is aligned with
  23479. */
  23480. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23481. /**
  23482. * No-Imposter type
  23483. */
  23484. static NoImpostor: number;
  23485. /**
  23486. * Sphere-Imposter type
  23487. */
  23488. static SphereImpostor: number;
  23489. /**
  23490. * Box-Imposter type
  23491. */
  23492. static BoxImpostor: number;
  23493. /**
  23494. * Plane-Imposter type
  23495. */
  23496. static PlaneImpostor: number;
  23497. /**
  23498. * Mesh-imposter type
  23499. */
  23500. static MeshImpostor: number;
  23501. /**
  23502. * Capsule-Impostor type (Ammo.js plugin only)
  23503. */
  23504. static CapsuleImpostor: number;
  23505. /**
  23506. * Cylinder-Imposter type
  23507. */
  23508. static CylinderImpostor: number;
  23509. /**
  23510. * Particle-Imposter type
  23511. */
  23512. static ParticleImpostor: number;
  23513. /**
  23514. * Heightmap-Imposter type
  23515. */
  23516. static HeightmapImpostor: number;
  23517. /**
  23518. * ConvexHull-Impostor type (Ammo.js plugin only)
  23519. */
  23520. static ConvexHullImpostor: number;
  23521. /**
  23522. * Rope-Imposter type
  23523. */
  23524. static RopeImpostor: number;
  23525. /**
  23526. * Cloth-Imposter type
  23527. */
  23528. static ClothImpostor: number;
  23529. /**
  23530. * Softbody-Imposter type
  23531. */
  23532. static SoftbodyImpostor: number;
  23533. }
  23534. }
  23535. declare module BABYLON {
  23536. /**
  23537. * @hidden
  23538. **/
  23539. export class _CreationDataStorage {
  23540. closePath?: boolean;
  23541. closeArray?: boolean;
  23542. idx: number[];
  23543. dashSize: number;
  23544. gapSize: number;
  23545. path3D: Path3D;
  23546. pathArray: Vector3[][];
  23547. arc: number;
  23548. radius: number;
  23549. cap: number;
  23550. tessellation: number;
  23551. }
  23552. /**
  23553. * @hidden
  23554. **/
  23555. class _InstanceDataStorage {
  23556. visibleInstances: any;
  23557. batchCache: _InstancesBatch;
  23558. instancesBufferSize: number;
  23559. instancesBuffer: Nullable<Buffer>;
  23560. instancesData: Float32Array;
  23561. overridenInstanceCount: number;
  23562. isFrozen: boolean;
  23563. previousBatch: Nullable<_InstancesBatch>;
  23564. hardwareInstancedRendering: boolean;
  23565. sideOrientation: number;
  23566. }
  23567. /**
  23568. * @hidden
  23569. **/
  23570. export class _InstancesBatch {
  23571. mustReturn: boolean;
  23572. visibleInstances: Nullable<InstancedMesh[]>[];
  23573. renderSelf: boolean[];
  23574. hardwareInstancedRendering: boolean[];
  23575. }
  23576. /**
  23577. * Class used to represent renderable models
  23578. */
  23579. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23580. /**
  23581. * Mesh side orientation : usually the external or front surface
  23582. */
  23583. static readonly FRONTSIDE: number;
  23584. /**
  23585. * Mesh side orientation : usually the internal or back surface
  23586. */
  23587. static readonly BACKSIDE: number;
  23588. /**
  23589. * Mesh side orientation : both internal and external or front and back surfaces
  23590. */
  23591. static readonly DOUBLESIDE: number;
  23592. /**
  23593. * Mesh side orientation : by default, `FRONTSIDE`
  23594. */
  23595. static readonly DEFAULTSIDE: number;
  23596. /**
  23597. * Mesh cap setting : no cap
  23598. */
  23599. static readonly NO_CAP: number;
  23600. /**
  23601. * Mesh cap setting : one cap at the beginning of the mesh
  23602. */
  23603. static readonly CAP_START: number;
  23604. /**
  23605. * Mesh cap setting : one cap at the end of the mesh
  23606. */
  23607. static readonly CAP_END: number;
  23608. /**
  23609. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23610. */
  23611. static readonly CAP_ALL: number;
  23612. /**
  23613. * Mesh pattern setting : no flip or rotate
  23614. */
  23615. static readonly NO_FLIP: number;
  23616. /**
  23617. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23618. */
  23619. static readonly FLIP_TILE: number;
  23620. /**
  23621. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23622. */
  23623. static readonly ROTATE_TILE: number;
  23624. /**
  23625. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23626. */
  23627. static readonly FLIP_ROW: number;
  23628. /**
  23629. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23630. */
  23631. static readonly ROTATE_ROW: number;
  23632. /**
  23633. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23634. */
  23635. static readonly FLIP_N_ROTATE_TILE: number;
  23636. /**
  23637. * Mesh pattern setting : rotate pattern and rotate
  23638. */
  23639. static readonly FLIP_N_ROTATE_ROW: number;
  23640. /**
  23641. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23642. */
  23643. static readonly CENTER: number;
  23644. /**
  23645. * Mesh tile positioning : part tiles on left
  23646. */
  23647. static readonly LEFT: number;
  23648. /**
  23649. * Mesh tile positioning : part tiles on right
  23650. */
  23651. static readonly RIGHT: number;
  23652. /**
  23653. * Mesh tile positioning : part tiles on top
  23654. */
  23655. static readonly TOP: number;
  23656. /**
  23657. * Mesh tile positioning : part tiles on bottom
  23658. */
  23659. static readonly BOTTOM: number;
  23660. /**
  23661. * Gets the default side orientation.
  23662. * @param orientation the orientation to value to attempt to get
  23663. * @returns the default orientation
  23664. * @hidden
  23665. */
  23666. static _GetDefaultSideOrientation(orientation?: number): number;
  23667. private _internalMeshDataInfo;
  23668. /**
  23669. * An event triggered before rendering the mesh
  23670. */
  23671. readonly onBeforeRenderObservable: Observable<Mesh>;
  23672. /**
  23673. * An event triggered before binding the mesh
  23674. */
  23675. readonly onBeforeBindObservable: Observable<Mesh>;
  23676. /**
  23677. * An event triggered after rendering the mesh
  23678. */
  23679. readonly onAfterRenderObservable: Observable<Mesh>;
  23680. /**
  23681. * An event triggered before drawing the mesh
  23682. */
  23683. readonly onBeforeDrawObservable: Observable<Mesh>;
  23684. private _onBeforeDrawObserver;
  23685. /**
  23686. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23687. */
  23688. onBeforeDraw: () => void;
  23689. readonly hasInstances: boolean;
  23690. /**
  23691. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23692. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23693. */
  23694. delayLoadState: number;
  23695. /**
  23696. * Gets the list of instances created from this mesh
  23697. * it is not supposed to be modified manually.
  23698. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23699. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23700. */
  23701. instances: InstancedMesh[];
  23702. /**
  23703. * Gets the file containing delay loading data for this mesh
  23704. */
  23705. delayLoadingFile: string;
  23706. /** @hidden */
  23707. _binaryInfo: any;
  23708. /**
  23709. * User defined function used to change how LOD level selection is done
  23710. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23711. */
  23712. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23713. /**
  23714. * Gets or sets the morph target manager
  23715. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23716. */
  23717. morphTargetManager: Nullable<MorphTargetManager>;
  23718. /** @hidden */
  23719. _creationDataStorage: Nullable<_CreationDataStorage>;
  23720. /** @hidden */
  23721. _geometry: Nullable<Geometry>;
  23722. /** @hidden */
  23723. _delayInfo: Array<string>;
  23724. /** @hidden */
  23725. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23726. /** @hidden */
  23727. _instanceDataStorage: _InstanceDataStorage;
  23728. private _effectiveMaterial;
  23729. /** @hidden */
  23730. _shouldGenerateFlatShading: boolean;
  23731. /** @hidden */
  23732. _originalBuilderSideOrientation: number;
  23733. /**
  23734. * Use this property to change the original side orientation defined at construction time
  23735. */
  23736. overrideMaterialSideOrientation: Nullable<number>;
  23737. /**
  23738. * Gets the source mesh (the one used to clone this one from)
  23739. */
  23740. readonly source: Nullable<Mesh>;
  23741. /**
  23742. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23743. */
  23744. isUnIndexed: boolean;
  23745. /**
  23746. * @constructor
  23747. * @param name The value used by scene.getMeshByName() to do a lookup.
  23748. * @param scene The scene to add this mesh to.
  23749. * @param parent The parent of this mesh, if it has one
  23750. * @param source An optional Mesh from which geometry is shared, cloned.
  23751. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23752. * When false, achieved by calling a clone(), also passing False.
  23753. * This will make creation of children, recursive.
  23754. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23755. */
  23756. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23757. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23758. /**
  23759. * Gets the class name
  23760. * @returns the string "Mesh".
  23761. */
  23762. getClassName(): string;
  23763. /** @hidden */
  23764. readonly _isMesh: boolean;
  23765. /**
  23766. * Returns a description of this mesh
  23767. * @param fullDetails define if full details about this mesh must be used
  23768. * @returns a descriptive string representing this mesh
  23769. */
  23770. toString(fullDetails?: boolean): string;
  23771. /** @hidden */
  23772. _unBindEffect(): void;
  23773. /**
  23774. * Gets a boolean indicating if this mesh has LOD
  23775. */
  23776. readonly hasLODLevels: boolean;
  23777. /**
  23778. * Gets the list of MeshLODLevel associated with the current mesh
  23779. * @returns an array of MeshLODLevel
  23780. */
  23781. getLODLevels(): MeshLODLevel[];
  23782. private _sortLODLevels;
  23783. /**
  23784. * Add a mesh as LOD level triggered at the given distance.
  23785. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23786. * @param distance The distance from the center of the object to show this level
  23787. * @param mesh The mesh to be added as LOD level (can be null)
  23788. * @return This mesh (for chaining)
  23789. */
  23790. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23791. /**
  23792. * Returns the LOD level mesh at the passed distance or null if not found.
  23793. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23794. * @param distance The distance from the center of the object to show this level
  23795. * @returns a Mesh or `null`
  23796. */
  23797. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23798. /**
  23799. * Remove a mesh from the LOD array
  23800. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23801. * @param mesh defines the mesh to be removed
  23802. * @return This mesh (for chaining)
  23803. */
  23804. removeLODLevel(mesh: Mesh): Mesh;
  23805. /**
  23806. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23807. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23808. * @param camera defines the camera to use to compute distance
  23809. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23810. * @return This mesh (for chaining)
  23811. */
  23812. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23813. /**
  23814. * Gets the mesh internal Geometry object
  23815. */
  23816. readonly geometry: Nullable<Geometry>;
  23817. /**
  23818. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23819. * @returns the total number of vertices
  23820. */
  23821. getTotalVertices(): number;
  23822. /**
  23823. * Returns the content of an associated vertex buffer
  23824. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23825. * - VertexBuffer.PositionKind
  23826. * - VertexBuffer.UVKind
  23827. * - VertexBuffer.UV2Kind
  23828. * - VertexBuffer.UV3Kind
  23829. * - VertexBuffer.UV4Kind
  23830. * - VertexBuffer.UV5Kind
  23831. * - VertexBuffer.UV6Kind
  23832. * - VertexBuffer.ColorKind
  23833. * - VertexBuffer.MatricesIndicesKind
  23834. * - VertexBuffer.MatricesIndicesExtraKind
  23835. * - VertexBuffer.MatricesWeightsKind
  23836. * - VertexBuffer.MatricesWeightsExtraKind
  23837. * @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
  23838. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23839. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23840. */
  23841. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23842. /**
  23843. * Returns the mesh VertexBuffer object from the requested `kind`
  23844. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23845. * - VertexBuffer.PositionKind
  23846. * - VertexBuffer.NormalKind
  23847. * - VertexBuffer.UVKind
  23848. * - VertexBuffer.UV2Kind
  23849. * - VertexBuffer.UV3Kind
  23850. * - VertexBuffer.UV4Kind
  23851. * - VertexBuffer.UV5Kind
  23852. * - VertexBuffer.UV6Kind
  23853. * - VertexBuffer.ColorKind
  23854. * - VertexBuffer.MatricesIndicesKind
  23855. * - VertexBuffer.MatricesIndicesExtraKind
  23856. * - VertexBuffer.MatricesWeightsKind
  23857. * - VertexBuffer.MatricesWeightsExtraKind
  23858. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23859. */
  23860. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23861. /**
  23862. * Tests if a specific vertex buffer is associated with this mesh
  23863. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23864. * - VertexBuffer.PositionKind
  23865. * - VertexBuffer.NormalKind
  23866. * - VertexBuffer.UVKind
  23867. * - VertexBuffer.UV2Kind
  23868. * - VertexBuffer.UV3Kind
  23869. * - VertexBuffer.UV4Kind
  23870. * - VertexBuffer.UV5Kind
  23871. * - VertexBuffer.UV6Kind
  23872. * - VertexBuffer.ColorKind
  23873. * - VertexBuffer.MatricesIndicesKind
  23874. * - VertexBuffer.MatricesIndicesExtraKind
  23875. * - VertexBuffer.MatricesWeightsKind
  23876. * - VertexBuffer.MatricesWeightsExtraKind
  23877. * @returns a boolean
  23878. */
  23879. isVerticesDataPresent(kind: string): boolean;
  23880. /**
  23881. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23882. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23883. * - VertexBuffer.PositionKind
  23884. * - VertexBuffer.UVKind
  23885. * - VertexBuffer.UV2Kind
  23886. * - VertexBuffer.UV3Kind
  23887. * - VertexBuffer.UV4Kind
  23888. * - VertexBuffer.UV5Kind
  23889. * - VertexBuffer.UV6Kind
  23890. * - VertexBuffer.ColorKind
  23891. * - VertexBuffer.MatricesIndicesKind
  23892. * - VertexBuffer.MatricesIndicesExtraKind
  23893. * - VertexBuffer.MatricesWeightsKind
  23894. * - VertexBuffer.MatricesWeightsExtraKind
  23895. * @returns a boolean
  23896. */
  23897. isVertexBufferUpdatable(kind: string): boolean;
  23898. /**
  23899. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23900. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23901. * - VertexBuffer.PositionKind
  23902. * - VertexBuffer.NormalKind
  23903. * - VertexBuffer.UVKind
  23904. * - VertexBuffer.UV2Kind
  23905. * - VertexBuffer.UV3Kind
  23906. * - VertexBuffer.UV4Kind
  23907. * - VertexBuffer.UV5Kind
  23908. * - VertexBuffer.UV6Kind
  23909. * - VertexBuffer.ColorKind
  23910. * - VertexBuffer.MatricesIndicesKind
  23911. * - VertexBuffer.MatricesIndicesExtraKind
  23912. * - VertexBuffer.MatricesWeightsKind
  23913. * - VertexBuffer.MatricesWeightsExtraKind
  23914. * @returns an array of strings
  23915. */
  23916. getVerticesDataKinds(): string[];
  23917. /**
  23918. * Returns a positive integer : the total number of indices in this mesh geometry.
  23919. * @returns the numner of indices or zero if the mesh has no geometry.
  23920. */
  23921. getTotalIndices(): number;
  23922. /**
  23923. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23924. * @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.
  23925. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23926. * @returns the indices array or an empty array if the mesh has no geometry
  23927. */
  23928. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23929. readonly isBlocked: boolean;
  23930. /**
  23931. * Determine if the current mesh is ready to be rendered
  23932. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23933. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23934. * @returns true if all associated assets are ready (material, textures, shaders)
  23935. */
  23936. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23937. /**
  23938. * 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.
  23939. */
  23940. readonly areNormalsFrozen: boolean;
  23941. /**
  23942. * 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.
  23943. * @returns the current mesh
  23944. */
  23945. freezeNormals(): Mesh;
  23946. /**
  23947. * 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
  23948. * @returns the current mesh
  23949. */
  23950. unfreezeNormals(): Mesh;
  23951. /**
  23952. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23953. */
  23954. overridenInstanceCount: number;
  23955. /** @hidden */
  23956. _preActivate(): Mesh;
  23957. /** @hidden */
  23958. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23959. /** @hidden */
  23960. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23961. /**
  23962. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23963. * This means the mesh underlying bounding box and sphere are recomputed.
  23964. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23965. * @returns the current mesh
  23966. */
  23967. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23968. /** @hidden */
  23969. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23970. /**
  23971. * This function will subdivide the mesh into multiple submeshes
  23972. * @param count defines the expected number of submeshes
  23973. */
  23974. subdivide(count: number): void;
  23975. /**
  23976. * Copy a FloatArray into a specific associated vertex buffer
  23977. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23978. * - VertexBuffer.PositionKind
  23979. * - VertexBuffer.UVKind
  23980. * - VertexBuffer.UV2Kind
  23981. * - VertexBuffer.UV3Kind
  23982. * - VertexBuffer.UV4Kind
  23983. * - VertexBuffer.UV5Kind
  23984. * - VertexBuffer.UV6Kind
  23985. * - VertexBuffer.ColorKind
  23986. * - VertexBuffer.MatricesIndicesKind
  23987. * - VertexBuffer.MatricesIndicesExtraKind
  23988. * - VertexBuffer.MatricesWeightsKind
  23989. * - VertexBuffer.MatricesWeightsExtraKind
  23990. * @param data defines the data source
  23991. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23992. * @param stride defines the data stride size (can be null)
  23993. * @returns the current mesh
  23994. */
  23995. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23996. /**
  23997. * Flags an associated vertex buffer as updatable
  23998. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23999. * - VertexBuffer.PositionKind
  24000. * - VertexBuffer.UVKind
  24001. * - VertexBuffer.UV2Kind
  24002. * - VertexBuffer.UV3Kind
  24003. * - VertexBuffer.UV4Kind
  24004. * - VertexBuffer.UV5Kind
  24005. * - VertexBuffer.UV6Kind
  24006. * - VertexBuffer.ColorKind
  24007. * - VertexBuffer.MatricesIndicesKind
  24008. * - VertexBuffer.MatricesIndicesExtraKind
  24009. * - VertexBuffer.MatricesWeightsKind
  24010. * - VertexBuffer.MatricesWeightsExtraKind
  24011. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24012. */
  24013. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24014. /**
  24015. * Sets the mesh global Vertex Buffer
  24016. * @param buffer defines the buffer to use
  24017. * @returns the current mesh
  24018. */
  24019. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24020. /**
  24021. * Update a specific associated vertex buffer
  24022. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24023. * - VertexBuffer.PositionKind
  24024. * - VertexBuffer.UVKind
  24025. * - VertexBuffer.UV2Kind
  24026. * - VertexBuffer.UV3Kind
  24027. * - VertexBuffer.UV4Kind
  24028. * - VertexBuffer.UV5Kind
  24029. * - VertexBuffer.UV6Kind
  24030. * - VertexBuffer.ColorKind
  24031. * - VertexBuffer.MatricesIndicesKind
  24032. * - VertexBuffer.MatricesIndicesExtraKind
  24033. * - VertexBuffer.MatricesWeightsKind
  24034. * - VertexBuffer.MatricesWeightsExtraKind
  24035. * @param data defines the data source
  24036. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24037. * @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)
  24038. * @returns the current mesh
  24039. */
  24040. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24041. /**
  24042. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24043. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24044. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24045. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24046. * @returns the current mesh
  24047. */
  24048. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24049. /**
  24050. * Creates a un-shared specific occurence of the geometry for the mesh.
  24051. * @returns the current mesh
  24052. */
  24053. makeGeometryUnique(): Mesh;
  24054. /**
  24055. * Set the index buffer of this mesh
  24056. * @param indices defines the source data
  24057. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24058. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24059. * @returns the current mesh
  24060. */
  24061. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24062. /**
  24063. * Update the current index buffer
  24064. * @param indices defines the source data
  24065. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24066. * @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)
  24067. * @returns the current mesh
  24068. */
  24069. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24070. /**
  24071. * Invert the geometry to move from a right handed system to a left handed one.
  24072. * @returns the current mesh
  24073. */
  24074. toLeftHanded(): Mesh;
  24075. /** @hidden */
  24076. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24077. /** @hidden */
  24078. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24079. /**
  24080. * Registers for this mesh a javascript function called just before the rendering process
  24081. * @param func defines the function to call before rendering this mesh
  24082. * @returns the current mesh
  24083. */
  24084. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24085. /**
  24086. * Disposes a previously registered javascript function called before the rendering
  24087. * @param func defines the function to remove
  24088. * @returns the current mesh
  24089. */
  24090. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24091. /**
  24092. * Registers for this mesh a javascript function called just after the rendering is complete
  24093. * @param func defines the function to call after rendering this mesh
  24094. * @returns the current mesh
  24095. */
  24096. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24097. /**
  24098. * Disposes a previously registered javascript function called after the rendering.
  24099. * @param func defines the function to remove
  24100. * @returns the current mesh
  24101. */
  24102. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24103. /** @hidden */
  24104. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24105. /** @hidden */
  24106. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24107. /** @hidden */
  24108. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24109. /** @hidden */
  24110. _rebuild(): void;
  24111. /** @hidden */
  24112. _freeze(): void;
  24113. /** @hidden */
  24114. _unFreeze(): void;
  24115. /**
  24116. * 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
  24117. * @param subMesh defines the subMesh to render
  24118. * @param enableAlphaMode defines if alpha mode can be changed
  24119. * @returns the current mesh
  24120. */
  24121. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24122. private _onBeforeDraw;
  24123. /**
  24124. * Renormalize the mesh and patch it up if there are no weights
  24125. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24126. * However in the case of zero weights then we set just a single influence to 1.
  24127. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24128. */
  24129. cleanMatrixWeights(): void;
  24130. private normalizeSkinFourWeights;
  24131. private normalizeSkinWeightsAndExtra;
  24132. /**
  24133. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24134. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24135. * the user know there was an issue with importing the mesh
  24136. * @returns a validation object with skinned, valid and report string
  24137. */
  24138. validateSkinning(): {
  24139. skinned: boolean;
  24140. valid: boolean;
  24141. report: string;
  24142. };
  24143. /** @hidden */
  24144. _checkDelayState(): Mesh;
  24145. private _queueLoad;
  24146. /**
  24147. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24148. * A mesh is in the frustum if its bounding box intersects the frustum
  24149. * @param frustumPlanes defines the frustum to test
  24150. * @returns true if the mesh is in the frustum planes
  24151. */
  24152. isInFrustum(frustumPlanes: Plane[]): boolean;
  24153. /**
  24154. * Sets the mesh material by the material or multiMaterial `id` property
  24155. * @param id is a string identifying the material or the multiMaterial
  24156. * @returns the current mesh
  24157. */
  24158. setMaterialByID(id: string): Mesh;
  24159. /**
  24160. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24161. * @returns an array of IAnimatable
  24162. */
  24163. getAnimatables(): IAnimatable[];
  24164. /**
  24165. * Modifies the mesh geometry according to the passed transformation matrix.
  24166. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24167. * The mesh normals are modified using the same transformation.
  24168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24169. * @param transform defines the transform matrix to use
  24170. * @see http://doc.babylonjs.com/resources/baking_transformations
  24171. * @returns the current mesh
  24172. */
  24173. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24174. /**
  24175. * Modifies the mesh geometry according to its own current World Matrix.
  24176. * The mesh World Matrix is then reset.
  24177. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24179. * @see http://doc.babylonjs.com/resources/baking_transformations
  24180. * @returns the current mesh
  24181. */
  24182. bakeCurrentTransformIntoVertices(): Mesh;
  24183. /** @hidden */
  24184. readonly _positions: Nullable<Vector3[]>;
  24185. /** @hidden */
  24186. _resetPointsArrayCache(): Mesh;
  24187. /** @hidden */
  24188. _generatePointsArray(): boolean;
  24189. /**
  24190. * Returns a new Mesh object generated from the current mesh properties.
  24191. * This method must not get confused with createInstance()
  24192. * @param name is a string, the name given to the new mesh
  24193. * @param newParent can be any Node object (default `null`)
  24194. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24195. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24196. * @returns a new mesh
  24197. */
  24198. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24199. /**
  24200. * Releases resources associated with this mesh.
  24201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24203. */
  24204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24205. /**
  24206. * Modifies the mesh geometry according to a displacement map.
  24207. * 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.
  24208. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24209. * @param url is a string, the URL from the image file is to be downloaded.
  24210. * @param minHeight is the lower limit of the displacement.
  24211. * @param maxHeight is the upper limit of the displacement.
  24212. * @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.
  24213. * @param uvOffset is an optional vector2 used to offset UV.
  24214. * @param uvScale is an optional vector2 used to scale UV.
  24215. * @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.
  24216. * @returns the Mesh.
  24217. */
  24218. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24219. /**
  24220. * Modifies the mesh geometry according to a displacementMap buffer.
  24221. * 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.
  24222. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24223. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24224. * @param heightMapWidth is the width of the buffer image.
  24225. * @param heightMapHeight is the height of the buffer image.
  24226. * @param minHeight is the lower limit of the displacement.
  24227. * @param maxHeight is the upper limit of the displacement.
  24228. * @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.
  24229. * @param uvOffset is an optional vector2 used to offset UV.
  24230. * @param uvScale is an optional vector2 used to scale UV.
  24231. * @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.
  24232. * @returns the Mesh.
  24233. */
  24234. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24235. /**
  24236. * Modify the mesh to get a flat shading rendering.
  24237. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24238. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24239. * @returns current mesh
  24240. */
  24241. convertToFlatShadedMesh(): Mesh;
  24242. /**
  24243. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24244. * In other words, more vertices, no more indices and a single bigger VBO.
  24245. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24246. * @returns current mesh
  24247. */
  24248. convertToUnIndexedMesh(): Mesh;
  24249. /**
  24250. * Inverses facet orientations.
  24251. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24252. * @param flipNormals will also inverts the normals
  24253. * @returns current mesh
  24254. */
  24255. flipFaces(flipNormals?: boolean): Mesh;
  24256. /**
  24257. * Increase the number of facets and hence vertices in a mesh
  24258. * Vertex normals are interpolated from existing vertex normals
  24259. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24260. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24261. */
  24262. increaseVertices(numberPerEdge: number): void;
  24263. /**
  24264. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24265. * This will undo any application of covertToFlatShadedMesh
  24266. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24267. */
  24268. forceSharedVertices(): void;
  24269. /** @hidden */
  24270. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24271. /** @hidden */
  24272. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24273. /**
  24274. * Creates a new InstancedMesh object from the mesh model.
  24275. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24276. * @param name defines the name of the new instance
  24277. * @returns a new InstancedMesh
  24278. */
  24279. createInstance(name: string): InstancedMesh;
  24280. /**
  24281. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24282. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24283. * @returns the current mesh
  24284. */
  24285. synchronizeInstances(): Mesh;
  24286. /**
  24287. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24288. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24289. * This should be used together with the simplification to avoid disappearing triangles.
  24290. * @param successCallback an optional success callback to be called after the optimization finished.
  24291. * @returns the current mesh
  24292. */
  24293. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24294. /**
  24295. * Serialize current mesh
  24296. * @param serializationObject defines the object which will receive the serialization data
  24297. */
  24298. serialize(serializationObject: any): void;
  24299. /** @hidden */
  24300. _syncGeometryWithMorphTargetManager(): void;
  24301. /** @hidden */
  24302. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24303. /**
  24304. * Returns a new Mesh object parsed from the source provided.
  24305. * @param parsedMesh is the source
  24306. * @param scene defines the hosting scene
  24307. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24308. * @returns a new Mesh
  24309. */
  24310. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24311. /**
  24312. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24313. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24314. * @param name defines the name of the mesh to create
  24315. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24316. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24317. * @param closePath creates a seam between the first and the last points of each path of the path array
  24318. * @param offset is taken in account only if the `pathArray` is containing a single path
  24319. * @param scene defines the hosting scene
  24320. * @param updatable defines if the mesh must be flagged as updatable
  24321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24322. * @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)
  24323. * @returns a new Mesh
  24324. */
  24325. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24326. /**
  24327. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24328. * @param name defines the name of the mesh to create
  24329. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24330. * @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
  24331. * @param scene defines the hosting scene
  24332. * @param updatable defines if the mesh must be flagged as updatable
  24333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24334. * @returns a new Mesh
  24335. */
  24336. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24337. /**
  24338. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24339. * @param name defines the name of the mesh to create
  24340. * @param size sets the size (float) of each box side (default 1)
  24341. * @param scene defines the hosting scene
  24342. * @param updatable defines if the mesh must be flagged as updatable
  24343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24344. * @returns a new Mesh
  24345. */
  24346. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24347. /**
  24348. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24349. * @param name defines the name of the mesh to create
  24350. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24351. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24352. * @param scene defines the hosting scene
  24353. * @param updatable defines if the mesh must be flagged as updatable
  24354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24355. * @returns a new Mesh
  24356. */
  24357. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24358. /**
  24359. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24360. * @param name defines the name of the mesh to create
  24361. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24362. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24363. * @param scene defines the hosting scene
  24364. * @returns a new Mesh
  24365. */
  24366. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24367. /**
  24368. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24369. * @param name defines the name of the mesh to create
  24370. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24371. * @param diameterTop set the top cap diameter (floats, default 1)
  24372. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24373. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24374. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24375. * @param scene defines the hosting scene
  24376. * @param updatable defines if the mesh must be flagged as updatable
  24377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24378. * @returns a new Mesh
  24379. */
  24380. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24381. /**
  24382. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24383. * @param name defines the name of the mesh to create
  24384. * @param diameter sets the diameter size (float) of the torus (default 1)
  24385. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24386. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24387. * @param scene defines the hosting scene
  24388. * @param updatable defines if the mesh must be flagged as updatable
  24389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24390. * @returns a new Mesh
  24391. */
  24392. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24393. /**
  24394. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24395. * @param name defines the name of the mesh to create
  24396. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24397. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24398. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24399. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24400. * @param p the number of windings on X axis (positive integers, default 2)
  24401. * @param q the number of windings on Y axis (positive integers, default 3)
  24402. * @param scene defines the hosting scene
  24403. * @param updatable defines if the mesh must be flagged as updatable
  24404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24405. * @returns a new Mesh
  24406. */
  24407. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24408. /**
  24409. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24410. * @param name defines the name of the mesh to create
  24411. * @param points is an array successive Vector3
  24412. * @param scene defines the hosting scene
  24413. * @param updatable defines if the mesh must be flagged as updatable
  24414. * @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).
  24415. * @returns a new Mesh
  24416. */
  24417. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24418. /**
  24419. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24420. * @param name defines the name of the mesh to create
  24421. * @param points is an array successive Vector3
  24422. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24423. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24424. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24425. * @param scene defines the hosting scene
  24426. * @param updatable defines if the mesh must be flagged as updatable
  24427. * @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)
  24428. * @returns a new Mesh
  24429. */
  24430. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24431. /**
  24432. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24433. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24434. * 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.
  24435. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24436. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24437. * Remember you can only change the shape positions, not their number when updating a polygon.
  24438. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24439. * @param name defines the name of the mesh to create
  24440. * @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
  24441. * @param scene defines the hosting scene
  24442. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24443. * @param updatable defines if the mesh must be flagged as updatable
  24444. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24445. * @param earcutInjection can be used to inject your own earcut reference
  24446. * @returns a new Mesh
  24447. */
  24448. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24449. /**
  24450. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24451. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24452. * @param name defines the name of the mesh to create
  24453. * @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
  24454. * @param depth defines the height of extrusion
  24455. * @param scene defines the hosting scene
  24456. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24457. * @param updatable defines if the mesh must be flagged as updatable
  24458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24459. * @param earcutInjection can be used to inject your own earcut reference
  24460. * @returns a new Mesh
  24461. */
  24462. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24463. /**
  24464. * Creates an extruded shape mesh.
  24465. * 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
  24466. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24467. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24468. * @param name defines the name of the mesh to create
  24469. * @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
  24470. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24471. * @param scale is the value to scale the shape
  24472. * @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
  24473. * @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
  24474. * @param scene defines the hosting scene
  24475. * @param updatable defines if the mesh must be flagged as updatable
  24476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24477. * @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)
  24478. * @returns a new Mesh
  24479. */
  24480. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24481. /**
  24482. * Creates an custom extruded shape mesh.
  24483. * The custom extrusion is a parametric shape.
  24484. * It has no predefined shape. Its final shape will depend on the input parameters.
  24485. * Please consider using the same method from the MeshBuilder class instead
  24486. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24487. * @param name defines the name of the mesh to create
  24488. * @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
  24489. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24490. * @param scaleFunction is a custom Javascript function called on each path point
  24491. * @param rotationFunction is a custom Javascript function called on each path point
  24492. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24493. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24494. * @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
  24495. * @param scene defines the hosting scene
  24496. * @param updatable defines if the mesh must be flagged as updatable
  24497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24498. * @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)
  24499. * @returns a new Mesh
  24500. */
  24501. 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;
  24502. /**
  24503. * Creates lathe mesh.
  24504. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24505. * Please consider using the same method from the MeshBuilder class instead
  24506. * @param name defines the name of the mesh to create
  24507. * @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
  24508. * @param radius is the radius value of the lathe
  24509. * @param tessellation is the side number of the lathe.
  24510. * @param scene defines the hosting scene
  24511. * @param updatable defines if the mesh must be flagged as updatable
  24512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24513. * @returns a new Mesh
  24514. */
  24515. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24516. /**
  24517. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24518. * @param name defines the name of the mesh to create
  24519. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24520. * @param scene defines the hosting scene
  24521. * @param updatable defines if the mesh must be flagged as updatable
  24522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24523. * @returns a new Mesh
  24524. */
  24525. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24526. /**
  24527. * Creates a ground mesh.
  24528. * Please consider using the same method from the MeshBuilder class instead
  24529. * @param name defines the name of the mesh to create
  24530. * @param width set the width of the ground
  24531. * @param height set the height of the ground
  24532. * @param subdivisions sets the number of subdivisions per side
  24533. * @param scene defines the hosting scene
  24534. * @param updatable defines if the mesh must be flagged as updatable
  24535. * @returns a new Mesh
  24536. */
  24537. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24538. /**
  24539. * Creates a tiled ground mesh.
  24540. * Please consider using the same method from the MeshBuilder class instead
  24541. * @param name defines the name of the mesh to create
  24542. * @param xmin set the ground minimum X coordinate
  24543. * @param zmin set the ground minimum Y coordinate
  24544. * @param xmax set the ground maximum X coordinate
  24545. * @param zmax set the ground maximum Z coordinate
  24546. * @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
  24547. * @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
  24548. * @param scene defines the hosting scene
  24549. * @param updatable defines if the mesh must be flagged as updatable
  24550. * @returns a new Mesh
  24551. */
  24552. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24553. w: number;
  24554. h: number;
  24555. }, precision: {
  24556. w: number;
  24557. h: number;
  24558. }, scene: Scene, updatable?: boolean): Mesh;
  24559. /**
  24560. * Creates a ground mesh from a height map.
  24561. * Please consider using the same method from the MeshBuilder class instead
  24562. * @see http://doc.babylonjs.com/babylon101/height_map
  24563. * @param name defines the name of the mesh to create
  24564. * @param url sets the URL of the height map image resource
  24565. * @param width set the ground width size
  24566. * @param height set the ground height size
  24567. * @param subdivisions sets the number of subdivision per side
  24568. * @param minHeight is the minimum altitude on the ground
  24569. * @param maxHeight is the maximum altitude on the ground
  24570. * @param scene defines the hosting scene
  24571. * @param updatable defines if the mesh must be flagged as updatable
  24572. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24573. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24574. * @returns a new Mesh
  24575. */
  24576. 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;
  24577. /**
  24578. * Creates a tube mesh.
  24579. * The tube is a parametric shape.
  24580. * It has no predefined shape. Its final shape will depend on the input parameters.
  24581. * Please consider using the same method from the MeshBuilder class instead
  24582. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24583. * @param name defines the name of the mesh to create
  24584. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24585. * @param radius sets the tube radius size
  24586. * @param tessellation is the number of sides on the tubular surface
  24587. * @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
  24588. * @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
  24589. * @param scene defines the hosting scene
  24590. * @param updatable defines if the mesh must be flagged as updatable
  24591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24592. * @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)
  24593. * @returns a new Mesh
  24594. */
  24595. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24596. (i: number, distance: number): number;
  24597. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24598. /**
  24599. * Creates a polyhedron mesh.
  24600. * Please consider using the same method from the MeshBuilder class instead.
  24601. * * 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
  24602. * * The parameter `size` (positive float, default 1) sets the polygon size
  24603. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24604. * * 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`
  24605. * * 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
  24606. * * 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)`)
  24607. * * 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
  24608. * * 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
  24609. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24610. * * 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
  24611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24612. * @param name defines the name of the mesh to create
  24613. * @param options defines the options used to create the mesh
  24614. * @param scene defines the hosting scene
  24615. * @returns a new Mesh
  24616. */
  24617. static CreatePolyhedron(name: string, options: {
  24618. type?: number;
  24619. size?: number;
  24620. sizeX?: number;
  24621. sizeY?: number;
  24622. sizeZ?: number;
  24623. custom?: any;
  24624. faceUV?: Vector4[];
  24625. faceColors?: Color4[];
  24626. updatable?: boolean;
  24627. sideOrientation?: number;
  24628. }, scene: Scene): Mesh;
  24629. /**
  24630. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24631. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24632. * * 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`)
  24633. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24634. * * 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
  24635. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24636. * * 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
  24637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24638. * @param name defines the name of the mesh
  24639. * @param options defines the options used to create the mesh
  24640. * @param scene defines the hosting scene
  24641. * @returns a new Mesh
  24642. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24643. */
  24644. static CreateIcoSphere(name: string, options: {
  24645. radius?: number;
  24646. flat?: boolean;
  24647. subdivisions?: number;
  24648. sideOrientation?: number;
  24649. updatable?: boolean;
  24650. }, scene: Scene): Mesh;
  24651. /**
  24652. * Creates a decal mesh.
  24653. * Please consider using the same method from the MeshBuilder class instead.
  24654. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24655. * @param name defines the name of the mesh
  24656. * @param sourceMesh defines the mesh receiving the decal
  24657. * @param position sets the position of the decal in world coordinates
  24658. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24659. * @param size sets the decal scaling
  24660. * @param angle sets the angle to rotate the decal
  24661. * @returns a new Mesh
  24662. */
  24663. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24664. /**
  24665. * Prepare internal position array for software CPU skinning
  24666. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24667. */
  24668. setPositionsForCPUSkinning(): Float32Array;
  24669. /**
  24670. * Prepare internal normal array for software CPU skinning
  24671. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24672. */
  24673. setNormalsForCPUSkinning(): Float32Array;
  24674. /**
  24675. * Updates the vertex buffer by applying transformation from the bones
  24676. * @param skeleton defines the skeleton to apply to current mesh
  24677. * @returns the current mesh
  24678. */
  24679. applySkeleton(skeleton: Skeleton): Mesh;
  24680. /**
  24681. * 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
  24682. * @param meshes defines the list of meshes to scan
  24683. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24684. */
  24685. static MinMax(meshes: AbstractMesh[]): {
  24686. min: Vector3;
  24687. max: Vector3;
  24688. };
  24689. /**
  24690. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24691. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24692. * @returns a vector3
  24693. */
  24694. static Center(meshesOrMinMaxVector: {
  24695. min: Vector3;
  24696. max: Vector3;
  24697. } | AbstractMesh[]): Vector3;
  24698. /**
  24699. * Merge the array of meshes into a single mesh for performance reasons.
  24700. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24701. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24702. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24703. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24704. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24705. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24706. * @returns a new mesh
  24707. */
  24708. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24709. /** @hidden */
  24710. addInstance(instance: InstancedMesh): void;
  24711. /** @hidden */
  24712. removeInstance(instance: InstancedMesh): void;
  24713. }
  24714. }
  24715. declare module BABYLON {
  24716. /**
  24717. * This is the base class of all the camera used in the application.
  24718. * @see http://doc.babylonjs.com/features/cameras
  24719. */
  24720. export class Camera extends Node {
  24721. /** @hidden */
  24722. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24723. /**
  24724. * This is the default projection mode used by the cameras.
  24725. * It helps recreating a feeling of perspective and better appreciate depth.
  24726. * This is the best way to simulate real life cameras.
  24727. */
  24728. static readonly PERSPECTIVE_CAMERA: number;
  24729. /**
  24730. * This helps creating camera with an orthographic mode.
  24731. * 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.
  24732. */
  24733. static readonly ORTHOGRAPHIC_CAMERA: number;
  24734. /**
  24735. * This is the default FOV mode for perspective cameras.
  24736. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24737. */
  24738. static readonly FOVMODE_VERTICAL_FIXED: number;
  24739. /**
  24740. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24741. */
  24742. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24743. /**
  24744. * This specifies ther is no need for a camera rig.
  24745. * Basically only one eye is rendered corresponding to the camera.
  24746. */
  24747. static readonly RIG_MODE_NONE: number;
  24748. /**
  24749. * Simulates a camera Rig with one blue eye and one red eye.
  24750. * This can be use with 3d blue and red glasses.
  24751. */
  24752. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24753. /**
  24754. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24755. */
  24756. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24757. /**
  24758. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24759. */
  24760. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24761. /**
  24762. * Defines that both eyes of the camera will be rendered over under each other.
  24763. */
  24764. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24765. /**
  24766. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24767. */
  24768. static readonly RIG_MODE_VR: number;
  24769. /**
  24770. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24771. */
  24772. static readonly RIG_MODE_WEBVR: number;
  24773. /**
  24774. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24775. */
  24776. static readonly RIG_MODE_CUSTOM: number;
  24777. /**
  24778. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24779. */
  24780. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24781. /**
  24782. * Define the input manager associated with the camera.
  24783. */
  24784. inputs: CameraInputsManager<Camera>;
  24785. /** @hidden */
  24786. _position: Vector3;
  24787. /**
  24788. * Define the current local position of the camera in the scene
  24789. */
  24790. position: Vector3;
  24791. /**
  24792. * The vector the camera should consider as up.
  24793. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24794. */
  24795. upVector: Vector3;
  24796. /**
  24797. * Define the current limit on the left side for an orthographic camera
  24798. * In scene unit
  24799. */
  24800. orthoLeft: Nullable<number>;
  24801. /**
  24802. * Define the current limit on the right side for an orthographic camera
  24803. * In scene unit
  24804. */
  24805. orthoRight: Nullable<number>;
  24806. /**
  24807. * Define the current limit on the bottom side for an orthographic camera
  24808. * In scene unit
  24809. */
  24810. orthoBottom: Nullable<number>;
  24811. /**
  24812. * Define the current limit on the top side for an orthographic camera
  24813. * In scene unit
  24814. */
  24815. orthoTop: Nullable<number>;
  24816. /**
  24817. * Field Of View is set in Radians. (default is 0.8)
  24818. */
  24819. fov: number;
  24820. /**
  24821. * Define the minimum distance the camera can see from.
  24822. * This is important to note that the depth buffer are not infinite and the closer it starts
  24823. * the more your scene might encounter depth fighting issue.
  24824. */
  24825. minZ: number;
  24826. /**
  24827. * Define the maximum distance the camera can see to.
  24828. * This is important to note that the depth buffer are not infinite and the further it end
  24829. * the more your scene might encounter depth fighting issue.
  24830. */
  24831. maxZ: number;
  24832. /**
  24833. * Define the default inertia of the camera.
  24834. * This helps giving a smooth feeling to the camera movement.
  24835. */
  24836. inertia: number;
  24837. /**
  24838. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24839. */
  24840. mode: number;
  24841. /**
  24842. * Define wether the camera is intermediate.
  24843. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24844. */
  24845. isIntermediate: boolean;
  24846. /**
  24847. * Define the viewport of the camera.
  24848. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24849. */
  24850. viewport: Viewport;
  24851. /**
  24852. * Restricts the camera to viewing objects with the same layerMask.
  24853. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24854. */
  24855. layerMask: number;
  24856. /**
  24857. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24858. */
  24859. fovMode: number;
  24860. /**
  24861. * Rig mode of the camera.
  24862. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24863. * This is normally controlled byt the camera themselves as internal use.
  24864. */
  24865. cameraRigMode: number;
  24866. /**
  24867. * Defines the distance between both "eyes" in case of a RIG
  24868. */
  24869. interaxialDistance: number;
  24870. /**
  24871. * Defines if stereoscopic rendering is done side by side or over under.
  24872. */
  24873. isStereoscopicSideBySide: boolean;
  24874. /**
  24875. * 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
  24876. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24877. * else in the scene. (Eg. security camera)
  24878. *
  24879. * 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)
  24880. */
  24881. customRenderTargets: RenderTargetTexture[];
  24882. /**
  24883. * When set, the camera will render to this render target instead of the default canvas
  24884. *
  24885. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24886. */
  24887. outputRenderTarget: Nullable<RenderTargetTexture>;
  24888. /**
  24889. * Observable triggered when the camera view matrix has changed.
  24890. */
  24891. onViewMatrixChangedObservable: Observable<Camera>;
  24892. /**
  24893. * Observable triggered when the camera Projection matrix has changed.
  24894. */
  24895. onProjectionMatrixChangedObservable: Observable<Camera>;
  24896. /**
  24897. * Observable triggered when the inputs have been processed.
  24898. */
  24899. onAfterCheckInputsObservable: Observable<Camera>;
  24900. /**
  24901. * Observable triggered when reset has been called and applied to the camera.
  24902. */
  24903. onRestoreStateObservable: Observable<Camera>;
  24904. /** @hidden */
  24905. _cameraRigParams: any;
  24906. /** @hidden */
  24907. _rigCameras: Camera[];
  24908. /** @hidden */
  24909. _rigPostProcess: Nullable<PostProcess>;
  24910. protected _webvrViewMatrix: Matrix;
  24911. /** @hidden */
  24912. _skipRendering: boolean;
  24913. /** @hidden */
  24914. _projectionMatrix: Matrix;
  24915. /** @hidden */
  24916. _postProcesses: Nullable<PostProcess>[];
  24917. /** @hidden */
  24918. _activeMeshes: SmartArray<AbstractMesh>;
  24919. protected _globalPosition: Vector3;
  24920. /** @hidden */
  24921. _computedViewMatrix: Matrix;
  24922. private _doNotComputeProjectionMatrix;
  24923. private _transformMatrix;
  24924. private _frustumPlanes;
  24925. private _refreshFrustumPlanes;
  24926. private _storedFov;
  24927. private _stateStored;
  24928. /**
  24929. * Instantiates a new camera object.
  24930. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24931. * @see http://doc.babylonjs.com/features/cameras
  24932. * @param name Defines the name of the camera in the scene
  24933. * @param position Defines the position of the camera
  24934. * @param scene Defines the scene the camera belongs too
  24935. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24936. */
  24937. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24938. /**
  24939. * Store current camera state (fov, position, etc..)
  24940. * @returns the camera
  24941. */
  24942. storeState(): Camera;
  24943. /**
  24944. * Restores the camera state values if it has been stored. You must call storeState() first
  24945. */
  24946. protected _restoreStateValues(): boolean;
  24947. /**
  24948. * Restored camera state. You must call storeState() first.
  24949. * @returns true if restored and false otherwise
  24950. */
  24951. restoreState(): boolean;
  24952. /**
  24953. * Gets the class name of the camera.
  24954. * @returns the class name
  24955. */
  24956. getClassName(): string;
  24957. /** @hidden */
  24958. readonly _isCamera: boolean;
  24959. /**
  24960. * Gets a string representation of the camera useful for debug purpose.
  24961. * @param fullDetails Defines that a more verboe level of logging is required
  24962. * @returns the string representation
  24963. */
  24964. toString(fullDetails?: boolean): string;
  24965. /**
  24966. * Gets the current world space position of the camera.
  24967. */
  24968. readonly globalPosition: Vector3;
  24969. /**
  24970. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24971. * @returns the active meshe list
  24972. */
  24973. getActiveMeshes(): SmartArray<AbstractMesh>;
  24974. /**
  24975. * Check wether a mesh is part of the current active mesh list of the camera
  24976. * @param mesh Defines the mesh to check
  24977. * @returns true if active, false otherwise
  24978. */
  24979. isActiveMesh(mesh: Mesh): boolean;
  24980. /**
  24981. * Is this camera ready to be used/rendered
  24982. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24983. * @return true if the camera is ready
  24984. */
  24985. isReady(completeCheck?: boolean): boolean;
  24986. /** @hidden */
  24987. _initCache(): void;
  24988. /** @hidden */
  24989. _updateCache(ignoreParentClass?: boolean): void;
  24990. /** @hidden */
  24991. _isSynchronized(): boolean;
  24992. /** @hidden */
  24993. _isSynchronizedViewMatrix(): boolean;
  24994. /** @hidden */
  24995. _isSynchronizedProjectionMatrix(): boolean;
  24996. /**
  24997. * Attach the input controls to a specific dom element to get the input from.
  24998. * @param element Defines the element the controls should be listened from
  24999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25000. */
  25001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25002. /**
  25003. * Detach the current controls from the specified dom element.
  25004. * @param element Defines the element to stop listening the inputs from
  25005. */
  25006. detachControl(element: HTMLElement): void;
  25007. /**
  25008. * Update the camera state according to the different inputs gathered during the frame.
  25009. */
  25010. update(): void;
  25011. /** @hidden */
  25012. _checkInputs(): void;
  25013. /** @hidden */
  25014. readonly rigCameras: Camera[];
  25015. /**
  25016. * Gets the post process used by the rig cameras
  25017. */
  25018. readonly rigPostProcess: Nullable<PostProcess>;
  25019. /**
  25020. * Internal, gets the first post proces.
  25021. * @returns the first post process to be run on this camera.
  25022. */
  25023. _getFirstPostProcess(): Nullable<PostProcess>;
  25024. private _cascadePostProcessesToRigCams;
  25025. /**
  25026. * Attach a post process to the camera.
  25027. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25028. * @param postProcess The post process to attach to the camera
  25029. * @param insertAt The position of the post process in case several of them are in use in the scene
  25030. * @returns the position the post process has been inserted at
  25031. */
  25032. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25033. /**
  25034. * Detach a post process to the camera.
  25035. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25036. * @param postProcess The post process to detach from the camera
  25037. */
  25038. detachPostProcess(postProcess: PostProcess): void;
  25039. /**
  25040. * Gets the current world matrix of the camera
  25041. */
  25042. getWorldMatrix(): Matrix;
  25043. /** @hidden */
  25044. _getViewMatrix(): Matrix;
  25045. /**
  25046. * Gets the current view matrix of the camera.
  25047. * @param force forces the camera to recompute the matrix without looking at the cached state
  25048. * @returns the view matrix
  25049. */
  25050. getViewMatrix(force?: boolean): Matrix;
  25051. /**
  25052. * Freeze the projection matrix.
  25053. * It will prevent the cache check of the camera projection compute and can speed up perf
  25054. * if no parameter of the camera are meant to change
  25055. * @param projection Defines manually a projection if necessary
  25056. */
  25057. freezeProjectionMatrix(projection?: Matrix): void;
  25058. /**
  25059. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25060. */
  25061. unfreezeProjectionMatrix(): void;
  25062. /**
  25063. * Gets the current projection matrix of the camera.
  25064. * @param force forces the camera to recompute the matrix without looking at the cached state
  25065. * @returns the projection matrix
  25066. */
  25067. getProjectionMatrix(force?: boolean): Matrix;
  25068. /**
  25069. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25070. * @returns a Matrix
  25071. */
  25072. getTransformationMatrix(): Matrix;
  25073. private _updateFrustumPlanes;
  25074. /**
  25075. * Checks if a cullable object (mesh...) is in the camera frustum
  25076. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25077. * @param target The object to check
  25078. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25079. * @returns true if the object is in frustum otherwise false
  25080. */
  25081. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25082. /**
  25083. * Checks if a cullable object (mesh...) is in the camera frustum
  25084. * Unlike isInFrustum this cheks the full bounding box
  25085. * @param target The object to check
  25086. * @returns true if the object is in frustum otherwise false
  25087. */
  25088. isCompletelyInFrustum(target: ICullable): boolean;
  25089. /**
  25090. * Gets a ray in the forward direction from the camera.
  25091. * @param length Defines the length of the ray to create
  25092. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25093. * @param origin Defines the start point of the ray which defaults to the camera position
  25094. * @returns the forward ray
  25095. */
  25096. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25097. /**
  25098. * Releases resources associated with this node.
  25099. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25100. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25101. */
  25102. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25103. /** @hidden */
  25104. _isLeftCamera: boolean;
  25105. /**
  25106. * Gets the left camera of a rig setup in case of Rigged Camera
  25107. */
  25108. readonly isLeftCamera: boolean;
  25109. /** @hidden */
  25110. _isRightCamera: boolean;
  25111. /**
  25112. * Gets the right camera of a rig setup in case of Rigged Camera
  25113. */
  25114. readonly isRightCamera: boolean;
  25115. /**
  25116. * Gets the left camera of a rig setup in case of Rigged Camera
  25117. */
  25118. readonly leftCamera: Nullable<FreeCamera>;
  25119. /**
  25120. * Gets the right camera of a rig setup in case of Rigged Camera
  25121. */
  25122. readonly rightCamera: Nullable<FreeCamera>;
  25123. /**
  25124. * Gets the left camera target of a rig setup in case of Rigged Camera
  25125. * @returns the target position
  25126. */
  25127. getLeftTarget(): Nullable<Vector3>;
  25128. /**
  25129. * Gets the right camera target of a rig setup in case of Rigged Camera
  25130. * @returns the target position
  25131. */
  25132. getRightTarget(): Nullable<Vector3>;
  25133. /**
  25134. * @hidden
  25135. */
  25136. setCameraRigMode(mode: number, rigParams: any): void;
  25137. /** @hidden */
  25138. static _setStereoscopicRigMode(camera: Camera): void;
  25139. /** @hidden */
  25140. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25141. /** @hidden */
  25142. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25143. /** @hidden */
  25144. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25145. /** @hidden */
  25146. _getVRProjectionMatrix(): Matrix;
  25147. protected _updateCameraRotationMatrix(): void;
  25148. protected _updateWebVRCameraRotationMatrix(): void;
  25149. /**
  25150. * This function MUST be overwritten by the different WebVR cameras available.
  25151. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25152. * @hidden
  25153. */
  25154. _getWebVRProjectionMatrix(): Matrix;
  25155. /**
  25156. * This function MUST be overwritten by the different WebVR cameras available.
  25157. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25158. * @hidden
  25159. */
  25160. _getWebVRViewMatrix(): Matrix;
  25161. /** @hidden */
  25162. setCameraRigParameter(name: string, value: any): void;
  25163. /**
  25164. * needs to be overridden by children so sub has required properties to be copied
  25165. * @hidden
  25166. */
  25167. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25168. /**
  25169. * May need to be overridden by children
  25170. * @hidden
  25171. */
  25172. _updateRigCameras(): void;
  25173. /** @hidden */
  25174. _setupInputs(): void;
  25175. /**
  25176. * Serialiaze the camera setup to a json represention
  25177. * @returns the JSON representation
  25178. */
  25179. serialize(): any;
  25180. /**
  25181. * Clones the current camera.
  25182. * @param name The cloned camera name
  25183. * @returns the cloned camera
  25184. */
  25185. clone(name: string): Camera;
  25186. /**
  25187. * Gets the direction of the camera relative to a given local axis.
  25188. * @param localAxis Defines the reference axis to provide a relative direction.
  25189. * @return the direction
  25190. */
  25191. getDirection(localAxis: Vector3): Vector3;
  25192. /**
  25193. * Returns the current camera absolute rotation
  25194. */
  25195. readonly absoluteRotation: Quaternion;
  25196. /**
  25197. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25198. * @param localAxis Defines the reference axis to provide a relative direction.
  25199. * @param result Defines the vector to store the result in
  25200. */
  25201. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25202. /**
  25203. * Gets a camera constructor for a given camera type
  25204. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25205. * @param name The name of the camera the result will be able to instantiate
  25206. * @param scene The scene the result will construct the camera in
  25207. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25208. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25209. * @returns a factory method to construc the camera
  25210. */
  25211. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25212. /**
  25213. * Compute the world matrix of the camera.
  25214. * @returns the camera workd matrix
  25215. */
  25216. computeWorldMatrix(): Matrix;
  25217. /**
  25218. * Parse a JSON and creates the camera from the parsed information
  25219. * @param parsedCamera The JSON to parse
  25220. * @param scene The scene to instantiate the camera in
  25221. * @returns the newly constructed camera
  25222. */
  25223. static Parse(parsedCamera: any, scene: Scene): Camera;
  25224. }
  25225. }
  25226. declare module BABYLON {
  25227. /**
  25228. * Class containing static functions to help procedurally build meshes
  25229. */
  25230. export class DiscBuilder {
  25231. /**
  25232. * Creates a plane polygonal mesh. By default, this is a disc
  25233. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25234. * * 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
  25235. * * 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
  25236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25237. * * 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
  25238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25239. * @param name defines the name of the mesh
  25240. * @param options defines the options used to create the mesh
  25241. * @param scene defines the hosting scene
  25242. * @returns the plane polygonal mesh
  25243. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25244. */
  25245. static CreateDisc(name: string, options: {
  25246. radius?: number;
  25247. tessellation?: number;
  25248. arc?: number;
  25249. updatable?: boolean;
  25250. sideOrientation?: number;
  25251. frontUVs?: Vector4;
  25252. backUVs?: Vector4;
  25253. }, scene?: Nullable<Scene>): Mesh;
  25254. }
  25255. }
  25256. declare module BABYLON {
  25257. /**
  25258. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25259. *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.
  25260. * The SPS is also a particle system. It provides some methods to manage the particles.
  25261. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25262. *
  25263. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25264. */
  25265. export class SolidParticleSystem implements IDisposable {
  25266. /**
  25267. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25268. * Example : var p = SPS.particles[i];
  25269. */
  25270. particles: SolidParticle[];
  25271. /**
  25272. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25273. */
  25274. nbParticles: number;
  25275. /**
  25276. * If the particles must ever face the camera (default false). Useful for planar particles.
  25277. */
  25278. billboard: boolean;
  25279. /**
  25280. * Recompute normals when adding a shape
  25281. */
  25282. recomputeNormals: boolean;
  25283. /**
  25284. * This a counter ofr your own usage. It's not set by any SPS functions.
  25285. */
  25286. counter: number;
  25287. /**
  25288. * The SPS name. This name is also given to the underlying mesh.
  25289. */
  25290. name: string;
  25291. /**
  25292. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25293. */
  25294. mesh: Mesh;
  25295. /**
  25296. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25297. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25298. */
  25299. vars: any;
  25300. /**
  25301. * This array is populated when the SPS is set as 'pickable'.
  25302. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25303. * Each element of this array is an object `{idx: int, faceId: int}`.
  25304. * `idx` is the picked particle index in the `SPS.particles` array
  25305. * `faceId` is the picked face index counted within this particle.
  25306. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25307. */
  25308. pickedParticles: {
  25309. idx: number;
  25310. faceId: number;
  25311. }[];
  25312. /**
  25313. * This array is populated when `enableDepthSort` is set to true.
  25314. * Each element of this array is an instance of the class DepthSortedParticle.
  25315. */
  25316. depthSortedParticles: DepthSortedParticle[];
  25317. /**
  25318. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25319. * @hidden
  25320. */
  25321. _bSphereOnly: boolean;
  25322. /**
  25323. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25324. * @hidden
  25325. */
  25326. _bSphereRadiusFactor: number;
  25327. private _scene;
  25328. private _positions;
  25329. private _indices;
  25330. private _normals;
  25331. private _colors;
  25332. private _uvs;
  25333. private _indices32;
  25334. private _positions32;
  25335. private _normals32;
  25336. private _fixedNormal32;
  25337. private _colors32;
  25338. private _uvs32;
  25339. private _index;
  25340. private _updatable;
  25341. private _pickable;
  25342. private _isVisibilityBoxLocked;
  25343. private _alwaysVisible;
  25344. private _depthSort;
  25345. private _shapeCounter;
  25346. private _copy;
  25347. private _color;
  25348. private _computeParticleColor;
  25349. private _computeParticleTexture;
  25350. private _computeParticleRotation;
  25351. private _computeParticleVertex;
  25352. private _computeBoundingBox;
  25353. private _depthSortParticles;
  25354. private _camera;
  25355. private _mustUnrotateFixedNormals;
  25356. private _particlesIntersect;
  25357. private _needs32Bits;
  25358. /**
  25359. * Creates a SPS (Solid Particle System) object.
  25360. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25361. * @param scene (Scene) is the scene in which the SPS is added.
  25362. * @param options defines the options of the sps e.g.
  25363. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25364. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25365. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25366. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25367. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25368. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25369. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25370. */
  25371. constructor(name: string, scene: Scene, options?: {
  25372. updatable?: boolean;
  25373. isPickable?: boolean;
  25374. enableDepthSort?: boolean;
  25375. particleIntersection?: boolean;
  25376. boundingSphereOnly?: boolean;
  25377. bSphereRadiusFactor?: number;
  25378. });
  25379. /**
  25380. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25381. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25382. * @returns the created mesh
  25383. */
  25384. buildMesh(): Mesh;
  25385. /**
  25386. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25387. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25388. * Thus the particles generated from `digest()` have their property `position` set yet.
  25389. * @param mesh ( Mesh ) is the mesh to be digested
  25390. * @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
  25391. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25392. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25393. * @returns the current SPS
  25394. */
  25395. digest(mesh: Mesh, options?: {
  25396. facetNb?: number;
  25397. number?: number;
  25398. delta?: number;
  25399. }): SolidParticleSystem;
  25400. private _unrotateFixedNormals;
  25401. private _resetCopy;
  25402. private _meshBuilder;
  25403. private _posToShape;
  25404. private _uvsToShapeUV;
  25405. private _addParticle;
  25406. /**
  25407. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25408. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25409. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25410. * @param nb (positive integer) the number of particles to be created from this model
  25411. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25412. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25413. * @returns the number of shapes in the system
  25414. */
  25415. addShape(mesh: Mesh, nb: number, options?: {
  25416. positionFunction?: any;
  25417. vertexFunction?: any;
  25418. }): number;
  25419. private _rebuildParticle;
  25420. /**
  25421. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25422. * @returns the SPS.
  25423. */
  25424. rebuildMesh(): SolidParticleSystem;
  25425. /**
  25426. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25427. * This method calls `updateParticle()` for each particle of the SPS.
  25428. * For an animated SPS, it is usually called within the render loop.
  25429. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25430. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25431. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25432. * @returns the SPS.
  25433. */
  25434. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25435. /**
  25436. * Disposes the SPS.
  25437. */
  25438. dispose(): void;
  25439. /**
  25440. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25442. * @returns the SPS.
  25443. */
  25444. refreshVisibleSize(): SolidParticleSystem;
  25445. /**
  25446. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25447. * @param size the size (float) of the visibility box
  25448. * note : this doesn't lock the SPS mesh bounding box.
  25449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25450. */
  25451. setVisibilityBox(size: number): void;
  25452. /**
  25453. * Gets whether the SPS as always visible or not
  25454. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25455. */
  25456. /**
  25457. * Sets the SPS as always visible or not
  25458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25459. */
  25460. isAlwaysVisible: boolean;
  25461. /**
  25462. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25463. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25464. */
  25465. /**
  25466. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25467. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25468. */
  25469. isVisibilityBoxLocked: boolean;
  25470. /**
  25471. * Tells to `setParticles()` to compute the particle rotations or not.
  25472. * Default value : true. The SPS is faster when it's set to false.
  25473. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25474. */
  25475. /**
  25476. * Gets if `setParticles()` computes the particle rotations or not.
  25477. * Default value : true. The SPS is faster when it's set to false.
  25478. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25479. */
  25480. computeParticleRotation: boolean;
  25481. /**
  25482. * Tells to `setParticles()` to compute the particle colors or not.
  25483. * Default value : true. The SPS is faster when it's set to false.
  25484. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25485. */
  25486. /**
  25487. * Gets if `setParticles()` computes the particle colors or not.
  25488. * Default value : true. The SPS is faster when it's set to false.
  25489. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25490. */
  25491. computeParticleColor: boolean;
  25492. /**
  25493. * Gets if `setParticles()` computes the particle textures or not.
  25494. * Default value : true. The SPS is faster when it's set to false.
  25495. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25496. */
  25497. computeParticleTexture: boolean;
  25498. /**
  25499. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25500. * Default value : false. The SPS is faster when it's set to false.
  25501. * Note : the particle custom vertex positions aren't stored values.
  25502. */
  25503. /**
  25504. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25505. * Default value : false. The SPS is faster when it's set to false.
  25506. * Note : the particle custom vertex positions aren't stored values.
  25507. */
  25508. computeParticleVertex: boolean;
  25509. /**
  25510. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25511. */
  25512. /**
  25513. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25514. */
  25515. computeBoundingBox: boolean;
  25516. /**
  25517. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25518. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25519. * Default : `true`
  25520. */
  25521. /**
  25522. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25523. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25524. * Default : `true`
  25525. */
  25526. depthSortParticles: boolean;
  25527. /**
  25528. * This function does nothing. It may be overwritten to set all the particle first values.
  25529. * The SPS doesn't call this function, you may have to call it by your own.
  25530. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25531. */
  25532. initParticles(): void;
  25533. /**
  25534. * This function does nothing. It may be overwritten to recycle a particle.
  25535. * The SPS doesn't call this function, you may have to call it by your own.
  25536. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25537. * @param particle The particle to recycle
  25538. * @returns the recycled particle
  25539. */
  25540. recycleParticle(particle: SolidParticle): SolidParticle;
  25541. /**
  25542. * Updates a particle : this function should be overwritten by the user.
  25543. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25545. * @example : just set a particle position or velocity and recycle conditions
  25546. * @param particle The particle to update
  25547. * @returns the updated particle
  25548. */
  25549. updateParticle(particle: SolidParticle): SolidParticle;
  25550. /**
  25551. * Updates a vertex of a particle : it can be overwritten by the user.
  25552. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25553. * @param particle the current particle
  25554. * @param vertex the current index of the current particle
  25555. * @param pt the index of the current vertex in the particle shape
  25556. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25557. * @example : just set a vertex particle position
  25558. * @returns the updated vertex
  25559. */
  25560. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25561. /**
  25562. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25563. * This does nothing and may be overwritten by the user.
  25564. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25565. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25566. * @param update the boolean update value actually passed to setParticles()
  25567. */
  25568. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25569. /**
  25570. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25571. * This will be passed three parameters.
  25572. * This does nothing and may be overwritten by the user.
  25573. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25574. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25575. * @param update the boolean update value actually passed to setParticles()
  25576. */
  25577. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25578. }
  25579. }
  25580. declare module BABYLON {
  25581. /**
  25582. * Represents one particle of a solid particle system.
  25583. */
  25584. export class SolidParticle {
  25585. /**
  25586. * particle global index
  25587. */
  25588. idx: number;
  25589. /**
  25590. * The color of the particle
  25591. */
  25592. color: Nullable<Color4>;
  25593. /**
  25594. * The world space position of the particle.
  25595. */
  25596. position: Vector3;
  25597. /**
  25598. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25599. */
  25600. rotation: Vector3;
  25601. /**
  25602. * The world space rotation quaternion of the particle.
  25603. */
  25604. rotationQuaternion: Nullable<Quaternion>;
  25605. /**
  25606. * The scaling of the particle.
  25607. */
  25608. scaling: Vector3;
  25609. /**
  25610. * The uvs of the particle.
  25611. */
  25612. uvs: Vector4;
  25613. /**
  25614. * The current speed of the particle.
  25615. */
  25616. velocity: Vector3;
  25617. /**
  25618. * The pivot point in the particle local space.
  25619. */
  25620. pivot: Vector3;
  25621. /**
  25622. * Must the particle be translated from its pivot point in its local space ?
  25623. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25624. * Default : false
  25625. */
  25626. translateFromPivot: boolean;
  25627. /**
  25628. * Is the particle active or not ?
  25629. */
  25630. alive: boolean;
  25631. /**
  25632. * Is the particle visible or not ?
  25633. */
  25634. isVisible: boolean;
  25635. /**
  25636. * Index of this particle in the global "positions" array (Internal use)
  25637. * @hidden
  25638. */
  25639. _pos: number;
  25640. /**
  25641. * @hidden Index of this particle in the global "indices" array (Internal use)
  25642. */
  25643. _ind: number;
  25644. /**
  25645. * @hidden ModelShape of this particle (Internal use)
  25646. */
  25647. _model: ModelShape;
  25648. /**
  25649. * ModelShape id of this particle
  25650. */
  25651. shapeId: number;
  25652. /**
  25653. * Index of the particle in its shape id
  25654. */
  25655. idxInShape: number;
  25656. /**
  25657. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25658. */
  25659. _modelBoundingInfo: BoundingInfo;
  25660. /**
  25661. * @hidden Particle BoundingInfo object (Internal use)
  25662. */
  25663. _boundingInfo: BoundingInfo;
  25664. /**
  25665. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25666. */
  25667. _sps: SolidParticleSystem;
  25668. /**
  25669. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25670. */
  25671. _stillInvisible: boolean;
  25672. /**
  25673. * @hidden Last computed particle rotation matrix
  25674. */
  25675. _rotationMatrix: number[];
  25676. /**
  25677. * Parent particle Id, if any.
  25678. * Default null.
  25679. */
  25680. parentId: Nullable<number>;
  25681. /**
  25682. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25683. * The possible values are :
  25684. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25685. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25686. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25687. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25688. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25689. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25690. * */
  25691. cullingStrategy: number;
  25692. /**
  25693. * @hidden Internal global position in the SPS.
  25694. */
  25695. _globalPosition: Vector3;
  25696. /**
  25697. * Creates a Solid Particle object.
  25698. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25699. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25700. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25701. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25702. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25703. * @param shapeId (integer) is the model shape identifier in the SPS.
  25704. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25705. * @param sps defines the sps it is associated to
  25706. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25707. */
  25708. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25709. /**
  25710. * Legacy support, changed scale to scaling
  25711. */
  25712. /**
  25713. * Legacy support, changed scale to scaling
  25714. */
  25715. scale: Vector3;
  25716. /**
  25717. * Legacy support, changed quaternion to rotationQuaternion
  25718. */
  25719. /**
  25720. * Legacy support, changed quaternion to rotationQuaternion
  25721. */
  25722. quaternion: Nullable<Quaternion>;
  25723. /**
  25724. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25725. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25726. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25727. * @returns true if it intersects
  25728. */
  25729. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25730. /**
  25731. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25732. * A particle is in the frustum if its bounding box intersects the frustum
  25733. * @param frustumPlanes defines the frustum to test
  25734. * @returns true if the particle is in the frustum planes
  25735. */
  25736. isInFrustum(frustumPlanes: Plane[]): boolean;
  25737. /**
  25738. * get the rotation matrix of the particle
  25739. * @hidden
  25740. */
  25741. getRotationMatrix(m: Matrix): void;
  25742. }
  25743. /**
  25744. * Represents the shape of the model used by one particle of a solid particle system.
  25745. * SPS internal tool, don't use it manually.
  25746. */
  25747. export class ModelShape {
  25748. /**
  25749. * The shape id
  25750. * @hidden
  25751. */
  25752. shapeID: number;
  25753. /**
  25754. * flat array of model positions (internal use)
  25755. * @hidden
  25756. */
  25757. _shape: Vector3[];
  25758. /**
  25759. * flat array of model UVs (internal use)
  25760. * @hidden
  25761. */
  25762. _shapeUV: number[];
  25763. /**
  25764. * length of the shape in the model indices array (internal use)
  25765. * @hidden
  25766. */
  25767. _indicesLength: number;
  25768. /**
  25769. * Custom position function (internal use)
  25770. * @hidden
  25771. */
  25772. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25773. /**
  25774. * Custom vertex function (internal use)
  25775. * @hidden
  25776. */
  25777. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25778. /**
  25779. * 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.
  25780. * SPS internal tool, don't use it manually.
  25781. * @hidden
  25782. */
  25783. 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>);
  25784. }
  25785. /**
  25786. * Represents a Depth Sorted Particle in the solid particle system.
  25787. */
  25788. export class DepthSortedParticle {
  25789. /**
  25790. * Index of the particle in the "indices" array
  25791. */
  25792. ind: number;
  25793. /**
  25794. * Length of the particle shape in the "indices" array
  25795. */
  25796. indicesLength: number;
  25797. /**
  25798. * Squared distance from the particle to the camera
  25799. */
  25800. sqDistance: number;
  25801. }
  25802. }
  25803. declare module BABYLON {
  25804. /**
  25805. * @hidden
  25806. */
  25807. export class _MeshCollisionData {
  25808. _checkCollisions: boolean;
  25809. _collisionMask: number;
  25810. _collisionGroup: number;
  25811. _collider: Nullable<Collider>;
  25812. _oldPositionForCollisions: Vector3;
  25813. _diffPositionForCollisions: Vector3;
  25814. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25815. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25816. }
  25817. }
  25818. declare module BABYLON {
  25819. /** @hidden */
  25820. class _FacetDataStorage {
  25821. facetPositions: Vector3[];
  25822. facetNormals: Vector3[];
  25823. facetPartitioning: number[][];
  25824. facetNb: number;
  25825. partitioningSubdivisions: number;
  25826. partitioningBBoxRatio: number;
  25827. facetDataEnabled: boolean;
  25828. facetParameters: any;
  25829. bbSize: Vector3;
  25830. subDiv: {
  25831. max: number;
  25832. X: number;
  25833. Y: number;
  25834. Z: number;
  25835. };
  25836. facetDepthSort: boolean;
  25837. facetDepthSortEnabled: boolean;
  25838. depthSortedIndices: IndicesArray;
  25839. depthSortedFacets: {
  25840. ind: number;
  25841. sqDistance: number;
  25842. }[];
  25843. facetDepthSortFunction: (f1: {
  25844. ind: number;
  25845. sqDistance: number;
  25846. }, f2: {
  25847. ind: number;
  25848. sqDistance: number;
  25849. }) => number;
  25850. facetDepthSortFrom: Vector3;
  25851. facetDepthSortOrigin: Vector3;
  25852. invertedMatrix: Matrix;
  25853. }
  25854. /**
  25855. * @hidden
  25856. **/
  25857. class _InternalAbstractMeshDataInfo {
  25858. _hasVertexAlpha: boolean;
  25859. _useVertexColors: boolean;
  25860. _numBoneInfluencers: number;
  25861. _applyFog: boolean;
  25862. _receiveShadows: boolean;
  25863. _facetData: _FacetDataStorage;
  25864. _visibility: number;
  25865. _skeleton: Nullable<Skeleton>;
  25866. _layerMask: number;
  25867. _computeBonesUsingShaders: boolean;
  25868. _isActive: boolean;
  25869. _onlyForInstances: boolean;
  25870. _isActiveIntermediate: boolean;
  25871. _onlyForInstancesIntermediate: boolean;
  25872. }
  25873. /**
  25874. * Class used to store all common mesh properties
  25875. */
  25876. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25877. /** No occlusion */
  25878. static OCCLUSION_TYPE_NONE: number;
  25879. /** Occlusion set to optimisitic */
  25880. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25881. /** Occlusion set to strict */
  25882. static OCCLUSION_TYPE_STRICT: number;
  25883. /** Use an accurante occlusion algorithm */
  25884. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25885. /** Use a conservative occlusion algorithm */
  25886. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25887. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25888. * Test order :
  25889. * Is the bounding sphere outside the frustum ?
  25890. * If not, are the bounding box vertices outside the frustum ?
  25891. * It not, then the cullable object is in the frustum.
  25892. */
  25893. static readonly CULLINGSTRATEGY_STANDARD: number;
  25894. /** Culling strategy : Bounding Sphere Only.
  25895. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25896. * It's also less accurate than the standard because some not visible objects can still be selected.
  25897. * Test : is the bounding sphere outside the frustum ?
  25898. * If not, then the cullable object is in the frustum.
  25899. */
  25900. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25901. /** Culling strategy : Optimistic Inclusion.
  25902. * This in an inclusion test first, then the standard exclusion test.
  25903. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25904. * 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.
  25905. * Anyway, it's as accurate as the standard strategy.
  25906. * Test :
  25907. * Is the cullable object bounding sphere center in the frustum ?
  25908. * If not, apply the default culling strategy.
  25909. */
  25910. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25911. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25912. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25913. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25914. * 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.
  25915. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25916. * Test :
  25917. * Is the cullable object bounding sphere center in the frustum ?
  25918. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25919. */
  25920. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25921. /**
  25922. * No billboard
  25923. */
  25924. static readonly BILLBOARDMODE_NONE: number;
  25925. /** Billboard on X axis */
  25926. static readonly BILLBOARDMODE_X: number;
  25927. /** Billboard on Y axis */
  25928. static readonly BILLBOARDMODE_Y: number;
  25929. /** Billboard on Z axis */
  25930. static readonly BILLBOARDMODE_Z: number;
  25931. /** Billboard on all axes */
  25932. static readonly BILLBOARDMODE_ALL: number;
  25933. /** Billboard on using position instead of orientation */
  25934. static readonly BILLBOARDMODE_USE_POSITION: number;
  25935. /** @hidden */
  25936. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25937. /**
  25938. * The culling strategy to use to check whether the mesh must be rendered or not.
  25939. * This value can be changed at any time and will be used on the next render mesh selection.
  25940. * The possible values are :
  25941. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25942. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25943. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25944. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25945. * Please read each static variable documentation to get details about the culling process.
  25946. * */
  25947. cullingStrategy: number;
  25948. /**
  25949. * Gets the number of facets in the mesh
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25951. */
  25952. readonly facetNb: number;
  25953. /**
  25954. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25956. */
  25957. partitioningSubdivisions: number;
  25958. /**
  25959. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25960. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25962. */
  25963. partitioningBBoxRatio: number;
  25964. /**
  25965. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25966. * Works only for updatable meshes.
  25967. * Doesn't work with multi-materials
  25968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25969. */
  25970. mustDepthSortFacets: boolean;
  25971. /**
  25972. * The location (Vector3) where the facet depth sort must be computed from.
  25973. * By default, the active camera position.
  25974. * Used only when facet depth sort is enabled
  25975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25976. */
  25977. facetDepthSortFrom: Vector3;
  25978. /**
  25979. * gets a boolean indicating if facetData is enabled
  25980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25981. */
  25982. readonly isFacetDataEnabled: boolean;
  25983. /** @hidden */
  25984. _updateNonUniformScalingState(value: boolean): boolean;
  25985. /**
  25986. * An event triggered when this mesh collides with another one
  25987. */
  25988. onCollideObservable: Observable<AbstractMesh>;
  25989. /** Set a function to call when this mesh collides with another one */
  25990. onCollide: () => void;
  25991. /**
  25992. * An event triggered when the collision's position changes
  25993. */
  25994. onCollisionPositionChangeObservable: Observable<Vector3>;
  25995. /** Set a function to call when the collision's position changes */
  25996. onCollisionPositionChange: () => void;
  25997. /**
  25998. * An event triggered when material is changed
  25999. */
  26000. onMaterialChangedObservable: Observable<AbstractMesh>;
  26001. /**
  26002. * Gets or sets the orientation for POV movement & rotation
  26003. */
  26004. definedFacingForward: boolean;
  26005. /** @hidden */
  26006. _occlusionQuery: Nullable<WebGLQuery>;
  26007. /** @hidden */
  26008. _renderingGroup: Nullable<RenderingGroup>;
  26009. /**
  26010. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26011. */
  26012. /**
  26013. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26014. */
  26015. visibility: number;
  26016. /** Gets or sets the alpha index used to sort transparent meshes
  26017. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26018. */
  26019. alphaIndex: number;
  26020. /**
  26021. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26022. */
  26023. isVisible: boolean;
  26024. /**
  26025. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26026. */
  26027. isPickable: boolean;
  26028. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26029. showSubMeshesBoundingBox: boolean;
  26030. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26032. */
  26033. isBlocker: boolean;
  26034. /**
  26035. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26036. */
  26037. enablePointerMoveEvents: boolean;
  26038. /**
  26039. * Specifies the rendering group id for this mesh (0 by default)
  26040. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26041. */
  26042. renderingGroupId: number;
  26043. private _material;
  26044. /** Gets or sets current material */
  26045. material: Nullable<Material>;
  26046. /**
  26047. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26048. * @see http://doc.babylonjs.com/babylon101/shadows
  26049. */
  26050. receiveShadows: boolean;
  26051. /** Defines color to use when rendering outline */
  26052. outlineColor: Color3;
  26053. /** Define width to use when rendering outline */
  26054. outlineWidth: number;
  26055. /** Defines color to use when rendering overlay */
  26056. overlayColor: Color3;
  26057. /** Defines alpha to use when rendering overlay */
  26058. overlayAlpha: number;
  26059. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26060. hasVertexAlpha: boolean;
  26061. /** 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) */
  26062. useVertexColors: boolean;
  26063. /**
  26064. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26065. */
  26066. computeBonesUsingShaders: boolean;
  26067. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26068. numBoneInfluencers: number;
  26069. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26070. applyFog: boolean;
  26071. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26072. useOctreeForRenderingSelection: boolean;
  26073. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26074. useOctreeForPicking: boolean;
  26075. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26076. useOctreeForCollisions: boolean;
  26077. /**
  26078. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26079. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26080. */
  26081. layerMask: number;
  26082. /**
  26083. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26084. */
  26085. alwaysSelectAsActiveMesh: boolean;
  26086. /**
  26087. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26088. */
  26089. doNotSyncBoundingInfo: boolean;
  26090. /**
  26091. * Gets or sets the current action manager
  26092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26093. */
  26094. actionManager: Nullable<AbstractActionManager>;
  26095. private _meshCollisionData;
  26096. /**
  26097. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26099. */
  26100. ellipsoid: Vector3;
  26101. /**
  26102. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26104. */
  26105. ellipsoidOffset: Vector3;
  26106. /**
  26107. * Gets or sets a collision mask used to mask collisions (default is -1).
  26108. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26109. */
  26110. collisionMask: number;
  26111. /**
  26112. * Gets or sets the current collision group mask (-1 by default).
  26113. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26114. */
  26115. collisionGroup: number;
  26116. /**
  26117. * Defines edge width used when edgesRenderer is enabled
  26118. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26119. */
  26120. edgesWidth: number;
  26121. /**
  26122. * Defines edge color used when edgesRenderer is enabled
  26123. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26124. */
  26125. edgesColor: Color4;
  26126. /** @hidden */
  26127. _edgesRenderer: Nullable<IEdgesRenderer>;
  26128. /** @hidden */
  26129. _masterMesh: Nullable<AbstractMesh>;
  26130. /** @hidden */
  26131. _boundingInfo: Nullable<BoundingInfo>;
  26132. /** @hidden */
  26133. _renderId: number;
  26134. /**
  26135. * Gets or sets the list of subMeshes
  26136. * @see http://doc.babylonjs.com/how_to/multi_materials
  26137. */
  26138. subMeshes: SubMesh[];
  26139. /** @hidden */
  26140. _intersectionsInProgress: AbstractMesh[];
  26141. /** @hidden */
  26142. _unIndexed: boolean;
  26143. /** @hidden */
  26144. _lightSources: Light[];
  26145. /** Gets the list of lights affecting that mesh */
  26146. readonly lightSources: Light[];
  26147. /** @hidden */
  26148. readonly _positions: Nullable<Vector3[]>;
  26149. /** @hidden */
  26150. _waitingData: {
  26151. lods: Nullable<any>;
  26152. actions: Nullable<any>;
  26153. freezeWorldMatrix: Nullable<boolean>;
  26154. };
  26155. /** @hidden */
  26156. _bonesTransformMatrices: Nullable<Float32Array>;
  26157. /** @hidden */
  26158. _transformMatrixTexture: Nullable<RawTexture>;
  26159. /**
  26160. * Gets or sets a skeleton to apply skining transformations
  26161. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26162. */
  26163. skeleton: Nullable<Skeleton>;
  26164. /**
  26165. * An event triggered when the mesh is rebuilt.
  26166. */
  26167. onRebuildObservable: Observable<AbstractMesh>;
  26168. /**
  26169. * Creates a new AbstractMesh
  26170. * @param name defines the name of the mesh
  26171. * @param scene defines the hosting scene
  26172. */
  26173. constructor(name: string, scene?: Nullable<Scene>);
  26174. /**
  26175. * Returns the string "AbstractMesh"
  26176. * @returns "AbstractMesh"
  26177. */
  26178. getClassName(): string;
  26179. /**
  26180. * Gets a string representation of the current mesh
  26181. * @param fullDetails defines a boolean indicating if full details must be included
  26182. * @returns a string representation of the current mesh
  26183. */
  26184. toString(fullDetails?: boolean): string;
  26185. /**
  26186. * @hidden
  26187. */
  26188. protected _getEffectiveParent(): Nullable<Node>;
  26189. /** @hidden */
  26190. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26191. /** @hidden */
  26192. _rebuild(): void;
  26193. /** @hidden */
  26194. _resyncLightSources(): void;
  26195. /** @hidden */
  26196. _resyncLighSource(light: Light): void;
  26197. /** @hidden */
  26198. _unBindEffect(): void;
  26199. /** @hidden */
  26200. _removeLightSource(light: Light, dispose: boolean): void;
  26201. private _markSubMeshesAsDirty;
  26202. /** @hidden */
  26203. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26204. /** @hidden */
  26205. _markSubMeshesAsAttributesDirty(): void;
  26206. /** @hidden */
  26207. _markSubMeshesAsMiscDirty(): void;
  26208. /**
  26209. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26210. */
  26211. scaling: Vector3;
  26212. /**
  26213. * Returns true if the mesh is blocked. Implemented by child classes
  26214. */
  26215. readonly isBlocked: boolean;
  26216. /**
  26217. * Returns the mesh itself by default. Implemented by child classes
  26218. * @param camera defines the camera to use to pick the right LOD level
  26219. * @returns the currentAbstractMesh
  26220. */
  26221. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26222. /**
  26223. * Returns 0 by default. Implemented by child classes
  26224. * @returns an integer
  26225. */
  26226. getTotalVertices(): number;
  26227. /**
  26228. * Returns a positive integer : the total number of indices in this mesh geometry.
  26229. * @returns the numner of indices or zero if the mesh has no geometry.
  26230. */
  26231. getTotalIndices(): number;
  26232. /**
  26233. * Returns null by default. Implemented by child classes
  26234. * @returns null
  26235. */
  26236. getIndices(): Nullable<IndicesArray>;
  26237. /**
  26238. * Returns the array of the requested vertex data kind. Implemented by child classes
  26239. * @param kind defines the vertex data kind to use
  26240. * @returns null
  26241. */
  26242. getVerticesData(kind: string): Nullable<FloatArray>;
  26243. /**
  26244. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26245. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26246. * Note that a new underlying VertexBuffer object is created each call.
  26247. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26248. * @param kind defines vertex data kind:
  26249. * * VertexBuffer.PositionKind
  26250. * * VertexBuffer.UVKind
  26251. * * VertexBuffer.UV2Kind
  26252. * * VertexBuffer.UV3Kind
  26253. * * VertexBuffer.UV4Kind
  26254. * * VertexBuffer.UV5Kind
  26255. * * VertexBuffer.UV6Kind
  26256. * * VertexBuffer.ColorKind
  26257. * * VertexBuffer.MatricesIndicesKind
  26258. * * VertexBuffer.MatricesIndicesExtraKind
  26259. * * VertexBuffer.MatricesWeightsKind
  26260. * * VertexBuffer.MatricesWeightsExtraKind
  26261. * @param data defines the data source
  26262. * @param updatable defines if the data must be flagged as updatable (or static)
  26263. * @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
  26264. * @returns the current mesh
  26265. */
  26266. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26267. /**
  26268. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26269. * If the mesh has no geometry, it is simply returned as it is.
  26270. * @param kind defines vertex data kind:
  26271. * * VertexBuffer.PositionKind
  26272. * * VertexBuffer.UVKind
  26273. * * VertexBuffer.UV2Kind
  26274. * * VertexBuffer.UV3Kind
  26275. * * VertexBuffer.UV4Kind
  26276. * * VertexBuffer.UV5Kind
  26277. * * VertexBuffer.UV6Kind
  26278. * * VertexBuffer.ColorKind
  26279. * * VertexBuffer.MatricesIndicesKind
  26280. * * VertexBuffer.MatricesIndicesExtraKind
  26281. * * VertexBuffer.MatricesWeightsKind
  26282. * * VertexBuffer.MatricesWeightsExtraKind
  26283. * @param data defines the data source
  26284. * @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
  26285. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26286. * @returns the current mesh
  26287. */
  26288. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26289. /**
  26290. * Sets the mesh indices,
  26291. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26292. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26293. * @param totalVertices Defines the total number of vertices
  26294. * @returns the current mesh
  26295. */
  26296. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26297. /**
  26298. * Gets a boolean indicating if specific vertex data is present
  26299. * @param kind defines the vertex data kind to use
  26300. * @returns true is data kind is present
  26301. */
  26302. isVerticesDataPresent(kind: string): boolean;
  26303. /**
  26304. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26305. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26306. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26307. * @returns a BoundingInfo
  26308. */
  26309. getBoundingInfo(): BoundingInfo;
  26310. /**
  26311. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26312. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26313. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26314. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26315. * @returns the current mesh
  26316. */
  26317. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26318. /**
  26319. * Overwrite the current bounding info
  26320. * @param boundingInfo defines the new bounding info
  26321. * @returns the current mesh
  26322. */
  26323. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26324. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26325. readonly useBones: boolean;
  26326. /** @hidden */
  26327. _preActivate(): void;
  26328. /** @hidden */
  26329. _preActivateForIntermediateRendering(renderId: number): void;
  26330. /** @hidden */
  26331. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26332. /** @hidden */
  26333. _postActivate(): void;
  26334. /** @hidden */
  26335. _freeze(): void;
  26336. /** @hidden */
  26337. _unFreeze(): void;
  26338. /**
  26339. * Gets the current world matrix
  26340. * @returns a Matrix
  26341. */
  26342. getWorldMatrix(): Matrix;
  26343. /** @hidden */
  26344. _getWorldMatrixDeterminant(): number;
  26345. /**
  26346. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26347. */
  26348. readonly isAnInstance: boolean;
  26349. /**
  26350. * Gets a boolean indicating if this mesh has instances
  26351. */
  26352. readonly hasInstances: boolean;
  26353. /**
  26354. * Perform relative position change from the point of view of behind the front of the mesh.
  26355. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26356. * Supports definition of mesh facing forward or backward
  26357. * @param amountRight defines the distance on the right axis
  26358. * @param amountUp defines the distance on the up axis
  26359. * @param amountForward defines the distance on the forward axis
  26360. * @returns the current mesh
  26361. */
  26362. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26363. /**
  26364. * Calculate relative position change from the point of view of behind the front of the mesh.
  26365. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26366. * Supports definition of mesh facing forward or backward
  26367. * @param amountRight defines the distance on the right axis
  26368. * @param amountUp defines the distance on the up axis
  26369. * @param amountForward defines the distance on the forward axis
  26370. * @returns the new displacement vector
  26371. */
  26372. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26373. /**
  26374. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26375. * Supports definition of mesh facing forward or backward
  26376. * @param flipBack defines the flip
  26377. * @param twirlClockwise defines the twirl
  26378. * @param tiltRight defines the tilt
  26379. * @returns the current mesh
  26380. */
  26381. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26382. /**
  26383. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26384. * Supports definition of mesh facing forward or backward.
  26385. * @param flipBack defines the flip
  26386. * @param twirlClockwise defines the twirl
  26387. * @param tiltRight defines the tilt
  26388. * @returns the new rotation vector
  26389. */
  26390. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26391. /**
  26392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26393. * This means the mesh underlying bounding box and sphere are recomputed.
  26394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26395. * @returns the current mesh
  26396. */
  26397. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26398. /** @hidden */
  26399. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26400. /** @hidden */
  26401. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26402. /** @hidden */
  26403. _updateBoundingInfo(): AbstractMesh;
  26404. /** @hidden */
  26405. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26406. /** @hidden */
  26407. protected _afterComputeWorldMatrix(): void;
  26408. /** @hidden */
  26409. readonly _effectiveMesh: AbstractMesh;
  26410. /**
  26411. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26412. * A mesh is in the frustum if its bounding box intersects the frustum
  26413. * @param frustumPlanes defines the frustum to test
  26414. * @returns true if the mesh is in the frustum planes
  26415. */
  26416. isInFrustum(frustumPlanes: Plane[]): boolean;
  26417. /**
  26418. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26419. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26420. * @param frustumPlanes defines the frustum to test
  26421. * @returns true if the mesh is completely in the frustum planes
  26422. */
  26423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26424. /**
  26425. * True if the mesh intersects another mesh or a SolidParticle object
  26426. * @param mesh defines a target mesh or SolidParticle to test
  26427. * @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)
  26428. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26429. * @returns true if there is an intersection
  26430. */
  26431. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26432. /**
  26433. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26434. * @param point defines the point to test
  26435. * @returns true if there is an intersection
  26436. */
  26437. intersectsPoint(point: Vector3): boolean;
  26438. /**
  26439. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26441. */
  26442. checkCollisions: boolean;
  26443. /**
  26444. * Gets Collider object used to compute collisions (not physics)
  26445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26446. */
  26447. readonly collider: Nullable<Collider>;
  26448. /**
  26449. * Move the mesh using collision engine
  26450. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26451. * @param displacement defines the requested displacement vector
  26452. * @returns the current mesh
  26453. */
  26454. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26455. private _onCollisionPositionChange;
  26456. /** @hidden */
  26457. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26458. /** @hidden */
  26459. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26460. /** @hidden */
  26461. _checkCollision(collider: Collider): AbstractMesh;
  26462. /** @hidden */
  26463. _generatePointsArray(): boolean;
  26464. /**
  26465. * Checks if the passed Ray intersects with the mesh
  26466. * @param ray defines the ray to use
  26467. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26469. * @returns the picking info
  26470. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26471. */
  26472. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26473. /**
  26474. * Clones the current mesh
  26475. * @param name defines the mesh name
  26476. * @param newParent defines the new mesh parent
  26477. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26478. * @returns the new mesh
  26479. */
  26480. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26481. /**
  26482. * Disposes all the submeshes of the current meshnp
  26483. * @returns the current mesh
  26484. */
  26485. releaseSubMeshes(): AbstractMesh;
  26486. /**
  26487. * Releases resources associated with this abstract mesh.
  26488. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26489. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26490. */
  26491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26492. /**
  26493. * Adds the passed mesh as a child to the current mesh
  26494. * @param mesh defines the child mesh
  26495. * @returns the current mesh
  26496. */
  26497. addChild(mesh: AbstractMesh): AbstractMesh;
  26498. /**
  26499. * Removes the passed mesh from the current mesh children list
  26500. * @param mesh defines the child mesh
  26501. * @returns the current mesh
  26502. */
  26503. removeChild(mesh: AbstractMesh): AbstractMesh;
  26504. /** @hidden */
  26505. private _initFacetData;
  26506. /**
  26507. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26508. * This method can be called within the render loop.
  26509. * 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
  26510. * @returns the current mesh
  26511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26512. */
  26513. updateFacetData(): AbstractMesh;
  26514. /**
  26515. * Returns the facetLocalNormals array.
  26516. * The normals are expressed in the mesh local spac
  26517. * @returns an array of Vector3
  26518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26519. */
  26520. getFacetLocalNormals(): Vector3[];
  26521. /**
  26522. * Returns the facetLocalPositions array.
  26523. * The facet positions are expressed in the mesh local space
  26524. * @returns an array of Vector3
  26525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26526. */
  26527. getFacetLocalPositions(): Vector3[];
  26528. /**
  26529. * Returns the facetLocalPartioning array
  26530. * @returns an array of array of numbers
  26531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26532. */
  26533. getFacetLocalPartitioning(): number[][];
  26534. /**
  26535. * Returns the i-th facet position in the world system.
  26536. * This method allocates a new Vector3 per call
  26537. * @param i defines the facet index
  26538. * @returns a new Vector3
  26539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26540. */
  26541. getFacetPosition(i: number): Vector3;
  26542. /**
  26543. * Sets the reference Vector3 with the i-th facet position in the world system
  26544. * @param i defines the facet index
  26545. * @param ref defines the target vector
  26546. * @returns the current mesh
  26547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26548. */
  26549. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26550. /**
  26551. * Returns the i-th facet normal in the world system.
  26552. * This method allocates a new Vector3 per call
  26553. * @param i defines the facet index
  26554. * @returns a new Vector3
  26555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26556. */
  26557. getFacetNormal(i: number): Vector3;
  26558. /**
  26559. * Sets the reference Vector3 with the i-th facet normal in the world system
  26560. * @param i defines the facet index
  26561. * @param ref defines the target vector
  26562. * @returns the current mesh
  26563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26564. */
  26565. getFacetNormalToRef(i: number, ref: Vector3): this;
  26566. /**
  26567. * 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)
  26568. * @param x defines x coordinate
  26569. * @param y defines y coordinate
  26570. * @param z defines z coordinate
  26571. * @returns the array of facet indexes
  26572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26573. */
  26574. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26575. /**
  26576. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26577. * @param projected sets as the (x,y,z) world projection on the facet
  26578. * @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
  26579. * @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
  26580. * @param x defines x coordinate
  26581. * @param y defines y coordinate
  26582. * @param z defines z coordinate
  26583. * @returns the face index if found (or null instead)
  26584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26585. */
  26586. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26587. /**
  26588. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26589. * @param projected sets as the (x,y,z) local projection on the facet
  26590. * @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
  26591. * @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
  26592. * @param x defines x coordinate
  26593. * @param y defines y coordinate
  26594. * @param z defines z coordinate
  26595. * @returns the face index if found (or null instead)
  26596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26597. */
  26598. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26599. /**
  26600. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26601. * @returns the parameters
  26602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26603. */
  26604. getFacetDataParameters(): any;
  26605. /**
  26606. * Disables the feature FacetData and frees the related memory
  26607. * @returns the current mesh
  26608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26609. */
  26610. disableFacetData(): AbstractMesh;
  26611. /**
  26612. * Updates the AbstractMesh indices array
  26613. * @param indices defines the data source
  26614. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26615. * @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)
  26616. * @returns the current mesh
  26617. */
  26618. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26619. /**
  26620. * Creates new normals data for the mesh
  26621. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26622. * @returns the current mesh
  26623. */
  26624. createNormals(updatable: boolean): AbstractMesh;
  26625. /**
  26626. * Align the mesh with a normal
  26627. * @param normal defines the normal to use
  26628. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26629. * @returns the current mesh
  26630. */
  26631. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26632. /** @hidden */
  26633. _checkOcclusionQuery(): boolean;
  26634. /**
  26635. * Disables the mesh edge rendering mode
  26636. * @returns the currentAbstractMesh
  26637. */
  26638. disableEdgesRendering(): AbstractMesh;
  26639. /**
  26640. * Enables the edge rendering mode on the mesh.
  26641. * This mode makes the mesh edges visible
  26642. * @param epsilon defines the maximal distance between two angles to detect a face
  26643. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26644. * @returns the currentAbstractMesh
  26645. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26646. */
  26647. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26648. }
  26649. }
  26650. declare module BABYLON {
  26651. /**
  26652. * Interface used to define ActionEvent
  26653. */
  26654. export interface IActionEvent {
  26655. /** The mesh or sprite that triggered the action */
  26656. source: any;
  26657. /** The X mouse cursor position at the time of the event */
  26658. pointerX: number;
  26659. /** The Y mouse cursor position at the time of the event */
  26660. pointerY: number;
  26661. /** The mesh that is currently pointed at (can be null) */
  26662. meshUnderPointer: Nullable<AbstractMesh>;
  26663. /** the original (browser) event that triggered the ActionEvent */
  26664. sourceEvent?: any;
  26665. /** additional data for the event */
  26666. additionalData?: any;
  26667. }
  26668. /**
  26669. * ActionEvent is the event being sent when an action is triggered.
  26670. */
  26671. export class ActionEvent implements IActionEvent {
  26672. /** The mesh or sprite that triggered the action */
  26673. source: any;
  26674. /** The X mouse cursor position at the time of the event */
  26675. pointerX: number;
  26676. /** The Y mouse cursor position at the time of the event */
  26677. pointerY: number;
  26678. /** The mesh that is currently pointed at (can be null) */
  26679. meshUnderPointer: Nullable<AbstractMesh>;
  26680. /** the original (browser) event that triggered the ActionEvent */
  26681. sourceEvent?: any;
  26682. /** additional data for the event */
  26683. additionalData?: any;
  26684. /**
  26685. * Creates a new ActionEvent
  26686. * @param source The mesh or sprite that triggered the action
  26687. * @param pointerX The X mouse cursor position at the time of the event
  26688. * @param pointerY The Y mouse cursor position at the time of the event
  26689. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26690. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26691. * @param additionalData additional data for the event
  26692. */
  26693. constructor(
  26694. /** The mesh or sprite that triggered the action */
  26695. source: any,
  26696. /** The X mouse cursor position at the time of the event */
  26697. pointerX: number,
  26698. /** The Y mouse cursor position at the time of the event */
  26699. pointerY: number,
  26700. /** The mesh that is currently pointed at (can be null) */
  26701. meshUnderPointer: Nullable<AbstractMesh>,
  26702. /** the original (browser) event that triggered the ActionEvent */
  26703. sourceEvent?: any,
  26704. /** additional data for the event */
  26705. additionalData?: any);
  26706. /**
  26707. * Helper function to auto-create an ActionEvent from a source mesh.
  26708. * @param source The source mesh that triggered the event
  26709. * @param evt The original (browser) event
  26710. * @param additionalData additional data for the event
  26711. * @returns the new ActionEvent
  26712. */
  26713. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26714. /**
  26715. * Helper function to auto-create an ActionEvent from a source sprite
  26716. * @param source The source sprite that triggered the event
  26717. * @param scene Scene associated with the sprite
  26718. * @param evt The original (browser) event
  26719. * @param additionalData additional data for the event
  26720. * @returns the new ActionEvent
  26721. */
  26722. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26723. /**
  26724. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26725. * @param scene the scene where the event occurred
  26726. * @param evt The original (browser) event
  26727. * @returns the new ActionEvent
  26728. */
  26729. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26730. /**
  26731. * Helper function to auto-create an ActionEvent from a primitive
  26732. * @param prim defines the target primitive
  26733. * @param pointerPos defines the pointer position
  26734. * @param evt The original (browser) event
  26735. * @param additionalData additional data for the event
  26736. * @returns the new ActionEvent
  26737. */
  26738. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26739. }
  26740. }
  26741. declare module BABYLON {
  26742. /**
  26743. * Abstract class used to decouple action Manager from scene and meshes.
  26744. * Do not instantiate.
  26745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26746. */
  26747. export abstract class AbstractActionManager implements IDisposable {
  26748. /** Gets the list of active triggers */
  26749. static Triggers: {
  26750. [key: string]: number;
  26751. };
  26752. /** Gets the cursor to use when hovering items */
  26753. hoverCursor: string;
  26754. /** Gets the list of actions */
  26755. actions: IAction[];
  26756. /**
  26757. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26758. */
  26759. isRecursive: boolean;
  26760. /**
  26761. * Releases all associated resources
  26762. */
  26763. abstract dispose(): void;
  26764. /**
  26765. * Does this action manager has pointer triggers
  26766. */
  26767. abstract readonly hasPointerTriggers: boolean;
  26768. /**
  26769. * Does this action manager has pick triggers
  26770. */
  26771. abstract readonly hasPickTriggers: boolean;
  26772. /**
  26773. * Process a specific trigger
  26774. * @param trigger defines the trigger to process
  26775. * @param evt defines the event details to be processed
  26776. */
  26777. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26778. /**
  26779. * Does this action manager handles actions of any of the given triggers
  26780. * @param triggers defines the triggers to be tested
  26781. * @return a boolean indicating whether one (or more) of the triggers is handled
  26782. */
  26783. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26784. /**
  26785. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26786. * speed.
  26787. * @param triggerA defines the trigger to be tested
  26788. * @param triggerB defines the trigger to be tested
  26789. * @return a boolean indicating whether one (or more) of the triggers is handled
  26790. */
  26791. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26792. /**
  26793. * Does this action manager handles actions of a given trigger
  26794. * @param trigger defines the trigger to be tested
  26795. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26796. * @return whether the trigger is handled
  26797. */
  26798. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26799. /**
  26800. * Serialize this manager to a JSON object
  26801. * @param name defines the property name to store this manager
  26802. * @returns a JSON representation of this manager
  26803. */
  26804. abstract serialize(name: string): any;
  26805. /**
  26806. * Registers an action to this action manager
  26807. * @param action defines the action to be registered
  26808. * @return the action amended (prepared) after registration
  26809. */
  26810. abstract registerAction(action: IAction): Nullable<IAction>;
  26811. /**
  26812. * Unregisters an action to this action manager
  26813. * @param action defines the action to be unregistered
  26814. * @return a boolean indicating whether the action has been unregistered
  26815. */
  26816. abstract unregisterAction(action: IAction): Boolean;
  26817. /**
  26818. * Does exist one action manager with at least one trigger
  26819. **/
  26820. static readonly HasTriggers: boolean;
  26821. /**
  26822. * Does exist one action manager with at least one pick trigger
  26823. **/
  26824. static readonly HasPickTriggers: boolean;
  26825. /**
  26826. * Does exist one action manager that handles actions of a given trigger
  26827. * @param trigger defines the trigger to be tested
  26828. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26829. **/
  26830. static HasSpecificTrigger(trigger: number): boolean;
  26831. }
  26832. }
  26833. declare module BABYLON {
  26834. /**
  26835. * Defines how a node can be built from a string name.
  26836. */
  26837. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26838. /**
  26839. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26840. */
  26841. export class Node implements IBehaviorAware<Node> {
  26842. /** @hidden */
  26843. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26844. private static _NodeConstructors;
  26845. /**
  26846. * Add a new node constructor
  26847. * @param type defines the type name of the node to construct
  26848. * @param constructorFunc defines the constructor function
  26849. */
  26850. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26851. /**
  26852. * Returns a node constructor based on type name
  26853. * @param type defines the type name
  26854. * @param name defines the new node name
  26855. * @param scene defines the hosting scene
  26856. * @param options defines optional options to transmit to constructors
  26857. * @returns the new constructor or null
  26858. */
  26859. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26860. /**
  26861. * Gets or sets the name of the node
  26862. */
  26863. name: string;
  26864. /**
  26865. * Gets or sets the id of the node
  26866. */
  26867. id: string;
  26868. /**
  26869. * Gets or sets the unique id of the node
  26870. */
  26871. uniqueId: number;
  26872. /**
  26873. * Gets or sets a string used to store user defined state for the node
  26874. */
  26875. state: string;
  26876. /**
  26877. * Gets or sets an object used to store user defined information for the node
  26878. */
  26879. metadata: any;
  26880. /**
  26881. * For internal use only. Please do not use.
  26882. */
  26883. reservedDataStore: any;
  26884. /**
  26885. * List of inspectable custom properties (used by the Inspector)
  26886. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26887. */
  26888. inspectableCustomProperties: IInspectable[];
  26889. /**
  26890. * Gets or sets a boolean used to define if the node must be serialized
  26891. */
  26892. doNotSerialize: boolean;
  26893. /** @hidden */
  26894. _isDisposed: boolean;
  26895. /**
  26896. * Gets a list of Animations associated with the node
  26897. */
  26898. animations: Animation[];
  26899. protected _ranges: {
  26900. [name: string]: Nullable<AnimationRange>;
  26901. };
  26902. /**
  26903. * Callback raised when the node is ready to be used
  26904. */
  26905. onReady: Nullable<(node: Node) => void>;
  26906. private _isEnabled;
  26907. private _isParentEnabled;
  26908. private _isReady;
  26909. /** @hidden */
  26910. _currentRenderId: number;
  26911. private _parentUpdateId;
  26912. /** @hidden */
  26913. _childUpdateId: number;
  26914. /** @hidden */
  26915. _waitingParentId: Nullable<string>;
  26916. /** @hidden */
  26917. _scene: Scene;
  26918. /** @hidden */
  26919. _cache: any;
  26920. private _parentNode;
  26921. private _children;
  26922. /** @hidden */
  26923. _worldMatrix: Matrix;
  26924. /** @hidden */
  26925. _worldMatrixDeterminant: number;
  26926. /** @hidden */
  26927. _worldMatrixDeterminantIsDirty: boolean;
  26928. /** @hidden */
  26929. private _sceneRootNodesIndex;
  26930. /**
  26931. * Gets a boolean indicating if the node has been disposed
  26932. * @returns true if the node was disposed
  26933. */
  26934. isDisposed(): boolean;
  26935. /**
  26936. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26937. * @see https://doc.babylonjs.com/how_to/parenting
  26938. */
  26939. parent: Nullable<Node>;
  26940. private addToSceneRootNodes;
  26941. private removeFromSceneRootNodes;
  26942. private _animationPropertiesOverride;
  26943. /**
  26944. * Gets or sets the animation properties override
  26945. */
  26946. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26947. /**
  26948. * Gets a string idenfifying the name of the class
  26949. * @returns "Node" string
  26950. */
  26951. getClassName(): string;
  26952. /** @hidden */
  26953. readonly _isNode: boolean;
  26954. /**
  26955. * An event triggered when the mesh is disposed
  26956. */
  26957. onDisposeObservable: Observable<Node>;
  26958. private _onDisposeObserver;
  26959. /**
  26960. * Sets a callback that will be raised when the node will be disposed
  26961. */
  26962. onDispose: () => void;
  26963. /**
  26964. * Creates a new Node
  26965. * @param name the name and id to be given to this node
  26966. * @param scene the scene this node will be added to
  26967. * @param addToRootNodes the node will be added to scene.rootNodes
  26968. */
  26969. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26970. /**
  26971. * Gets the scene of the node
  26972. * @returns a scene
  26973. */
  26974. getScene(): Scene;
  26975. /**
  26976. * Gets the engine of the node
  26977. * @returns a Engine
  26978. */
  26979. getEngine(): Engine;
  26980. private _behaviors;
  26981. /**
  26982. * Attach a behavior to the node
  26983. * @see http://doc.babylonjs.com/features/behaviour
  26984. * @param behavior defines the behavior to attach
  26985. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26986. * @returns the current Node
  26987. */
  26988. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26989. /**
  26990. * Remove an attached behavior
  26991. * @see http://doc.babylonjs.com/features/behaviour
  26992. * @param behavior defines the behavior to attach
  26993. * @returns the current Node
  26994. */
  26995. removeBehavior(behavior: Behavior<Node>): Node;
  26996. /**
  26997. * Gets the list of attached behaviors
  26998. * @see http://doc.babylonjs.com/features/behaviour
  26999. */
  27000. readonly behaviors: Behavior<Node>[];
  27001. /**
  27002. * Gets an attached behavior by name
  27003. * @param name defines the name of the behavior to look for
  27004. * @see http://doc.babylonjs.com/features/behaviour
  27005. * @returns null if behavior was not found else the requested behavior
  27006. */
  27007. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27008. /**
  27009. * Returns the latest update of the World matrix
  27010. * @returns a Matrix
  27011. */
  27012. getWorldMatrix(): Matrix;
  27013. /** @hidden */
  27014. _getWorldMatrixDeterminant(): number;
  27015. /**
  27016. * Returns directly the latest state of the mesh World matrix.
  27017. * A Matrix is returned.
  27018. */
  27019. readonly worldMatrixFromCache: Matrix;
  27020. /** @hidden */
  27021. _initCache(): void;
  27022. /** @hidden */
  27023. updateCache(force?: boolean): void;
  27024. /** @hidden */
  27025. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27026. /** @hidden */
  27027. _updateCache(ignoreParentClass?: boolean): void;
  27028. /** @hidden */
  27029. _isSynchronized(): boolean;
  27030. /** @hidden */
  27031. _markSyncedWithParent(): void;
  27032. /** @hidden */
  27033. isSynchronizedWithParent(): boolean;
  27034. /** @hidden */
  27035. isSynchronized(): boolean;
  27036. /**
  27037. * Is this node ready to be used/rendered
  27038. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27039. * @return true if the node is ready
  27040. */
  27041. isReady(completeCheck?: boolean): boolean;
  27042. /**
  27043. * Is this node enabled?
  27044. * 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
  27045. * @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
  27046. * @return whether this node (and its parent) is enabled
  27047. */
  27048. isEnabled(checkAncestors?: boolean): boolean;
  27049. /** @hidden */
  27050. protected _syncParentEnabledState(): void;
  27051. /**
  27052. * Set the enabled state of this node
  27053. * @param value defines the new enabled state
  27054. */
  27055. setEnabled(value: boolean): void;
  27056. /**
  27057. * Is this node a descendant of the given node?
  27058. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27059. * @param ancestor defines the parent node to inspect
  27060. * @returns a boolean indicating if this node is a descendant of the given node
  27061. */
  27062. isDescendantOf(ancestor: Node): boolean;
  27063. /** @hidden */
  27064. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27065. /**
  27066. * Will return all nodes that have this node as ascendant
  27067. * @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
  27068. * @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
  27069. * @return all children nodes of all types
  27070. */
  27071. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27072. /**
  27073. * Get all child-meshes of this node
  27074. * @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)
  27075. * @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
  27076. * @returns an array of AbstractMesh
  27077. */
  27078. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27079. /**
  27080. * Get all direct children of this node
  27081. * @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
  27082. * @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)
  27083. * @returns an array of Node
  27084. */
  27085. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27086. /** @hidden */
  27087. _setReady(state: boolean): void;
  27088. /**
  27089. * Get an animation by name
  27090. * @param name defines the name of the animation to look for
  27091. * @returns null if not found else the requested animation
  27092. */
  27093. getAnimationByName(name: string): Nullable<Animation>;
  27094. /**
  27095. * Creates an animation range for this node
  27096. * @param name defines the name of the range
  27097. * @param from defines the starting key
  27098. * @param to defines the end key
  27099. */
  27100. createAnimationRange(name: string, from: number, to: number): void;
  27101. /**
  27102. * Delete a specific animation range
  27103. * @param name defines the name of the range to delete
  27104. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27105. */
  27106. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27107. /**
  27108. * Get an animation range by name
  27109. * @param name defines the name of the animation range to look for
  27110. * @returns null if not found else the requested animation range
  27111. */
  27112. getAnimationRange(name: string): Nullable<AnimationRange>;
  27113. /**
  27114. * Gets the list of all animation ranges defined on this node
  27115. * @returns an array
  27116. */
  27117. getAnimationRanges(): Nullable<AnimationRange>[];
  27118. /**
  27119. * Will start the animation sequence
  27120. * @param name defines the range frames for animation sequence
  27121. * @param loop defines if the animation should loop (false by default)
  27122. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27123. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27124. * @returns the object created for this animation. If range does not exist, it will return null
  27125. */
  27126. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27127. /**
  27128. * Serialize animation ranges into a JSON compatible object
  27129. * @returns serialization object
  27130. */
  27131. serializeAnimationRanges(): any;
  27132. /**
  27133. * Computes the world matrix of the node
  27134. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27135. * @returns the world matrix
  27136. */
  27137. computeWorldMatrix(force?: boolean): Matrix;
  27138. /**
  27139. * Releases resources associated with this node.
  27140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27142. */
  27143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27144. /**
  27145. * Parse animation range data from a serialization object and store them into a given node
  27146. * @param node defines where to store the animation ranges
  27147. * @param parsedNode defines the serialization object to read data from
  27148. * @param scene defines the hosting scene
  27149. */
  27150. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27151. /**
  27152. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27153. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27154. * @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
  27155. * @returns the new bounding vectors
  27156. */
  27157. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27158. min: Vector3;
  27159. max: Vector3;
  27160. };
  27161. }
  27162. }
  27163. declare module BABYLON {
  27164. /**
  27165. * @hidden
  27166. */
  27167. export class _IAnimationState {
  27168. key: number;
  27169. repeatCount: number;
  27170. workValue?: any;
  27171. loopMode?: number;
  27172. offsetValue?: any;
  27173. highLimitValue?: any;
  27174. }
  27175. /**
  27176. * Class used to store any kind of animation
  27177. */
  27178. export class Animation {
  27179. /**Name of the animation */
  27180. name: string;
  27181. /**Property to animate */
  27182. targetProperty: string;
  27183. /**The frames per second of the animation */
  27184. framePerSecond: number;
  27185. /**The data type of the animation */
  27186. dataType: number;
  27187. /**The loop mode of the animation */
  27188. loopMode?: number | undefined;
  27189. /**Specifies if blending should be enabled */
  27190. enableBlending?: boolean | undefined;
  27191. /**
  27192. * Use matrix interpolation instead of using direct key value when animating matrices
  27193. */
  27194. static AllowMatricesInterpolation: boolean;
  27195. /**
  27196. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27197. */
  27198. static AllowMatrixDecomposeForInterpolation: boolean;
  27199. /**
  27200. * Stores the key frames of the animation
  27201. */
  27202. private _keys;
  27203. /**
  27204. * Stores the easing function of the animation
  27205. */
  27206. private _easingFunction;
  27207. /**
  27208. * @hidden Internal use only
  27209. */
  27210. _runtimeAnimations: RuntimeAnimation[];
  27211. /**
  27212. * The set of event that will be linked to this animation
  27213. */
  27214. private _events;
  27215. /**
  27216. * Stores an array of target property paths
  27217. */
  27218. targetPropertyPath: string[];
  27219. /**
  27220. * Stores the blending speed of the animation
  27221. */
  27222. blendingSpeed: number;
  27223. /**
  27224. * Stores the animation ranges for the animation
  27225. */
  27226. private _ranges;
  27227. /**
  27228. * @hidden Internal use
  27229. */
  27230. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27231. /**
  27232. * Sets up an animation
  27233. * @param property The property to animate
  27234. * @param animationType The animation type to apply
  27235. * @param framePerSecond The frames per second of the animation
  27236. * @param easingFunction The easing function used in the animation
  27237. * @returns The created animation
  27238. */
  27239. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27240. /**
  27241. * Create and start an animation on a node
  27242. * @param name defines the name of the global animation that will be run on all nodes
  27243. * @param node defines the root node where the animation will take place
  27244. * @param targetProperty defines property to animate
  27245. * @param framePerSecond defines the number of frame per second yo use
  27246. * @param totalFrame defines the number of frames in total
  27247. * @param from defines the initial value
  27248. * @param to defines the final value
  27249. * @param loopMode defines which loop mode you want to use (off by default)
  27250. * @param easingFunction defines the easing function to use (linear by default)
  27251. * @param onAnimationEnd defines the callback to call when animation end
  27252. * @returns the animatable created for this animation
  27253. */
  27254. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27255. /**
  27256. * Create and start an animation on a node and its descendants
  27257. * @param name defines the name of the global animation that will be run on all nodes
  27258. * @param node defines the root node where the animation will take place
  27259. * @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
  27260. * @param targetProperty defines property to animate
  27261. * @param framePerSecond defines the number of frame per second to use
  27262. * @param totalFrame defines the number of frames in total
  27263. * @param from defines the initial value
  27264. * @param to defines the final value
  27265. * @param loopMode defines which loop mode you want to use (off by default)
  27266. * @param easingFunction defines the easing function to use (linear by default)
  27267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27268. * @returns the list of animatables created for all nodes
  27269. * @example https://www.babylonjs-playground.com/#MH0VLI
  27270. */
  27271. 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[]>;
  27272. /**
  27273. * Creates a new animation, merges it with the existing animations and starts it
  27274. * @param name Name of the animation
  27275. * @param node Node which contains the scene that begins the animations
  27276. * @param targetProperty Specifies which property to animate
  27277. * @param framePerSecond The frames per second of the animation
  27278. * @param totalFrame The total number of frames
  27279. * @param from The frame at the beginning of the animation
  27280. * @param to The frame at the end of the animation
  27281. * @param loopMode Specifies the loop mode of the animation
  27282. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27283. * @param onAnimationEnd Callback to run once the animation is complete
  27284. * @returns Nullable animation
  27285. */
  27286. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27287. /**
  27288. * Transition property of an host to the target Value
  27289. * @param property The property to transition
  27290. * @param targetValue The target Value of the property
  27291. * @param host The object where the property to animate belongs
  27292. * @param scene Scene used to run the animation
  27293. * @param frameRate Framerate (in frame/s) to use
  27294. * @param transition The transition type we want to use
  27295. * @param duration The duration of the animation, in milliseconds
  27296. * @param onAnimationEnd Callback trigger at the end of the animation
  27297. * @returns Nullable animation
  27298. */
  27299. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27300. /**
  27301. * Return the array of runtime animations currently using this animation
  27302. */
  27303. readonly runtimeAnimations: RuntimeAnimation[];
  27304. /**
  27305. * Specifies if any of the runtime animations are currently running
  27306. */
  27307. readonly hasRunningRuntimeAnimations: boolean;
  27308. /**
  27309. * Initializes the animation
  27310. * @param name Name of the animation
  27311. * @param targetProperty Property to animate
  27312. * @param framePerSecond The frames per second of the animation
  27313. * @param dataType The data type of the animation
  27314. * @param loopMode The loop mode of the animation
  27315. * @param enableBlending Specifies if blending should be enabled
  27316. */
  27317. constructor(
  27318. /**Name of the animation */
  27319. name: string,
  27320. /**Property to animate */
  27321. targetProperty: string,
  27322. /**The frames per second of the animation */
  27323. framePerSecond: number,
  27324. /**The data type of the animation */
  27325. dataType: number,
  27326. /**The loop mode of the animation */
  27327. loopMode?: number | undefined,
  27328. /**Specifies if blending should be enabled */
  27329. enableBlending?: boolean | undefined);
  27330. /**
  27331. * Converts the animation to a string
  27332. * @param fullDetails support for multiple levels of logging within scene loading
  27333. * @returns String form of the animation
  27334. */
  27335. toString(fullDetails?: boolean): string;
  27336. /**
  27337. * Add an event to this animation
  27338. * @param event Event to add
  27339. */
  27340. addEvent(event: AnimationEvent): void;
  27341. /**
  27342. * Remove all events found at the given frame
  27343. * @param frame The frame to remove events from
  27344. */
  27345. removeEvents(frame: number): void;
  27346. /**
  27347. * Retrieves all the events from the animation
  27348. * @returns Events from the animation
  27349. */
  27350. getEvents(): AnimationEvent[];
  27351. /**
  27352. * Creates an animation range
  27353. * @param name Name of the animation range
  27354. * @param from Starting frame of the animation range
  27355. * @param to Ending frame of the animation
  27356. */
  27357. createRange(name: string, from: number, to: number): void;
  27358. /**
  27359. * Deletes an animation range by name
  27360. * @param name Name of the animation range to delete
  27361. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27362. */
  27363. deleteRange(name: string, deleteFrames?: boolean): void;
  27364. /**
  27365. * Gets the animation range by name, or null if not defined
  27366. * @param name Name of the animation range
  27367. * @returns Nullable animation range
  27368. */
  27369. getRange(name: string): Nullable<AnimationRange>;
  27370. /**
  27371. * Gets the key frames from the animation
  27372. * @returns The key frames of the animation
  27373. */
  27374. getKeys(): Array<IAnimationKey>;
  27375. /**
  27376. * Gets the highest frame rate of the animation
  27377. * @returns Highest frame rate of the animation
  27378. */
  27379. getHighestFrame(): number;
  27380. /**
  27381. * Gets the easing function of the animation
  27382. * @returns Easing function of the animation
  27383. */
  27384. getEasingFunction(): IEasingFunction;
  27385. /**
  27386. * Sets the easing function of the animation
  27387. * @param easingFunction A custom mathematical formula for animation
  27388. */
  27389. setEasingFunction(easingFunction: EasingFunction): void;
  27390. /**
  27391. * Interpolates a scalar linearly
  27392. * @param startValue Start value of the animation curve
  27393. * @param endValue End value of the animation curve
  27394. * @param gradient Scalar amount to interpolate
  27395. * @returns Interpolated scalar value
  27396. */
  27397. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27398. /**
  27399. * Interpolates a scalar cubically
  27400. * @param startValue Start value of the animation curve
  27401. * @param outTangent End tangent of the animation
  27402. * @param endValue End value of the animation curve
  27403. * @param inTangent Start tangent of the animation curve
  27404. * @param gradient Scalar amount to interpolate
  27405. * @returns Interpolated scalar value
  27406. */
  27407. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27408. /**
  27409. * Interpolates a quaternion using a spherical linear interpolation
  27410. * @param startValue Start value of the animation curve
  27411. * @param endValue End value of the animation curve
  27412. * @param gradient Scalar amount to interpolate
  27413. * @returns Interpolated quaternion value
  27414. */
  27415. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27416. /**
  27417. * Interpolates a quaternion cubically
  27418. * @param startValue Start value of the animation curve
  27419. * @param outTangent End tangent of the animation curve
  27420. * @param endValue End value of the animation curve
  27421. * @param inTangent Start tangent of the animation curve
  27422. * @param gradient Scalar amount to interpolate
  27423. * @returns Interpolated quaternion value
  27424. */
  27425. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27426. /**
  27427. * Interpolates a Vector3 linearl
  27428. * @param startValue Start value of the animation curve
  27429. * @param endValue End value of the animation curve
  27430. * @param gradient Scalar amount to interpolate
  27431. * @returns Interpolated scalar value
  27432. */
  27433. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27434. /**
  27435. * Interpolates a Vector3 cubically
  27436. * @param startValue Start value of the animation curve
  27437. * @param outTangent End tangent of the animation
  27438. * @param endValue End value of the animation curve
  27439. * @param inTangent Start tangent of the animation curve
  27440. * @param gradient Scalar amount to interpolate
  27441. * @returns InterpolatedVector3 value
  27442. */
  27443. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27444. /**
  27445. * Interpolates a Vector2 linearly
  27446. * @param startValue Start value of the animation curve
  27447. * @param endValue End value of the animation curve
  27448. * @param gradient Scalar amount to interpolate
  27449. * @returns Interpolated Vector2 value
  27450. */
  27451. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27452. /**
  27453. * Interpolates a Vector2 cubically
  27454. * @param startValue Start value of the animation curve
  27455. * @param outTangent End tangent of the animation
  27456. * @param endValue End value of the animation curve
  27457. * @param inTangent Start tangent of the animation curve
  27458. * @param gradient Scalar amount to interpolate
  27459. * @returns Interpolated Vector2 value
  27460. */
  27461. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27462. /**
  27463. * Interpolates a size linearly
  27464. * @param startValue Start value of the animation curve
  27465. * @param endValue End value of the animation curve
  27466. * @param gradient Scalar amount to interpolate
  27467. * @returns Interpolated Size value
  27468. */
  27469. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27470. /**
  27471. * Interpolates a Color3 linearly
  27472. * @param startValue Start value of the animation curve
  27473. * @param endValue End value of the animation curve
  27474. * @param gradient Scalar amount to interpolate
  27475. * @returns Interpolated Color3 value
  27476. */
  27477. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27478. /**
  27479. * @hidden Internal use only
  27480. */
  27481. _getKeyValue(value: any): any;
  27482. /**
  27483. * @hidden Internal use only
  27484. */
  27485. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27486. /**
  27487. * Defines the function to use to interpolate matrices
  27488. * @param startValue defines the start matrix
  27489. * @param endValue defines the end matrix
  27490. * @param gradient defines the gradient between both matrices
  27491. * @param result defines an optional target matrix where to store the interpolation
  27492. * @returns the interpolated matrix
  27493. */
  27494. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27495. /**
  27496. * Makes a copy of the animation
  27497. * @returns Cloned animation
  27498. */
  27499. clone(): Animation;
  27500. /**
  27501. * Sets the key frames of the animation
  27502. * @param values The animation key frames to set
  27503. */
  27504. setKeys(values: Array<IAnimationKey>): void;
  27505. /**
  27506. * Serializes the animation to an object
  27507. * @returns Serialized object
  27508. */
  27509. serialize(): any;
  27510. /**
  27511. * Float animation type
  27512. */
  27513. private static _ANIMATIONTYPE_FLOAT;
  27514. /**
  27515. * Vector3 animation type
  27516. */
  27517. private static _ANIMATIONTYPE_VECTOR3;
  27518. /**
  27519. * Quaternion animation type
  27520. */
  27521. private static _ANIMATIONTYPE_QUATERNION;
  27522. /**
  27523. * Matrix animation type
  27524. */
  27525. private static _ANIMATIONTYPE_MATRIX;
  27526. /**
  27527. * Color3 animation type
  27528. */
  27529. private static _ANIMATIONTYPE_COLOR3;
  27530. /**
  27531. * Vector2 animation type
  27532. */
  27533. private static _ANIMATIONTYPE_VECTOR2;
  27534. /**
  27535. * Size animation type
  27536. */
  27537. private static _ANIMATIONTYPE_SIZE;
  27538. /**
  27539. * Relative Loop Mode
  27540. */
  27541. private static _ANIMATIONLOOPMODE_RELATIVE;
  27542. /**
  27543. * Cycle Loop Mode
  27544. */
  27545. private static _ANIMATIONLOOPMODE_CYCLE;
  27546. /**
  27547. * Constant Loop Mode
  27548. */
  27549. private static _ANIMATIONLOOPMODE_CONSTANT;
  27550. /**
  27551. * Get the float animation type
  27552. */
  27553. static readonly ANIMATIONTYPE_FLOAT: number;
  27554. /**
  27555. * Get the Vector3 animation type
  27556. */
  27557. static readonly ANIMATIONTYPE_VECTOR3: number;
  27558. /**
  27559. * Get the Vector2 animation type
  27560. */
  27561. static readonly ANIMATIONTYPE_VECTOR2: number;
  27562. /**
  27563. * Get the Size animation type
  27564. */
  27565. static readonly ANIMATIONTYPE_SIZE: number;
  27566. /**
  27567. * Get the Quaternion animation type
  27568. */
  27569. static readonly ANIMATIONTYPE_QUATERNION: number;
  27570. /**
  27571. * Get the Matrix animation type
  27572. */
  27573. static readonly ANIMATIONTYPE_MATRIX: number;
  27574. /**
  27575. * Get the Color3 animation type
  27576. */
  27577. static readonly ANIMATIONTYPE_COLOR3: number;
  27578. /**
  27579. * Get the Relative Loop Mode
  27580. */
  27581. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27582. /**
  27583. * Get the Cycle Loop Mode
  27584. */
  27585. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27586. /**
  27587. * Get the Constant Loop Mode
  27588. */
  27589. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27590. /** @hidden */
  27591. static _UniversalLerp(left: any, right: any, amount: number): any;
  27592. /**
  27593. * Parses an animation object and creates an animation
  27594. * @param parsedAnimation Parsed animation object
  27595. * @returns Animation object
  27596. */
  27597. static Parse(parsedAnimation: any): Animation;
  27598. /**
  27599. * Appends the serialized animations from the source animations
  27600. * @param source Source containing the animations
  27601. * @param destination Target to store the animations
  27602. */
  27603. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27604. }
  27605. }
  27606. declare module BABYLON {
  27607. /**
  27608. * Interface containing an array of animations
  27609. */
  27610. export interface IAnimatable {
  27611. /**
  27612. * Array of animations
  27613. */
  27614. animations: Nullable<Array<Animation>>;
  27615. }
  27616. }
  27617. declare module BABYLON {
  27618. /**
  27619. * This represents all the required information to add a fresnel effect on a material:
  27620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27621. */
  27622. export class FresnelParameters {
  27623. private _isEnabled;
  27624. /**
  27625. * Define if the fresnel effect is enable or not.
  27626. */
  27627. isEnabled: boolean;
  27628. /**
  27629. * Define the color used on edges (grazing angle)
  27630. */
  27631. leftColor: Color3;
  27632. /**
  27633. * Define the color used on center
  27634. */
  27635. rightColor: Color3;
  27636. /**
  27637. * Define bias applied to computed fresnel term
  27638. */
  27639. bias: number;
  27640. /**
  27641. * Defined the power exponent applied to fresnel term
  27642. */
  27643. power: number;
  27644. /**
  27645. * Clones the current fresnel and its valuues
  27646. * @returns a clone fresnel configuration
  27647. */
  27648. clone(): FresnelParameters;
  27649. /**
  27650. * Serializes the current fresnel parameters to a JSON representation.
  27651. * @return the JSON serialization
  27652. */
  27653. serialize(): any;
  27654. /**
  27655. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27656. * @param parsedFresnelParameters Define the JSON representation
  27657. * @returns the parsed parameters
  27658. */
  27659. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27660. }
  27661. }
  27662. declare module BABYLON {
  27663. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27664. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27665. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27666. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27667. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27668. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27669. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27670. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27671. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27672. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27673. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27674. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27675. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27676. /**
  27677. * Decorator used to define property that can be serialized as reference to a camera
  27678. * @param sourceName defines the name of the property to decorate
  27679. */
  27680. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27681. /**
  27682. * Class used to help serialization objects
  27683. */
  27684. export class SerializationHelper {
  27685. /** @hidden */
  27686. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27687. /** @hidden */
  27688. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27689. /** @hidden */
  27690. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27691. /** @hidden */
  27692. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27693. /**
  27694. * Appends the serialized animations from the source animations
  27695. * @param source Source containing the animations
  27696. * @param destination Target to store the animations
  27697. */
  27698. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27699. /**
  27700. * Static function used to serialized a specific entity
  27701. * @param entity defines the entity to serialize
  27702. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27703. * @returns a JSON compatible object representing the serialization of the entity
  27704. */
  27705. static Serialize<T>(entity: T, serializationObject?: any): any;
  27706. /**
  27707. * Creates a new entity from a serialization data object
  27708. * @param creationFunction defines a function used to instanciated the new entity
  27709. * @param source defines the source serialization data
  27710. * @param scene defines the hosting scene
  27711. * @param rootUrl defines the root url for resources
  27712. * @returns a new entity
  27713. */
  27714. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27715. /**
  27716. * Clones an object
  27717. * @param creationFunction defines the function used to instanciate the new object
  27718. * @param source defines the source object
  27719. * @returns the cloned object
  27720. */
  27721. static Clone<T>(creationFunction: () => T, source: T): T;
  27722. /**
  27723. * Instanciates a new object based on a source one (some data will be shared between both object)
  27724. * @param creationFunction defines the function used to instanciate the new object
  27725. * @param source defines the source object
  27726. * @returns the new object
  27727. */
  27728. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27729. }
  27730. }
  27731. declare module BABYLON {
  27732. /**
  27733. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27734. */
  27735. export interface CubeMapInfo {
  27736. /**
  27737. * The pixel array for the front face.
  27738. * This is stored in format, left to right, up to down format.
  27739. */
  27740. front: Nullable<ArrayBufferView>;
  27741. /**
  27742. * The pixel array for the back face.
  27743. * This is stored in format, left to right, up to down format.
  27744. */
  27745. back: Nullable<ArrayBufferView>;
  27746. /**
  27747. * The pixel array for the left face.
  27748. * This is stored in format, left to right, up to down format.
  27749. */
  27750. left: Nullable<ArrayBufferView>;
  27751. /**
  27752. * The pixel array for the right face.
  27753. * This is stored in format, left to right, up to down format.
  27754. */
  27755. right: Nullable<ArrayBufferView>;
  27756. /**
  27757. * The pixel array for the up face.
  27758. * This is stored in format, left to right, up to down format.
  27759. */
  27760. up: Nullable<ArrayBufferView>;
  27761. /**
  27762. * The pixel array for the down face.
  27763. * This is stored in format, left to right, up to down format.
  27764. */
  27765. down: Nullable<ArrayBufferView>;
  27766. /**
  27767. * The size of the cubemap stored.
  27768. *
  27769. * Each faces will be size * size pixels.
  27770. */
  27771. size: number;
  27772. /**
  27773. * The format of the texture.
  27774. *
  27775. * RGBA, RGB.
  27776. */
  27777. format: number;
  27778. /**
  27779. * The type of the texture data.
  27780. *
  27781. * UNSIGNED_INT, FLOAT.
  27782. */
  27783. type: number;
  27784. /**
  27785. * Specifies whether the texture is in gamma space.
  27786. */
  27787. gammaSpace: boolean;
  27788. }
  27789. /**
  27790. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27791. */
  27792. export class PanoramaToCubeMapTools {
  27793. private static FACE_FRONT;
  27794. private static FACE_BACK;
  27795. private static FACE_RIGHT;
  27796. private static FACE_LEFT;
  27797. private static FACE_DOWN;
  27798. private static FACE_UP;
  27799. /**
  27800. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27801. *
  27802. * @param float32Array The source data.
  27803. * @param inputWidth The width of the input panorama.
  27804. * @param inputHeight The height of the input panorama.
  27805. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27806. * @return The cubemap data
  27807. */
  27808. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27809. private static CreateCubemapTexture;
  27810. private static CalcProjectionSpherical;
  27811. }
  27812. }
  27813. declare module BABYLON {
  27814. /**
  27815. * Helper class dealing with the extraction of spherical polynomial dataArray
  27816. * from a cube map.
  27817. */
  27818. export class CubeMapToSphericalPolynomialTools {
  27819. private static FileFaces;
  27820. /**
  27821. * Converts a texture to the according Spherical Polynomial data.
  27822. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27823. *
  27824. * @param texture The texture to extract the information from.
  27825. * @return The Spherical Polynomial data.
  27826. */
  27827. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27828. /**
  27829. * Converts a cubemap to the according Spherical Polynomial data.
  27830. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27831. *
  27832. * @param cubeInfo The Cube map to extract the information from.
  27833. * @return The Spherical Polynomial data.
  27834. */
  27835. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27836. }
  27837. }
  27838. declare module BABYLON {
  27839. /**
  27840. * Class used to manipulate GUIDs
  27841. */
  27842. export class GUID {
  27843. /**
  27844. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27845. * Be aware Math.random() could cause collisions, but:
  27846. * "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"
  27847. * @returns a pseudo random id
  27848. */
  27849. static RandomId(): string;
  27850. }
  27851. }
  27852. declare module BABYLON {
  27853. /**
  27854. * Base class of all the textures in babylon.
  27855. * It groups all the common properties the materials, post process, lights... might need
  27856. * in order to make a correct use of the texture.
  27857. */
  27858. export class BaseTexture implements IAnimatable {
  27859. /**
  27860. * Default anisotropic filtering level for the application.
  27861. * It is set to 4 as a good tradeoff between perf and quality.
  27862. */
  27863. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27864. /**
  27865. * Gets or sets the unique id of the texture
  27866. */
  27867. uniqueId: number;
  27868. /**
  27869. * Define the name of the texture.
  27870. */
  27871. name: string;
  27872. /**
  27873. * Gets or sets an object used to store user defined information.
  27874. */
  27875. metadata: any;
  27876. /**
  27877. * For internal use only. Please do not use.
  27878. */
  27879. reservedDataStore: any;
  27880. private _hasAlpha;
  27881. /**
  27882. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27883. */
  27884. hasAlpha: boolean;
  27885. /**
  27886. * Defines if the alpha value should be determined via the rgb values.
  27887. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27888. */
  27889. getAlphaFromRGB: boolean;
  27890. /**
  27891. * Intensity or strength of the texture.
  27892. * It is commonly used by materials to fine tune the intensity of the texture
  27893. */
  27894. level: number;
  27895. /**
  27896. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27897. * This is part of the texture as textures usually maps to one uv set.
  27898. */
  27899. coordinatesIndex: number;
  27900. private _coordinatesMode;
  27901. /**
  27902. * How a texture is mapped.
  27903. *
  27904. * | Value | Type | Description |
  27905. * | ----- | ----------------------------------- | ----------- |
  27906. * | 0 | EXPLICIT_MODE | |
  27907. * | 1 | SPHERICAL_MODE | |
  27908. * | 2 | PLANAR_MODE | |
  27909. * | 3 | CUBIC_MODE | |
  27910. * | 4 | PROJECTION_MODE | |
  27911. * | 5 | SKYBOX_MODE | |
  27912. * | 6 | INVCUBIC_MODE | |
  27913. * | 7 | EQUIRECTANGULAR_MODE | |
  27914. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27915. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27916. */
  27917. coordinatesMode: number;
  27918. /**
  27919. * | Value | Type | Description |
  27920. * | ----- | ------------------ | ----------- |
  27921. * | 0 | CLAMP_ADDRESSMODE | |
  27922. * | 1 | WRAP_ADDRESSMODE | |
  27923. * | 2 | MIRROR_ADDRESSMODE | |
  27924. */
  27925. wrapU: number;
  27926. /**
  27927. * | Value | Type | Description |
  27928. * | ----- | ------------------ | ----------- |
  27929. * | 0 | CLAMP_ADDRESSMODE | |
  27930. * | 1 | WRAP_ADDRESSMODE | |
  27931. * | 2 | MIRROR_ADDRESSMODE | |
  27932. */
  27933. wrapV: number;
  27934. /**
  27935. * | Value | Type | Description |
  27936. * | ----- | ------------------ | ----------- |
  27937. * | 0 | CLAMP_ADDRESSMODE | |
  27938. * | 1 | WRAP_ADDRESSMODE | |
  27939. * | 2 | MIRROR_ADDRESSMODE | |
  27940. */
  27941. wrapR: number;
  27942. /**
  27943. * With compliant hardware and browser (supporting anisotropic filtering)
  27944. * this defines the level of anisotropic filtering in the texture.
  27945. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27946. */
  27947. anisotropicFilteringLevel: number;
  27948. /**
  27949. * Define if the texture is a cube texture or if false a 2d texture.
  27950. */
  27951. isCube: boolean;
  27952. /**
  27953. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27954. */
  27955. is3D: boolean;
  27956. /**
  27957. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27958. * HDR texture are usually stored in linear space.
  27959. * This only impacts the PBR and Background materials
  27960. */
  27961. gammaSpace: boolean;
  27962. /**
  27963. * Gets or sets whether or not the texture contains RGBD data.
  27964. */
  27965. isRGBD: boolean;
  27966. /**
  27967. * Is Z inverted in the texture (useful in a cube texture).
  27968. */
  27969. invertZ: boolean;
  27970. /**
  27971. * Are mip maps generated for this texture or not.
  27972. */
  27973. readonly noMipmap: boolean;
  27974. /**
  27975. * @hidden
  27976. */
  27977. lodLevelInAlpha: boolean;
  27978. /**
  27979. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27980. */
  27981. lodGenerationOffset: number;
  27982. /**
  27983. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27984. */
  27985. lodGenerationScale: number;
  27986. /**
  27987. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27988. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27989. * average roughness values.
  27990. */
  27991. linearSpecularLOD: boolean;
  27992. /**
  27993. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27994. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27995. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27996. */
  27997. irradianceTexture: Nullable<BaseTexture>;
  27998. /**
  27999. * Define if the texture is a render target.
  28000. */
  28001. isRenderTarget: boolean;
  28002. /**
  28003. * Define the unique id of the texture in the scene.
  28004. */
  28005. readonly uid: string;
  28006. /**
  28007. * Return a string representation of the texture.
  28008. * @returns the texture as a string
  28009. */
  28010. toString(): string;
  28011. /**
  28012. * Get the class name of the texture.
  28013. * @returns "BaseTexture"
  28014. */
  28015. getClassName(): string;
  28016. /**
  28017. * Define the list of animation attached to the texture.
  28018. */
  28019. animations: Animation[];
  28020. /**
  28021. * An event triggered when the texture is disposed.
  28022. */
  28023. onDisposeObservable: Observable<BaseTexture>;
  28024. private _onDisposeObserver;
  28025. /**
  28026. * Callback triggered when the texture has been disposed.
  28027. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28028. */
  28029. onDispose: () => void;
  28030. /**
  28031. * Define the current state of the loading sequence when in delayed load mode.
  28032. */
  28033. delayLoadState: number;
  28034. private _scene;
  28035. /** @hidden */
  28036. _texture: Nullable<InternalTexture>;
  28037. private _uid;
  28038. /**
  28039. * Define if the texture is preventinga material to render or not.
  28040. * If not and the texture is not ready, the engine will use a default black texture instead.
  28041. */
  28042. readonly isBlocking: boolean;
  28043. /**
  28044. * Instantiates a new BaseTexture.
  28045. * Base class of all the textures in babylon.
  28046. * It groups all the common properties the materials, post process, lights... might need
  28047. * in order to make a correct use of the texture.
  28048. * @param scene Define the scene the texture blongs to
  28049. */
  28050. constructor(scene: Nullable<Scene>);
  28051. /**
  28052. * Get the scene the texture belongs to.
  28053. * @returns the scene or null if undefined
  28054. */
  28055. getScene(): Nullable<Scene>;
  28056. /**
  28057. * Get the texture transform matrix used to offset tile the texture for istance.
  28058. * @returns the transformation matrix
  28059. */
  28060. getTextureMatrix(): Matrix;
  28061. /**
  28062. * Get the texture reflection matrix used to rotate/transform the reflection.
  28063. * @returns the reflection matrix
  28064. */
  28065. getReflectionTextureMatrix(): Matrix;
  28066. /**
  28067. * Get the underlying lower level texture from Babylon.
  28068. * @returns the insternal texture
  28069. */
  28070. getInternalTexture(): Nullable<InternalTexture>;
  28071. /**
  28072. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28073. * @returns true if ready or not blocking
  28074. */
  28075. isReadyOrNotBlocking(): boolean;
  28076. /**
  28077. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28078. * @returns true if fully ready
  28079. */
  28080. isReady(): boolean;
  28081. private _cachedSize;
  28082. /**
  28083. * Get the size of the texture.
  28084. * @returns the texture size.
  28085. */
  28086. getSize(): ISize;
  28087. /**
  28088. * Get the base size of the texture.
  28089. * It can be different from the size if the texture has been resized for POT for instance
  28090. * @returns the base size
  28091. */
  28092. getBaseSize(): ISize;
  28093. /**
  28094. * Update the sampling mode of the texture.
  28095. * Default is Trilinear mode.
  28096. *
  28097. * | Value | Type | Description |
  28098. * | ----- | ------------------ | ----------- |
  28099. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28100. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28101. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28102. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28103. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28104. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28105. * | 7 | NEAREST_LINEAR | |
  28106. * | 8 | NEAREST_NEAREST | |
  28107. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28108. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28109. * | 11 | LINEAR_LINEAR | |
  28110. * | 12 | LINEAR_NEAREST | |
  28111. *
  28112. * > _mag_: magnification filter (close to the viewer)
  28113. * > _min_: minification filter (far from the viewer)
  28114. * > _mip_: filter used between mip map levels
  28115. *@param samplingMode Define the new sampling mode of the texture
  28116. */
  28117. updateSamplingMode(samplingMode: number): void;
  28118. /**
  28119. * Scales the texture if is `canRescale()`
  28120. * @param ratio the resize factor we want to use to rescale
  28121. */
  28122. scale(ratio: number): void;
  28123. /**
  28124. * Get if the texture can rescale.
  28125. */
  28126. readonly canRescale: boolean;
  28127. /** @hidden */
  28128. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28129. /** @hidden */
  28130. _rebuild(): void;
  28131. /**
  28132. * Triggers the load sequence in delayed load mode.
  28133. */
  28134. delayLoad(): void;
  28135. /**
  28136. * Clones the texture.
  28137. * @returns the cloned texture
  28138. */
  28139. clone(): Nullable<BaseTexture>;
  28140. /**
  28141. * Get the texture underlying type (INT, FLOAT...)
  28142. */
  28143. readonly textureType: number;
  28144. /**
  28145. * Get the texture underlying format (RGB, RGBA...)
  28146. */
  28147. readonly textureFormat: number;
  28148. /**
  28149. * Indicates that textures need to be re-calculated for all materials
  28150. */
  28151. protected _markAllSubMeshesAsTexturesDirty(): void;
  28152. /**
  28153. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28154. * This will returns an RGBA array buffer containing either in values (0-255) or
  28155. * float values (0-1) depending of the underlying buffer type.
  28156. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28157. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28158. * @param buffer defines a user defined buffer to fill with data (can be null)
  28159. * @returns The Array buffer containing the pixels data.
  28160. */
  28161. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28162. /**
  28163. * Release and destroy the underlying lower level texture aka internalTexture.
  28164. */
  28165. releaseInternalTexture(): void;
  28166. /**
  28167. * Get the polynomial representation of the texture data.
  28168. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28169. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28170. */
  28171. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28172. /** @hidden */
  28173. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28174. /** @hidden */
  28175. readonly _lodTextureMid: Nullable<BaseTexture>;
  28176. /** @hidden */
  28177. readonly _lodTextureLow: Nullable<BaseTexture>;
  28178. /**
  28179. * Dispose the texture and release its associated resources.
  28180. */
  28181. dispose(): void;
  28182. /**
  28183. * Serialize the texture into a JSON representation that can be parsed later on.
  28184. * @returns the JSON representation of the texture
  28185. */
  28186. serialize(): any;
  28187. /**
  28188. * Helper function to be called back once a list of texture contains only ready textures.
  28189. * @param textures Define the list of textures to wait for
  28190. * @param callback Define the callback triggered once the entire list will be ready
  28191. */
  28192. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28193. }
  28194. }
  28195. declare module BABYLON {
  28196. /**
  28197. * Options to be used when creating an effect.
  28198. */
  28199. export class EffectCreationOptions {
  28200. /**
  28201. * Atrributes that will be used in the shader.
  28202. */
  28203. attributes: string[];
  28204. /**
  28205. * Uniform varible names that will be set in the shader.
  28206. */
  28207. uniformsNames: string[];
  28208. /**
  28209. * Uniform buffer varible names that will be set in the shader.
  28210. */
  28211. uniformBuffersNames: string[];
  28212. /**
  28213. * Sampler texture variable names that will be set in the shader.
  28214. */
  28215. samplers: string[];
  28216. /**
  28217. * Define statements that will be set in the shader.
  28218. */
  28219. defines: any;
  28220. /**
  28221. * Possible fallbacks for this effect to improve performance when needed.
  28222. */
  28223. fallbacks: Nullable<IEffectFallbacks>;
  28224. /**
  28225. * Callback that will be called when the shader is compiled.
  28226. */
  28227. onCompiled: Nullable<(effect: Effect) => void>;
  28228. /**
  28229. * Callback that will be called if an error occurs during shader compilation.
  28230. */
  28231. onError: Nullable<(effect: Effect, errors: string) => void>;
  28232. /**
  28233. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28234. */
  28235. indexParameters?: any;
  28236. /**
  28237. * Max number of lights that can be used in the shader.
  28238. */
  28239. maxSimultaneousLights?: number;
  28240. /**
  28241. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28242. */
  28243. transformFeedbackVaryings?: Nullable<string[]>;
  28244. }
  28245. /**
  28246. * Effect containing vertex and fragment shader that can be executed on an object.
  28247. */
  28248. export class Effect implements IDisposable {
  28249. /**
  28250. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28251. */
  28252. static ShadersRepository: string;
  28253. /**
  28254. * Name of the effect.
  28255. */
  28256. name: any;
  28257. /**
  28258. * String container all the define statements that should be set on the shader.
  28259. */
  28260. defines: string;
  28261. /**
  28262. * Callback that will be called when the shader is compiled.
  28263. */
  28264. onCompiled: Nullable<(effect: Effect) => void>;
  28265. /**
  28266. * Callback that will be called if an error occurs during shader compilation.
  28267. */
  28268. onError: Nullable<(effect: Effect, errors: string) => void>;
  28269. /**
  28270. * Callback that will be called when effect is bound.
  28271. */
  28272. onBind: Nullable<(effect: Effect) => void>;
  28273. /**
  28274. * Unique ID of the effect.
  28275. */
  28276. uniqueId: number;
  28277. /**
  28278. * Observable that will be called when the shader is compiled.
  28279. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28280. */
  28281. onCompileObservable: Observable<Effect>;
  28282. /**
  28283. * Observable that will be called if an error occurs during shader compilation.
  28284. */
  28285. onErrorObservable: Observable<Effect>;
  28286. /** @hidden */
  28287. _onBindObservable: Nullable<Observable<Effect>>;
  28288. /**
  28289. * Observable that will be called when effect is bound.
  28290. */
  28291. readonly onBindObservable: Observable<Effect>;
  28292. /** @hidden */
  28293. _bonesComputationForcedToCPU: boolean;
  28294. private static _uniqueIdSeed;
  28295. private _engine;
  28296. private _uniformBuffersNames;
  28297. private _uniformsNames;
  28298. private _samplerList;
  28299. private _samplers;
  28300. private _isReady;
  28301. private _compilationError;
  28302. private _attributesNames;
  28303. private _attributes;
  28304. private _uniforms;
  28305. /**
  28306. * Key for the effect.
  28307. * @hidden
  28308. */
  28309. _key: string;
  28310. private _indexParameters;
  28311. private _fallbacks;
  28312. private _vertexSourceCode;
  28313. private _fragmentSourceCode;
  28314. private _vertexSourceCodeOverride;
  28315. private _fragmentSourceCodeOverride;
  28316. private _transformFeedbackVaryings;
  28317. /**
  28318. * Compiled shader to webGL program.
  28319. * @hidden
  28320. */
  28321. _pipelineContext: Nullable<IPipelineContext>;
  28322. private _valueCache;
  28323. private static _baseCache;
  28324. /**
  28325. * Instantiates an effect.
  28326. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28327. * @param baseName Name of the effect.
  28328. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28329. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28330. * @param samplers List of sampler variables that will be passed to the shader.
  28331. * @param engine Engine to be used to render the effect
  28332. * @param defines Define statements to be added to the shader.
  28333. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28334. * @param onCompiled Callback that will be called when the shader is compiled.
  28335. * @param onError Callback that will be called if an error occurs during shader compilation.
  28336. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28337. */
  28338. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28339. private _useFinalCode;
  28340. /**
  28341. * Unique key for this effect
  28342. */
  28343. readonly key: string;
  28344. /**
  28345. * If the effect has been compiled and prepared.
  28346. * @returns if the effect is compiled and prepared.
  28347. */
  28348. isReady(): boolean;
  28349. private _isReadyInternal;
  28350. /**
  28351. * The engine the effect was initialized with.
  28352. * @returns the engine.
  28353. */
  28354. getEngine(): Engine;
  28355. /**
  28356. * The pipeline context for this effect
  28357. * @returns the associated pipeline context
  28358. */
  28359. getPipelineContext(): Nullable<IPipelineContext>;
  28360. /**
  28361. * The set of names of attribute variables for the shader.
  28362. * @returns An array of attribute names.
  28363. */
  28364. getAttributesNames(): string[];
  28365. /**
  28366. * Returns the attribute at the given index.
  28367. * @param index The index of the attribute.
  28368. * @returns The location of the attribute.
  28369. */
  28370. getAttributeLocation(index: number): number;
  28371. /**
  28372. * Returns the attribute based on the name of the variable.
  28373. * @param name of the attribute to look up.
  28374. * @returns the attribute location.
  28375. */
  28376. getAttributeLocationByName(name: string): number;
  28377. /**
  28378. * The number of attributes.
  28379. * @returns the numnber of attributes.
  28380. */
  28381. getAttributesCount(): number;
  28382. /**
  28383. * Gets the index of a uniform variable.
  28384. * @param uniformName of the uniform to look up.
  28385. * @returns the index.
  28386. */
  28387. getUniformIndex(uniformName: string): number;
  28388. /**
  28389. * Returns the attribute based on the name of the variable.
  28390. * @param uniformName of the uniform to look up.
  28391. * @returns the location of the uniform.
  28392. */
  28393. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28394. /**
  28395. * Returns an array of sampler variable names
  28396. * @returns The array of sampler variable neames.
  28397. */
  28398. getSamplers(): string[];
  28399. /**
  28400. * The error from the last compilation.
  28401. * @returns the error string.
  28402. */
  28403. getCompilationError(): string;
  28404. /**
  28405. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28406. * @param func The callback to be used.
  28407. */
  28408. executeWhenCompiled(func: (effect: Effect) => void): void;
  28409. private _checkIsReady;
  28410. /** @hidden */
  28411. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28412. /** @hidden */
  28413. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28414. /** @hidden */
  28415. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28416. /**
  28417. * Recompiles the webGL program
  28418. * @param vertexSourceCode The source code for the vertex shader.
  28419. * @param fragmentSourceCode The source code for the fragment shader.
  28420. * @param onCompiled Callback called when completed.
  28421. * @param onError Callback called on error.
  28422. * @hidden
  28423. */
  28424. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28425. /**
  28426. * Prepares the effect
  28427. * @hidden
  28428. */
  28429. _prepareEffect(): void;
  28430. private _processCompilationErrors;
  28431. /**
  28432. * Checks if the effect is supported. (Must be called after compilation)
  28433. */
  28434. readonly isSupported: boolean;
  28435. /**
  28436. * Binds a texture to the engine to be used as output of the shader.
  28437. * @param channel Name of the output variable.
  28438. * @param texture Texture to bind.
  28439. * @hidden
  28440. */
  28441. _bindTexture(channel: string, texture: InternalTexture): void;
  28442. /**
  28443. * Sets a texture on the engine to be used in the shader.
  28444. * @param channel Name of the sampler variable.
  28445. * @param texture Texture to set.
  28446. */
  28447. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28448. /**
  28449. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28450. * @param channel Name of the sampler variable.
  28451. * @param texture Texture to set.
  28452. */
  28453. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28454. /**
  28455. * Sets an array of textures on the engine to be used in the shader.
  28456. * @param channel Name of the variable.
  28457. * @param textures Textures to set.
  28458. */
  28459. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28460. /**
  28461. * 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)
  28462. * @param channel Name of the sampler variable.
  28463. * @param postProcess Post process to get the input texture from.
  28464. */
  28465. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28466. /**
  28467. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28468. * 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)
  28469. * @param channel Name of the sampler variable.
  28470. * @param postProcess Post process to get the output texture from.
  28471. */
  28472. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28473. /** @hidden */
  28474. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28475. /** @hidden */
  28476. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28477. /** @hidden */
  28478. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28479. /** @hidden */
  28480. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28481. /**
  28482. * Binds a buffer to a uniform.
  28483. * @param buffer Buffer to bind.
  28484. * @param name Name of the uniform variable to bind to.
  28485. */
  28486. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28487. /**
  28488. * Binds block to a uniform.
  28489. * @param blockName Name of the block to bind.
  28490. * @param index Index to bind.
  28491. */
  28492. bindUniformBlock(blockName: string, index: number): void;
  28493. /**
  28494. * Sets an interger value on a uniform variable.
  28495. * @param uniformName Name of the variable.
  28496. * @param value Value to be set.
  28497. * @returns this effect.
  28498. */
  28499. setInt(uniformName: string, value: number): Effect;
  28500. /**
  28501. * Sets an int array on a uniform variable.
  28502. * @param uniformName Name of the variable.
  28503. * @param array array to be set.
  28504. * @returns this effect.
  28505. */
  28506. setIntArray(uniformName: string, array: Int32Array): Effect;
  28507. /**
  28508. * 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)
  28509. * @param uniformName Name of the variable.
  28510. * @param array array to be set.
  28511. * @returns this effect.
  28512. */
  28513. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28514. /**
  28515. * 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)
  28516. * @param uniformName Name of the variable.
  28517. * @param array array to be set.
  28518. * @returns this effect.
  28519. */
  28520. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28521. /**
  28522. * 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)
  28523. * @param uniformName Name of the variable.
  28524. * @param array array to be set.
  28525. * @returns this effect.
  28526. */
  28527. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28528. /**
  28529. * Sets an float array on a uniform variable.
  28530. * @param uniformName Name of the variable.
  28531. * @param array array to be set.
  28532. * @returns this effect.
  28533. */
  28534. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28535. /**
  28536. * 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)
  28537. * @param uniformName Name of the variable.
  28538. * @param array array to be set.
  28539. * @returns this effect.
  28540. */
  28541. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28542. /**
  28543. * 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)
  28544. * @param uniformName Name of the variable.
  28545. * @param array array to be set.
  28546. * @returns this effect.
  28547. */
  28548. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28549. /**
  28550. * 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)
  28551. * @param uniformName Name of the variable.
  28552. * @param array array to be set.
  28553. * @returns this effect.
  28554. */
  28555. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28556. /**
  28557. * Sets an array on a uniform variable.
  28558. * @param uniformName Name of the variable.
  28559. * @param array array to be set.
  28560. * @returns this effect.
  28561. */
  28562. setArray(uniformName: string, array: number[]): Effect;
  28563. /**
  28564. * 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)
  28565. * @param uniformName Name of the variable.
  28566. * @param array array to be set.
  28567. * @returns this effect.
  28568. */
  28569. setArray2(uniformName: string, array: number[]): Effect;
  28570. /**
  28571. * 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)
  28572. * @param uniformName Name of the variable.
  28573. * @param array array to be set.
  28574. * @returns this effect.
  28575. */
  28576. setArray3(uniformName: string, array: number[]): Effect;
  28577. /**
  28578. * 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)
  28579. * @param uniformName Name of the variable.
  28580. * @param array array to be set.
  28581. * @returns this effect.
  28582. */
  28583. setArray4(uniformName: string, array: number[]): Effect;
  28584. /**
  28585. * Sets matrices on a uniform variable.
  28586. * @param uniformName Name of the variable.
  28587. * @param matrices matrices to be set.
  28588. * @returns this effect.
  28589. */
  28590. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28591. /**
  28592. * Sets matrix on a uniform variable.
  28593. * @param uniformName Name of the variable.
  28594. * @param matrix matrix to be set.
  28595. * @returns this effect.
  28596. */
  28597. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28598. /**
  28599. * 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)
  28600. * @param uniformName Name of the variable.
  28601. * @param matrix matrix to be set.
  28602. * @returns this effect.
  28603. */
  28604. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28605. /**
  28606. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28607. * @param uniformName Name of the variable.
  28608. * @param matrix matrix to be set.
  28609. * @returns this effect.
  28610. */
  28611. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28612. /**
  28613. * Sets a float on a uniform variable.
  28614. * @param uniformName Name of the variable.
  28615. * @param value value to be set.
  28616. * @returns this effect.
  28617. */
  28618. setFloat(uniformName: string, value: number): Effect;
  28619. /**
  28620. * Sets a boolean on a uniform variable.
  28621. * @param uniformName Name of the variable.
  28622. * @param bool value to be set.
  28623. * @returns this effect.
  28624. */
  28625. setBool(uniformName: string, bool: boolean): Effect;
  28626. /**
  28627. * Sets a Vector2 on a uniform variable.
  28628. * @param uniformName Name of the variable.
  28629. * @param vector2 vector2 to be set.
  28630. * @returns this effect.
  28631. */
  28632. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28633. /**
  28634. * Sets a float2 on a uniform variable.
  28635. * @param uniformName Name of the variable.
  28636. * @param x First float in float2.
  28637. * @param y Second float in float2.
  28638. * @returns this effect.
  28639. */
  28640. setFloat2(uniformName: string, x: number, y: number): Effect;
  28641. /**
  28642. * Sets a Vector3 on a uniform variable.
  28643. * @param uniformName Name of the variable.
  28644. * @param vector3 Value to be set.
  28645. * @returns this effect.
  28646. */
  28647. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28648. /**
  28649. * Sets a float3 on a uniform variable.
  28650. * @param uniformName Name of the variable.
  28651. * @param x First float in float3.
  28652. * @param y Second float in float3.
  28653. * @param z Third float in float3.
  28654. * @returns this effect.
  28655. */
  28656. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28657. /**
  28658. * Sets a Vector4 on a uniform variable.
  28659. * @param uniformName Name of the variable.
  28660. * @param vector4 Value to be set.
  28661. * @returns this effect.
  28662. */
  28663. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28664. /**
  28665. * Sets a float4 on a uniform variable.
  28666. * @param uniformName Name of the variable.
  28667. * @param x First float in float4.
  28668. * @param y Second float in float4.
  28669. * @param z Third float in float4.
  28670. * @param w Fourth float in float4.
  28671. * @returns this effect.
  28672. */
  28673. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28674. /**
  28675. * Sets a Color3 on a uniform variable.
  28676. * @param uniformName Name of the variable.
  28677. * @param color3 Value to be set.
  28678. * @returns this effect.
  28679. */
  28680. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28681. /**
  28682. * Sets a Color4 on a uniform variable.
  28683. * @param uniformName Name of the variable.
  28684. * @param color3 Value to be set.
  28685. * @param alpha Alpha value to be set.
  28686. * @returns this effect.
  28687. */
  28688. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28689. /**
  28690. * Sets a Color4 on a uniform variable
  28691. * @param uniformName defines the name of the variable
  28692. * @param color4 defines the value to be set
  28693. * @returns this effect.
  28694. */
  28695. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28696. /** Release all associated resources */
  28697. dispose(): void;
  28698. /**
  28699. * This function will add a new shader to the shader store
  28700. * @param name the name of the shader
  28701. * @param pixelShader optional pixel shader content
  28702. * @param vertexShader optional vertex shader content
  28703. */
  28704. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28705. /**
  28706. * Store of each shader (The can be looked up using effect.key)
  28707. */
  28708. static ShadersStore: {
  28709. [key: string]: string;
  28710. };
  28711. /**
  28712. * Store of each included file for a shader (The can be looked up using effect.key)
  28713. */
  28714. static IncludesShadersStore: {
  28715. [key: string]: string;
  28716. };
  28717. /**
  28718. * Resets the cache of effects.
  28719. */
  28720. static ResetCache(): void;
  28721. }
  28722. }
  28723. declare module BABYLON {
  28724. /**
  28725. * Class used to describe the capabilities of the engine relatively to the current browser
  28726. */
  28727. export class EngineCapabilities {
  28728. /** Maximum textures units per fragment shader */
  28729. maxTexturesImageUnits: number;
  28730. /** Maximum texture units per vertex shader */
  28731. maxVertexTextureImageUnits: number;
  28732. /** Maximum textures units in the entire pipeline */
  28733. maxCombinedTexturesImageUnits: number;
  28734. /** Maximum texture size */
  28735. maxTextureSize: number;
  28736. /** Maximum cube texture size */
  28737. maxCubemapTextureSize: number;
  28738. /** Maximum render texture size */
  28739. maxRenderTextureSize: number;
  28740. /** Maximum number of vertex attributes */
  28741. maxVertexAttribs: number;
  28742. /** Maximum number of varyings */
  28743. maxVaryingVectors: number;
  28744. /** Maximum number of uniforms per vertex shader */
  28745. maxVertexUniformVectors: number;
  28746. /** Maximum number of uniforms per fragment shader */
  28747. maxFragmentUniformVectors: number;
  28748. /** Defines if standard derivates (dx/dy) are supported */
  28749. standardDerivatives: boolean;
  28750. /** Defines if s3tc texture compression is supported */
  28751. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28752. /** Defines if pvrtc texture compression is supported */
  28753. pvrtc: any;
  28754. /** Defines if etc1 texture compression is supported */
  28755. etc1: any;
  28756. /** Defines if etc2 texture compression is supported */
  28757. etc2: any;
  28758. /** Defines if astc texture compression is supported */
  28759. astc: any;
  28760. /** Defines if float textures are supported */
  28761. textureFloat: boolean;
  28762. /** Defines if vertex array objects are supported */
  28763. vertexArrayObject: boolean;
  28764. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28765. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28766. /** Gets the maximum level of anisotropy supported */
  28767. maxAnisotropy: number;
  28768. /** Defines if instancing is supported */
  28769. instancedArrays: boolean;
  28770. /** Defines if 32 bits indices are supported */
  28771. uintIndices: boolean;
  28772. /** Defines if high precision shaders are supported */
  28773. highPrecisionShaderSupported: boolean;
  28774. /** Defines if depth reading in the fragment shader is supported */
  28775. fragmentDepthSupported: boolean;
  28776. /** Defines if float texture linear filtering is supported*/
  28777. textureFloatLinearFiltering: boolean;
  28778. /** Defines if rendering to float textures is supported */
  28779. textureFloatRender: boolean;
  28780. /** Defines if half float textures are supported*/
  28781. textureHalfFloat: boolean;
  28782. /** Defines if half float texture linear filtering is supported*/
  28783. textureHalfFloatLinearFiltering: boolean;
  28784. /** Defines if rendering to half float textures is supported */
  28785. textureHalfFloatRender: boolean;
  28786. /** Defines if textureLOD shader command is supported */
  28787. textureLOD: boolean;
  28788. /** Defines if draw buffers extension is supported */
  28789. drawBuffersExtension: boolean;
  28790. /** Defines if depth textures are supported */
  28791. depthTextureExtension: boolean;
  28792. /** Defines if float color buffer are supported */
  28793. colorBufferFloat: boolean;
  28794. /** Gets disjoint timer query extension (null if not supported) */
  28795. timerQuery: EXT_disjoint_timer_query;
  28796. /** Defines if timestamp can be used with timer query */
  28797. canUseTimestampForTimerQuery: boolean;
  28798. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28799. multiview: any;
  28800. /** Function used to let the system compiles shaders in background */
  28801. parallelShaderCompile: {
  28802. COMPLETION_STATUS_KHR: number;
  28803. };
  28804. /** Max number of texture samples for MSAA */
  28805. maxMSAASamples: number;
  28806. /** Defines if the blend min max extension is supported */
  28807. blendMinMax: boolean;
  28808. }
  28809. }
  28810. declare module BABYLON {
  28811. /**
  28812. * This class is used to track a performance counter which is number based.
  28813. * The user has access to many properties which give statistics of different nature.
  28814. *
  28815. * The implementer can track two kinds of Performance Counter: time and count.
  28816. * 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.
  28817. * 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.
  28818. */
  28819. export class PerfCounter {
  28820. /**
  28821. * Gets or sets a global boolean to turn on and off all the counters
  28822. */
  28823. static Enabled: boolean;
  28824. /**
  28825. * Returns the smallest value ever
  28826. */
  28827. readonly min: number;
  28828. /**
  28829. * Returns the biggest value ever
  28830. */
  28831. readonly max: number;
  28832. /**
  28833. * Returns the average value since the performance counter is running
  28834. */
  28835. readonly average: number;
  28836. /**
  28837. * Returns the average value of the last second the counter was monitored
  28838. */
  28839. readonly lastSecAverage: number;
  28840. /**
  28841. * Returns the current value
  28842. */
  28843. readonly current: number;
  28844. /**
  28845. * Gets the accumulated total
  28846. */
  28847. readonly total: number;
  28848. /**
  28849. * Gets the total value count
  28850. */
  28851. readonly count: number;
  28852. /**
  28853. * Creates a new counter
  28854. */
  28855. constructor();
  28856. /**
  28857. * Call this method to start monitoring a new frame.
  28858. * 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.
  28859. */
  28860. fetchNewFrame(): void;
  28861. /**
  28862. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28863. * @param newCount the count value to add to the monitored count
  28864. * @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.
  28865. */
  28866. addCount(newCount: number, fetchResult: boolean): void;
  28867. /**
  28868. * Start monitoring this performance counter
  28869. */
  28870. beginMonitoring(): void;
  28871. /**
  28872. * Compute the time lapsed since the previous beginMonitoring() call.
  28873. * @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
  28874. */
  28875. endMonitoring(newFrame?: boolean): void;
  28876. private _fetchResult;
  28877. private _startMonitoringTime;
  28878. private _min;
  28879. private _max;
  28880. private _average;
  28881. private _current;
  28882. private _totalValueCount;
  28883. private _totalAccumulated;
  28884. private _lastSecAverage;
  28885. private _lastSecAccumulated;
  28886. private _lastSecTime;
  28887. private _lastSecValueCount;
  28888. }
  28889. }
  28890. declare module BABYLON {
  28891. /**
  28892. * @hidden
  28893. **/
  28894. export class DepthCullingState {
  28895. private _isDepthTestDirty;
  28896. private _isDepthMaskDirty;
  28897. private _isDepthFuncDirty;
  28898. private _isCullFaceDirty;
  28899. private _isCullDirty;
  28900. private _isZOffsetDirty;
  28901. private _isFrontFaceDirty;
  28902. private _depthTest;
  28903. private _depthMask;
  28904. private _depthFunc;
  28905. private _cull;
  28906. private _cullFace;
  28907. private _zOffset;
  28908. private _frontFace;
  28909. /**
  28910. * Initializes the state.
  28911. */
  28912. constructor();
  28913. readonly isDirty: boolean;
  28914. zOffset: number;
  28915. cullFace: Nullable<number>;
  28916. cull: Nullable<boolean>;
  28917. depthFunc: Nullable<number>;
  28918. depthMask: boolean;
  28919. depthTest: boolean;
  28920. frontFace: Nullable<number>;
  28921. reset(): void;
  28922. apply(gl: WebGLRenderingContext): void;
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * @hidden
  28928. **/
  28929. export class StencilState {
  28930. /** 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 */
  28931. static readonly ALWAYS: number;
  28932. /** Passed to stencilOperation to specify that stencil value must be kept */
  28933. static readonly KEEP: number;
  28934. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28935. static readonly REPLACE: number;
  28936. private _isStencilTestDirty;
  28937. private _isStencilMaskDirty;
  28938. private _isStencilFuncDirty;
  28939. private _isStencilOpDirty;
  28940. private _stencilTest;
  28941. private _stencilMask;
  28942. private _stencilFunc;
  28943. private _stencilFuncRef;
  28944. private _stencilFuncMask;
  28945. private _stencilOpStencilFail;
  28946. private _stencilOpDepthFail;
  28947. private _stencilOpStencilDepthPass;
  28948. readonly isDirty: boolean;
  28949. stencilFunc: number;
  28950. stencilFuncRef: number;
  28951. stencilFuncMask: number;
  28952. stencilOpStencilFail: number;
  28953. stencilOpDepthFail: number;
  28954. stencilOpStencilDepthPass: number;
  28955. stencilMask: number;
  28956. stencilTest: boolean;
  28957. constructor();
  28958. reset(): void;
  28959. apply(gl: WebGLRenderingContext): void;
  28960. }
  28961. }
  28962. declare module BABYLON {
  28963. /**
  28964. * @hidden
  28965. **/
  28966. export class AlphaState {
  28967. private _isAlphaBlendDirty;
  28968. private _isBlendFunctionParametersDirty;
  28969. private _isBlendEquationParametersDirty;
  28970. private _isBlendConstantsDirty;
  28971. private _alphaBlend;
  28972. private _blendFunctionParameters;
  28973. private _blendEquationParameters;
  28974. private _blendConstants;
  28975. /**
  28976. * Initializes the state.
  28977. */
  28978. constructor();
  28979. readonly isDirty: boolean;
  28980. alphaBlend: boolean;
  28981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28984. reset(): void;
  28985. apply(gl: WebGLRenderingContext): void;
  28986. }
  28987. }
  28988. declare module BABYLON {
  28989. /** @hidden */
  28990. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28991. attributeProcessor(attribute: string): string;
  28992. varyingProcessor(varying: string, isFragment: boolean): string;
  28993. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28994. }
  28995. }
  28996. declare module BABYLON {
  28997. /**
  28998. * Interface for attribute information associated with buffer instanciation
  28999. */
  29000. export class InstancingAttributeInfo {
  29001. /**
  29002. * Index/offset of the attribute in the vertex shader
  29003. */
  29004. index: number;
  29005. /**
  29006. * size of the attribute, 1, 2, 3 or 4
  29007. */
  29008. attributeSize: number;
  29009. /**
  29010. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29011. * default is FLOAT
  29012. */
  29013. attribyteType: number;
  29014. /**
  29015. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29016. */
  29017. normalized: boolean;
  29018. /**
  29019. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29020. */
  29021. offset: number;
  29022. /**
  29023. * Name of the GLSL attribute, for debugging purpose only
  29024. */
  29025. attributeName: string;
  29026. }
  29027. }
  29028. declare module BABYLON {
  29029. interface ThinEngine {
  29030. /**
  29031. * Update a video texture
  29032. * @param texture defines the texture to update
  29033. * @param video defines the video element to use
  29034. * @param invertY defines if data must be stored with Y axis inverted
  29035. */
  29036. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29037. }
  29038. }
  29039. declare module BABYLON {
  29040. /**
  29041. * Settings for finer control over video usage
  29042. */
  29043. export interface VideoTextureSettings {
  29044. /**
  29045. * Applies `autoplay` to video, if specified
  29046. */
  29047. autoPlay?: boolean;
  29048. /**
  29049. * Applies `loop` to video, if specified
  29050. */
  29051. loop?: boolean;
  29052. /**
  29053. * Automatically updates internal texture from video at every frame in the render loop
  29054. */
  29055. autoUpdateTexture: boolean;
  29056. /**
  29057. * Image src displayed during the video loading or until the user interacts with the video.
  29058. */
  29059. poster?: string;
  29060. }
  29061. /**
  29062. * If you want to display a video in your scene, this is the special texture for that.
  29063. * This special texture works similar to other textures, with the exception of a few parameters.
  29064. * @see https://doc.babylonjs.com/how_to/video_texture
  29065. */
  29066. export class VideoTexture extends Texture {
  29067. /**
  29068. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29069. */
  29070. readonly autoUpdateTexture: boolean;
  29071. /**
  29072. * The video instance used by the texture internally
  29073. */
  29074. readonly video: HTMLVideoElement;
  29075. private _onUserActionRequestedObservable;
  29076. /**
  29077. * Event triggerd when a dom action is required by the user to play the video.
  29078. * This happens due to recent changes in browser policies preventing video to auto start.
  29079. */
  29080. readonly onUserActionRequestedObservable: Observable<Texture>;
  29081. private _generateMipMaps;
  29082. private _engine;
  29083. private _stillImageCaptured;
  29084. private _displayingPosterTexture;
  29085. private _settings;
  29086. private _createInternalTextureOnEvent;
  29087. private _frameId;
  29088. /**
  29089. * Creates a video texture.
  29090. * If you want to display a video in your scene, this is the special texture for that.
  29091. * This special texture works similar to other textures, with the exception of a few parameters.
  29092. * @see https://doc.babylonjs.com/how_to/video_texture
  29093. * @param name optional name, will detect from video source, if not defined
  29094. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29095. * @param scene is obviously the current scene.
  29096. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29097. * @param invertY is false by default but can be used to invert video on Y axis
  29098. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29099. * @param settings allows finer control over video usage
  29100. */
  29101. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29102. private _getName;
  29103. private _getVideo;
  29104. private _createInternalTexture;
  29105. private reset;
  29106. /**
  29107. * @hidden Internal method to initiate `update`.
  29108. */
  29109. _rebuild(): void;
  29110. /**
  29111. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29112. */
  29113. update(): void;
  29114. /**
  29115. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29116. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29117. */
  29118. updateTexture(isVisible: boolean): void;
  29119. protected _updateInternalTexture: () => void;
  29120. /**
  29121. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29122. * @param url New url.
  29123. */
  29124. updateURL(url: string): void;
  29125. /**
  29126. * Dispose the texture and release its associated resources.
  29127. */
  29128. dispose(): void;
  29129. /**
  29130. * Creates a video texture straight from a stream.
  29131. * @param scene Define the scene the texture should be created in
  29132. * @param stream Define the stream the texture should be created from
  29133. * @returns The created video texture as a promise
  29134. */
  29135. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29136. /**
  29137. * Creates a video texture straight from your WebCam video feed.
  29138. * @param scene Define the scene the texture should be created in
  29139. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29140. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29141. * @returns The created video texture as a promise
  29142. */
  29143. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29144. minWidth: number;
  29145. maxWidth: number;
  29146. minHeight: number;
  29147. maxHeight: number;
  29148. deviceId: string;
  29149. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29150. /**
  29151. * Creates a video texture straight from your WebCam video feed.
  29152. * @param scene Define the scene the texture should be created in
  29153. * @param onReady Define a callback to triggered once the texture will be ready
  29154. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29155. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29156. */
  29157. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29158. minWidth: number;
  29159. maxWidth: number;
  29160. minHeight: number;
  29161. maxHeight: number;
  29162. deviceId: string;
  29163. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29164. }
  29165. }
  29166. declare module BABYLON {
  29167. /**
  29168. * Defines the interface used by objects working like Scene
  29169. * @hidden
  29170. */
  29171. interface ISceneLike {
  29172. _addPendingData(data: any): void;
  29173. _removePendingData(data: any): void;
  29174. offlineProvider: IOfflineProvider;
  29175. }
  29176. /** Interface defining initialization parameters for Engine class */
  29177. export interface EngineOptions extends WebGLContextAttributes {
  29178. /**
  29179. * Defines if the engine should no exceed a specified device ratio
  29180. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29181. */
  29182. limitDeviceRatio?: number;
  29183. /**
  29184. * Defines if webvr should be enabled automatically
  29185. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29186. */
  29187. autoEnableWebVR?: boolean;
  29188. /**
  29189. * Defines if webgl2 should be turned off even if supported
  29190. * @see http://doc.babylonjs.com/features/webgl2
  29191. */
  29192. disableWebGL2Support?: boolean;
  29193. /**
  29194. * Defines if webaudio should be initialized as well
  29195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29196. */
  29197. audioEngine?: boolean;
  29198. /**
  29199. * Defines if animations should run using a deterministic lock step
  29200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29201. */
  29202. deterministicLockstep?: boolean;
  29203. /** Defines the maximum steps to use with deterministic lock step mode */
  29204. lockstepMaxSteps?: number;
  29205. /**
  29206. * Defines that engine should ignore context lost events
  29207. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29208. */
  29209. doNotHandleContextLost?: boolean;
  29210. /**
  29211. * Defines that engine should ignore modifying touch action attribute and style
  29212. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29213. */
  29214. doNotHandleTouchAction?: boolean;
  29215. /**
  29216. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29217. */
  29218. useHighPrecisionFloats?: boolean;
  29219. }
  29220. /**
  29221. * The base engine class (root of all engines)
  29222. */
  29223. export class ThinEngine {
  29224. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29225. static ExceptionList: ({
  29226. key: string;
  29227. capture: string;
  29228. captureConstraint: number;
  29229. targets: string[];
  29230. } | {
  29231. key: string;
  29232. capture: null;
  29233. captureConstraint: null;
  29234. targets: string[];
  29235. })[];
  29236. /** @hidden */
  29237. static _TextureLoaders: IInternalTextureLoader[];
  29238. /**
  29239. * Returns the current npm package of the sdk
  29240. */
  29241. static readonly NpmPackage: string;
  29242. /**
  29243. * Returns the current version of the framework
  29244. */
  29245. static readonly Version: string;
  29246. /**
  29247. * Returns a string describing the current engine
  29248. */
  29249. readonly description: string;
  29250. /**
  29251. * Gets or sets the epsilon value used by collision engine
  29252. */
  29253. static CollisionsEpsilon: number;
  29254. /**
  29255. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29256. */
  29257. static ShadersRepository: string;
  29258. /** @hidden */
  29259. _shaderProcessor: IShaderProcessor;
  29260. /**
  29261. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29262. */
  29263. forcePOTTextures: boolean;
  29264. /**
  29265. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29266. */
  29267. isFullscreen: boolean;
  29268. /**
  29269. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29270. */
  29271. cullBackFaces: boolean;
  29272. /**
  29273. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29274. */
  29275. renderEvenInBackground: boolean;
  29276. /**
  29277. * Gets or sets a boolean indicating that cache can be kept between frames
  29278. */
  29279. preventCacheWipeBetweenFrames: boolean;
  29280. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29281. validateShaderPrograms: boolean;
  29282. /**
  29283. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29284. */
  29285. disableUniformBuffers: boolean;
  29286. /** @hidden */
  29287. _uniformBuffers: UniformBuffer[];
  29288. /**
  29289. * Gets a boolean indicating that the engine supports uniform buffers
  29290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29291. */
  29292. readonly supportsUniformBuffers: boolean;
  29293. /** @hidden */
  29294. _gl: WebGLRenderingContext;
  29295. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29296. protected _windowIsBackground: boolean;
  29297. protected _webGLVersion: number;
  29298. protected _highPrecisionShadersAllowed: boolean;
  29299. /** @hidden */
  29300. readonly _shouldUseHighPrecisionShader: boolean;
  29301. /**
  29302. * Gets a boolean indicating that only power of 2 textures are supported
  29303. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29304. */
  29305. readonly needPOTTextures: boolean;
  29306. /** @hidden */
  29307. _badOS: boolean;
  29308. /** @hidden */
  29309. _badDesktopOS: boolean;
  29310. private _hardwareScalingLevel;
  29311. /** @hidden */
  29312. _caps: EngineCapabilities;
  29313. private _isStencilEnable;
  29314. protected _colorWrite: boolean;
  29315. /** @hidden */
  29316. _drawCalls: PerfCounter;
  29317. private _glVersion;
  29318. private _glRenderer;
  29319. private _glVendor;
  29320. /** @hidden */
  29321. _videoTextureSupported: boolean;
  29322. protected _renderingQueueLaunched: boolean;
  29323. protected _activeRenderLoops: (() => void)[];
  29324. /**
  29325. * Observable signaled when a context lost event is raised
  29326. */
  29327. onContextLostObservable: Observable<ThinEngine>;
  29328. /**
  29329. * Observable signaled when a context restored event is raised
  29330. */
  29331. onContextRestoredObservable: Observable<ThinEngine>;
  29332. private _onContextLost;
  29333. private _onContextRestored;
  29334. protected _contextWasLost: boolean;
  29335. /** @hidden */
  29336. _doNotHandleContextLost: boolean;
  29337. /**
  29338. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29340. */
  29341. doNotHandleContextLost: boolean;
  29342. /**
  29343. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29344. */
  29345. disableVertexArrayObjects: boolean;
  29346. /** @hidden */
  29347. protected _depthCullingState: DepthCullingState;
  29348. /** @hidden */
  29349. protected _stencilState: StencilState;
  29350. /** @hidden */
  29351. protected _alphaState: AlphaState;
  29352. /** @hidden */
  29353. _internalTexturesCache: InternalTexture[];
  29354. /** @hidden */
  29355. protected _activeChannel: number;
  29356. private _currentTextureChannel;
  29357. /** @hidden */
  29358. protected _boundTexturesCache: {
  29359. [key: string]: Nullable<InternalTexture>;
  29360. };
  29361. /** @hidden */
  29362. protected _currentEffect: Nullable<Effect>;
  29363. /** @hidden */
  29364. protected _currentProgram: Nullable<WebGLProgram>;
  29365. private _compiledEffects;
  29366. private _vertexAttribArraysEnabled;
  29367. /** @hidden */
  29368. protected _cachedViewport: Nullable<IViewportLike>;
  29369. private _cachedVertexArrayObject;
  29370. /** @hidden */
  29371. protected _cachedVertexBuffers: any;
  29372. /** @hidden */
  29373. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29374. /** @hidden */
  29375. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29376. /** @hidden */
  29377. _currentRenderTarget: Nullable<InternalTexture>;
  29378. private _uintIndicesCurrentlySet;
  29379. private _currentBoundBuffer;
  29380. /** @hidden */
  29381. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29382. private _currentBufferPointers;
  29383. private _currentInstanceLocations;
  29384. private _currentInstanceBuffers;
  29385. private _textureUnits;
  29386. /** @hidden */
  29387. _workingCanvas: Nullable<HTMLCanvasElement>;
  29388. /** @hidden */
  29389. _workingContext: Nullable<CanvasRenderingContext2D>;
  29390. /** @hidden */
  29391. _bindedRenderFunction: any;
  29392. private _vaoRecordInProgress;
  29393. private _mustWipeVertexAttributes;
  29394. private _emptyTexture;
  29395. private _emptyCubeTexture;
  29396. private _emptyTexture3D;
  29397. /** @hidden */
  29398. _frameHandler: number;
  29399. private _nextFreeTextureSlots;
  29400. private _maxSimultaneousTextures;
  29401. private _activeRequests;
  29402. protected _texturesSupported: string[];
  29403. /** @hidden */
  29404. _textureFormatInUse: Nullable<string>;
  29405. protected readonly _supportsHardwareTextureRescaling: boolean;
  29406. /**
  29407. * Gets the list of texture formats supported
  29408. */
  29409. readonly texturesSupported: Array<string>;
  29410. /**
  29411. * Gets the list of texture formats in use
  29412. */
  29413. readonly textureFormatInUse: Nullable<string>;
  29414. /**
  29415. * Gets the current viewport
  29416. */
  29417. readonly currentViewport: Nullable<IViewportLike>;
  29418. /**
  29419. * Gets the default empty texture
  29420. */
  29421. readonly emptyTexture: InternalTexture;
  29422. /**
  29423. * Gets the default empty 3D texture
  29424. */
  29425. readonly emptyTexture3D: InternalTexture;
  29426. /**
  29427. * Gets the default empty cube texture
  29428. */
  29429. readonly emptyCubeTexture: InternalTexture;
  29430. /**
  29431. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29432. */
  29433. readonly premultipliedAlpha: boolean;
  29434. /**
  29435. * Creates a new engine
  29436. * @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
  29437. * @param antialias defines enable antialiasing (default: false)
  29438. * @param options defines further options to be sent to the getContext() function
  29439. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29440. */
  29441. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29442. private _rebuildInternalTextures;
  29443. private _rebuildEffects;
  29444. /**
  29445. * Gets a boolean indicating if all created effects are ready
  29446. * @returns true if all effects are ready
  29447. */
  29448. areAllEffectsReady(): boolean;
  29449. protected _rebuildBuffers(): void;
  29450. private _initGLContext;
  29451. /**
  29452. * Gets version of the current webGL context
  29453. */
  29454. readonly webGLVersion: number;
  29455. /**
  29456. * Gets a string idenfifying the name of the class
  29457. * @returns "Engine" string
  29458. */
  29459. getClassName(): string;
  29460. /**
  29461. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29462. */
  29463. readonly isStencilEnable: boolean;
  29464. /** @hidden */
  29465. _prepareWorkingCanvas(): void;
  29466. /**
  29467. * Reset the texture cache to empty state
  29468. */
  29469. resetTextureCache(): void;
  29470. /**
  29471. * Gets an object containing information about the current webGL context
  29472. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29473. */
  29474. getGlInfo(): {
  29475. vendor: string;
  29476. renderer: string;
  29477. version: string;
  29478. };
  29479. /**
  29480. * Defines the hardware scaling level.
  29481. * By default the hardware scaling level is computed from the window device ratio.
  29482. * 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.
  29483. * @param level defines the level to use
  29484. */
  29485. setHardwareScalingLevel(level: number): void;
  29486. /**
  29487. * Gets the current hardware scaling level.
  29488. * By default the hardware scaling level is computed from the window device ratio.
  29489. * 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.
  29490. * @returns a number indicating the current hardware scaling level
  29491. */
  29492. getHardwareScalingLevel(): number;
  29493. /**
  29494. * Gets the list of loaded textures
  29495. * @returns an array containing all loaded textures
  29496. */
  29497. getLoadedTexturesCache(): InternalTexture[];
  29498. /**
  29499. * Gets the object containing all engine capabilities
  29500. * @returns the EngineCapabilities object
  29501. */
  29502. getCaps(): EngineCapabilities;
  29503. /**
  29504. * stop executing a render loop function and remove it from the execution array
  29505. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29506. */
  29507. stopRenderLoop(renderFunction?: () => void): void;
  29508. /** @hidden */
  29509. _renderLoop(): void;
  29510. /**
  29511. * Gets the HTML canvas attached with the current webGL context
  29512. * @returns a HTML canvas
  29513. */
  29514. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29515. /**
  29516. * Gets host window
  29517. * @returns the host window object
  29518. */
  29519. getHostWindow(): Window;
  29520. /**
  29521. * Gets the current render width
  29522. * @param useScreen defines if screen size must be used (or the current render target if any)
  29523. * @returns a number defining the current render width
  29524. */
  29525. getRenderWidth(useScreen?: boolean): number;
  29526. /**
  29527. * Gets the current render height
  29528. * @param useScreen defines if screen size must be used (or the current render target if any)
  29529. * @returns a number defining the current render height
  29530. */
  29531. getRenderHeight(useScreen?: boolean): number;
  29532. /**
  29533. * Can be used to override the current requestAnimationFrame requester.
  29534. * @hidden
  29535. */
  29536. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29537. /**
  29538. * Register and execute a render loop. The engine can have more than one render function
  29539. * @param renderFunction defines the function to continuously execute
  29540. */
  29541. runRenderLoop(renderFunction: () => void): void;
  29542. /**
  29543. * Clear the current render buffer or the current render target (if any is set up)
  29544. * @param color defines the color to use
  29545. * @param backBuffer defines if the back buffer must be cleared
  29546. * @param depth defines if the depth buffer must be cleared
  29547. * @param stencil defines if the stencil buffer must be cleared
  29548. */
  29549. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29550. private _viewportCached;
  29551. /** @hidden */
  29552. _viewport(x: number, y: number, width: number, height: number): void;
  29553. /**
  29554. * Set the WebGL's viewport
  29555. * @param viewport defines the viewport element to be used
  29556. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29557. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29558. */
  29559. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29560. /**
  29561. * Begin a new frame
  29562. */
  29563. beginFrame(): void;
  29564. /**
  29565. * Enf the current frame
  29566. */
  29567. endFrame(): void;
  29568. /**
  29569. * Resize the view according to the canvas' size
  29570. */
  29571. resize(): void;
  29572. /**
  29573. * Force a specific size of the canvas
  29574. * @param width defines the new canvas' width
  29575. * @param height defines the new canvas' height
  29576. */
  29577. setSize(width: number, height: number): void;
  29578. /**
  29579. * Binds the frame buffer to the specified texture.
  29580. * @param texture The texture to render to or null for the default canvas
  29581. * @param faceIndex The face of the texture to render to in case of cube texture
  29582. * @param requiredWidth The width of the target to render to
  29583. * @param requiredHeight The height of the target to render to
  29584. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29585. * @param depthStencilTexture The depth stencil texture to use to render
  29586. * @param lodLevel defines le lod level to bind to the frame buffer
  29587. */
  29588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29589. /** @hidden */
  29590. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29591. /**
  29592. * Unbind the current render target texture from the webGL context
  29593. * @param texture defines the render target texture to unbind
  29594. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29595. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29596. */
  29597. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29598. /**
  29599. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29600. */
  29601. flushFramebuffer(): void;
  29602. /**
  29603. * Unbind the current render target and bind the default framebuffer
  29604. */
  29605. restoreDefaultFramebuffer(): void;
  29606. private _resetVertexBufferBinding;
  29607. /**
  29608. * Creates a vertex buffer
  29609. * @param data the data for the vertex buffer
  29610. * @returns the new WebGL static buffer
  29611. */
  29612. createVertexBuffer(data: DataArray): DataBuffer;
  29613. private _createVertexBuffer;
  29614. /**
  29615. * Creates a dynamic vertex buffer
  29616. * @param data the data for the dynamic vertex buffer
  29617. * @returns the new WebGL dynamic buffer
  29618. */
  29619. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29620. /**
  29621. * Update a dynamic index buffer
  29622. * @param indexBuffer defines the target index buffer
  29623. * @param indices defines the data to update
  29624. * @param offset defines the offset in the target index buffer where update should start
  29625. */
  29626. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29627. /**
  29628. * Updates a dynamic vertex buffer.
  29629. * @param vertexBuffer the vertex buffer to update
  29630. * @param data the data used to update the vertex buffer
  29631. * @param byteOffset the byte offset of the data
  29632. * @param byteLength the byte length of the data
  29633. */
  29634. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29635. private _resetIndexBufferBinding;
  29636. /**
  29637. * Creates a new index buffer
  29638. * @param indices defines the content of the index buffer
  29639. * @param updatable defines if the index buffer must be updatable
  29640. * @returns a new webGL buffer
  29641. */
  29642. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29643. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29644. /**
  29645. * Bind a webGL buffer to the webGL context
  29646. * @param buffer defines the buffer to bind
  29647. */
  29648. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29649. private bindIndexBuffer;
  29650. private bindBuffer;
  29651. /**
  29652. * update the bound buffer with the given data
  29653. * @param data defines the data to update
  29654. */
  29655. updateArrayBuffer(data: Float32Array): void;
  29656. private _vertexAttribPointer;
  29657. private _bindIndexBufferWithCache;
  29658. private _bindVertexBuffersAttributes;
  29659. /**
  29660. * Records a vertex array object
  29661. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29662. * @param vertexBuffers defines the list of vertex buffers to store
  29663. * @param indexBuffer defines the index buffer to store
  29664. * @param effect defines the effect to store
  29665. * @returns the new vertex array object
  29666. */
  29667. recordVertexArrayObject(vertexBuffers: {
  29668. [key: string]: VertexBuffer;
  29669. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29670. /**
  29671. * Bind a specific vertex array object
  29672. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29673. * @param vertexArrayObject defines the vertex array object to bind
  29674. * @param indexBuffer defines the index buffer to bind
  29675. */
  29676. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29677. /**
  29678. * Bind webGl buffers directly to the webGL context
  29679. * @param vertexBuffer defines the vertex buffer to bind
  29680. * @param indexBuffer defines the index buffer to bind
  29681. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29682. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29683. * @param effect defines the effect associated with the vertex buffer
  29684. */
  29685. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29686. private _unbindVertexArrayObject;
  29687. /**
  29688. * Bind a list of vertex buffers to the webGL context
  29689. * @param vertexBuffers defines the list of vertex buffers to bind
  29690. * @param indexBuffer defines the index buffer to bind
  29691. * @param effect defines the effect associated with the vertex buffers
  29692. */
  29693. bindBuffers(vertexBuffers: {
  29694. [key: string]: Nullable<VertexBuffer>;
  29695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29696. /**
  29697. * Unbind all instance attributes
  29698. */
  29699. unbindInstanceAttributes(): void;
  29700. /**
  29701. * Release and free the memory of a vertex array object
  29702. * @param vao defines the vertex array object to delete
  29703. */
  29704. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29705. /** @hidden */
  29706. _releaseBuffer(buffer: DataBuffer): boolean;
  29707. protected _deleteBuffer(buffer: DataBuffer): void;
  29708. /**
  29709. * Creates a webGL buffer to use with instanciation
  29710. * @param capacity defines the size of the buffer
  29711. * @returns the webGL buffer
  29712. */
  29713. createInstancesBuffer(capacity: number): DataBuffer;
  29714. /**
  29715. * Delete a webGL buffer used with instanciation
  29716. * @param buffer defines the webGL buffer to delete
  29717. */
  29718. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29719. /**
  29720. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29721. * @param instancesBuffer defines the webGL buffer to update and bind
  29722. * @param data defines the data to store in the buffer
  29723. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29724. */
  29725. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29726. /**
  29727. * Apply all cached states (depth, culling, stencil and alpha)
  29728. */
  29729. applyStates(): void;
  29730. /**
  29731. * Send a draw order
  29732. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29733. * @param indexStart defines the starting index
  29734. * @param indexCount defines the number of index to draw
  29735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29736. */
  29737. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29738. /**
  29739. * Draw a list of points
  29740. * @param verticesStart defines the index of first vertex to draw
  29741. * @param verticesCount defines the count of vertices to draw
  29742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29743. */
  29744. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29745. /**
  29746. * Draw a list of unindexed primitives
  29747. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29748. * @param verticesStart defines the index of first vertex to draw
  29749. * @param verticesCount defines the count of vertices to draw
  29750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29751. */
  29752. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29753. /**
  29754. * Draw a list of indexed primitives
  29755. * @param fillMode defines the primitive to use
  29756. * @param indexStart defines the starting index
  29757. * @param indexCount defines the number of index to draw
  29758. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29759. */
  29760. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29761. /**
  29762. * Draw a list of unindexed primitives
  29763. * @param fillMode defines the primitive to use
  29764. * @param verticesStart defines the index of first vertex to draw
  29765. * @param verticesCount defines the count of vertices to draw
  29766. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29767. */
  29768. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29769. private _drawMode;
  29770. /** @hidden */
  29771. _releaseEffect(effect: Effect): void;
  29772. /** @hidden */
  29773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29774. /**
  29775. * Create a new effect (used to store vertex/fragment shaders)
  29776. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29777. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29778. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29779. * @param samplers defines an array of string used to represent textures
  29780. * @param defines defines the string containing the defines to use to compile the shaders
  29781. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29782. * @param onCompiled defines a function to call when the effect creation is successful
  29783. * @param onError defines a function to call when the effect creation has failed
  29784. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29785. * @returns the new Effect
  29786. */
  29787. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29788. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29789. private _compileShader;
  29790. private _compileRawShader;
  29791. /**
  29792. * Directly creates a webGL program
  29793. * @param pipelineContext defines the pipeline context to attach to
  29794. * @param vertexCode defines the vertex shader code to use
  29795. * @param fragmentCode defines the fragment shader code to use
  29796. * @param context defines the webGL context to use (if not set, the current one will be used)
  29797. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29798. * @returns the new webGL program
  29799. */
  29800. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29801. /**
  29802. * Creates a webGL program
  29803. * @param pipelineContext defines the pipeline context to attach to
  29804. * @param vertexCode defines the vertex shader code to use
  29805. * @param fragmentCode defines the fragment shader code to use
  29806. * @param defines defines the string containing the defines to use to compile the shaders
  29807. * @param context defines the webGL context to use (if not set, the current one will be used)
  29808. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29809. * @returns the new webGL program
  29810. */
  29811. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29812. /**
  29813. * Creates a new pipeline context
  29814. * @returns the new pipeline
  29815. */
  29816. createPipelineContext(): IPipelineContext;
  29817. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29818. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29819. /** @hidden */
  29820. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29821. /** @hidden */
  29822. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29823. /** @hidden */
  29824. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29825. /**
  29826. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29827. * @param pipelineContext defines the pipeline context to use
  29828. * @param uniformsNames defines the list of uniform names
  29829. * @returns an array of webGL uniform locations
  29830. */
  29831. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29832. /**
  29833. * Gets the lsit of active attributes for a given webGL program
  29834. * @param pipelineContext defines the pipeline context to use
  29835. * @param attributesNames defines the list of attribute names to get
  29836. * @returns an array of indices indicating the offset of each attribute
  29837. */
  29838. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29839. /**
  29840. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29841. * @param effect defines the effect to activate
  29842. */
  29843. enableEffect(effect: Nullable<Effect>): void;
  29844. /**
  29845. * Set the value of an uniform to an array of int32
  29846. * @param uniform defines the webGL uniform location where to store the value
  29847. * @param array defines the array of int32 to store
  29848. */
  29849. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29850. /**
  29851. * Set the value of an uniform to an array of int32 (stored as vec2)
  29852. * @param uniform defines the webGL uniform location where to store the value
  29853. * @param array defines the array of int32 to store
  29854. */
  29855. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29856. /**
  29857. * Set the value of an uniform to an array of int32 (stored as vec3)
  29858. * @param uniform defines the webGL uniform location where to store the value
  29859. * @param array defines the array of int32 to store
  29860. */
  29861. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29862. /**
  29863. * Set the value of an uniform to an array of int32 (stored as vec4)
  29864. * @param uniform defines the webGL uniform location where to store the value
  29865. * @param array defines the array of int32 to store
  29866. */
  29867. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29868. /**
  29869. * Set the value of an uniform to an array of float32
  29870. * @param uniform defines the webGL uniform location where to store the value
  29871. * @param array defines the array of float32 to store
  29872. */
  29873. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29874. /**
  29875. * Set the value of an uniform to an array of float32 (stored as vec2)
  29876. * @param uniform defines the webGL uniform location where to store the value
  29877. * @param array defines the array of float32 to store
  29878. */
  29879. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29880. /**
  29881. * Set the value of an uniform to an array of float32 (stored as vec3)
  29882. * @param uniform defines the webGL uniform location where to store the value
  29883. * @param array defines the array of float32 to store
  29884. */
  29885. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29886. /**
  29887. * Set the value of an uniform to an array of float32 (stored as vec4)
  29888. * @param uniform defines the webGL uniform location where to store the value
  29889. * @param array defines the array of float32 to store
  29890. */
  29891. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29892. /**
  29893. * Set the value of an uniform to an array of number
  29894. * @param uniform defines the webGL uniform location where to store the value
  29895. * @param array defines the array of number to store
  29896. */
  29897. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29898. /**
  29899. * Set the value of an uniform to an array of number (stored as vec2)
  29900. * @param uniform defines the webGL uniform location where to store the value
  29901. * @param array defines the array of number to store
  29902. */
  29903. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29904. /**
  29905. * Set the value of an uniform to an array of number (stored as vec3)
  29906. * @param uniform defines the webGL uniform location where to store the value
  29907. * @param array defines the array of number to store
  29908. */
  29909. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29910. /**
  29911. * Set the value of an uniform to an array of number (stored as vec4)
  29912. * @param uniform defines the webGL uniform location where to store the value
  29913. * @param array defines the array of number to store
  29914. */
  29915. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29916. /**
  29917. * Set the value of an uniform to an array of float32 (stored as matrices)
  29918. * @param uniform defines the webGL uniform location where to store the value
  29919. * @param matrices defines the array of float32 to store
  29920. */
  29921. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29922. /**
  29923. * Set the value of an uniform to a matrix (3x3)
  29924. * @param uniform defines the webGL uniform location where to store the value
  29925. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29926. */
  29927. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29928. /**
  29929. * Set the value of an uniform to a matrix (2x2)
  29930. * @param uniform defines the webGL uniform location where to store the value
  29931. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29932. */
  29933. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29934. /**
  29935. * Set the value of an uniform to a number (int)
  29936. * @param uniform defines the webGL uniform location where to store the value
  29937. * @param value defines the int number to store
  29938. */
  29939. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29940. /**
  29941. * Set the value of an uniform to a number (float)
  29942. * @param uniform defines the webGL uniform location where to store the value
  29943. * @param value defines the float number to store
  29944. */
  29945. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29946. /**
  29947. * Set the value of an uniform to a vec2
  29948. * @param uniform defines the webGL uniform location where to store the value
  29949. * @param x defines the 1st component of the value
  29950. * @param y defines the 2nd component of the value
  29951. */
  29952. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29953. /**
  29954. * Set the value of an uniform to a vec3
  29955. * @param uniform defines the webGL uniform location where to store the value
  29956. * @param x defines the 1st component of the value
  29957. * @param y defines the 2nd component of the value
  29958. * @param z defines the 3rd component of the value
  29959. */
  29960. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29961. /**
  29962. * Set the value of an uniform to a boolean
  29963. * @param uniform defines the webGL uniform location where to store the value
  29964. * @param bool defines the boolean to store
  29965. */
  29966. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29967. /**
  29968. * Set the value of an uniform to a vec4
  29969. * @param uniform defines the webGL uniform location where to store the value
  29970. * @param x defines the 1st component of the value
  29971. * @param y defines the 2nd component of the value
  29972. * @param z defines the 3rd component of the value
  29973. * @param w defines the 4th component of the value
  29974. */
  29975. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29976. /**
  29977. * Sets a Color4 on a uniform variable
  29978. * @param uniform defines the uniform location
  29979. * @param color4 defines the value to be set
  29980. */
  29981. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29982. /**
  29983. * Gets the depth culling state manager
  29984. */
  29985. readonly depthCullingState: DepthCullingState;
  29986. /**
  29987. * Gets the alpha state manager
  29988. */
  29989. readonly alphaState: AlphaState;
  29990. /**
  29991. * Gets the stencil state manager
  29992. */
  29993. readonly stencilState: StencilState;
  29994. /**
  29995. * Clears the list of texture accessible through engine.
  29996. * This can help preventing texture load conflict due to name collision.
  29997. */
  29998. clearInternalTexturesCache(): void;
  29999. /**
  30000. * Force the entire cache to be cleared
  30001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30003. */
  30004. wipeCaches(bruteForce?: boolean): void;
  30005. /** @hidden */
  30006. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30007. min: number;
  30008. mag: number;
  30009. };
  30010. /** @hidden */
  30011. _createTexture(): WebGLTexture;
  30012. /**
  30013. * Usually called from Texture.ts.
  30014. * Passed information to create a WebGLTexture
  30015. * @param urlArg defines a value which contains one of the following:
  30016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30020. * @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)
  30021. * @param scene needed for loading to the correct scene
  30022. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30023. * @param onLoad optional callback to be called upon successful completion
  30024. * @param onError optional callback to be called upon failure
  30025. * @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
  30026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30028. * @param forcedExtension defines the extension to use to pick the right loader
  30029. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30030. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30031. */
  30032. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30033. /**
  30034. * @hidden
  30035. */
  30036. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30037. /**
  30038. * Creates a raw texture
  30039. * @param data defines the data to store in the texture
  30040. * @param width defines the width of the texture
  30041. * @param height defines the height of the texture
  30042. * @param format defines the format of the data
  30043. * @param generateMipMaps defines if the engine should generate the mip levels
  30044. * @param invertY defines if data must be stored with Y axis inverted
  30045. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30046. * @param compression defines the compression used (null by default)
  30047. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30048. * @returns the raw texture inside an InternalTexture
  30049. */
  30050. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30051. /**
  30052. * Creates a new raw cube texture
  30053. * @param data defines the array of data to use to create each face
  30054. * @param size defines the size of the textures
  30055. * @param format defines the format of the data
  30056. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30057. * @param generateMipMaps defines if the engine should generate the mip levels
  30058. * @param invertY defines if data must be stored with Y axis inverted
  30059. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30060. * @param compression defines the compression used (null by default)
  30061. * @returns the cube texture as an InternalTexture
  30062. */
  30063. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30064. /**
  30065. * Creates a new raw 3D texture
  30066. * @param data defines the data used to create the texture
  30067. * @param width defines the width of the texture
  30068. * @param height defines the height of the texture
  30069. * @param depth defines the depth of the texture
  30070. * @param format defines the format of the texture
  30071. * @param generateMipMaps defines if the engine must generate mip levels
  30072. * @param invertY defines if data must be stored with Y axis inverted
  30073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30074. * @param compression defines the compressed used (can be null)
  30075. * @param textureType defines the compressed used (can be null)
  30076. * @returns a new raw 3D texture (stored in an InternalTexture)
  30077. */
  30078. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30079. private _unpackFlipYCached;
  30080. /**
  30081. * In case you are sharing the context with other applications, it might
  30082. * be interested to not cache the unpack flip y state to ensure a consistent
  30083. * value would be set.
  30084. */
  30085. enableUnpackFlipYCached: boolean;
  30086. /** @hidden */
  30087. _unpackFlipY(value: boolean): void;
  30088. /** @hidden */
  30089. _getUnpackAlignement(): number;
  30090. /**
  30091. * Update the sampling mode of a given texture
  30092. * @param samplingMode defines the required sampling mode
  30093. * @param texture defines the texture to update
  30094. */
  30095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30096. /**
  30097. * Updates a depth texture Comparison Mode and Function.
  30098. * If the comparison Function is equal to 0, the mode will be set to none.
  30099. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30100. * @param texture The texture to set the comparison function for
  30101. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30102. */
  30103. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30104. /** @hidden */
  30105. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30106. width: number;
  30107. height: number;
  30108. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30109. /**
  30110. * Creates a depth stencil texture.
  30111. * This is only available in WebGL 2 or with the depth texture extension available.
  30112. * @param size The size of face edge in the texture.
  30113. * @param options The options defining the texture.
  30114. * @returns The texture
  30115. */
  30116. createDepthStencilTexture(size: number | {
  30117. width: number;
  30118. height: number;
  30119. }, options: DepthTextureCreationOptions): InternalTexture;
  30120. /**
  30121. * Creates a depth stencil texture.
  30122. * This is only available in WebGL 2 or with the depth texture extension available.
  30123. * @param size The size of face edge in the texture.
  30124. * @param options The options defining the texture.
  30125. * @returns The texture
  30126. */
  30127. private _createDepthStencilTexture;
  30128. /**
  30129. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30130. * @param renderTarget The render target to set the frame buffer for
  30131. */
  30132. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30133. /** @hidden */
  30134. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30135. /** @hidden */
  30136. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30137. /** @hidden */
  30138. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30139. /** @hidden */
  30140. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30141. /** @hidden */
  30142. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30143. /**
  30144. * @hidden
  30145. */
  30146. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30147. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30148. private _prepareWebGLTexture;
  30149. /** @hidden */
  30150. _releaseFramebufferObjects(texture: InternalTexture): void;
  30151. /** @hidden */
  30152. _releaseTexture(texture: InternalTexture): void;
  30153. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30154. protected _setProgram(program: WebGLProgram): void;
  30155. protected _boundUniforms: {
  30156. [key: number]: WebGLUniformLocation;
  30157. };
  30158. /**
  30159. * Binds an effect to the webGL context
  30160. * @param effect defines the effect to bind
  30161. */
  30162. bindSamplers(effect: Effect): void;
  30163. private _activateCurrentTexture;
  30164. /** @hidden */
  30165. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30166. /** @hidden */
  30167. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30168. /**
  30169. * Unbind all textures from the webGL context
  30170. */
  30171. unbindAllTextures(): void;
  30172. /**
  30173. * Sets a texture to the according uniform.
  30174. * @param channel The texture channel
  30175. * @param uniform The uniform to set
  30176. * @param texture The texture to apply
  30177. */
  30178. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30179. private _bindSamplerUniformToChannel;
  30180. private _getTextureWrapMode;
  30181. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30182. /**
  30183. * Sets an array of texture to the webGL context
  30184. * @param channel defines the channel where the texture array must be set
  30185. * @param uniform defines the associated uniform location
  30186. * @param textures defines the array of textures to bind
  30187. */
  30188. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30189. /** @hidden */
  30190. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30191. private _setTextureParameterFloat;
  30192. private _setTextureParameterInteger;
  30193. /**
  30194. * Unbind all vertex attributes from the webGL context
  30195. */
  30196. unbindAllAttributes(): void;
  30197. /**
  30198. * 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
  30199. */
  30200. releaseEffects(): void;
  30201. /**
  30202. * Dispose and release all associated resources
  30203. */
  30204. dispose(): void;
  30205. /**
  30206. * Attach a new callback raised when context lost event is fired
  30207. * @param callback defines the callback to call
  30208. */
  30209. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30210. /**
  30211. * Attach a new callback raised when context restored event is fired
  30212. * @param callback defines the callback to call
  30213. */
  30214. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30215. /**
  30216. * Get the current error code of the webGL context
  30217. * @returns the error code
  30218. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30219. */
  30220. getError(): number;
  30221. private _canRenderToFloatFramebuffer;
  30222. private _canRenderToHalfFloatFramebuffer;
  30223. private _canRenderToFramebuffer;
  30224. /** @hidden */
  30225. _getWebGLTextureType(type: number): number;
  30226. /** @hidden */
  30227. _getInternalFormat(format: number): number;
  30228. /** @hidden */
  30229. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30230. /** @hidden */
  30231. _getRGBAMultiSampleBufferFormat(type: number): number;
  30232. /** @hidden */
  30233. _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;
  30234. /**
  30235. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30236. * @returns true if the engine can be created
  30237. * @ignorenaming
  30238. */
  30239. static isSupported(): boolean;
  30240. /**
  30241. * Find the next highest power of two.
  30242. * @param x Number to start search from.
  30243. * @return Next highest power of two.
  30244. */
  30245. static CeilingPOT(x: number): number;
  30246. /**
  30247. * Find the next lowest power of two.
  30248. * @param x Number to start search from.
  30249. * @return Next lowest power of two.
  30250. */
  30251. static FloorPOT(x: number): number;
  30252. /**
  30253. * Find the nearest power of two.
  30254. * @param x Number to start search from.
  30255. * @return Next nearest power of two.
  30256. */
  30257. static NearestPOT(x: number): number;
  30258. /**
  30259. * Get the closest exponent of two
  30260. * @param value defines the value to approximate
  30261. * @param max defines the maximum value to return
  30262. * @param mode defines how to define the closest value
  30263. * @returns closest exponent of two of the given value
  30264. */
  30265. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30266. /**
  30267. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30268. * @param func - the function to be called
  30269. * @param requester - the object that will request the next frame. Falls back to window.
  30270. * @returns frame number
  30271. */
  30272. static QueueNewFrame(func: () => void, requester?: any): number;
  30273. }
  30274. }
  30275. declare module BABYLON {
  30276. /**
  30277. * Class used to store data associated with WebGL texture data for the engine
  30278. * This class should not be used directly
  30279. */
  30280. export class InternalTexture {
  30281. /** @hidden */
  30282. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30283. /**
  30284. * The source of the texture data is unknown
  30285. */
  30286. static DATASOURCE_UNKNOWN: number;
  30287. /**
  30288. * Texture data comes from an URL
  30289. */
  30290. static DATASOURCE_URL: number;
  30291. /**
  30292. * Texture data is only used for temporary storage
  30293. */
  30294. static DATASOURCE_TEMP: number;
  30295. /**
  30296. * Texture data comes from raw data (ArrayBuffer)
  30297. */
  30298. static DATASOURCE_RAW: number;
  30299. /**
  30300. * Texture content is dynamic (video or dynamic texture)
  30301. */
  30302. static DATASOURCE_DYNAMIC: number;
  30303. /**
  30304. * Texture content is generated by rendering to it
  30305. */
  30306. static DATASOURCE_RENDERTARGET: number;
  30307. /**
  30308. * Texture content is part of a multi render target process
  30309. */
  30310. static DATASOURCE_MULTIRENDERTARGET: number;
  30311. /**
  30312. * Texture data comes from a cube data file
  30313. */
  30314. static DATASOURCE_CUBE: number;
  30315. /**
  30316. * Texture data comes from a raw cube data
  30317. */
  30318. static DATASOURCE_CUBERAW: number;
  30319. /**
  30320. * Texture data come from a prefiltered cube data file
  30321. */
  30322. static DATASOURCE_CUBEPREFILTERED: number;
  30323. /**
  30324. * Texture content is raw 3D data
  30325. */
  30326. static DATASOURCE_RAW3D: number;
  30327. /**
  30328. * Texture content is a depth texture
  30329. */
  30330. static DATASOURCE_DEPTHTEXTURE: number;
  30331. /**
  30332. * Texture data comes from a raw cube data encoded with RGBD
  30333. */
  30334. static DATASOURCE_CUBERAW_RGBD: number;
  30335. /**
  30336. * Defines if the texture is ready
  30337. */
  30338. isReady: boolean;
  30339. /**
  30340. * Defines if the texture is a cube texture
  30341. */
  30342. isCube: boolean;
  30343. /**
  30344. * Defines if the texture contains 3D data
  30345. */
  30346. is3D: boolean;
  30347. /**
  30348. * Defines if the texture contains multiview data
  30349. */
  30350. isMultiview: boolean;
  30351. /**
  30352. * Gets the URL used to load this texture
  30353. */
  30354. url: string;
  30355. /**
  30356. * Gets the sampling mode of the texture
  30357. */
  30358. samplingMode: number;
  30359. /**
  30360. * Gets a boolean indicating if the texture needs mipmaps generation
  30361. */
  30362. generateMipMaps: boolean;
  30363. /**
  30364. * Gets the number of samples used by the texture (WebGL2+ only)
  30365. */
  30366. samples: number;
  30367. /**
  30368. * Gets the type of the texture (int, float...)
  30369. */
  30370. type: number;
  30371. /**
  30372. * Gets the format of the texture (RGB, RGBA...)
  30373. */
  30374. format: number;
  30375. /**
  30376. * Observable called when the texture is loaded
  30377. */
  30378. onLoadedObservable: Observable<InternalTexture>;
  30379. /**
  30380. * Gets the width of the texture
  30381. */
  30382. width: number;
  30383. /**
  30384. * Gets the height of the texture
  30385. */
  30386. height: number;
  30387. /**
  30388. * Gets the depth of the texture
  30389. */
  30390. depth: number;
  30391. /**
  30392. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30393. */
  30394. baseWidth: number;
  30395. /**
  30396. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30397. */
  30398. baseHeight: number;
  30399. /**
  30400. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30401. */
  30402. baseDepth: number;
  30403. /**
  30404. * Gets a boolean indicating if the texture is inverted on Y axis
  30405. */
  30406. invertY: boolean;
  30407. /** @hidden */
  30408. _invertVScale: boolean;
  30409. /** @hidden */
  30410. _associatedChannel: number;
  30411. /** @hidden */
  30412. _dataSource: number;
  30413. /** @hidden */
  30414. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30415. /** @hidden */
  30416. _bufferView: Nullable<ArrayBufferView>;
  30417. /** @hidden */
  30418. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30419. /** @hidden */
  30420. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30421. /** @hidden */
  30422. _size: number;
  30423. /** @hidden */
  30424. _extension: string;
  30425. /** @hidden */
  30426. _files: Nullable<string[]>;
  30427. /** @hidden */
  30428. _workingCanvas: Nullable<HTMLCanvasElement>;
  30429. /** @hidden */
  30430. _workingContext: Nullable<CanvasRenderingContext2D>;
  30431. /** @hidden */
  30432. _framebuffer: Nullable<WebGLFramebuffer>;
  30433. /** @hidden */
  30434. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30435. /** @hidden */
  30436. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30437. /** @hidden */
  30438. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30439. /** @hidden */
  30440. _attachments: Nullable<number[]>;
  30441. /** @hidden */
  30442. _cachedCoordinatesMode: Nullable<number>;
  30443. /** @hidden */
  30444. _cachedWrapU: Nullable<number>;
  30445. /** @hidden */
  30446. _cachedWrapV: Nullable<number>;
  30447. /** @hidden */
  30448. _cachedWrapR: Nullable<number>;
  30449. /** @hidden */
  30450. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30451. /** @hidden */
  30452. _isDisabled: boolean;
  30453. /** @hidden */
  30454. _compression: Nullable<string>;
  30455. /** @hidden */
  30456. _generateStencilBuffer: boolean;
  30457. /** @hidden */
  30458. _generateDepthBuffer: boolean;
  30459. /** @hidden */
  30460. _comparisonFunction: number;
  30461. /** @hidden */
  30462. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30463. /** @hidden */
  30464. _lodGenerationScale: number;
  30465. /** @hidden */
  30466. _lodGenerationOffset: number;
  30467. /** @hidden */
  30468. _colorTextureArray: Nullable<WebGLTexture>;
  30469. /** @hidden */
  30470. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30471. /** @hidden */
  30472. _lodTextureHigh: Nullable<BaseTexture>;
  30473. /** @hidden */
  30474. _lodTextureMid: Nullable<BaseTexture>;
  30475. /** @hidden */
  30476. _lodTextureLow: Nullable<BaseTexture>;
  30477. /** @hidden */
  30478. _isRGBD: boolean;
  30479. /** @hidden */
  30480. _linearSpecularLOD: boolean;
  30481. /** @hidden */
  30482. _irradianceTexture: Nullable<BaseTexture>;
  30483. /** @hidden */
  30484. _webGLTexture: Nullable<WebGLTexture>;
  30485. /** @hidden */
  30486. _references: number;
  30487. private _engine;
  30488. /**
  30489. * Gets the Engine the texture belongs to.
  30490. * @returns The babylon engine
  30491. */
  30492. getEngine(): ThinEngine;
  30493. /**
  30494. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30495. */
  30496. readonly dataSource: number;
  30497. /**
  30498. * Creates a new InternalTexture
  30499. * @param engine defines the engine to use
  30500. * @param dataSource defines the type of data that will be used
  30501. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30502. */
  30503. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  30504. /**
  30505. * Increments the number of references (ie. the number of Texture that point to it)
  30506. */
  30507. incrementReferences(): void;
  30508. /**
  30509. * Change the size of the texture (not the size of the content)
  30510. * @param width defines the new width
  30511. * @param height defines the new height
  30512. * @param depth defines the new depth (1 by default)
  30513. */
  30514. updateSize(width: int, height: int, depth?: int): void;
  30515. /** @hidden */
  30516. _rebuild(): void;
  30517. /** @hidden */
  30518. _swapAndDie(target: InternalTexture): void;
  30519. /**
  30520. * Dispose the current allocated resources
  30521. */
  30522. dispose(): void;
  30523. }
  30524. }
  30525. declare module BABYLON {
  30526. /**
  30527. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30529. */
  30530. export class Analyser {
  30531. /**
  30532. * Gets or sets the smoothing
  30533. * @ignorenaming
  30534. */
  30535. SMOOTHING: number;
  30536. /**
  30537. * Gets or sets the FFT table size
  30538. * @ignorenaming
  30539. */
  30540. FFT_SIZE: number;
  30541. /**
  30542. * Gets or sets the bar graph amplitude
  30543. * @ignorenaming
  30544. */
  30545. BARGRAPHAMPLITUDE: number;
  30546. /**
  30547. * Gets or sets the position of the debug canvas
  30548. * @ignorenaming
  30549. */
  30550. DEBUGCANVASPOS: {
  30551. x: number;
  30552. y: number;
  30553. };
  30554. /**
  30555. * Gets or sets the debug canvas size
  30556. * @ignorenaming
  30557. */
  30558. DEBUGCANVASSIZE: {
  30559. width: number;
  30560. height: number;
  30561. };
  30562. private _byteFreqs;
  30563. private _byteTime;
  30564. private _floatFreqs;
  30565. private _webAudioAnalyser;
  30566. private _debugCanvas;
  30567. private _debugCanvasContext;
  30568. private _scene;
  30569. private _registerFunc;
  30570. private _audioEngine;
  30571. /**
  30572. * Creates a new analyser
  30573. * @param scene defines hosting scene
  30574. */
  30575. constructor(scene: Scene);
  30576. /**
  30577. * Get the number of data values you will have to play with for the visualization
  30578. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30579. * @returns a number
  30580. */
  30581. getFrequencyBinCount(): number;
  30582. /**
  30583. * Gets the current frequency data as a byte array
  30584. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30585. * @returns a Uint8Array
  30586. */
  30587. getByteFrequencyData(): Uint8Array;
  30588. /**
  30589. * Gets the current waveform as a byte array
  30590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30591. * @returns a Uint8Array
  30592. */
  30593. getByteTimeDomainData(): Uint8Array;
  30594. /**
  30595. * Gets the current frequency data as a float array
  30596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30597. * @returns a Float32Array
  30598. */
  30599. getFloatFrequencyData(): Float32Array;
  30600. /**
  30601. * Renders the debug canvas
  30602. */
  30603. drawDebugCanvas(): void;
  30604. /**
  30605. * Stops rendering the debug canvas and removes it
  30606. */
  30607. stopDebugCanvas(): void;
  30608. /**
  30609. * Connects two audio nodes
  30610. * @param inputAudioNode defines first node to connect
  30611. * @param outputAudioNode defines second node to connect
  30612. */
  30613. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30614. /**
  30615. * Releases all associated resources
  30616. */
  30617. dispose(): void;
  30618. }
  30619. }
  30620. declare module BABYLON {
  30621. /**
  30622. * This represents an audio engine and it is responsible
  30623. * to play, synchronize and analyse sounds throughout the application.
  30624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30625. */
  30626. export interface IAudioEngine extends IDisposable {
  30627. /**
  30628. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30629. */
  30630. readonly canUseWebAudio: boolean;
  30631. /**
  30632. * Gets the current AudioContext if available.
  30633. */
  30634. readonly audioContext: Nullable<AudioContext>;
  30635. /**
  30636. * The master gain node defines the global audio volume of your audio engine.
  30637. */
  30638. readonly masterGain: GainNode;
  30639. /**
  30640. * Gets whether or not mp3 are supported by your browser.
  30641. */
  30642. readonly isMP3supported: boolean;
  30643. /**
  30644. * Gets whether or not ogg are supported by your browser.
  30645. */
  30646. readonly isOGGsupported: boolean;
  30647. /**
  30648. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30649. * @ignoreNaming
  30650. */
  30651. WarnedWebAudioUnsupported: boolean;
  30652. /**
  30653. * Defines if the audio engine relies on a custom unlocked button.
  30654. * In this case, the embedded button will not be displayed.
  30655. */
  30656. useCustomUnlockedButton: boolean;
  30657. /**
  30658. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30659. */
  30660. readonly unlocked: boolean;
  30661. /**
  30662. * Event raised when audio has been unlocked on the browser.
  30663. */
  30664. onAudioUnlockedObservable: Observable<AudioEngine>;
  30665. /**
  30666. * Event raised when audio has been locked on the browser.
  30667. */
  30668. onAudioLockedObservable: Observable<AudioEngine>;
  30669. /**
  30670. * Flags the audio engine in Locked state.
  30671. * This happens due to new browser policies preventing audio to autoplay.
  30672. */
  30673. lock(): void;
  30674. /**
  30675. * Unlocks the audio engine once a user action has been done on the dom.
  30676. * This is helpful to resume play once browser policies have been satisfied.
  30677. */
  30678. unlock(): void;
  30679. }
  30680. /**
  30681. * This represents the default audio engine used in babylon.
  30682. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30684. */
  30685. export class AudioEngine implements IAudioEngine {
  30686. private _audioContext;
  30687. private _audioContextInitialized;
  30688. private _muteButton;
  30689. private _hostElement;
  30690. /**
  30691. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30692. */
  30693. canUseWebAudio: boolean;
  30694. /**
  30695. * The master gain node defines the global audio volume of your audio engine.
  30696. */
  30697. masterGain: GainNode;
  30698. /**
  30699. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30700. * @ignoreNaming
  30701. */
  30702. WarnedWebAudioUnsupported: boolean;
  30703. /**
  30704. * Gets whether or not mp3 are supported by your browser.
  30705. */
  30706. isMP3supported: boolean;
  30707. /**
  30708. * Gets whether or not ogg are supported by your browser.
  30709. */
  30710. isOGGsupported: boolean;
  30711. /**
  30712. * Gets whether audio has been unlocked on the device.
  30713. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30714. * a user interaction has happened.
  30715. */
  30716. unlocked: boolean;
  30717. /**
  30718. * Defines if the audio engine relies on a custom unlocked button.
  30719. * In this case, the embedded button will not be displayed.
  30720. */
  30721. useCustomUnlockedButton: boolean;
  30722. /**
  30723. * Event raised when audio has been unlocked on the browser.
  30724. */
  30725. onAudioUnlockedObservable: Observable<AudioEngine>;
  30726. /**
  30727. * Event raised when audio has been locked on the browser.
  30728. */
  30729. onAudioLockedObservable: Observable<AudioEngine>;
  30730. /**
  30731. * Gets the current AudioContext if available.
  30732. */
  30733. readonly audioContext: Nullable<AudioContext>;
  30734. private _connectedAnalyser;
  30735. /**
  30736. * Instantiates a new audio engine.
  30737. *
  30738. * There should be only one per page as some browsers restrict the number
  30739. * of audio contexts you can create.
  30740. * @param hostElement defines the host element where to display the mute icon if necessary
  30741. */
  30742. constructor(hostElement?: Nullable<HTMLElement>);
  30743. /**
  30744. * Flags the audio engine in Locked state.
  30745. * This happens due to new browser policies preventing audio to autoplay.
  30746. */
  30747. lock(): void;
  30748. /**
  30749. * Unlocks the audio engine once a user action has been done on the dom.
  30750. * This is helpful to resume play once browser policies have been satisfied.
  30751. */
  30752. unlock(): void;
  30753. private _resumeAudioContext;
  30754. private _initializeAudioContext;
  30755. private _tryToRun;
  30756. private _triggerRunningState;
  30757. private _triggerSuspendedState;
  30758. private _displayMuteButton;
  30759. private _moveButtonToTopLeft;
  30760. private _onResize;
  30761. private _hideMuteButton;
  30762. /**
  30763. * Destroy and release the resources associated with the audio ccontext.
  30764. */
  30765. dispose(): void;
  30766. /**
  30767. * Gets the global volume sets on the master gain.
  30768. * @returns the global volume if set or -1 otherwise
  30769. */
  30770. getGlobalVolume(): number;
  30771. /**
  30772. * Sets the global volume of your experience (sets on the master gain).
  30773. * @param newVolume Defines the new global volume of the application
  30774. */
  30775. setGlobalVolume(newVolume: number): void;
  30776. /**
  30777. * Connect the audio engine to an audio analyser allowing some amazing
  30778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30780. * @param analyser The analyser to connect to the engine
  30781. */
  30782. connectToAnalyser(analyser: Analyser): void;
  30783. }
  30784. }
  30785. declare module BABYLON {
  30786. /**
  30787. * Interface used to present a loading screen while loading a scene
  30788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30789. */
  30790. export interface ILoadingScreen {
  30791. /**
  30792. * Function called to display the loading screen
  30793. */
  30794. displayLoadingUI: () => void;
  30795. /**
  30796. * Function called to hide the loading screen
  30797. */
  30798. hideLoadingUI: () => void;
  30799. /**
  30800. * Gets or sets the color to use for the background
  30801. */
  30802. loadingUIBackgroundColor: string;
  30803. /**
  30804. * Gets or sets the text to display while loading
  30805. */
  30806. loadingUIText: string;
  30807. }
  30808. /**
  30809. * Class used for the default loading screen
  30810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30811. */
  30812. export class DefaultLoadingScreen implements ILoadingScreen {
  30813. private _renderingCanvas;
  30814. private _loadingText;
  30815. private _loadingDivBackgroundColor;
  30816. private _loadingDiv;
  30817. private _loadingTextDiv;
  30818. /** Gets or sets the logo url to use for the default loading screen */
  30819. static DefaultLogoUrl: string;
  30820. /** Gets or sets the spinner url to use for the default loading screen */
  30821. static DefaultSpinnerUrl: string;
  30822. /**
  30823. * Creates a new default loading screen
  30824. * @param _renderingCanvas defines the canvas used to render the scene
  30825. * @param _loadingText defines the default text to display
  30826. * @param _loadingDivBackgroundColor defines the default background color
  30827. */
  30828. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30829. /**
  30830. * Function called to display the loading screen
  30831. */
  30832. displayLoadingUI(): void;
  30833. /**
  30834. * Function called to hide the loading screen
  30835. */
  30836. hideLoadingUI(): void;
  30837. /**
  30838. * Gets or sets the text to display while loading
  30839. */
  30840. loadingUIText: string;
  30841. /**
  30842. * Gets or sets the color to use for the background
  30843. */
  30844. loadingUIBackgroundColor: string;
  30845. private _resizeLoadingUI;
  30846. }
  30847. }
  30848. declare module BABYLON {
  30849. /**
  30850. * Interface for any object that can request an animation frame
  30851. */
  30852. export interface ICustomAnimationFrameRequester {
  30853. /**
  30854. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30855. */
  30856. renderFunction?: Function;
  30857. /**
  30858. * Called to request the next frame to render to
  30859. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30860. */
  30861. requestAnimationFrame: Function;
  30862. /**
  30863. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30864. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30865. */
  30866. requestID?: number;
  30867. }
  30868. }
  30869. declare module BABYLON {
  30870. /**
  30871. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30872. */
  30873. export class PerformanceMonitor {
  30874. private _enabled;
  30875. private _rollingFrameTime;
  30876. private _lastFrameTimeMs;
  30877. /**
  30878. * constructor
  30879. * @param frameSampleSize The number of samples required to saturate the sliding window
  30880. */
  30881. constructor(frameSampleSize?: number);
  30882. /**
  30883. * Samples current frame
  30884. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30885. */
  30886. sampleFrame(timeMs?: number): void;
  30887. /**
  30888. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30889. */
  30890. readonly averageFrameTime: number;
  30891. /**
  30892. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30893. */
  30894. readonly averageFrameTimeVariance: number;
  30895. /**
  30896. * Returns the frame time of the most recent frame
  30897. */
  30898. readonly instantaneousFrameTime: number;
  30899. /**
  30900. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30901. */
  30902. readonly averageFPS: number;
  30903. /**
  30904. * Returns the average framerate in frames per second using the most recent frame time
  30905. */
  30906. readonly instantaneousFPS: number;
  30907. /**
  30908. * Returns true if enough samples have been taken to completely fill the sliding window
  30909. */
  30910. readonly isSaturated: boolean;
  30911. /**
  30912. * Enables contributions to the sliding window sample set
  30913. */
  30914. enable(): void;
  30915. /**
  30916. * Disables contributions to the sliding window sample set
  30917. * Samples will not be interpolated over the disabled period
  30918. */
  30919. disable(): void;
  30920. /**
  30921. * Returns true if sampling is enabled
  30922. */
  30923. readonly isEnabled: boolean;
  30924. /**
  30925. * Resets performance monitor
  30926. */
  30927. reset(): void;
  30928. }
  30929. /**
  30930. * RollingAverage
  30931. *
  30932. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30933. */
  30934. export class RollingAverage {
  30935. /**
  30936. * Current average
  30937. */
  30938. average: number;
  30939. /**
  30940. * Current variance
  30941. */
  30942. variance: number;
  30943. protected _samples: Array<number>;
  30944. protected _sampleCount: number;
  30945. protected _pos: number;
  30946. protected _m2: number;
  30947. /**
  30948. * constructor
  30949. * @param length The number of samples required to saturate the sliding window
  30950. */
  30951. constructor(length: number);
  30952. /**
  30953. * Adds a sample to the sample set
  30954. * @param v The sample value
  30955. */
  30956. add(v: number): void;
  30957. /**
  30958. * Returns previously added values or null if outside of history or outside the sliding window domain
  30959. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30960. * @return Value previously recorded with add() or null if outside of range
  30961. */
  30962. history(i: number): number;
  30963. /**
  30964. * Returns true if enough samples have been taken to completely fill the sliding window
  30965. * @return true if sample-set saturated
  30966. */
  30967. isSaturated(): boolean;
  30968. /**
  30969. * Resets the rolling average (equivalent to 0 samples taken so far)
  30970. */
  30971. reset(): void;
  30972. /**
  30973. * Wraps a value around the sample range boundaries
  30974. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30975. * @return Wrapped position in sample range
  30976. */
  30977. protected _wrapPosition(i: number): number;
  30978. }
  30979. }
  30980. declare module BABYLON {
  30981. /**
  30982. * Defines the interface used by display changed events
  30983. */
  30984. export interface IDisplayChangedEventArgs {
  30985. /** Gets the vrDisplay object (if any) */
  30986. vrDisplay: Nullable<any>;
  30987. /** Gets a boolean indicating if webVR is supported */
  30988. vrSupported: boolean;
  30989. }
  30990. /**
  30991. * Defines the interface used by objects containing a viewport (like a camera)
  30992. */
  30993. interface IViewportOwnerLike {
  30994. /**
  30995. * Gets or sets the viewport
  30996. */
  30997. viewport: IViewportLike;
  30998. }
  30999. /**
  31000. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31001. */
  31002. export class Engine extends ThinEngine {
  31003. /** Defines that alpha blending is disabled */
  31004. static readonly ALPHA_DISABLE: number;
  31005. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31006. static readonly ALPHA_ADD: number;
  31007. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31008. static readonly ALPHA_COMBINE: number;
  31009. /** Defines that alpha blending to DEST - SRC * DEST */
  31010. static readonly ALPHA_SUBTRACT: number;
  31011. /** Defines that alpha blending to SRC * DEST */
  31012. static readonly ALPHA_MULTIPLY: number;
  31013. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31014. static readonly ALPHA_MAXIMIZED: number;
  31015. /** Defines that alpha blending to SRC + DEST */
  31016. static readonly ALPHA_ONEONE: number;
  31017. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31018. static readonly ALPHA_PREMULTIPLIED: number;
  31019. /**
  31020. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31021. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31022. */
  31023. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31024. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31025. static readonly ALPHA_INTERPOLATE: number;
  31026. /**
  31027. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31028. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31029. */
  31030. static readonly ALPHA_SCREENMODE: number;
  31031. /** Defines that the ressource is not delayed*/
  31032. static readonly DELAYLOADSTATE_NONE: number;
  31033. /** Defines that the ressource was successfully delay loaded */
  31034. static readonly DELAYLOADSTATE_LOADED: number;
  31035. /** Defines that the ressource is currently delay loading */
  31036. static readonly DELAYLOADSTATE_LOADING: number;
  31037. /** Defines that the ressource is delayed and has not started loading */
  31038. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31039. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31040. static readonly NEVER: number;
  31041. /** 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 */
  31042. static readonly ALWAYS: number;
  31043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31044. static readonly LESS: number;
  31045. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31046. static readonly EQUAL: number;
  31047. /** 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 */
  31048. static readonly LEQUAL: number;
  31049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31050. static readonly GREATER: number;
  31051. /** 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 */
  31052. static readonly GEQUAL: number;
  31053. /** 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 */
  31054. static readonly NOTEQUAL: number;
  31055. /** Passed to stencilOperation to specify that stencil value must be kept */
  31056. static readonly KEEP: number;
  31057. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31058. static readonly REPLACE: number;
  31059. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31060. static readonly INCR: number;
  31061. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31062. static readonly DECR: number;
  31063. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31064. static readonly INVERT: number;
  31065. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31066. static readonly INCR_WRAP: number;
  31067. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31068. static readonly DECR_WRAP: number;
  31069. /** Texture is not repeating outside of 0..1 UVs */
  31070. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31071. /** Texture is repeating outside of 0..1 UVs */
  31072. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31073. /** Texture is repeating and mirrored */
  31074. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31075. /** ALPHA */
  31076. static readonly TEXTUREFORMAT_ALPHA: number;
  31077. /** LUMINANCE */
  31078. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31079. /** LUMINANCE_ALPHA */
  31080. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31081. /** RGB */
  31082. static readonly TEXTUREFORMAT_RGB: number;
  31083. /** RGBA */
  31084. static readonly TEXTUREFORMAT_RGBA: number;
  31085. /** RED */
  31086. static readonly TEXTUREFORMAT_RED: number;
  31087. /** RED (2nd reference) */
  31088. static readonly TEXTUREFORMAT_R: number;
  31089. /** RG */
  31090. static readonly TEXTUREFORMAT_RG: number;
  31091. /** RED_INTEGER */
  31092. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31093. /** RED_INTEGER (2nd reference) */
  31094. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31095. /** RG_INTEGER */
  31096. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31097. /** RGB_INTEGER */
  31098. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31099. /** RGBA_INTEGER */
  31100. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31101. /** UNSIGNED_BYTE */
  31102. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31103. /** UNSIGNED_BYTE (2nd reference) */
  31104. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31105. /** FLOAT */
  31106. static readonly TEXTURETYPE_FLOAT: number;
  31107. /** HALF_FLOAT */
  31108. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31109. /** BYTE */
  31110. static readonly TEXTURETYPE_BYTE: number;
  31111. /** SHORT */
  31112. static readonly TEXTURETYPE_SHORT: number;
  31113. /** UNSIGNED_SHORT */
  31114. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31115. /** INT */
  31116. static readonly TEXTURETYPE_INT: number;
  31117. /** UNSIGNED_INT */
  31118. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31119. /** UNSIGNED_SHORT_4_4_4_4 */
  31120. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31121. /** UNSIGNED_SHORT_5_5_5_1 */
  31122. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31123. /** UNSIGNED_SHORT_5_6_5 */
  31124. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31125. /** UNSIGNED_INT_2_10_10_10_REV */
  31126. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31127. /** UNSIGNED_INT_24_8 */
  31128. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31129. /** UNSIGNED_INT_10F_11F_11F_REV */
  31130. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31131. /** UNSIGNED_INT_5_9_9_9_REV */
  31132. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31133. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31134. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31135. /** nearest is mag = nearest and min = nearest and mip = linear */
  31136. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31137. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31138. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31139. /** Trilinear is mag = linear and min = linear and mip = linear */
  31140. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31141. /** nearest is mag = nearest and min = nearest and mip = linear */
  31142. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31143. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31144. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31145. /** Trilinear is mag = linear and min = linear and mip = linear */
  31146. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31147. /** mag = nearest and min = nearest and mip = nearest */
  31148. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31149. /** mag = nearest and min = linear and mip = nearest */
  31150. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31151. /** mag = nearest and min = linear and mip = linear */
  31152. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31153. /** mag = nearest and min = linear and mip = none */
  31154. static readonly TEXTURE_NEAREST_LINEAR: number;
  31155. /** mag = nearest and min = nearest and mip = none */
  31156. static readonly TEXTURE_NEAREST_NEAREST: number;
  31157. /** mag = linear and min = nearest and mip = nearest */
  31158. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31159. /** mag = linear and min = nearest and mip = linear */
  31160. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31161. /** mag = linear and min = linear and mip = none */
  31162. static readonly TEXTURE_LINEAR_LINEAR: number;
  31163. /** mag = linear and min = nearest and mip = none */
  31164. static readonly TEXTURE_LINEAR_NEAREST: number;
  31165. /** Explicit coordinates mode */
  31166. static readonly TEXTURE_EXPLICIT_MODE: number;
  31167. /** Spherical coordinates mode */
  31168. static readonly TEXTURE_SPHERICAL_MODE: number;
  31169. /** Planar coordinates mode */
  31170. static readonly TEXTURE_PLANAR_MODE: number;
  31171. /** Cubic coordinates mode */
  31172. static readonly TEXTURE_CUBIC_MODE: number;
  31173. /** Projection coordinates mode */
  31174. static readonly TEXTURE_PROJECTION_MODE: number;
  31175. /** Skybox coordinates mode */
  31176. static readonly TEXTURE_SKYBOX_MODE: number;
  31177. /** Inverse Cubic coordinates mode */
  31178. static readonly TEXTURE_INVCUBIC_MODE: number;
  31179. /** Equirectangular coordinates mode */
  31180. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31181. /** Equirectangular Fixed coordinates mode */
  31182. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31183. /** Equirectangular Fixed Mirrored coordinates mode */
  31184. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31185. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31186. static readonly SCALEMODE_FLOOR: number;
  31187. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31188. static readonly SCALEMODE_NEAREST: number;
  31189. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31190. static readonly SCALEMODE_CEILING: number;
  31191. /**
  31192. * Returns the current npm package of the sdk
  31193. */
  31194. static readonly NpmPackage: string;
  31195. /**
  31196. * Returns the current version of the framework
  31197. */
  31198. static readonly Version: string;
  31199. /** Gets the list of created engines */
  31200. static readonly Instances: Engine[];
  31201. /**
  31202. * Gets the latest created engine
  31203. */
  31204. static readonly LastCreatedEngine: Nullable<Engine>;
  31205. /**
  31206. * Gets the latest created scene
  31207. */
  31208. static readonly LastCreatedScene: Nullable<Scene>;
  31209. /**
  31210. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31211. * @param flag defines which part of the materials must be marked as dirty
  31212. * @param predicate defines a predicate used to filter which materials should be affected
  31213. */
  31214. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31215. /**
  31216. * Method called to create the default loading screen.
  31217. * This can be overriden in your own app.
  31218. * @param canvas The rendering canvas element
  31219. * @returns The loading screen
  31220. */
  31221. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31222. /**
  31223. * Method called to create the default rescale post process on each engine.
  31224. */
  31225. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31226. /**
  31227. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31228. **/
  31229. enableOfflineSupport: boolean;
  31230. /**
  31231. * 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)
  31232. **/
  31233. disableManifestCheck: boolean;
  31234. /**
  31235. * Gets the list of created scenes
  31236. */
  31237. scenes: Scene[];
  31238. /**
  31239. * Event raised when a new scene is created
  31240. */
  31241. onNewSceneAddedObservable: Observable<Scene>;
  31242. /**
  31243. * Gets the list of created postprocesses
  31244. */
  31245. postProcesses: PostProcess[];
  31246. /**
  31247. * Gets a boolean indicating if the pointer is currently locked
  31248. */
  31249. isPointerLock: boolean;
  31250. /**
  31251. * Observable event triggered each time the rendering canvas is resized
  31252. */
  31253. onResizeObservable: Observable<Engine>;
  31254. /**
  31255. * Observable event triggered each time the canvas loses focus
  31256. */
  31257. onCanvasBlurObservable: Observable<Engine>;
  31258. /**
  31259. * Observable event triggered each time the canvas gains focus
  31260. */
  31261. onCanvasFocusObservable: Observable<Engine>;
  31262. /**
  31263. * Observable event triggered each time the canvas receives pointerout event
  31264. */
  31265. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31266. /**
  31267. * Observable event triggered before each texture is initialized
  31268. */
  31269. onBeforeTextureInitObservable: Observable<Texture>;
  31270. /**
  31271. * Observable raised when the engine begins a new frame
  31272. */
  31273. onBeginFrameObservable: Observable<Engine>;
  31274. /**
  31275. * If set, will be used to request the next animation frame for the render loop
  31276. */
  31277. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31278. /**
  31279. * Observable raised when the engine ends the current frame
  31280. */
  31281. onEndFrameObservable: Observable<Engine>;
  31282. /**
  31283. * Observable raised when the engine is about to compile a shader
  31284. */
  31285. onBeforeShaderCompilationObservable: Observable<Engine>;
  31286. /**
  31287. * Observable raised when the engine has jsut compiled a shader
  31288. */
  31289. onAfterShaderCompilationObservable: Observable<Engine>;
  31290. /**
  31291. * Gets the audio engine
  31292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31293. * @ignorenaming
  31294. */
  31295. static audioEngine: IAudioEngine;
  31296. /**
  31297. * Default AudioEngine factory responsible of creating the Audio Engine.
  31298. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31299. */
  31300. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31301. /**
  31302. * Default offline support factory responsible of creating a tool used to store data locally.
  31303. * By default, this will create a Database object if the workload has been embedded.
  31304. */
  31305. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31306. private _loadingScreen;
  31307. private _pointerLockRequested;
  31308. private _dummyFramebuffer;
  31309. private _rescalePostProcess;
  31310. /** @hidden */
  31311. protected _alphaMode: number;
  31312. /** @hidden */
  31313. protected _alphaEquation: number;
  31314. private _deterministicLockstep;
  31315. private _lockstepMaxSteps;
  31316. protected readonly _supportsHardwareTextureRescaling: boolean;
  31317. private _fps;
  31318. private _deltaTime;
  31319. /**
  31320. * Turn this value on if you want to pause FPS computation when in background
  31321. */
  31322. disablePerformanceMonitorInBackground: boolean;
  31323. private _performanceMonitor;
  31324. /**
  31325. * Gets the performance monitor attached to this engine
  31326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31327. */
  31328. readonly performanceMonitor: PerformanceMonitor;
  31329. private _onFocus;
  31330. private _onBlur;
  31331. private _onCanvasPointerOut;
  31332. private _onCanvasBlur;
  31333. private _onCanvasFocus;
  31334. private _onFullscreenChange;
  31335. private _onPointerLockChange;
  31336. /**
  31337. * Creates a new engine
  31338. * @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
  31339. * @param antialias defines enable antialiasing (default: false)
  31340. * @param options defines further options to be sent to the getContext() function
  31341. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31342. */
  31343. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31344. /**
  31345. * Gets current aspect ratio
  31346. * @param viewportOwner defines the camera to use to get the aspect ratio
  31347. * @param useScreen defines if screen size must be used (or the current render target if any)
  31348. * @returns a number defining the aspect ratio
  31349. */
  31350. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31351. /**
  31352. * Gets current screen aspect ratio
  31353. * @returns a number defining the aspect ratio
  31354. */
  31355. getScreenAspectRatio(): number;
  31356. /**
  31357. * Gets host document
  31358. * @returns the host document object
  31359. */
  31360. getHostDocument(): Document;
  31361. /**
  31362. * Gets the client rect of the HTML canvas attached with the current webGL context
  31363. * @returns a client rectanglee
  31364. */
  31365. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31366. /**
  31367. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31369. * @returns true if engine is in deterministic lock step mode
  31370. */
  31371. isDeterministicLockStep(): boolean;
  31372. /**
  31373. * Gets the max steps when engine is running in deterministic lock step
  31374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31375. * @returns the max steps
  31376. */
  31377. getLockstepMaxSteps(): number;
  31378. /**
  31379. * Force the mipmap generation for the given render target texture
  31380. * @param texture defines the render target texture to use
  31381. */
  31382. generateMipMapsForCubemap(texture: InternalTexture): void;
  31383. /** States */
  31384. /**
  31385. * Set various states to the webGL context
  31386. * @param culling defines backface culling state
  31387. * @param zOffset defines the value to apply to zOffset (0 by default)
  31388. * @param force defines if states must be applied even if cache is up to date
  31389. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31390. */
  31391. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31392. /**
  31393. * Set the z offset to apply to current rendering
  31394. * @param value defines the offset to apply
  31395. */
  31396. setZOffset(value: number): void;
  31397. /**
  31398. * Gets the current value of the zOffset
  31399. * @returns the current zOffset state
  31400. */
  31401. getZOffset(): number;
  31402. /**
  31403. * Enable or disable depth buffering
  31404. * @param enable defines the state to set
  31405. */
  31406. setDepthBuffer(enable: boolean): void;
  31407. /**
  31408. * Gets a boolean indicating if depth writing is enabled
  31409. * @returns the current depth writing state
  31410. */
  31411. getDepthWrite(): boolean;
  31412. /**
  31413. * Enable or disable depth writing
  31414. * @param enable defines the state to set
  31415. */
  31416. setDepthWrite(enable: boolean): void;
  31417. /**
  31418. * Enable or disable color writing
  31419. * @param enable defines the state to set
  31420. */
  31421. setColorWrite(enable: boolean): void;
  31422. /**
  31423. * Gets a boolean indicating if color writing is enabled
  31424. * @returns the current color writing state
  31425. */
  31426. getColorWrite(): boolean;
  31427. /**
  31428. * Sets alpha constants used by some alpha blending modes
  31429. * @param r defines the red component
  31430. * @param g defines the green component
  31431. * @param b defines the blue component
  31432. * @param a defines the alpha component
  31433. */
  31434. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31435. /**
  31436. * Sets the current alpha mode
  31437. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31438. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31440. */
  31441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31442. /**
  31443. * Gets the current alpha mode
  31444. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31445. * @returns the current alpha mode
  31446. */
  31447. getAlphaMode(): number;
  31448. /**
  31449. * Sets the current alpha equation
  31450. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31451. */
  31452. setAlphaEquation(equation: number): void;
  31453. /**
  31454. * Gets the current alpha equation.
  31455. * @returns the current alpha equation
  31456. */
  31457. getAlphaEquation(): number;
  31458. /**
  31459. * Gets a boolean indicating if stencil buffer is enabled
  31460. * @returns the current stencil buffer state
  31461. */
  31462. getStencilBuffer(): boolean;
  31463. /**
  31464. * Enable or disable the stencil buffer
  31465. * @param enable defines if the stencil buffer must be enabled or disabled
  31466. */
  31467. setStencilBuffer(enable: boolean): void;
  31468. /**
  31469. * Gets the current stencil mask
  31470. * @returns a number defining the new stencil mask to use
  31471. */
  31472. getStencilMask(): number;
  31473. /**
  31474. * Sets the current stencil mask
  31475. * @param mask defines the new stencil mask to use
  31476. */
  31477. setStencilMask(mask: number): void;
  31478. /**
  31479. * Gets the current stencil function
  31480. * @returns a number defining the stencil function to use
  31481. */
  31482. getStencilFunction(): number;
  31483. /**
  31484. * Gets the current stencil reference value
  31485. * @returns a number defining the stencil reference value to use
  31486. */
  31487. getStencilFunctionReference(): number;
  31488. /**
  31489. * Gets the current stencil mask
  31490. * @returns a number defining the stencil mask to use
  31491. */
  31492. getStencilFunctionMask(): number;
  31493. /**
  31494. * Sets the current stencil function
  31495. * @param stencilFunc defines the new stencil function to use
  31496. */
  31497. setStencilFunction(stencilFunc: number): void;
  31498. /**
  31499. * Sets the current stencil reference
  31500. * @param reference defines the new stencil reference to use
  31501. */
  31502. setStencilFunctionReference(reference: number): void;
  31503. /**
  31504. * Sets the current stencil mask
  31505. * @param mask defines the new stencil mask to use
  31506. */
  31507. setStencilFunctionMask(mask: number): void;
  31508. /**
  31509. * Gets the current stencil operation when stencil fails
  31510. * @returns a number defining stencil operation to use when stencil fails
  31511. */
  31512. getStencilOperationFail(): number;
  31513. /**
  31514. * Gets the current stencil operation when depth fails
  31515. * @returns a number defining stencil operation to use when depth fails
  31516. */
  31517. getStencilOperationDepthFail(): number;
  31518. /**
  31519. * Gets the current stencil operation when stencil passes
  31520. * @returns a number defining stencil operation to use when stencil passes
  31521. */
  31522. getStencilOperationPass(): number;
  31523. /**
  31524. * Sets the stencil operation to use when stencil fails
  31525. * @param operation defines the stencil operation to use when stencil fails
  31526. */
  31527. setStencilOperationFail(operation: number): void;
  31528. /**
  31529. * Sets the stencil operation to use when depth fails
  31530. * @param operation defines the stencil operation to use when depth fails
  31531. */
  31532. setStencilOperationDepthFail(operation: number): void;
  31533. /**
  31534. * Sets the stencil operation to use when stencil passes
  31535. * @param operation defines the stencil operation to use when stencil passes
  31536. */
  31537. setStencilOperationPass(operation: number): void;
  31538. /**
  31539. * Sets a boolean indicating if the dithering state is enabled or disabled
  31540. * @param value defines the dithering state
  31541. */
  31542. setDitheringState(value: boolean): void;
  31543. /**
  31544. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31545. * @param value defines the rasterizer state
  31546. */
  31547. setRasterizerState(value: boolean): void;
  31548. /**
  31549. * Gets the current depth function
  31550. * @returns a number defining the depth function
  31551. */
  31552. getDepthFunction(): Nullable<number>;
  31553. /**
  31554. * Sets the current depth function
  31555. * @param depthFunc defines the function to use
  31556. */
  31557. setDepthFunction(depthFunc: number): void;
  31558. /**
  31559. * Sets the current depth function to GREATER
  31560. */
  31561. setDepthFunctionToGreater(): void;
  31562. /**
  31563. * Sets the current depth function to GEQUAL
  31564. */
  31565. setDepthFunctionToGreaterOrEqual(): void;
  31566. /**
  31567. * Sets the current depth function to LESS
  31568. */
  31569. setDepthFunctionToLess(): void;
  31570. /**
  31571. * Sets the current depth function to LEQUAL
  31572. */
  31573. setDepthFunctionToLessOrEqual(): void;
  31574. private _cachedStencilBuffer;
  31575. private _cachedStencilFunction;
  31576. private _cachedStencilMask;
  31577. private _cachedStencilOperationPass;
  31578. private _cachedStencilOperationFail;
  31579. private _cachedStencilOperationDepthFail;
  31580. private _cachedStencilReference;
  31581. /**
  31582. * Caches the the state of the stencil buffer
  31583. */
  31584. cacheStencilState(): void;
  31585. /**
  31586. * Restores the state of the stencil buffer
  31587. */
  31588. restoreStencilState(): void;
  31589. /**
  31590. * Directly set the WebGL Viewport
  31591. * @param x defines the x coordinate of the viewport (in screen space)
  31592. * @param y defines the y coordinate of the viewport (in screen space)
  31593. * @param width defines the width of the viewport (in screen space)
  31594. * @param height defines the height of the viewport (in screen space)
  31595. * @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
  31596. */
  31597. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31598. /**
  31599. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31600. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31601. * @param y defines the y-coordinate of the corner of the clear rectangle
  31602. * @param width defines the width of the clear rectangle
  31603. * @param height defines the height of the clear rectangle
  31604. * @param clearColor defines the clear color
  31605. */
  31606. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31607. /**
  31608. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31609. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31610. * @param y defines the y-coordinate of the corner of the clear rectangle
  31611. * @param width defines the width of the clear rectangle
  31612. * @param height defines the height of the clear rectangle
  31613. */
  31614. enableScissor(x: number, y: number, width: number, height: number): void;
  31615. /**
  31616. * Disable previously set scissor test rectangle
  31617. */
  31618. disableScissor(): void;
  31619. /**
  31620. * Initializes a webVR display and starts listening to display change events
  31621. * The onVRDisplayChangedObservable will be notified upon these changes
  31622. * @returns The onVRDisplayChangedObservable
  31623. */
  31624. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31625. /** @hidden */
  31626. _prepareVRComponent(): void;
  31627. /** @hidden */
  31628. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31629. /** @hidden */
  31630. _submitVRFrame(): void;
  31631. /**
  31632. * Call this function to leave webVR mode
  31633. * Will do nothing if webVR is not supported or if there is no webVR device
  31634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31635. */
  31636. disableVR(): void;
  31637. /**
  31638. * Gets a boolean indicating that the system is in VR mode and is presenting
  31639. * @returns true if VR mode is engaged
  31640. */
  31641. isVRPresenting(): boolean;
  31642. /** @hidden */
  31643. _requestVRFrame(): void;
  31644. /** @hidden */
  31645. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31646. /**
  31647. * Gets the source code of the vertex shader associated with a specific webGL program
  31648. * @param program defines the program to use
  31649. * @returns a string containing the source code of the vertex shader associated with the program
  31650. */
  31651. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31652. /**
  31653. * Gets the source code of the fragment shader associated with a specific webGL program
  31654. * @param program defines the program to use
  31655. * @returns a string containing the source code of the fragment shader associated with the program
  31656. */
  31657. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31658. /**
  31659. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31660. * @param x defines the x coordinate of the rectangle where pixels must be read
  31661. * @param y defines the y coordinate of the rectangle where pixels must be read
  31662. * @param width defines the width of the rectangle where pixels must be read
  31663. * @param height defines the height of the rectangle where pixels must be read
  31664. * @returns a Uint8Array containing RGBA colors
  31665. */
  31666. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31667. /**
  31668. * Sets a depth stencil texture from a render target to the according uniform.
  31669. * @param channel The texture channel
  31670. * @param uniform The uniform to set
  31671. * @param texture The render target texture containing the depth stencil texture to apply
  31672. */
  31673. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31674. /**
  31675. * Sets a texture to the webGL context from a postprocess
  31676. * @param channel defines the channel to use
  31677. * @param postProcess defines the source postprocess
  31678. */
  31679. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31680. /**
  31681. * Binds the output of the passed in post process to the texture channel specified
  31682. * @param channel The channel the texture should be bound to
  31683. * @param postProcess The post process which's output should be bound
  31684. */
  31685. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31686. /** @hidden */
  31687. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31688. protected _rebuildBuffers(): void;
  31689. _renderLoop(): void;
  31690. /**
  31691. * Toggle full screen mode
  31692. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31693. */
  31694. switchFullscreen(requestPointerLock: boolean): void;
  31695. /**
  31696. * Enters full screen mode
  31697. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31698. */
  31699. enterFullscreen(requestPointerLock: boolean): void;
  31700. /**
  31701. * Exits full screen mode
  31702. */
  31703. exitFullscreen(): void;
  31704. /**
  31705. * Enters Pointerlock mode
  31706. */
  31707. enterPointerlock(): void;
  31708. /**
  31709. * Exits Pointerlock mode
  31710. */
  31711. exitPointerlock(): void;
  31712. /**
  31713. * Begin a new frame
  31714. */
  31715. beginFrame(): void;
  31716. /**
  31717. * Enf the current frame
  31718. */
  31719. endFrame(): void;
  31720. resize(): void;
  31721. /**
  31722. * Set the compressed texture format to use, based on the formats you have, and the formats
  31723. * supported by the hardware / browser.
  31724. *
  31725. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31726. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31727. * to API arguments needed to compressed textures. This puts the burden on the container
  31728. * generator to house the arcane code for determining these for current & future formats.
  31729. *
  31730. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31731. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31732. *
  31733. * Note: The result of this call is not taken into account when a texture is base64.
  31734. *
  31735. * @param formatsAvailable defines the list of those format families you have created
  31736. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31737. *
  31738. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31739. * @returns The extension selected.
  31740. */
  31741. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31742. /**
  31743. * Force a specific size of the canvas
  31744. * @param width defines the new canvas' width
  31745. * @param height defines the new canvas' height
  31746. */
  31747. setSize(width: number, height: number): void;
  31748. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31751. _releaseTexture(texture: InternalTexture): void;
  31752. /**
  31753. * @hidden
  31754. * Rescales a texture
  31755. * @param source input texutre
  31756. * @param destination destination texture
  31757. * @param scene scene to use to render the resize
  31758. * @param internalFormat format to use when resizing
  31759. * @param onComplete callback to be called when resize has completed
  31760. */
  31761. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31762. /**
  31763. * Gets the current framerate
  31764. * @returns a number representing the framerate
  31765. */
  31766. getFps(): number;
  31767. /**
  31768. * Gets the time spent between current and previous frame
  31769. * @returns a number representing the delta time in ms
  31770. */
  31771. getDeltaTime(): number;
  31772. private _measureFps;
  31773. /**
  31774. * Creates a new render target texture
  31775. * @param size defines the size of the texture
  31776. * @param options defines the options used to create the texture
  31777. * @returns a new render target texture stored in an InternalTexture
  31778. */
  31779. createRenderTargetTexture(size: number | {
  31780. width: number;
  31781. height: number;
  31782. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31783. /**
  31784. * Updates the sample count of a render target texture
  31785. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31786. * @param texture defines the texture to update
  31787. * @param samples defines the sample count to set
  31788. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31789. */
  31790. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31791. /** @hidden */
  31792. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31793. dispose(): void;
  31794. private _disableTouchAction;
  31795. /**
  31796. * Display the loading screen
  31797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31798. */
  31799. displayLoadingUI(): void;
  31800. /**
  31801. * Hide the loading screen
  31802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31803. */
  31804. hideLoadingUI(): void;
  31805. /**
  31806. * Gets the current loading screen object
  31807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31808. */
  31809. /**
  31810. * Sets the current loading screen object
  31811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31812. */
  31813. loadingScreen: ILoadingScreen;
  31814. /**
  31815. * Sets the current loading screen text
  31816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31817. */
  31818. loadingUIText: string;
  31819. /**
  31820. * Sets the current loading screen background color
  31821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31822. */
  31823. loadingUIBackgroundColor: string;
  31824. /** Pointerlock and fullscreen */
  31825. /**
  31826. * Ask the browser to promote the current element to pointerlock mode
  31827. * @param element defines the DOM element to promote
  31828. */
  31829. static _RequestPointerlock(element: HTMLElement): void;
  31830. /**
  31831. * Asks the browser to exit pointerlock mode
  31832. */
  31833. static _ExitPointerlock(): void;
  31834. /**
  31835. * Ask the browser to promote the current element to fullscreen rendering mode
  31836. * @param element defines the DOM element to promote
  31837. */
  31838. static _RequestFullscreen(element: HTMLElement): void;
  31839. /**
  31840. * Asks the browser to exit fullscreen mode
  31841. */
  31842. static _ExitFullscreen(): void;
  31843. }
  31844. }
  31845. declare module BABYLON {
  31846. /**
  31847. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31848. * during the life time of the application.
  31849. */
  31850. export class EngineStore {
  31851. /** Gets the list of created engines */
  31852. static Instances: Engine[];
  31853. /** @hidden */
  31854. static _LastCreatedScene: Nullable<Scene>;
  31855. /**
  31856. * Gets the latest created engine
  31857. */
  31858. static readonly LastCreatedEngine: Nullable<Engine>;
  31859. /**
  31860. * Gets the latest created scene
  31861. */
  31862. static readonly LastCreatedScene: Nullable<Scene>;
  31863. /**
  31864. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31865. * @ignorenaming
  31866. */
  31867. static UseFallbackTexture: boolean;
  31868. /**
  31869. * Texture content used if a texture cannot loaded
  31870. * @ignorenaming
  31871. */
  31872. static FallbackTexture: string;
  31873. }
  31874. }
  31875. declare module BABYLON {
  31876. /**
  31877. * Helper class that provides a small promise polyfill
  31878. */
  31879. export class PromisePolyfill {
  31880. /**
  31881. * Static function used to check if the polyfill is required
  31882. * If this is the case then the function will inject the polyfill to window.Promise
  31883. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31884. */
  31885. static Apply(force?: boolean): void;
  31886. }
  31887. }
  31888. declare module BABYLON {
  31889. /**
  31890. * Interface for screenshot methods with describe argument called `size` as object with options
  31891. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31892. */
  31893. export interface IScreenshotSize {
  31894. /**
  31895. * number in pixels for canvas height
  31896. */
  31897. height?: number;
  31898. /**
  31899. * multiplier allowing render at a higher or lower resolution
  31900. * If value is defined then height and width will be ignored and taken from camera
  31901. */
  31902. precision?: number;
  31903. /**
  31904. * number in pixels for canvas width
  31905. */
  31906. width?: number;
  31907. }
  31908. }
  31909. declare module BABYLON {
  31910. interface IColor4Like {
  31911. r: float;
  31912. g: float;
  31913. b: float;
  31914. a: float;
  31915. }
  31916. /**
  31917. * Class containing a set of static utilities functions
  31918. */
  31919. export class Tools {
  31920. /**
  31921. * Gets or sets the base URL to use to load assets
  31922. */
  31923. static BaseUrl: string;
  31924. /**
  31925. * Enable/Disable Custom HTTP Request Headers globally.
  31926. * default = false
  31927. * @see CustomRequestHeaders
  31928. */
  31929. static UseCustomRequestHeaders: boolean;
  31930. /**
  31931. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31932. * i.e. when loading files, where the server/service expects an Authorization header
  31933. */
  31934. static CustomRequestHeaders: {
  31935. [key: string]: string;
  31936. };
  31937. /**
  31938. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31939. */
  31940. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31941. /**
  31942. * Default behaviour for cors in the application.
  31943. * It can be a string if the expected behavior is identical in the entire app.
  31944. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31945. */
  31946. static CorsBehavior: string | ((url: string | string[]) => string);
  31947. /**
  31948. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31949. * @ignorenaming
  31950. */
  31951. static UseFallbackTexture: boolean;
  31952. /**
  31953. * Use this object to register external classes like custom textures or material
  31954. * to allow the laoders to instantiate them
  31955. */
  31956. static RegisteredExternalClasses: {
  31957. [key: string]: Object;
  31958. };
  31959. /**
  31960. * Texture content used if a texture cannot loaded
  31961. * @ignorenaming
  31962. */
  31963. static fallbackTexture: string;
  31964. /**
  31965. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31966. * @param u defines the coordinate on X axis
  31967. * @param v defines the coordinate on Y axis
  31968. * @param width defines the width of the source data
  31969. * @param height defines the height of the source data
  31970. * @param pixels defines the source byte array
  31971. * @param color defines the output color
  31972. */
  31973. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31974. /**
  31975. * Interpolates between a and b via alpha
  31976. * @param a The lower value (returned when alpha = 0)
  31977. * @param b The upper value (returned when alpha = 1)
  31978. * @param alpha The interpolation-factor
  31979. * @return The mixed value
  31980. */
  31981. static Mix(a: number, b: number, alpha: number): number;
  31982. /**
  31983. * Tries to instantiate a new object from a given class name
  31984. * @param className defines the class name to instantiate
  31985. * @returns the new object or null if the system was not able to do the instantiation
  31986. */
  31987. static Instantiate(className: string): any;
  31988. /**
  31989. * Provides a slice function that will work even on IE
  31990. * @param data defines the array to slice
  31991. * @param start defines the start of the data (optional)
  31992. * @param end defines the end of the data (optional)
  31993. * @returns the new sliced array
  31994. */
  31995. static Slice<T>(data: T, start?: number, end?: number): T;
  31996. /**
  31997. * Polyfill for setImmediate
  31998. * @param action defines the action to execute after the current execution block
  31999. */
  32000. static SetImmediate(action: () => void): void;
  32001. /**
  32002. * Function indicating if a number is an exponent of 2
  32003. * @param value defines the value to test
  32004. * @returns true if the value is an exponent of 2
  32005. */
  32006. static IsExponentOfTwo(value: number): boolean;
  32007. private static _tmpFloatArray;
  32008. /**
  32009. * Returns the nearest 32-bit single precision float representation of a Number
  32010. * @param value A Number. If the parameter is of a different type, it will get converted
  32011. * to a number or to NaN if it cannot be converted
  32012. * @returns number
  32013. */
  32014. static FloatRound(value: number): number;
  32015. /**
  32016. * Extracts the filename from a path
  32017. * @param path defines the path to use
  32018. * @returns the filename
  32019. */
  32020. static GetFilename(path: string): string;
  32021. /**
  32022. * Extracts the "folder" part of a path (everything before the filename).
  32023. * @param uri The URI to extract the info from
  32024. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32025. * @returns The "folder" part of the path
  32026. */
  32027. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32028. /**
  32029. * Extracts text content from a DOM element hierarchy
  32030. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32031. */
  32032. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32033. /**
  32034. * Convert an angle in radians to degrees
  32035. * @param angle defines the angle to convert
  32036. * @returns the angle in degrees
  32037. */
  32038. static ToDegrees(angle: number): number;
  32039. /**
  32040. * Convert an angle in degrees to radians
  32041. * @param angle defines the angle to convert
  32042. * @returns the angle in radians
  32043. */
  32044. static ToRadians(angle: number): number;
  32045. /**
  32046. * Encode a buffer to a base64 string
  32047. * @param buffer defines the buffer to encode
  32048. * @returns the encoded string
  32049. */
  32050. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32051. /**
  32052. * Returns an array if obj is not an array
  32053. * @param obj defines the object to evaluate as an array
  32054. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32055. * @returns either obj directly if obj is an array or a new array containing obj
  32056. */
  32057. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32058. /**
  32059. * Gets the pointer prefix to use
  32060. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32061. */
  32062. static GetPointerPrefix(): string;
  32063. /**
  32064. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32065. * @param url define the url we are trying
  32066. * @param element define the dom element where to configure the cors policy
  32067. */
  32068. static SetCorsBehavior(url: string | string[], element: {
  32069. crossOrigin: string | null;
  32070. }): void;
  32071. /**
  32072. * Removes unwanted characters from an url
  32073. * @param url defines the url to clean
  32074. * @returns the cleaned url
  32075. */
  32076. static CleanUrl(url: string): string;
  32077. /**
  32078. * Gets or sets a function used to pre-process url before using them to load assets
  32079. */
  32080. static PreprocessUrl: (url: string) => string;
  32081. /**
  32082. * Loads an image as an HTMLImageElement.
  32083. * @param input url string, ArrayBuffer, or Blob to load
  32084. * @param onLoad callback called when the image successfully loads
  32085. * @param onError callback called when the image fails to load
  32086. * @param offlineProvider offline provider for caching
  32087. * @returns the HTMLImageElement of the loaded image
  32088. */
  32089. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32090. /**
  32091. * Loads a file
  32092. * @param url url string, ArrayBuffer, or Blob to load
  32093. * @param onSuccess callback called when the file successfully loads
  32094. * @param onProgress callback called while file is loading (if the server supports this mode)
  32095. * @param offlineProvider defines the offline provider for caching
  32096. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32097. * @param onError callback called when the file fails to load
  32098. * @returns a file request object
  32099. */
  32100. 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;
  32101. /**
  32102. * Loads a file from a url
  32103. * @param url the file url to load
  32104. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32105. */
  32106. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32107. /**
  32108. * Load a script (identified by an url). When the url returns, the
  32109. * content of this file is added into a new script element, attached to the DOM (body element)
  32110. * @param scriptUrl defines the url of the script to laod
  32111. * @param onSuccess defines the callback called when the script is loaded
  32112. * @param onError defines the callback to call if an error occurs
  32113. * @param scriptId defines the id of the script element
  32114. */
  32115. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32116. /**
  32117. * Load an asynchronous script (identified by an url). When the url returns, the
  32118. * content of this file is added into a new script element, attached to the DOM (body element)
  32119. * @param scriptUrl defines the url of the script to laod
  32120. * @param scriptId defines the id of the script element
  32121. * @returns a promise request object
  32122. */
  32123. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32124. /**
  32125. * Loads a file from a blob
  32126. * @param fileToLoad defines the blob to use
  32127. * @param callback defines the callback to call when data is loaded
  32128. * @param progressCallback defines the callback to call during loading process
  32129. * @returns a file request object
  32130. */
  32131. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32132. /**
  32133. * Loads a file
  32134. * @param fileToLoad defines the file to load
  32135. * @param callback defines the callback to call when data is loaded
  32136. * @param progressCallBack defines the callback to call during loading process
  32137. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32138. * @returns a file request object
  32139. */
  32140. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32141. /**
  32142. * Creates a data url from a given string content
  32143. * @param content defines the content to convert
  32144. * @returns the new data url link
  32145. */
  32146. static FileAsURL(content: string): string;
  32147. /**
  32148. * Format the given number to a specific decimal format
  32149. * @param value defines the number to format
  32150. * @param decimals defines the number of decimals to use
  32151. * @returns the formatted string
  32152. */
  32153. static Format(value: number, decimals?: number): string;
  32154. /**
  32155. * Tries to copy an object by duplicating every property
  32156. * @param source defines the source object
  32157. * @param destination defines the target object
  32158. * @param doNotCopyList defines a list of properties to avoid
  32159. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32160. */
  32161. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32162. /**
  32163. * Gets a boolean indicating if the given object has no own property
  32164. * @param obj defines the object to test
  32165. * @returns true if object has no own property
  32166. */
  32167. static IsEmpty(obj: any): boolean;
  32168. /**
  32169. * Function used to register events at window level
  32170. * @param windowElement defines the Window object to use
  32171. * @param events defines the events to register
  32172. */
  32173. static RegisterTopRootEvents(windowElement: Window, events: {
  32174. name: string;
  32175. handler: Nullable<(e: FocusEvent) => any>;
  32176. }[]): void;
  32177. /**
  32178. * Function used to unregister events from window level
  32179. * @param windowElement defines the Window object to use
  32180. * @param events defines the events to unregister
  32181. */
  32182. static UnregisterTopRootEvents(windowElement: Window, events: {
  32183. name: string;
  32184. handler: Nullable<(e: FocusEvent) => any>;
  32185. }[]): void;
  32186. /**
  32187. * @ignore
  32188. */
  32189. static _ScreenshotCanvas: HTMLCanvasElement;
  32190. /**
  32191. * Dumps the current bound framebuffer
  32192. * @param width defines the rendering width
  32193. * @param height defines the rendering height
  32194. * @param engine defines the hosting engine
  32195. * @param successCallback defines the callback triggered once the data are available
  32196. * @param mimeType defines the mime type of the result
  32197. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32198. */
  32199. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32200. /**
  32201. * Converts the canvas data to blob.
  32202. * This acts as a polyfill for browsers not supporting the to blob function.
  32203. * @param canvas Defines the canvas to extract the data from
  32204. * @param successCallback Defines the callback triggered once the data are available
  32205. * @param mimeType Defines the mime type of the result
  32206. */
  32207. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32208. /**
  32209. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32210. * @param successCallback defines the callback triggered once the data are available
  32211. * @param mimeType defines the mime type of the result
  32212. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32213. */
  32214. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32215. /**
  32216. * Downloads a blob in the browser
  32217. * @param blob defines the blob to download
  32218. * @param fileName defines the name of the downloaded file
  32219. */
  32220. static Download(blob: Blob, fileName: string): void;
  32221. /**
  32222. * Captures a screenshot of the current rendering
  32223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32224. * @param engine defines the rendering engine
  32225. * @param camera defines the source camera
  32226. * @param size This parameter can be set to a single number or to an object with the
  32227. * following (optional) properties: precision, width, height. If a single number is passed,
  32228. * it will be used for both width and height. If an object is passed, the screenshot size
  32229. * will be derived from the parameters. The precision property is a multiplier allowing
  32230. * rendering at a higher or lower resolution
  32231. * @param successCallback defines the callback receives a single parameter which contains the
  32232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32233. * src parameter of an <img> to display it
  32234. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32235. * Check your browser for supported MIME types
  32236. */
  32237. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32238. /**
  32239. * Captures a screenshot of the current rendering
  32240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32241. * @param engine defines the rendering engine
  32242. * @param camera defines the source camera
  32243. * @param size This parameter can be set to a single number or to an object with the
  32244. * following (optional) properties: precision, width, height. If a single number is passed,
  32245. * it will be used for both width and height. If an object is passed, the screenshot size
  32246. * will be derived from the parameters. The precision property is a multiplier allowing
  32247. * rendering at a higher or lower resolution
  32248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32249. * Check your browser for supported MIME types
  32250. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32251. * to the src parameter of an <img> to display it
  32252. */
  32253. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32254. /**
  32255. * Generates an image screenshot from the specified camera.
  32256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32257. * @param engine The engine to use for rendering
  32258. * @param camera The camera to use for rendering
  32259. * @param size This parameter can be set to a single number or to an object with the
  32260. * following (optional) properties: precision, width, height. If a single number is passed,
  32261. * it will be used for both width and height. If an object is passed, the screenshot size
  32262. * will be derived from the parameters. The precision property is a multiplier allowing
  32263. * rendering at a higher or lower resolution
  32264. * @param successCallback The callback receives a single parameter which contains the
  32265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32266. * src parameter of an <img> to display it
  32267. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32268. * Check your browser for supported MIME types
  32269. * @param samples Texture samples (default: 1)
  32270. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32271. * @param fileName A name for for the downloaded file.
  32272. */
  32273. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32274. /**
  32275. * Generates an image screenshot from the specified camera.
  32276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32277. * @param engine The engine to use for rendering
  32278. * @param camera The camera to use for rendering
  32279. * @param size This parameter can be set to a single number or to an object with the
  32280. * following (optional) properties: precision, width, height. If a single number is passed,
  32281. * it will be used for both width and height. If an object is passed, the screenshot size
  32282. * will be derived from the parameters. The precision property is a multiplier allowing
  32283. * rendering at a higher or lower resolution
  32284. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32285. * Check your browser for supported MIME types
  32286. * @param samples Texture samples (default: 1)
  32287. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32288. * @param fileName A name for for the downloaded file.
  32289. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32290. * to the src parameter of an <img> to display it
  32291. */
  32292. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32293. /**
  32294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32295. * Be aware Math.random() could cause collisions, but:
  32296. * "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"
  32297. * @returns a pseudo random id
  32298. */
  32299. static RandomId(): string;
  32300. /**
  32301. * Test if the given uri is a base64 string
  32302. * @param uri The uri to test
  32303. * @return True if the uri is a base64 string or false otherwise
  32304. */
  32305. static IsBase64(uri: string): boolean;
  32306. /**
  32307. * Decode the given base64 uri.
  32308. * @param uri The uri to decode
  32309. * @return The decoded base64 data.
  32310. */
  32311. static DecodeBase64(uri: string): ArrayBuffer;
  32312. /**
  32313. * Gets the absolute url.
  32314. * @param url the input url
  32315. * @return the absolute url
  32316. */
  32317. static GetAbsoluteUrl(url: string): string;
  32318. /**
  32319. * No log
  32320. */
  32321. static readonly NoneLogLevel: number;
  32322. /**
  32323. * Only message logs
  32324. */
  32325. static readonly MessageLogLevel: number;
  32326. /**
  32327. * Only warning logs
  32328. */
  32329. static readonly WarningLogLevel: number;
  32330. /**
  32331. * Only error logs
  32332. */
  32333. static readonly ErrorLogLevel: number;
  32334. /**
  32335. * All logs
  32336. */
  32337. static readonly AllLogLevel: number;
  32338. /**
  32339. * Gets a value indicating the number of loading errors
  32340. * @ignorenaming
  32341. */
  32342. static readonly errorsCount: number;
  32343. /**
  32344. * Callback called when a new log is added
  32345. */
  32346. static OnNewCacheEntry: (entry: string) => void;
  32347. /**
  32348. * Log a message to the console
  32349. * @param message defines the message to log
  32350. */
  32351. static Log(message: string): void;
  32352. /**
  32353. * Write a warning message to the console
  32354. * @param message defines the message to log
  32355. */
  32356. static Warn(message: string): void;
  32357. /**
  32358. * Write an error message to the console
  32359. * @param message defines the message to log
  32360. */
  32361. static Error(message: string): void;
  32362. /**
  32363. * Gets current log cache (list of logs)
  32364. */
  32365. static readonly LogCache: string;
  32366. /**
  32367. * Clears the log cache
  32368. */
  32369. static ClearLogCache(): void;
  32370. /**
  32371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32372. */
  32373. static LogLevels: number;
  32374. /**
  32375. * Checks if the window object exists
  32376. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32377. */
  32378. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32379. /**
  32380. * No performance log
  32381. */
  32382. static readonly PerformanceNoneLogLevel: number;
  32383. /**
  32384. * Use user marks to log performance
  32385. */
  32386. static readonly PerformanceUserMarkLogLevel: number;
  32387. /**
  32388. * Log performance to the console
  32389. */
  32390. static readonly PerformanceConsoleLogLevel: number;
  32391. private static _performance;
  32392. /**
  32393. * Sets the current performance log level
  32394. */
  32395. static PerformanceLogLevel: number;
  32396. private static _StartPerformanceCounterDisabled;
  32397. private static _EndPerformanceCounterDisabled;
  32398. private static _StartUserMark;
  32399. private static _EndUserMark;
  32400. private static _StartPerformanceConsole;
  32401. private static _EndPerformanceConsole;
  32402. /**
  32403. * Starts a performance counter
  32404. */
  32405. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32406. /**
  32407. * Ends a specific performance coutner
  32408. */
  32409. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32410. /**
  32411. * Gets either window.performance.now() if supported or Date.now() else
  32412. */
  32413. static readonly Now: number;
  32414. /**
  32415. * This method will return the name of the class used to create the instance of the given object.
  32416. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32417. * @param object the object to get the class name from
  32418. * @param isType defines if the object is actually a type
  32419. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32420. */
  32421. static GetClassName(object: any, isType?: boolean): string;
  32422. /**
  32423. * Gets the first element of an array satisfying a given predicate
  32424. * @param array defines the array to browse
  32425. * @param predicate defines the predicate to use
  32426. * @returns null if not found or the element
  32427. */
  32428. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32429. /**
  32430. * This method will return the name of the full name of the class, including its owning module (if any).
  32431. * 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).
  32432. * @param object the object to get the class name from
  32433. * @param isType defines if the object is actually a type
  32434. * @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.
  32435. * @ignorenaming
  32436. */
  32437. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32438. /**
  32439. * Returns a promise that resolves after the given amount of time.
  32440. * @param delay Number of milliseconds to delay
  32441. * @returns Promise that resolves after the given amount of time
  32442. */
  32443. static DelayAsync(delay: number): Promise<void>;
  32444. }
  32445. /**
  32446. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32447. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32448. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32449. * @param name The name of the class, case should be preserved
  32450. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32451. */
  32452. export function className(name: string, module?: string): (target: Object) => void;
  32453. /**
  32454. * An implementation of a loop for asynchronous functions.
  32455. */
  32456. export class AsyncLoop {
  32457. /**
  32458. * Defines the number of iterations for the loop
  32459. */
  32460. iterations: number;
  32461. /**
  32462. * Defines the current index of the loop.
  32463. */
  32464. index: number;
  32465. private _done;
  32466. private _fn;
  32467. private _successCallback;
  32468. /**
  32469. * Constructor.
  32470. * @param iterations the number of iterations.
  32471. * @param func the function to run each iteration
  32472. * @param successCallback the callback that will be called upon succesful execution
  32473. * @param offset starting offset.
  32474. */
  32475. constructor(
  32476. /**
  32477. * Defines the number of iterations for the loop
  32478. */
  32479. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32480. /**
  32481. * Execute the next iteration. Must be called after the last iteration was finished.
  32482. */
  32483. executeNext(): void;
  32484. /**
  32485. * Break the loop and run the success callback.
  32486. */
  32487. breakLoop(): void;
  32488. /**
  32489. * Create and run an async loop.
  32490. * @param iterations the number of iterations.
  32491. * @param fn the function to run each iteration
  32492. * @param successCallback the callback that will be called upon succesful execution
  32493. * @param offset starting offset.
  32494. * @returns the created async loop object
  32495. */
  32496. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32497. /**
  32498. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32499. * @param iterations total number of iterations
  32500. * @param syncedIterations number of synchronous iterations in each async iteration.
  32501. * @param fn the function to call each iteration.
  32502. * @param callback a success call back that will be called when iterating stops.
  32503. * @param breakFunction a break condition (optional)
  32504. * @param timeout timeout settings for the setTimeout function. default - 0.
  32505. * @returns the created async loop object
  32506. */
  32507. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32508. }
  32509. }
  32510. declare module BABYLON {
  32511. /**
  32512. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32513. * The underlying implementation relies on an associative array to ensure the best performances.
  32514. * The value can be anything including 'null' but except 'undefined'
  32515. */
  32516. export class StringDictionary<T> {
  32517. /**
  32518. * This will clear this dictionary and copy the content from the 'source' one.
  32519. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32520. * @param source the dictionary to take the content from and copy to this dictionary
  32521. */
  32522. copyFrom(source: StringDictionary<T>): void;
  32523. /**
  32524. * Get a value based from its key
  32525. * @param key the given key to get the matching value from
  32526. * @return the value if found, otherwise undefined is returned
  32527. */
  32528. get(key: string): T | undefined;
  32529. /**
  32530. * Get a value from its key or add it if it doesn't exist.
  32531. * This method will ensure you that a given key/data will be present in the dictionary.
  32532. * @param key the given key to get the matching value from
  32533. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32534. * The factory will only be invoked if there's no data for the given key.
  32535. * @return the value corresponding to the key.
  32536. */
  32537. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32538. /**
  32539. * Get a value from its key if present in the dictionary otherwise add it
  32540. * @param key the key to get the value from
  32541. * @param val if there's no such key/value pair in the dictionary add it with this value
  32542. * @return the value corresponding to the key
  32543. */
  32544. getOrAdd(key: string, val: T): T;
  32545. /**
  32546. * Check if there's a given key in the dictionary
  32547. * @param key the key to check for
  32548. * @return true if the key is present, false otherwise
  32549. */
  32550. contains(key: string): boolean;
  32551. /**
  32552. * Add a new key and its corresponding value
  32553. * @param key the key to add
  32554. * @param value the value corresponding to the key
  32555. * @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
  32556. */
  32557. add(key: string, value: T): boolean;
  32558. /**
  32559. * Update a specific value associated to a key
  32560. * @param key defines the key to use
  32561. * @param value defines the value to store
  32562. * @returns true if the value was updated (or false if the key was not found)
  32563. */
  32564. set(key: string, value: T): boolean;
  32565. /**
  32566. * Get the element of the given key and remove it from the dictionary
  32567. * @param key defines the key to search
  32568. * @returns the value associated with the key or null if not found
  32569. */
  32570. getAndRemove(key: string): Nullable<T>;
  32571. /**
  32572. * Remove a key/value from the dictionary.
  32573. * @param key the key to remove
  32574. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32575. */
  32576. remove(key: string): boolean;
  32577. /**
  32578. * Clear the whole content of the dictionary
  32579. */
  32580. clear(): void;
  32581. /**
  32582. * Gets the current count
  32583. */
  32584. readonly count: number;
  32585. /**
  32586. * Execute a callback on each key/val of the dictionary.
  32587. * Note that you can remove any element in this dictionary in the callback implementation
  32588. * @param callback the callback to execute on a given key/value pair
  32589. */
  32590. forEach(callback: (key: string, val: T) => void): void;
  32591. /**
  32592. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32593. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32594. * Note that you can remove any element in this dictionary in the callback implementation
  32595. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32596. * @returns the first item
  32597. */
  32598. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32599. private _count;
  32600. private _data;
  32601. }
  32602. }
  32603. declare module BABYLON {
  32604. /** @hidden */
  32605. export interface ICollisionCoordinator {
  32606. createCollider(): Collider;
  32607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32608. init(scene: Scene): void;
  32609. }
  32610. /** @hidden */
  32611. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32612. private _scene;
  32613. private _scaledPosition;
  32614. private _scaledVelocity;
  32615. private _finalPosition;
  32616. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32617. createCollider(): Collider;
  32618. init(scene: Scene): void;
  32619. private _collideWithWorld;
  32620. }
  32621. }
  32622. declare module BABYLON {
  32623. /**
  32624. * Class used to manage all inputs for the scene.
  32625. */
  32626. export class InputManager {
  32627. /** The distance in pixel that you have to move to prevent some events */
  32628. static DragMovementThreshold: number;
  32629. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32630. static LongPressDelay: number;
  32631. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32632. static DoubleClickDelay: number;
  32633. /** If you need to check double click without raising a single click at first click, enable this flag */
  32634. static ExclusiveDoubleClickMode: boolean;
  32635. private _wheelEventName;
  32636. private _onPointerMove;
  32637. private _onPointerDown;
  32638. private _onPointerUp;
  32639. private _initClickEvent;
  32640. private _initActionManager;
  32641. private _delayedSimpleClick;
  32642. private _delayedSimpleClickTimeout;
  32643. private _previousDelayedSimpleClickTimeout;
  32644. private _meshPickProceed;
  32645. private _previousButtonPressed;
  32646. private _currentPickResult;
  32647. private _previousPickResult;
  32648. private _totalPointersPressed;
  32649. private _doubleClickOccured;
  32650. private _pointerOverMesh;
  32651. private _pickedDownMesh;
  32652. private _pickedUpMesh;
  32653. private _pointerX;
  32654. private _pointerY;
  32655. private _unTranslatedPointerX;
  32656. private _unTranslatedPointerY;
  32657. private _startingPointerPosition;
  32658. private _previousStartingPointerPosition;
  32659. private _startingPointerTime;
  32660. private _previousStartingPointerTime;
  32661. private _pointerCaptures;
  32662. private _onKeyDown;
  32663. private _onKeyUp;
  32664. private _onCanvasFocusObserver;
  32665. private _onCanvasBlurObserver;
  32666. private _scene;
  32667. /**
  32668. * Creates a new InputManager
  32669. * @param scene defines the hosting scene
  32670. */
  32671. constructor(scene: Scene);
  32672. /**
  32673. * Gets the mesh that is currently under the pointer
  32674. */
  32675. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32676. /**
  32677. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32678. */
  32679. readonly unTranslatedPointer: Vector2;
  32680. /**
  32681. * Gets or sets the current on-screen X position of the pointer
  32682. */
  32683. pointerX: number;
  32684. /**
  32685. * Gets or sets the current on-screen Y position of the pointer
  32686. */
  32687. pointerY: number;
  32688. private _updatePointerPosition;
  32689. private _processPointerMove;
  32690. private _setRayOnPointerInfo;
  32691. private _checkPrePointerObservable;
  32692. /**
  32693. * Use this method to simulate a pointer move on a mesh
  32694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32697. */
  32698. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32699. /**
  32700. * Use this method to simulate a pointer down on a mesh
  32701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32704. */
  32705. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32706. private _processPointerDown;
  32707. /** @hidden */
  32708. _isPointerSwiping(): boolean;
  32709. /**
  32710. * Use this method to simulate a pointer up on a mesh
  32711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32714. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32715. */
  32716. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32717. private _processPointerUp;
  32718. /**
  32719. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32720. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32721. * @returns true if the pointer was captured
  32722. */
  32723. isPointerCaptured(pointerId?: number): boolean;
  32724. /**
  32725. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32726. * @param attachUp defines if you want to attach events to pointerup
  32727. * @param attachDown defines if you want to attach events to pointerdown
  32728. * @param attachMove defines if you want to attach events to pointermove
  32729. */
  32730. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32731. /**
  32732. * Detaches all event handlers
  32733. */
  32734. detachControl(): void;
  32735. /**
  32736. * Force the value of meshUnderPointer
  32737. * @param mesh defines the mesh to use
  32738. */
  32739. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32740. /**
  32741. * Gets the mesh under the pointer
  32742. * @returns a Mesh or null if no mesh is under the pointer
  32743. */
  32744. getPointerOverMesh(): Nullable<AbstractMesh>;
  32745. }
  32746. }
  32747. declare module BABYLON {
  32748. /**
  32749. * Helper class used to generate session unique ID
  32750. */
  32751. export class UniqueIdGenerator {
  32752. private static _UniqueIdCounter;
  32753. /**
  32754. * Gets an unique (relatively to the current scene) Id
  32755. */
  32756. static readonly UniqueId: number;
  32757. }
  32758. }
  32759. declare module BABYLON {
  32760. /**
  32761. * This class defines the direct association between an animation and a target
  32762. */
  32763. export class TargetedAnimation {
  32764. /**
  32765. * Animation to perform
  32766. */
  32767. animation: Animation;
  32768. /**
  32769. * Target to animate
  32770. */
  32771. target: any;
  32772. /**
  32773. * Serialize the object
  32774. * @returns the JSON object representing the current entity
  32775. */
  32776. serialize(): any;
  32777. }
  32778. /**
  32779. * Use this class to create coordinated animations on multiple targets
  32780. */
  32781. export class AnimationGroup implements IDisposable {
  32782. /** The name of the animation group */
  32783. name: string;
  32784. private _scene;
  32785. private _targetedAnimations;
  32786. private _animatables;
  32787. private _from;
  32788. private _to;
  32789. private _isStarted;
  32790. private _isPaused;
  32791. private _speedRatio;
  32792. private _loopAnimation;
  32793. /**
  32794. * Gets or sets the unique id of the node
  32795. */
  32796. uniqueId: number;
  32797. /**
  32798. * This observable will notify when one animation have ended
  32799. */
  32800. onAnimationEndObservable: Observable<TargetedAnimation>;
  32801. /**
  32802. * Observer raised when one animation loops
  32803. */
  32804. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32805. /**
  32806. * This observable will notify when all animations have ended.
  32807. */
  32808. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32809. /**
  32810. * This observable will notify when all animations have paused.
  32811. */
  32812. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32813. /**
  32814. * This observable will notify when all animations are playing.
  32815. */
  32816. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32817. /**
  32818. * Gets the first frame
  32819. */
  32820. readonly from: number;
  32821. /**
  32822. * Gets the last frame
  32823. */
  32824. readonly to: number;
  32825. /**
  32826. * Define if the animations are started
  32827. */
  32828. readonly isStarted: boolean;
  32829. /**
  32830. * Gets a value indicating that the current group is playing
  32831. */
  32832. readonly isPlaying: boolean;
  32833. /**
  32834. * Gets or sets the speed ratio to use for all animations
  32835. */
  32836. /**
  32837. * Gets or sets the speed ratio to use for all animations
  32838. */
  32839. speedRatio: number;
  32840. /**
  32841. * Gets or sets if all animations should loop or not
  32842. */
  32843. loopAnimation: boolean;
  32844. /**
  32845. * Gets the targeted animations for this animation group
  32846. */
  32847. readonly targetedAnimations: Array<TargetedAnimation>;
  32848. /**
  32849. * returning the list of animatables controlled by this animation group.
  32850. */
  32851. readonly animatables: Array<Animatable>;
  32852. /**
  32853. * Instantiates a new Animation Group.
  32854. * This helps managing several animations at once.
  32855. * @see http://doc.babylonjs.com/how_to/group
  32856. * @param name Defines the name of the group
  32857. * @param scene Defines the scene the group belongs to
  32858. */
  32859. constructor(
  32860. /** The name of the animation group */
  32861. name: string, scene?: Nullable<Scene>);
  32862. /**
  32863. * Add an animation (with its target) in the group
  32864. * @param animation defines the animation we want to add
  32865. * @param target defines the target of the animation
  32866. * @returns the TargetedAnimation object
  32867. */
  32868. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32869. /**
  32870. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32871. * It can add constant keys at begin or end
  32872. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32873. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32874. * @returns the animation group
  32875. */
  32876. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32877. /**
  32878. * Start all animations on given targets
  32879. * @param loop defines if animations must loop
  32880. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32881. * @param from defines the from key (optional)
  32882. * @param to defines the to key (optional)
  32883. * @returns the current animation group
  32884. */
  32885. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32886. /**
  32887. * Pause all animations
  32888. * @returns the animation group
  32889. */
  32890. pause(): AnimationGroup;
  32891. /**
  32892. * Play all animations to initial state
  32893. * This function will start() the animations if they were not started or will restart() them if they were paused
  32894. * @param loop defines if animations must loop
  32895. * @returns the animation group
  32896. */
  32897. play(loop?: boolean): AnimationGroup;
  32898. /**
  32899. * Reset all animations to initial state
  32900. * @returns the animation group
  32901. */
  32902. reset(): AnimationGroup;
  32903. /**
  32904. * Restart animations from key 0
  32905. * @returns the animation group
  32906. */
  32907. restart(): AnimationGroup;
  32908. /**
  32909. * Stop all animations
  32910. * @returns the animation group
  32911. */
  32912. stop(): AnimationGroup;
  32913. /**
  32914. * Set animation weight for all animatables
  32915. * @param weight defines the weight to use
  32916. * @return the animationGroup
  32917. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32918. */
  32919. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32920. /**
  32921. * Synchronize and normalize all animatables with a source animatable
  32922. * @param root defines the root animatable to synchronize with
  32923. * @return the animationGroup
  32924. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32925. */
  32926. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32927. /**
  32928. * Goes to a specific frame in this animation group
  32929. * @param frame the frame number to go to
  32930. * @return the animationGroup
  32931. */
  32932. goToFrame(frame: number): AnimationGroup;
  32933. /**
  32934. * Dispose all associated resources
  32935. */
  32936. dispose(): void;
  32937. private _checkAnimationGroupEnded;
  32938. /**
  32939. * Clone the current animation group and returns a copy
  32940. * @param newName defines the name of the new group
  32941. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32942. * @returns the new aniamtion group
  32943. */
  32944. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32945. /**
  32946. * Serializes the animationGroup to an object
  32947. * @returns Serialized object
  32948. */
  32949. serialize(): any;
  32950. /**
  32951. * Returns a new AnimationGroup object parsed from the source provided.
  32952. * @param parsedAnimationGroup defines the source
  32953. * @param scene defines the scene that will receive the animationGroup
  32954. * @returns a new AnimationGroup
  32955. */
  32956. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32957. /**
  32958. * Returns the string "AnimationGroup"
  32959. * @returns "AnimationGroup"
  32960. */
  32961. getClassName(): string;
  32962. /**
  32963. * Creates a detailled string about the object
  32964. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32965. * @returns a string representing the object
  32966. */
  32967. toString(fullDetails?: boolean): string;
  32968. }
  32969. }
  32970. declare module BABYLON {
  32971. /**
  32972. * Define an interface for all classes that will hold resources
  32973. */
  32974. export interface IDisposable {
  32975. /**
  32976. * Releases all held resources
  32977. */
  32978. dispose(): void;
  32979. }
  32980. /** Interface defining initialization parameters for Scene class */
  32981. export interface SceneOptions {
  32982. /**
  32983. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32984. * It will improve performance when the number of geometries becomes important.
  32985. */
  32986. useGeometryUniqueIdsMap?: boolean;
  32987. /**
  32988. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32989. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32990. */
  32991. useMaterialMeshMap?: boolean;
  32992. /**
  32993. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32994. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32995. */
  32996. useClonedMeshhMap?: boolean;
  32997. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32998. virtual?: boolean;
  32999. }
  33000. /**
  33001. * Represents a scene to be rendered by the engine.
  33002. * @see http://doc.babylonjs.com/features/scene
  33003. */
  33004. export class Scene extends AbstractScene implements IAnimatable {
  33005. /** The fog is deactivated */
  33006. static readonly FOGMODE_NONE: number;
  33007. /** The fog density is following an exponential function */
  33008. static readonly FOGMODE_EXP: number;
  33009. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33010. static readonly FOGMODE_EXP2: number;
  33011. /** The fog density is following a linear function. */
  33012. static readonly FOGMODE_LINEAR: number;
  33013. /**
  33014. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33015. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33016. */
  33017. static MinDeltaTime: number;
  33018. /**
  33019. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33021. */
  33022. static MaxDeltaTime: number;
  33023. /**
  33024. * Factory used to create the default material.
  33025. * @param name The name of the material to create
  33026. * @param scene The scene to create the material for
  33027. * @returns The default material
  33028. */
  33029. static DefaultMaterialFactory(scene: Scene): Material;
  33030. /**
  33031. * Factory used to create the a collision coordinator.
  33032. * @returns The collision coordinator
  33033. */
  33034. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33035. /** @hidden */
  33036. _inputManager: InputManager;
  33037. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33038. cameraToUseForPointers: Nullable<Camera>;
  33039. /** @hidden */
  33040. readonly _isScene: boolean;
  33041. /**
  33042. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33043. */
  33044. autoClear: boolean;
  33045. /**
  33046. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33047. */
  33048. autoClearDepthAndStencil: boolean;
  33049. /**
  33050. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33051. */
  33052. clearColor: Color4;
  33053. /**
  33054. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33055. */
  33056. ambientColor: Color3;
  33057. /**
  33058. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33059. * It should only be one of the following (if not the default embedded one):
  33060. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33061. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33062. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33063. * The material properties need to be setup according to the type of texture in use.
  33064. */
  33065. environmentBRDFTexture: BaseTexture;
  33066. /** @hidden */
  33067. protected _environmentTexture: Nullable<BaseTexture>;
  33068. /**
  33069. * Texture used in all pbr material as the reflection texture.
  33070. * As in the majority of the scene they are the same (exception for multi room and so on),
  33071. * this is easier to reference from here than from all the materials.
  33072. */
  33073. /**
  33074. * Texture used in all pbr material as the reflection texture.
  33075. * As in the majority of the scene they are the same (exception for multi room and so on),
  33076. * this is easier to set here than in all the materials.
  33077. */
  33078. environmentTexture: Nullable<BaseTexture>;
  33079. /** @hidden */
  33080. protected _environmentIntensity: number;
  33081. /**
  33082. * Intensity of the environment in all pbr material.
  33083. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33084. * As in the majority of the scene they are the same (exception for multi room and so on),
  33085. * this is easier to reference from here than from all the materials.
  33086. */
  33087. /**
  33088. * Intensity of the environment in all pbr material.
  33089. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33090. * As in the majority of the scene they are the same (exception for multi room and so on),
  33091. * this is easier to set here than in all the materials.
  33092. */
  33093. environmentIntensity: number;
  33094. /** @hidden */
  33095. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33096. /**
  33097. * Default image processing configuration used either in the rendering
  33098. * Forward main pass or through the imageProcessingPostProcess if present.
  33099. * As in the majority of the scene they are the same (exception for multi camera),
  33100. * this is easier to reference from here than from all the materials and post process.
  33101. *
  33102. * No setter as we it is a shared configuration, you can set the values instead.
  33103. */
  33104. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33105. private _forceWireframe;
  33106. /**
  33107. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33108. */
  33109. forceWireframe: boolean;
  33110. private _forcePointsCloud;
  33111. /**
  33112. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33113. */
  33114. forcePointsCloud: boolean;
  33115. /**
  33116. * Gets or sets the active clipplane 1
  33117. */
  33118. clipPlane: Nullable<Plane>;
  33119. /**
  33120. * Gets or sets the active clipplane 2
  33121. */
  33122. clipPlane2: Nullable<Plane>;
  33123. /**
  33124. * Gets or sets the active clipplane 3
  33125. */
  33126. clipPlane3: Nullable<Plane>;
  33127. /**
  33128. * Gets or sets the active clipplane 4
  33129. */
  33130. clipPlane4: Nullable<Plane>;
  33131. /**
  33132. * Gets or sets a boolean indicating if animations are enabled
  33133. */
  33134. animationsEnabled: boolean;
  33135. private _animationPropertiesOverride;
  33136. /**
  33137. * Gets or sets the animation properties override
  33138. */
  33139. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33140. /**
  33141. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33142. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33143. */
  33144. useConstantAnimationDeltaTime: boolean;
  33145. /**
  33146. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33147. * Please note that it requires to run a ray cast through the scene on every frame
  33148. */
  33149. constantlyUpdateMeshUnderPointer: boolean;
  33150. /**
  33151. * Defines the HTML cursor to use when hovering over interactive elements
  33152. */
  33153. hoverCursor: string;
  33154. /**
  33155. * Defines the HTML default cursor to use (empty by default)
  33156. */
  33157. defaultCursor: string;
  33158. /**
  33159. * This is used to call preventDefault() on pointer down
  33160. * in order to block unwanted artifacts like system double clicks
  33161. */
  33162. preventDefaultOnPointerDown: boolean;
  33163. /**
  33164. * This is used to call preventDefault() on pointer up
  33165. * in order to block unwanted artifacts like system double clicks
  33166. */
  33167. preventDefaultOnPointerUp: boolean;
  33168. /**
  33169. * Gets or sets user defined metadata
  33170. */
  33171. metadata: any;
  33172. /**
  33173. * For internal use only. Please do not use.
  33174. */
  33175. reservedDataStore: any;
  33176. /**
  33177. * Gets the name of the plugin used to load this scene (null by default)
  33178. */
  33179. loadingPluginName: string;
  33180. /**
  33181. * Use this array to add regular expressions used to disable offline support for specific urls
  33182. */
  33183. disableOfflineSupportExceptionRules: RegExp[];
  33184. /**
  33185. * An event triggered when the scene is disposed.
  33186. */
  33187. onDisposeObservable: Observable<Scene>;
  33188. private _onDisposeObserver;
  33189. /** Sets a function to be executed when this scene is disposed. */
  33190. onDispose: () => void;
  33191. /**
  33192. * An event triggered before rendering the scene (right after animations and physics)
  33193. */
  33194. onBeforeRenderObservable: Observable<Scene>;
  33195. private _onBeforeRenderObserver;
  33196. /** Sets a function to be executed before rendering this scene */
  33197. beforeRender: Nullable<() => void>;
  33198. /**
  33199. * An event triggered after rendering the scene
  33200. */
  33201. onAfterRenderObservable: Observable<Scene>;
  33202. /**
  33203. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33204. */
  33205. onAfterRenderCameraObservable: Observable<Camera>;
  33206. private _onAfterRenderObserver;
  33207. /** Sets a function to be executed after rendering this scene */
  33208. afterRender: Nullable<() => void>;
  33209. /**
  33210. * An event triggered before animating the scene
  33211. */
  33212. onBeforeAnimationsObservable: Observable<Scene>;
  33213. /**
  33214. * An event triggered after animations processing
  33215. */
  33216. onAfterAnimationsObservable: Observable<Scene>;
  33217. /**
  33218. * An event triggered before draw calls are ready to be sent
  33219. */
  33220. onBeforeDrawPhaseObservable: Observable<Scene>;
  33221. /**
  33222. * An event triggered after draw calls have been sent
  33223. */
  33224. onAfterDrawPhaseObservable: Observable<Scene>;
  33225. /**
  33226. * An event triggered when the scene is ready
  33227. */
  33228. onReadyObservable: Observable<Scene>;
  33229. /**
  33230. * An event triggered before rendering a camera
  33231. */
  33232. onBeforeCameraRenderObservable: Observable<Camera>;
  33233. private _onBeforeCameraRenderObserver;
  33234. /** Sets a function to be executed before rendering a camera*/
  33235. beforeCameraRender: () => void;
  33236. /**
  33237. * An event triggered after rendering a camera
  33238. */
  33239. onAfterCameraRenderObservable: Observable<Camera>;
  33240. private _onAfterCameraRenderObserver;
  33241. /** Sets a function to be executed after rendering a camera*/
  33242. afterCameraRender: () => void;
  33243. /**
  33244. * An event triggered when active meshes evaluation is about to start
  33245. */
  33246. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33247. /**
  33248. * An event triggered when active meshes evaluation is done
  33249. */
  33250. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33251. /**
  33252. * An event triggered when particles rendering is about to start
  33253. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33254. */
  33255. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33256. /**
  33257. * An event triggered when particles rendering is done
  33258. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33259. */
  33260. onAfterParticlesRenderingObservable: Observable<Scene>;
  33261. /**
  33262. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33263. */
  33264. onDataLoadedObservable: Observable<Scene>;
  33265. /**
  33266. * An event triggered when a camera is created
  33267. */
  33268. onNewCameraAddedObservable: Observable<Camera>;
  33269. /**
  33270. * An event triggered when a camera is removed
  33271. */
  33272. onCameraRemovedObservable: Observable<Camera>;
  33273. /**
  33274. * An event triggered when a light is created
  33275. */
  33276. onNewLightAddedObservable: Observable<Light>;
  33277. /**
  33278. * An event triggered when a light is removed
  33279. */
  33280. onLightRemovedObservable: Observable<Light>;
  33281. /**
  33282. * An event triggered when a geometry is created
  33283. */
  33284. onNewGeometryAddedObservable: Observable<Geometry>;
  33285. /**
  33286. * An event triggered when a geometry is removed
  33287. */
  33288. onGeometryRemovedObservable: Observable<Geometry>;
  33289. /**
  33290. * An event triggered when a transform node is created
  33291. */
  33292. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33293. /**
  33294. * An event triggered when a transform node is removed
  33295. */
  33296. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33297. /**
  33298. * An event triggered when a mesh is created
  33299. */
  33300. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33301. /**
  33302. * An event triggered when a mesh is removed
  33303. */
  33304. onMeshRemovedObservable: Observable<AbstractMesh>;
  33305. /**
  33306. * An event triggered when a skeleton is created
  33307. */
  33308. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33309. /**
  33310. * An event triggered when a skeleton is removed
  33311. */
  33312. onSkeletonRemovedObservable: Observable<Skeleton>;
  33313. /**
  33314. * An event triggered when a material is created
  33315. */
  33316. onNewMaterialAddedObservable: Observable<Material>;
  33317. /**
  33318. * An event triggered when a material is removed
  33319. */
  33320. onMaterialRemovedObservable: Observable<Material>;
  33321. /**
  33322. * An event triggered when a texture is created
  33323. */
  33324. onNewTextureAddedObservable: Observable<BaseTexture>;
  33325. /**
  33326. * An event triggered when a texture is removed
  33327. */
  33328. onTextureRemovedObservable: Observable<BaseTexture>;
  33329. /**
  33330. * An event triggered when render targets are about to be rendered
  33331. * Can happen multiple times per frame.
  33332. */
  33333. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33334. /**
  33335. * An event triggered when render targets were rendered.
  33336. * Can happen multiple times per frame.
  33337. */
  33338. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33339. /**
  33340. * An event triggered before calculating deterministic simulation step
  33341. */
  33342. onBeforeStepObservable: Observable<Scene>;
  33343. /**
  33344. * An event triggered after calculating deterministic simulation step
  33345. */
  33346. onAfterStepObservable: Observable<Scene>;
  33347. /**
  33348. * An event triggered when the activeCamera property is updated
  33349. */
  33350. onActiveCameraChanged: Observable<Scene>;
  33351. /**
  33352. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33353. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33354. * 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)
  33355. */
  33356. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33357. /**
  33358. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33359. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33360. * 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)
  33361. */
  33362. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33363. /**
  33364. * This Observable will when a mesh has been imported into the scene.
  33365. */
  33366. onMeshImportedObservable: Observable<AbstractMesh>;
  33367. /**
  33368. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33369. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33370. */
  33371. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33372. /** @hidden */
  33373. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33374. /**
  33375. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33376. */
  33377. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33378. /**
  33379. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33380. */
  33381. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33382. /**
  33383. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33384. */
  33385. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33386. /** Callback called when a pointer move is detected */
  33387. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33388. /** Callback called when a pointer down is detected */
  33389. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33390. /** Callback called when a pointer up is detected */
  33391. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33392. /** Callback called when a pointer pick is detected */
  33393. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33394. /**
  33395. * 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).
  33396. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33397. */
  33398. onPrePointerObservable: Observable<PointerInfoPre>;
  33399. /**
  33400. * Observable event triggered each time an input event is received from the rendering canvas
  33401. */
  33402. onPointerObservable: Observable<PointerInfo>;
  33403. /**
  33404. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33405. */
  33406. readonly unTranslatedPointer: Vector2;
  33407. /**
  33408. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33409. */
  33410. static DragMovementThreshold: number;
  33411. /**
  33412. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33413. */
  33414. static LongPressDelay: number;
  33415. /**
  33416. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33417. */
  33418. static DoubleClickDelay: number;
  33419. /** If you need to check double click without raising a single click at first click, enable this flag */
  33420. static ExclusiveDoubleClickMode: boolean;
  33421. /** @hidden */
  33422. _mirroredCameraPosition: Nullable<Vector3>;
  33423. /**
  33424. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33425. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33426. */
  33427. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33428. /**
  33429. * Observable event triggered each time an keyboard event is received from the hosting window
  33430. */
  33431. onKeyboardObservable: Observable<KeyboardInfo>;
  33432. private _useRightHandedSystem;
  33433. /**
  33434. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33435. */
  33436. useRightHandedSystem: boolean;
  33437. private _timeAccumulator;
  33438. private _currentStepId;
  33439. private _currentInternalStep;
  33440. /**
  33441. * Sets the step Id used by deterministic lock step
  33442. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33443. * @param newStepId defines the step Id
  33444. */
  33445. setStepId(newStepId: number): void;
  33446. /**
  33447. * Gets the step Id used by deterministic lock step
  33448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33449. * @returns the step Id
  33450. */
  33451. getStepId(): number;
  33452. /**
  33453. * Gets the internal step used by deterministic lock step
  33454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33455. * @returns the internal step
  33456. */
  33457. getInternalStep(): number;
  33458. private _fogEnabled;
  33459. /**
  33460. * Gets or sets a boolean indicating if fog is enabled on this scene
  33461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33462. * (Default is true)
  33463. */
  33464. fogEnabled: boolean;
  33465. private _fogMode;
  33466. /**
  33467. * Gets or sets the fog mode to use
  33468. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33469. * | mode | value |
  33470. * | --- | --- |
  33471. * | FOGMODE_NONE | 0 |
  33472. * | FOGMODE_EXP | 1 |
  33473. * | FOGMODE_EXP2 | 2 |
  33474. * | FOGMODE_LINEAR | 3 |
  33475. */
  33476. fogMode: number;
  33477. /**
  33478. * Gets or sets the fog color to use
  33479. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33480. * (Default is Color3(0.2, 0.2, 0.3))
  33481. */
  33482. fogColor: Color3;
  33483. /**
  33484. * Gets or sets the fog density to use
  33485. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33486. * (Default is 0.1)
  33487. */
  33488. fogDensity: number;
  33489. /**
  33490. * Gets or sets the fog start distance to use
  33491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33492. * (Default is 0)
  33493. */
  33494. fogStart: number;
  33495. /**
  33496. * Gets or sets the fog end distance to use
  33497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33498. * (Default is 1000)
  33499. */
  33500. fogEnd: number;
  33501. private _shadowsEnabled;
  33502. /**
  33503. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33504. */
  33505. shadowsEnabled: boolean;
  33506. private _lightsEnabled;
  33507. /**
  33508. * Gets or sets a boolean indicating if lights are enabled on this scene
  33509. */
  33510. lightsEnabled: boolean;
  33511. /** All of the active cameras added to this scene. */
  33512. activeCameras: Camera[];
  33513. /** @hidden */
  33514. _activeCamera: Nullable<Camera>;
  33515. /** Gets or sets the current active camera */
  33516. activeCamera: Nullable<Camera>;
  33517. private _defaultMaterial;
  33518. /** The default material used on meshes when no material is affected */
  33519. /** The default material used on meshes when no material is affected */
  33520. defaultMaterial: Material;
  33521. private _texturesEnabled;
  33522. /**
  33523. * Gets or sets a boolean indicating if textures are enabled on this scene
  33524. */
  33525. texturesEnabled: boolean;
  33526. /**
  33527. * Gets or sets a boolean indicating if particles are enabled on this scene
  33528. */
  33529. particlesEnabled: boolean;
  33530. /**
  33531. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33532. */
  33533. spritesEnabled: boolean;
  33534. private _skeletonsEnabled;
  33535. /**
  33536. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33537. */
  33538. skeletonsEnabled: boolean;
  33539. /**
  33540. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33541. */
  33542. lensFlaresEnabled: boolean;
  33543. /**
  33544. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33545. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33546. */
  33547. collisionsEnabled: boolean;
  33548. private _collisionCoordinator;
  33549. /** @hidden */
  33550. readonly collisionCoordinator: ICollisionCoordinator;
  33551. /**
  33552. * Defines the gravity applied to this scene (used only for collisions)
  33553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33554. */
  33555. gravity: Vector3;
  33556. /**
  33557. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33558. */
  33559. postProcessesEnabled: boolean;
  33560. /**
  33561. * The list of postprocesses added to the scene
  33562. */
  33563. postProcesses: PostProcess[];
  33564. /**
  33565. * Gets the current postprocess manager
  33566. */
  33567. postProcessManager: PostProcessManager;
  33568. /**
  33569. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33570. */
  33571. renderTargetsEnabled: boolean;
  33572. /**
  33573. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33574. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33575. */
  33576. dumpNextRenderTargets: boolean;
  33577. /**
  33578. * The list of user defined render targets added to the scene
  33579. */
  33580. customRenderTargets: RenderTargetTexture[];
  33581. /**
  33582. * Defines if texture loading must be delayed
  33583. * If true, textures will only be loaded when they need to be rendered
  33584. */
  33585. useDelayedTextureLoading: boolean;
  33586. /**
  33587. * Gets the list of meshes imported to the scene through SceneLoader
  33588. */
  33589. importedMeshesFiles: String[];
  33590. /**
  33591. * Gets or sets a boolean indicating if probes are enabled on this scene
  33592. */
  33593. probesEnabled: boolean;
  33594. /**
  33595. * Gets or sets the current offline provider to use to store scene data
  33596. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33597. */
  33598. offlineProvider: IOfflineProvider;
  33599. /**
  33600. * Gets or sets the action manager associated with the scene
  33601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33602. */
  33603. actionManager: AbstractActionManager;
  33604. private _meshesForIntersections;
  33605. /**
  33606. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33607. */
  33608. proceduralTexturesEnabled: boolean;
  33609. private _engine;
  33610. private _totalVertices;
  33611. /** @hidden */
  33612. _activeIndices: PerfCounter;
  33613. /** @hidden */
  33614. _activeParticles: PerfCounter;
  33615. /** @hidden */
  33616. _activeBones: PerfCounter;
  33617. private _animationRatio;
  33618. /** @hidden */
  33619. _animationTimeLast: number;
  33620. /** @hidden */
  33621. _animationTime: number;
  33622. /**
  33623. * Gets or sets a general scale for animation speed
  33624. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33625. */
  33626. animationTimeScale: number;
  33627. /** @hidden */
  33628. _cachedMaterial: Nullable<Material>;
  33629. /** @hidden */
  33630. _cachedEffect: Nullable<Effect>;
  33631. /** @hidden */
  33632. _cachedVisibility: Nullable<number>;
  33633. private _renderId;
  33634. private _frameId;
  33635. private _executeWhenReadyTimeoutId;
  33636. private _intermediateRendering;
  33637. private _viewUpdateFlag;
  33638. private _projectionUpdateFlag;
  33639. /** @hidden */
  33640. _toBeDisposed: Nullable<IDisposable>[];
  33641. private _activeRequests;
  33642. /** @hidden */
  33643. _pendingData: any[];
  33644. private _isDisposed;
  33645. /**
  33646. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33647. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33648. */
  33649. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33650. private _activeMeshes;
  33651. private _processedMaterials;
  33652. private _renderTargets;
  33653. /** @hidden */
  33654. _activeParticleSystems: SmartArray<IParticleSystem>;
  33655. private _activeSkeletons;
  33656. private _softwareSkinnedMeshes;
  33657. private _renderingManager;
  33658. /** @hidden */
  33659. _activeAnimatables: Animatable[];
  33660. private _transformMatrix;
  33661. private _sceneUbo;
  33662. /** @hidden */
  33663. _viewMatrix: Matrix;
  33664. private _projectionMatrix;
  33665. /** @hidden */
  33666. _forcedViewPosition: Nullable<Vector3>;
  33667. /** @hidden */
  33668. _frustumPlanes: Plane[];
  33669. /**
  33670. * Gets the list of frustum planes (built from the active camera)
  33671. */
  33672. readonly frustumPlanes: Plane[];
  33673. /**
  33674. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33675. * This is useful if there are more lights that the maximum simulteanous authorized
  33676. */
  33677. requireLightSorting: boolean;
  33678. /** @hidden */
  33679. readonly useMaterialMeshMap: boolean;
  33680. /** @hidden */
  33681. readonly useClonedMeshhMap: boolean;
  33682. private _externalData;
  33683. private _uid;
  33684. /**
  33685. * @hidden
  33686. * Backing store of defined scene components.
  33687. */
  33688. _components: ISceneComponent[];
  33689. /**
  33690. * @hidden
  33691. * Backing store of defined scene components.
  33692. */
  33693. _serializableComponents: ISceneSerializableComponent[];
  33694. /**
  33695. * List of components to register on the next registration step.
  33696. */
  33697. private _transientComponents;
  33698. /**
  33699. * Registers the transient components if needed.
  33700. */
  33701. private _registerTransientComponents;
  33702. /**
  33703. * @hidden
  33704. * Add a component to the scene.
  33705. * Note that the ccomponent could be registered on th next frame if this is called after
  33706. * the register component stage.
  33707. * @param component Defines the component to add to the scene
  33708. */
  33709. _addComponent(component: ISceneComponent): void;
  33710. /**
  33711. * @hidden
  33712. * Gets a component from the scene.
  33713. * @param name defines the name of the component to retrieve
  33714. * @returns the component or null if not present
  33715. */
  33716. _getComponent(name: string): Nullable<ISceneComponent>;
  33717. /**
  33718. * @hidden
  33719. * Defines the actions happening before camera updates.
  33720. */
  33721. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33722. /**
  33723. * @hidden
  33724. * Defines the actions happening before clear the canvas.
  33725. */
  33726. _beforeClearStage: Stage<SimpleStageAction>;
  33727. /**
  33728. * @hidden
  33729. * Defines the actions when collecting render targets for the frame.
  33730. */
  33731. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33732. /**
  33733. * @hidden
  33734. * Defines the actions happening for one camera in the frame.
  33735. */
  33736. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33737. /**
  33738. * @hidden
  33739. * Defines the actions happening during the per mesh ready checks.
  33740. */
  33741. _isReadyForMeshStage: Stage<MeshStageAction>;
  33742. /**
  33743. * @hidden
  33744. * Defines the actions happening before evaluate active mesh checks.
  33745. */
  33746. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33747. /**
  33748. * @hidden
  33749. * Defines the actions happening during the evaluate sub mesh checks.
  33750. */
  33751. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33752. /**
  33753. * @hidden
  33754. * Defines the actions happening during the active mesh stage.
  33755. */
  33756. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33757. /**
  33758. * @hidden
  33759. * Defines the actions happening during the per camera render target step.
  33760. */
  33761. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33762. /**
  33763. * @hidden
  33764. * Defines the actions happening just before the active camera is drawing.
  33765. */
  33766. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33767. /**
  33768. * @hidden
  33769. * Defines the actions happening just before a render target is drawing.
  33770. */
  33771. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33772. /**
  33773. * @hidden
  33774. * Defines the actions happening just before a rendering group is drawing.
  33775. */
  33776. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33777. /**
  33778. * @hidden
  33779. * Defines the actions happening just before a mesh is drawing.
  33780. */
  33781. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33782. /**
  33783. * @hidden
  33784. * Defines the actions happening just after a mesh has been drawn.
  33785. */
  33786. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33787. /**
  33788. * @hidden
  33789. * Defines the actions happening just after a rendering group has been drawn.
  33790. */
  33791. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33792. /**
  33793. * @hidden
  33794. * Defines the actions happening just after the active camera has been drawn.
  33795. */
  33796. _afterCameraDrawStage: Stage<CameraStageAction>;
  33797. /**
  33798. * @hidden
  33799. * Defines the actions happening just after a render target has been drawn.
  33800. */
  33801. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33802. /**
  33803. * @hidden
  33804. * Defines the actions happening just after rendering all cameras and computing intersections.
  33805. */
  33806. _afterRenderStage: Stage<SimpleStageAction>;
  33807. /**
  33808. * @hidden
  33809. * Defines the actions happening when a pointer move event happens.
  33810. */
  33811. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33812. /**
  33813. * @hidden
  33814. * Defines the actions happening when a pointer down event happens.
  33815. */
  33816. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33817. /**
  33818. * @hidden
  33819. * Defines the actions happening when a pointer up event happens.
  33820. */
  33821. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33822. /**
  33823. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33824. */
  33825. private geometriesByUniqueId;
  33826. /**
  33827. * Creates a new Scene
  33828. * @param engine defines the engine to use to render this scene
  33829. * @param options defines the scene options
  33830. */
  33831. constructor(engine: Engine, options?: SceneOptions);
  33832. /**
  33833. * Gets a string idenfifying the name of the class
  33834. * @returns "Scene" string
  33835. */
  33836. getClassName(): string;
  33837. private _defaultMeshCandidates;
  33838. /**
  33839. * @hidden
  33840. */
  33841. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33842. private _defaultSubMeshCandidates;
  33843. /**
  33844. * @hidden
  33845. */
  33846. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33847. /**
  33848. * Sets the default candidate providers for the scene.
  33849. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33850. * and getCollidingSubMeshCandidates to their default function
  33851. */
  33852. setDefaultCandidateProviders(): void;
  33853. /**
  33854. * Gets the mesh that is currently under the pointer
  33855. */
  33856. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33857. /**
  33858. * Gets or sets the current on-screen X position of the pointer
  33859. */
  33860. pointerX: number;
  33861. /**
  33862. * Gets or sets the current on-screen Y position of the pointer
  33863. */
  33864. pointerY: number;
  33865. /**
  33866. * Gets the cached material (ie. the latest rendered one)
  33867. * @returns the cached material
  33868. */
  33869. getCachedMaterial(): Nullable<Material>;
  33870. /**
  33871. * Gets the cached effect (ie. the latest rendered one)
  33872. * @returns the cached effect
  33873. */
  33874. getCachedEffect(): Nullable<Effect>;
  33875. /**
  33876. * Gets the cached visibility state (ie. the latest rendered one)
  33877. * @returns the cached visibility state
  33878. */
  33879. getCachedVisibility(): Nullable<number>;
  33880. /**
  33881. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33882. * @param material defines the current material
  33883. * @param effect defines the current effect
  33884. * @param visibility defines the current visibility state
  33885. * @returns true if one parameter is not cached
  33886. */
  33887. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33888. /**
  33889. * Gets the engine associated with the scene
  33890. * @returns an Engine
  33891. */
  33892. getEngine(): Engine;
  33893. /**
  33894. * Gets the total number of vertices rendered per frame
  33895. * @returns the total number of vertices rendered per frame
  33896. */
  33897. getTotalVertices(): number;
  33898. /**
  33899. * Gets the performance counter for total vertices
  33900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33901. */
  33902. readonly totalVerticesPerfCounter: PerfCounter;
  33903. /**
  33904. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33905. * @returns the total number of active indices rendered per frame
  33906. */
  33907. getActiveIndices(): number;
  33908. /**
  33909. * Gets the performance counter for active indices
  33910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33911. */
  33912. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33913. /**
  33914. * Gets the total number of active particles rendered per frame
  33915. * @returns the total number of active particles rendered per frame
  33916. */
  33917. getActiveParticles(): number;
  33918. /**
  33919. * Gets the performance counter for active particles
  33920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33921. */
  33922. readonly activeParticlesPerfCounter: PerfCounter;
  33923. /**
  33924. * Gets the total number of active bones rendered per frame
  33925. * @returns the total number of active bones rendered per frame
  33926. */
  33927. getActiveBones(): number;
  33928. /**
  33929. * Gets the performance counter for active bones
  33930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33931. */
  33932. readonly activeBonesPerfCounter: PerfCounter;
  33933. /**
  33934. * Gets the array of active meshes
  33935. * @returns an array of AbstractMesh
  33936. */
  33937. getActiveMeshes(): SmartArray<AbstractMesh>;
  33938. /**
  33939. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33940. * @returns a number
  33941. */
  33942. getAnimationRatio(): number;
  33943. /**
  33944. * Gets an unique Id for the current render phase
  33945. * @returns a number
  33946. */
  33947. getRenderId(): number;
  33948. /**
  33949. * Gets an unique Id for the current frame
  33950. * @returns a number
  33951. */
  33952. getFrameId(): number;
  33953. /** Call this function if you want to manually increment the render Id*/
  33954. incrementRenderId(): void;
  33955. private _createUbo;
  33956. /**
  33957. * Use this method to simulate a pointer move on a mesh
  33958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33961. * @returns the current scene
  33962. */
  33963. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33964. /**
  33965. * Use this method to simulate a pointer down on a mesh
  33966. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33967. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33968. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33969. * @returns the current scene
  33970. */
  33971. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33972. /**
  33973. * Use this method to simulate a pointer up on a mesh
  33974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33977. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33978. * @returns the current scene
  33979. */
  33980. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33981. /**
  33982. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33983. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33984. * @returns true if the pointer was captured
  33985. */
  33986. isPointerCaptured(pointerId?: number): boolean;
  33987. /**
  33988. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33989. * @param attachUp defines if you want to attach events to pointerup
  33990. * @param attachDown defines if you want to attach events to pointerdown
  33991. * @param attachMove defines if you want to attach events to pointermove
  33992. */
  33993. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33994. /** Detaches all event handlers*/
  33995. detachControl(): void;
  33996. /**
  33997. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33998. * Delay loaded resources are not taking in account
  33999. * @return true if all required resources are ready
  34000. */
  34001. isReady(): boolean;
  34002. /** Resets all cached information relative to material (including effect and visibility) */
  34003. resetCachedMaterial(): void;
  34004. /**
  34005. * Registers a function to be called before every frame render
  34006. * @param func defines the function to register
  34007. */
  34008. registerBeforeRender(func: () => void): void;
  34009. /**
  34010. * Unregisters a function called before every frame render
  34011. * @param func defines the function to unregister
  34012. */
  34013. unregisterBeforeRender(func: () => void): void;
  34014. /**
  34015. * Registers a function to be called after every frame render
  34016. * @param func defines the function to register
  34017. */
  34018. registerAfterRender(func: () => void): void;
  34019. /**
  34020. * Unregisters a function called after every frame render
  34021. * @param func defines the function to unregister
  34022. */
  34023. unregisterAfterRender(func: () => void): void;
  34024. private _executeOnceBeforeRender;
  34025. /**
  34026. * The provided function will run before render once and will be disposed afterwards.
  34027. * A timeout delay can be provided so that the function will be executed in N ms.
  34028. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34029. * @param func The function to be executed.
  34030. * @param timeout optional delay in ms
  34031. */
  34032. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34033. /** @hidden */
  34034. _addPendingData(data: any): void;
  34035. /** @hidden */
  34036. _removePendingData(data: any): void;
  34037. /**
  34038. * Returns the number of items waiting to be loaded
  34039. * @returns the number of items waiting to be loaded
  34040. */
  34041. getWaitingItemsCount(): number;
  34042. /**
  34043. * Returns a boolean indicating if the scene is still loading data
  34044. */
  34045. readonly isLoading: boolean;
  34046. /**
  34047. * Registers a function to be executed when the scene is ready
  34048. * @param {Function} func - the function to be executed
  34049. */
  34050. executeWhenReady(func: () => void): void;
  34051. /**
  34052. * Returns a promise that resolves when the scene is ready
  34053. * @returns A promise that resolves when the scene is ready
  34054. */
  34055. whenReadyAsync(): Promise<void>;
  34056. /** @hidden */
  34057. _checkIsReady(): void;
  34058. /**
  34059. * Gets all animatable attached to the scene
  34060. */
  34061. readonly animatables: Animatable[];
  34062. /**
  34063. * Resets the last animation time frame.
  34064. * Useful to override when animations start running when loading a scene for the first time.
  34065. */
  34066. resetLastAnimationTimeFrame(): void;
  34067. /**
  34068. * Gets the current view matrix
  34069. * @returns a Matrix
  34070. */
  34071. getViewMatrix(): Matrix;
  34072. /**
  34073. * Gets the current projection matrix
  34074. * @returns a Matrix
  34075. */
  34076. getProjectionMatrix(): Matrix;
  34077. /**
  34078. * Gets the current transform matrix
  34079. * @returns a Matrix made of View * Projection
  34080. */
  34081. getTransformMatrix(): Matrix;
  34082. /**
  34083. * Sets the current transform matrix
  34084. * @param viewL defines the View matrix to use
  34085. * @param projectionL defines the Projection matrix to use
  34086. * @param viewR defines the right View matrix to use (if provided)
  34087. * @param projectionR defines the right Projection matrix to use (if provided)
  34088. */
  34089. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34090. /**
  34091. * Gets the uniform buffer used to store scene data
  34092. * @returns a UniformBuffer
  34093. */
  34094. getSceneUniformBuffer(): UniformBuffer;
  34095. /**
  34096. * Gets an unique (relatively to the current scene) Id
  34097. * @returns an unique number for the scene
  34098. */
  34099. getUniqueId(): number;
  34100. /**
  34101. * Add a mesh to the list of scene's meshes
  34102. * @param newMesh defines the mesh to add
  34103. * @param recursive if all child meshes should also be added to the scene
  34104. */
  34105. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34106. /**
  34107. * Remove a mesh for the list of scene's meshes
  34108. * @param toRemove defines the mesh to remove
  34109. * @param recursive if all child meshes should also be removed from the scene
  34110. * @returns the index where the mesh was in the mesh list
  34111. */
  34112. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34113. /**
  34114. * Add a transform node to the list of scene's transform nodes
  34115. * @param newTransformNode defines the transform node to add
  34116. */
  34117. addTransformNode(newTransformNode: TransformNode): void;
  34118. /**
  34119. * Remove a transform node for the list of scene's transform nodes
  34120. * @param toRemove defines the transform node to remove
  34121. * @returns the index where the transform node was in the transform node list
  34122. */
  34123. removeTransformNode(toRemove: TransformNode): number;
  34124. /**
  34125. * Remove a skeleton for the list of scene's skeletons
  34126. * @param toRemove defines the skeleton to remove
  34127. * @returns the index where the skeleton was in the skeleton list
  34128. */
  34129. removeSkeleton(toRemove: Skeleton): number;
  34130. /**
  34131. * Remove a morph target for the list of scene's morph targets
  34132. * @param toRemove defines the morph target to remove
  34133. * @returns the index where the morph target was in the morph target list
  34134. */
  34135. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34136. /**
  34137. * Remove a light for the list of scene's lights
  34138. * @param toRemove defines the light to remove
  34139. * @returns the index where the light was in the light list
  34140. */
  34141. removeLight(toRemove: Light): number;
  34142. /**
  34143. * Remove a camera for the list of scene's cameras
  34144. * @param toRemove defines the camera to remove
  34145. * @returns the index where the camera was in the camera list
  34146. */
  34147. removeCamera(toRemove: Camera): number;
  34148. /**
  34149. * Remove a particle system for the list of scene's particle systems
  34150. * @param toRemove defines the particle system to remove
  34151. * @returns the index where the particle system was in the particle system list
  34152. */
  34153. removeParticleSystem(toRemove: IParticleSystem): number;
  34154. /**
  34155. * Remove a animation for the list of scene's animations
  34156. * @param toRemove defines the animation to remove
  34157. * @returns the index where the animation was in the animation list
  34158. */
  34159. removeAnimation(toRemove: Animation): number;
  34160. /**
  34161. * Will stop the animation of the given target
  34162. * @param target - the target
  34163. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34164. * @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)
  34165. */
  34166. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34167. /**
  34168. * Removes the given animation group from this scene.
  34169. * @param toRemove The animation group to remove
  34170. * @returns The index of the removed animation group
  34171. */
  34172. removeAnimationGroup(toRemove: AnimationGroup): number;
  34173. /**
  34174. * Removes the given multi-material from this scene.
  34175. * @param toRemove The multi-material to remove
  34176. * @returns The index of the removed multi-material
  34177. */
  34178. removeMultiMaterial(toRemove: MultiMaterial): number;
  34179. /**
  34180. * Removes the given material from this scene.
  34181. * @param toRemove The material to remove
  34182. * @returns The index of the removed material
  34183. */
  34184. removeMaterial(toRemove: Material): number;
  34185. /**
  34186. * Removes the given action manager from this scene.
  34187. * @param toRemove The action manager to remove
  34188. * @returns The index of the removed action manager
  34189. */
  34190. removeActionManager(toRemove: AbstractActionManager): number;
  34191. /**
  34192. * Removes the given texture from this scene.
  34193. * @param toRemove The texture to remove
  34194. * @returns The index of the removed texture
  34195. */
  34196. removeTexture(toRemove: BaseTexture): number;
  34197. /**
  34198. * Adds the given light to this scene
  34199. * @param newLight The light to add
  34200. */
  34201. addLight(newLight: Light): void;
  34202. /**
  34203. * Sorts the list list based on light priorities
  34204. */
  34205. sortLightsByPriority(): void;
  34206. /**
  34207. * Adds the given camera to this scene
  34208. * @param newCamera The camera to add
  34209. */
  34210. addCamera(newCamera: Camera): void;
  34211. /**
  34212. * Adds the given skeleton to this scene
  34213. * @param newSkeleton The skeleton to add
  34214. */
  34215. addSkeleton(newSkeleton: Skeleton): void;
  34216. /**
  34217. * Adds the given particle system to this scene
  34218. * @param newParticleSystem The particle system to add
  34219. */
  34220. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34221. /**
  34222. * Adds the given animation to this scene
  34223. * @param newAnimation The animation to add
  34224. */
  34225. addAnimation(newAnimation: Animation): void;
  34226. /**
  34227. * Adds the given animation group to this scene.
  34228. * @param newAnimationGroup The animation group to add
  34229. */
  34230. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34231. /**
  34232. * Adds the given multi-material to this scene
  34233. * @param newMultiMaterial The multi-material to add
  34234. */
  34235. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34236. /**
  34237. * Adds the given material to this scene
  34238. * @param newMaterial The material to add
  34239. */
  34240. addMaterial(newMaterial: Material): void;
  34241. /**
  34242. * Adds the given morph target to this scene
  34243. * @param newMorphTargetManager The morph target to add
  34244. */
  34245. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34246. /**
  34247. * Adds the given geometry to this scene
  34248. * @param newGeometry The geometry to add
  34249. */
  34250. addGeometry(newGeometry: Geometry): void;
  34251. /**
  34252. * Adds the given action manager to this scene
  34253. * @param newActionManager The action manager to add
  34254. */
  34255. addActionManager(newActionManager: AbstractActionManager): void;
  34256. /**
  34257. * Adds the given texture to this scene.
  34258. * @param newTexture The texture to add
  34259. */
  34260. addTexture(newTexture: BaseTexture): void;
  34261. /**
  34262. * Switch active camera
  34263. * @param newCamera defines the new active camera
  34264. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34265. */
  34266. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34267. /**
  34268. * sets the active camera of the scene using its ID
  34269. * @param id defines the camera's ID
  34270. * @return the new active camera or null if none found.
  34271. */
  34272. setActiveCameraByID(id: string): Nullable<Camera>;
  34273. /**
  34274. * sets the active camera of the scene using its name
  34275. * @param name defines the camera's name
  34276. * @returns the new active camera or null if none found.
  34277. */
  34278. setActiveCameraByName(name: string): Nullable<Camera>;
  34279. /**
  34280. * get an animation group using its name
  34281. * @param name defines the material's name
  34282. * @return the animation group or null if none found.
  34283. */
  34284. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34285. /**
  34286. * Get a material using its unique id
  34287. * @param uniqueId defines the material's unique id
  34288. * @return the material or null if none found.
  34289. */
  34290. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34291. /**
  34292. * get a material using its id
  34293. * @param id defines the material's ID
  34294. * @return the material or null if none found.
  34295. */
  34296. getMaterialByID(id: string): Nullable<Material>;
  34297. /**
  34298. * Gets a the last added material using a given id
  34299. * @param id defines the material's ID
  34300. * @return the last material with the given id or null if none found.
  34301. */
  34302. getLastMaterialByID(id: string): Nullable<Material>;
  34303. /**
  34304. * Gets a material using its name
  34305. * @param name defines the material's name
  34306. * @return the material or null if none found.
  34307. */
  34308. getMaterialByName(name: string): Nullable<Material>;
  34309. /**
  34310. * Get a texture using its unique id
  34311. * @param uniqueId defines the texture's unique id
  34312. * @return the texture or null if none found.
  34313. */
  34314. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34315. /**
  34316. * Gets a camera using its id
  34317. * @param id defines the id to look for
  34318. * @returns the camera or null if not found
  34319. */
  34320. getCameraByID(id: string): Nullable<Camera>;
  34321. /**
  34322. * Gets a camera using its unique id
  34323. * @param uniqueId defines the unique id to look for
  34324. * @returns the camera or null if not found
  34325. */
  34326. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34327. /**
  34328. * Gets a camera using its name
  34329. * @param name defines the camera's name
  34330. * @return the camera or null if none found.
  34331. */
  34332. getCameraByName(name: string): Nullable<Camera>;
  34333. /**
  34334. * Gets a bone using its id
  34335. * @param id defines the bone's id
  34336. * @return the bone or null if not found
  34337. */
  34338. getBoneByID(id: string): Nullable<Bone>;
  34339. /**
  34340. * Gets a bone using its id
  34341. * @param name defines the bone's name
  34342. * @return the bone or null if not found
  34343. */
  34344. getBoneByName(name: string): Nullable<Bone>;
  34345. /**
  34346. * Gets a light node using its name
  34347. * @param name defines the the light's name
  34348. * @return the light or null if none found.
  34349. */
  34350. getLightByName(name: string): Nullable<Light>;
  34351. /**
  34352. * Gets a light node using its id
  34353. * @param id defines the light's id
  34354. * @return the light or null if none found.
  34355. */
  34356. getLightByID(id: string): Nullable<Light>;
  34357. /**
  34358. * Gets a light node using its scene-generated unique ID
  34359. * @param uniqueId defines the light's unique id
  34360. * @return the light or null if none found.
  34361. */
  34362. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34363. /**
  34364. * Gets a particle system by id
  34365. * @param id defines the particle system id
  34366. * @return the corresponding system or null if none found
  34367. */
  34368. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34369. /**
  34370. * Gets a geometry using its ID
  34371. * @param id defines the geometry's id
  34372. * @return the geometry or null if none found.
  34373. */
  34374. getGeometryByID(id: string): Nullable<Geometry>;
  34375. private _getGeometryByUniqueID;
  34376. /**
  34377. * Add a new geometry to this scene
  34378. * @param geometry defines the geometry to be added to the scene.
  34379. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34380. * @return a boolean defining if the geometry was added or not
  34381. */
  34382. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34383. /**
  34384. * Removes an existing geometry
  34385. * @param geometry defines the geometry to be removed from the scene
  34386. * @return a boolean defining if the geometry was removed or not
  34387. */
  34388. removeGeometry(geometry: Geometry): boolean;
  34389. /**
  34390. * Gets the list of geometries attached to the scene
  34391. * @returns an array of Geometry
  34392. */
  34393. getGeometries(): Geometry[];
  34394. /**
  34395. * Gets the first added mesh found of a given ID
  34396. * @param id defines the id to search for
  34397. * @return the mesh found or null if not found at all
  34398. */
  34399. getMeshByID(id: string): Nullable<AbstractMesh>;
  34400. /**
  34401. * Gets a list of meshes using their id
  34402. * @param id defines the id to search for
  34403. * @returns a list of meshes
  34404. */
  34405. getMeshesByID(id: string): Array<AbstractMesh>;
  34406. /**
  34407. * Gets the first added transform node found of a given ID
  34408. * @param id defines the id to search for
  34409. * @return the found transform node or null if not found at all.
  34410. */
  34411. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34412. /**
  34413. * Gets a transform node with its auto-generated unique id
  34414. * @param uniqueId efines the unique id to search for
  34415. * @return the found transform node or null if not found at all.
  34416. */
  34417. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34418. /**
  34419. * Gets a list of transform nodes using their id
  34420. * @param id defines the id to search for
  34421. * @returns a list of transform nodes
  34422. */
  34423. getTransformNodesByID(id: string): Array<TransformNode>;
  34424. /**
  34425. * Gets a mesh with its auto-generated unique id
  34426. * @param uniqueId defines the unique id to search for
  34427. * @return the found mesh or null if not found at all.
  34428. */
  34429. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34430. /**
  34431. * Gets a the last added mesh using a given id
  34432. * @param id defines the id to search for
  34433. * @return the found mesh or null if not found at all.
  34434. */
  34435. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34436. /**
  34437. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34438. * @param id defines the id to search for
  34439. * @return the found node or null if not found at all
  34440. */
  34441. getLastEntryByID(id: string): Nullable<Node>;
  34442. /**
  34443. * Gets a node (Mesh, Camera, Light) using a given id
  34444. * @param id defines the id to search for
  34445. * @return the found node or null if not found at all
  34446. */
  34447. getNodeByID(id: string): Nullable<Node>;
  34448. /**
  34449. * Gets a node (Mesh, Camera, Light) using a given name
  34450. * @param name defines the name to search for
  34451. * @return the found node or null if not found at all.
  34452. */
  34453. getNodeByName(name: string): Nullable<Node>;
  34454. /**
  34455. * Gets a mesh using a given name
  34456. * @param name defines the name to search for
  34457. * @return the found mesh or null if not found at all.
  34458. */
  34459. getMeshByName(name: string): Nullable<AbstractMesh>;
  34460. /**
  34461. * Gets a transform node using a given name
  34462. * @param name defines the name to search for
  34463. * @return the found transform node or null if not found at all.
  34464. */
  34465. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34466. /**
  34467. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34468. * @param id defines the id to search for
  34469. * @return the found skeleton or null if not found at all.
  34470. */
  34471. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34472. /**
  34473. * Gets a skeleton using a given auto generated unique id
  34474. * @param uniqueId defines the unique id to search for
  34475. * @return the found skeleton or null if not found at all.
  34476. */
  34477. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34478. /**
  34479. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34480. * @param id defines the id to search for
  34481. * @return the found skeleton or null if not found at all.
  34482. */
  34483. getSkeletonById(id: string): Nullable<Skeleton>;
  34484. /**
  34485. * Gets a skeleton using a given name
  34486. * @param name defines the name to search for
  34487. * @return the found skeleton or null if not found at all.
  34488. */
  34489. getSkeletonByName(name: string): Nullable<Skeleton>;
  34490. /**
  34491. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34492. * @param id defines the id to search for
  34493. * @return the found morph target manager or null if not found at all.
  34494. */
  34495. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34496. /**
  34497. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34498. * @param id defines the id to search for
  34499. * @return the found morph target or null if not found at all.
  34500. */
  34501. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34502. /**
  34503. * Gets a boolean indicating if the given mesh is active
  34504. * @param mesh defines the mesh to look for
  34505. * @returns true if the mesh is in the active list
  34506. */
  34507. isActiveMesh(mesh: AbstractMesh): boolean;
  34508. /**
  34509. * Return a unique id as a string which can serve as an identifier for the scene
  34510. */
  34511. readonly uid: string;
  34512. /**
  34513. * Add an externaly attached data from its key.
  34514. * This method call will fail and return false, if such key already exists.
  34515. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34516. * @param key the unique key that identifies the data
  34517. * @param data the data object to associate to the key for this Engine instance
  34518. * @return true if no such key were already present and the data was added successfully, false otherwise
  34519. */
  34520. addExternalData<T>(key: string, data: T): boolean;
  34521. /**
  34522. * Get an externaly attached data from its key
  34523. * @param key the unique key that identifies the data
  34524. * @return the associated data, if present (can be null), or undefined if not present
  34525. */
  34526. getExternalData<T>(key: string): Nullable<T>;
  34527. /**
  34528. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34529. * @param key the unique key that identifies the data
  34530. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34531. * @return the associated data, can be null if the factory returned null.
  34532. */
  34533. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34534. /**
  34535. * Remove an externaly attached data from the Engine instance
  34536. * @param key the unique key that identifies the data
  34537. * @return true if the data was successfully removed, false if it doesn't exist
  34538. */
  34539. removeExternalData(key: string): boolean;
  34540. private _evaluateSubMesh;
  34541. /**
  34542. * Clear the processed materials smart array preventing retention point in material dispose.
  34543. */
  34544. freeProcessedMaterials(): void;
  34545. private _preventFreeActiveMeshesAndRenderingGroups;
  34546. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34547. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34548. * when disposing several meshes in a row or a hierarchy of meshes.
  34549. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34550. */
  34551. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34552. /**
  34553. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34554. */
  34555. freeActiveMeshes(): void;
  34556. /**
  34557. * Clear the info related to rendering groups preventing retention points during dispose.
  34558. */
  34559. freeRenderingGroups(): void;
  34560. /** @hidden */
  34561. _isInIntermediateRendering(): boolean;
  34562. /**
  34563. * Lambda returning the list of potentially active meshes.
  34564. */
  34565. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34566. /**
  34567. * Lambda returning the list of potentially active sub meshes.
  34568. */
  34569. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34570. /**
  34571. * Lambda returning the list of potentially intersecting sub meshes.
  34572. */
  34573. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34574. /**
  34575. * Lambda returning the list of potentially colliding sub meshes.
  34576. */
  34577. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34578. private _activeMeshesFrozen;
  34579. /**
  34580. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34581. * @returns the current scene
  34582. */
  34583. freezeActiveMeshes(): Scene;
  34584. /**
  34585. * Use this function to restart evaluating active meshes on every frame
  34586. * @returns the current scene
  34587. */
  34588. unfreezeActiveMeshes(): Scene;
  34589. private _evaluateActiveMeshes;
  34590. private _activeMesh;
  34591. /**
  34592. * Update the transform matrix to update from the current active camera
  34593. * @param force defines a boolean used to force the update even if cache is up to date
  34594. */
  34595. updateTransformMatrix(force?: boolean): void;
  34596. private _bindFrameBuffer;
  34597. /** @hidden */
  34598. _allowPostProcessClearColor: boolean;
  34599. /** @hidden */
  34600. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34601. private _processSubCameras;
  34602. private _checkIntersections;
  34603. /** @hidden */
  34604. _advancePhysicsEngineStep(step: number): void;
  34605. /**
  34606. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34607. */
  34608. getDeterministicFrameTime: () => number;
  34609. /** @hidden */
  34610. _animate(): void;
  34611. /** Execute all animations (for a frame) */
  34612. animate(): void;
  34613. /**
  34614. * Render the scene
  34615. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34616. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34617. */
  34618. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34619. /**
  34620. * Freeze all materials
  34621. * A frozen material will not be updatable but should be faster to render
  34622. */
  34623. freezeMaterials(): void;
  34624. /**
  34625. * Unfreeze all materials
  34626. * A frozen material will not be updatable but should be faster to render
  34627. */
  34628. unfreezeMaterials(): void;
  34629. /**
  34630. * Releases all held ressources
  34631. */
  34632. dispose(): void;
  34633. /**
  34634. * Gets if the scene is already disposed
  34635. */
  34636. readonly isDisposed: boolean;
  34637. /**
  34638. * Call this function to reduce memory footprint of the scene.
  34639. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34640. */
  34641. clearCachedVertexData(): void;
  34642. /**
  34643. * This function will remove the local cached buffer data from texture.
  34644. * It will save memory but will prevent the texture from being rebuilt
  34645. */
  34646. cleanCachedTextureBuffer(): void;
  34647. /**
  34648. * Get the world extend vectors with an optional filter
  34649. *
  34650. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34651. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34652. */
  34653. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34654. min: Vector3;
  34655. max: Vector3;
  34656. };
  34657. /**
  34658. * Creates a ray that can be used to pick in the scene
  34659. * @param x defines the x coordinate of the origin (on-screen)
  34660. * @param y defines the y coordinate of the origin (on-screen)
  34661. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34662. * @param camera defines the camera to use for the picking
  34663. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34664. * @returns a Ray
  34665. */
  34666. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34667. /**
  34668. * Creates a ray that can be used to pick in the scene
  34669. * @param x defines the x coordinate of the origin (on-screen)
  34670. * @param y defines the y coordinate of the origin (on-screen)
  34671. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34672. * @param result defines the ray where to store the picking ray
  34673. * @param camera defines the camera to use for the picking
  34674. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34675. * @returns the current scene
  34676. */
  34677. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34678. /**
  34679. * Creates a ray that can be used to pick in the scene
  34680. * @param x defines the x coordinate of the origin (on-screen)
  34681. * @param y defines the y coordinate of the origin (on-screen)
  34682. * @param camera defines the camera to use for the picking
  34683. * @returns a Ray
  34684. */
  34685. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34686. /**
  34687. * Creates a ray that can be used to pick in the scene
  34688. * @param x defines the x coordinate of the origin (on-screen)
  34689. * @param y defines the y coordinate of the origin (on-screen)
  34690. * @param result defines the ray where to store the picking ray
  34691. * @param camera defines the camera to use for the picking
  34692. * @returns the current scene
  34693. */
  34694. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34695. /** Launch a ray to try to pick a mesh in the scene
  34696. * @param x position on screen
  34697. * @param y position on screen
  34698. * @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
  34699. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34700. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34701. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34702. * @returns a PickingInfo
  34703. */
  34704. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34705. /** Use the given ray to pick a mesh in the scene
  34706. * @param ray The ray to use to pick meshes
  34707. * @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
  34708. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34710. * @returns a PickingInfo
  34711. */
  34712. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34713. /**
  34714. * Launch a ray to try to pick a mesh in the scene
  34715. * @param x X position on screen
  34716. * @param y Y position on screen
  34717. * @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
  34718. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34720. * @returns an array of PickingInfo
  34721. */
  34722. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34723. /**
  34724. * Launch a ray to try to pick a mesh in the scene
  34725. * @param ray Ray to use
  34726. * @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
  34727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34728. * @returns an array of PickingInfo
  34729. */
  34730. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34731. /**
  34732. * Force the value of meshUnderPointer
  34733. * @param mesh defines the mesh to use
  34734. */
  34735. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34736. /**
  34737. * Gets the mesh under the pointer
  34738. * @returns a Mesh or null if no mesh is under the pointer
  34739. */
  34740. getPointerOverMesh(): Nullable<AbstractMesh>;
  34741. /** @hidden */
  34742. _rebuildGeometries(): void;
  34743. /** @hidden */
  34744. _rebuildTextures(): void;
  34745. private _getByTags;
  34746. /**
  34747. * Get a list of meshes by tags
  34748. * @param tagsQuery defines the tags query to use
  34749. * @param forEach defines a predicate used to filter results
  34750. * @returns an array of Mesh
  34751. */
  34752. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34753. /**
  34754. * Get a list of cameras by tags
  34755. * @param tagsQuery defines the tags query to use
  34756. * @param forEach defines a predicate used to filter results
  34757. * @returns an array of Camera
  34758. */
  34759. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34760. /**
  34761. * Get a list of lights by tags
  34762. * @param tagsQuery defines the tags query to use
  34763. * @param forEach defines a predicate used to filter results
  34764. * @returns an array of Light
  34765. */
  34766. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34767. /**
  34768. * Get a list of materials by tags
  34769. * @param tagsQuery defines the tags query to use
  34770. * @param forEach defines a predicate used to filter results
  34771. * @returns an array of Material
  34772. */
  34773. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34774. /**
  34775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34776. * This allowed control for front to back rendering or reversly depending of the special needs.
  34777. *
  34778. * @param renderingGroupId The rendering group id corresponding to its index
  34779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34782. */
  34783. 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;
  34784. /**
  34785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34786. *
  34787. * @param renderingGroupId The rendering group id corresponding to its index
  34788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34791. */
  34792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34793. /**
  34794. * Gets the current auto clear configuration for one rendering group of the rendering
  34795. * manager.
  34796. * @param index the rendering group index to get the information for
  34797. * @returns The auto clear setup for the requested rendering group
  34798. */
  34799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34800. private _blockMaterialDirtyMechanism;
  34801. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34802. blockMaterialDirtyMechanism: boolean;
  34803. /**
  34804. * Will flag all materials as dirty to trigger new shader compilation
  34805. * @param flag defines the flag used to specify which material part must be marked as dirty
  34806. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34807. */
  34808. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34809. /** @hidden */
  34810. _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;
  34811. /** @hidden */
  34812. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34813. }
  34814. }
  34815. declare module BABYLON {
  34816. /**
  34817. * Set of assets to keep when moving a scene into an asset container.
  34818. */
  34819. export class KeepAssets extends AbstractScene {
  34820. }
  34821. /**
  34822. * Container with a set of assets that can be added or removed from a scene.
  34823. */
  34824. export class AssetContainer extends AbstractScene {
  34825. /**
  34826. * The scene the AssetContainer belongs to.
  34827. */
  34828. scene: Scene;
  34829. /**
  34830. * Instantiates an AssetContainer.
  34831. * @param scene The scene the AssetContainer belongs to.
  34832. */
  34833. constructor(scene: Scene);
  34834. /**
  34835. * Adds all the assets from the container to the scene.
  34836. */
  34837. addAllToScene(): void;
  34838. /**
  34839. * Removes all the assets in the container from the scene
  34840. */
  34841. removeAllFromScene(): void;
  34842. /**
  34843. * Disposes all the assets in the container
  34844. */
  34845. dispose(): void;
  34846. private _moveAssets;
  34847. /**
  34848. * Removes all the assets contained in the scene and adds them to the container.
  34849. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34850. */
  34851. moveAllFromScene(keepAssets?: KeepAssets): void;
  34852. /**
  34853. * 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.
  34854. * @returns the root mesh
  34855. */
  34856. createRootMesh(): Mesh;
  34857. }
  34858. }
  34859. declare module BABYLON {
  34860. /**
  34861. * Defines how the parser contract is defined.
  34862. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34863. */
  34864. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34865. /**
  34866. * Defines how the individual parser contract is defined.
  34867. * These parser can parse an individual asset
  34868. */
  34869. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34870. /**
  34871. * Base class of the scene acting as a container for the different elements composing a scene.
  34872. * This class is dynamically extended by the different components of the scene increasing
  34873. * flexibility and reducing coupling
  34874. */
  34875. export abstract class AbstractScene {
  34876. /**
  34877. * Stores the list of available parsers in the application.
  34878. */
  34879. private static _BabylonFileParsers;
  34880. /**
  34881. * Stores the list of available individual parsers in the application.
  34882. */
  34883. private static _IndividualBabylonFileParsers;
  34884. /**
  34885. * Adds a parser in the list of available ones
  34886. * @param name Defines the name of the parser
  34887. * @param parser Defines the parser to add
  34888. */
  34889. static AddParser(name: string, parser: BabylonFileParser): void;
  34890. /**
  34891. * Gets a general parser from the list of avaialble ones
  34892. * @param name Defines the name of the parser
  34893. * @returns the requested parser or null
  34894. */
  34895. static GetParser(name: string): Nullable<BabylonFileParser>;
  34896. /**
  34897. * Adds n individual parser in the list of available ones
  34898. * @param name Defines the name of the parser
  34899. * @param parser Defines the parser to add
  34900. */
  34901. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34902. /**
  34903. * Gets an individual parser from the list of avaialble ones
  34904. * @param name Defines the name of the parser
  34905. * @returns the requested parser or null
  34906. */
  34907. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34908. /**
  34909. * Parser json data and populate both a scene and its associated container object
  34910. * @param jsonData Defines the data to parse
  34911. * @param scene Defines the scene to parse the data for
  34912. * @param container Defines the container attached to the parsing sequence
  34913. * @param rootUrl Defines the root url of the data
  34914. */
  34915. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34916. /**
  34917. * Gets the list of root nodes (ie. nodes with no parent)
  34918. */
  34919. rootNodes: Node[];
  34920. /** All of the cameras added to this scene
  34921. * @see http://doc.babylonjs.com/babylon101/cameras
  34922. */
  34923. cameras: Camera[];
  34924. /**
  34925. * All of the lights added to this scene
  34926. * @see http://doc.babylonjs.com/babylon101/lights
  34927. */
  34928. lights: Light[];
  34929. /**
  34930. * All of the (abstract) meshes added to this scene
  34931. */
  34932. meshes: AbstractMesh[];
  34933. /**
  34934. * The list of skeletons added to the scene
  34935. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34936. */
  34937. skeletons: Skeleton[];
  34938. /**
  34939. * All of the particle systems added to this scene
  34940. * @see http://doc.babylonjs.com/babylon101/particles
  34941. */
  34942. particleSystems: IParticleSystem[];
  34943. /**
  34944. * Gets a list of Animations associated with the scene
  34945. */
  34946. animations: Animation[];
  34947. /**
  34948. * All of the animation groups added to this scene
  34949. * @see http://doc.babylonjs.com/how_to/group
  34950. */
  34951. animationGroups: AnimationGroup[];
  34952. /**
  34953. * All of the multi-materials added to this scene
  34954. * @see http://doc.babylonjs.com/how_to/multi_materials
  34955. */
  34956. multiMaterials: MultiMaterial[];
  34957. /**
  34958. * All of the materials added to this scene
  34959. * In the context of a Scene, it is not supposed to be modified manually.
  34960. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34961. * Note also that the order of the Material wihin the array is not significant and might change.
  34962. * @see http://doc.babylonjs.com/babylon101/materials
  34963. */
  34964. materials: Material[];
  34965. /**
  34966. * The list of morph target managers added to the scene
  34967. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34968. */
  34969. morphTargetManagers: MorphTargetManager[];
  34970. /**
  34971. * The list of geometries used in the scene.
  34972. */
  34973. geometries: Geometry[];
  34974. /**
  34975. * All of the tranform nodes added to this scene
  34976. * In the context of a Scene, it is not supposed to be modified manually.
  34977. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34978. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34979. * @see http://doc.babylonjs.com/how_to/transformnode
  34980. */
  34981. transformNodes: TransformNode[];
  34982. /**
  34983. * ActionManagers available on the scene.
  34984. */
  34985. actionManagers: AbstractActionManager[];
  34986. /**
  34987. * Textures to keep.
  34988. */
  34989. textures: BaseTexture[];
  34990. /**
  34991. * Environment texture for the scene
  34992. */
  34993. environmentTexture: Nullable<BaseTexture>;
  34994. }
  34995. }
  34996. declare module BABYLON {
  34997. /**
  34998. * Interface used to define options for Sound class
  34999. */
  35000. export interface ISoundOptions {
  35001. /**
  35002. * Does the sound autoplay once loaded.
  35003. */
  35004. autoplay?: boolean;
  35005. /**
  35006. * Does the sound loop after it finishes playing once.
  35007. */
  35008. loop?: boolean;
  35009. /**
  35010. * Sound's volume
  35011. */
  35012. volume?: number;
  35013. /**
  35014. * Is it a spatial sound?
  35015. */
  35016. spatialSound?: boolean;
  35017. /**
  35018. * Maximum distance to hear that sound
  35019. */
  35020. maxDistance?: number;
  35021. /**
  35022. * Uses user defined attenuation function
  35023. */
  35024. useCustomAttenuation?: boolean;
  35025. /**
  35026. * Define the roll off factor of spatial sounds.
  35027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35028. */
  35029. rolloffFactor?: number;
  35030. /**
  35031. * Define the reference distance the sound should be heard perfectly.
  35032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35033. */
  35034. refDistance?: number;
  35035. /**
  35036. * Define the distance attenuation model the sound will follow.
  35037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35038. */
  35039. distanceModel?: string;
  35040. /**
  35041. * Defines the playback speed (1 by default)
  35042. */
  35043. playbackRate?: number;
  35044. /**
  35045. * Defines if the sound is from a streaming source
  35046. */
  35047. streaming?: boolean;
  35048. /**
  35049. * Defines an optional length (in seconds) inside the sound file
  35050. */
  35051. length?: number;
  35052. /**
  35053. * Defines an optional offset (in seconds) inside the sound file
  35054. */
  35055. offset?: number;
  35056. /**
  35057. * If true, URLs will not be required to state the audio file codec to use.
  35058. */
  35059. skipCodecCheck?: boolean;
  35060. }
  35061. /**
  35062. * Defines a sound that can be played in the application.
  35063. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35065. */
  35066. export class Sound {
  35067. /**
  35068. * The name of the sound in the scene.
  35069. */
  35070. name: string;
  35071. /**
  35072. * Does the sound autoplay once loaded.
  35073. */
  35074. autoplay: boolean;
  35075. /**
  35076. * Does the sound loop after it finishes playing once.
  35077. */
  35078. loop: boolean;
  35079. /**
  35080. * Does the sound use a custom attenuation curve to simulate the falloff
  35081. * happening when the source gets further away from the camera.
  35082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35083. */
  35084. useCustomAttenuation: boolean;
  35085. /**
  35086. * The sound track id this sound belongs to.
  35087. */
  35088. soundTrackId: number;
  35089. /**
  35090. * Is this sound currently played.
  35091. */
  35092. isPlaying: boolean;
  35093. /**
  35094. * Is this sound currently paused.
  35095. */
  35096. isPaused: boolean;
  35097. /**
  35098. * Does this sound enables spatial sound.
  35099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35100. */
  35101. spatialSound: boolean;
  35102. /**
  35103. * Define the reference distance the sound should be heard perfectly.
  35104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35105. */
  35106. refDistance: number;
  35107. /**
  35108. * Define the roll off factor of spatial sounds.
  35109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35110. */
  35111. rolloffFactor: number;
  35112. /**
  35113. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35115. */
  35116. maxDistance: number;
  35117. /**
  35118. * Define the distance attenuation model the sound will follow.
  35119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35120. */
  35121. distanceModel: string;
  35122. /**
  35123. * @hidden
  35124. * Back Compat
  35125. **/
  35126. onended: () => any;
  35127. /**
  35128. * Observable event when the current playing sound finishes.
  35129. */
  35130. onEndedObservable: Observable<Sound>;
  35131. private _panningModel;
  35132. private _playbackRate;
  35133. private _streaming;
  35134. private _startTime;
  35135. private _startOffset;
  35136. private _position;
  35137. /** @hidden */
  35138. _positionInEmitterSpace: boolean;
  35139. private _localDirection;
  35140. private _volume;
  35141. private _isReadyToPlay;
  35142. private _isDirectional;
  35143. private _readyToPlayCallback;
  35144. private _audioBuffer;
  35145. private _soundSource;
  35146. private _streamingSource;
  35147. private _soundPanner;
  35148. private _soundGain;
  35149. private _inputAudioNode;
  35150. private _outputAudioNode;
  35151. private _coneInnerAngle;
  35152. private _coneOuterAngle;
  35153. private _coneOuterGain;
  35154. private _scene;
  35155. private _connectedTransformNode;
  35156. private _customAttenuationFunction;
  35157. private _registerFunc;
  35158. private _isOutputConnected;
  35159. private _htmlAudioElement;
  35160. private _urlType;
  35161. private _length?;
  35162. private _offset?;
  35163. /** @hidden */
  35164. static _SceneComponentInitialization: (scene: Scene) => void;
  35165. /**
  35166. * Create a sound and attach it to a scene
  35167. * @param name Name of your sound
  35168. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35169. * @param scene defines the scene the sound belongs to
  35170. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35171. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35172. */
  35173. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35174. /**
  35175. * Release the sound and its associated resources
  35176. */
  35177. dispose(): void;
  35178. /**
  35179. * Gets if the sounds is ready to be played or not.
  35180. * @returns true if ready, otherwise false
  35181. */
  35182. isReady(): boolean;
  35183. private _soundLoaded;
  35184. /**
  35185. * Sets the data of the sound from an audiobuffer
  35186. * @param audioBuffer The audioBuffer containing the data
  35187. */
  35188. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35189. /**
  35190. * Updates the current sounds options such as maxdistance, loop...
  35191. * @param options A JSON object containing values named as the object properties
  35192. */
  35193. updateOptions(options: ISoundOptions): void;
  35194. private _createSpatialParameters;
  35195. private _updateSpatialParameters;
  35196. /**
  35197. * Switch the panning model to HRTF:
  35198. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35200. */
  35201. switchPanningModelToHRTF(): void;
  35202. /**
  35203. * Switch the panning model to Equal Power:
  35204. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35206. */
  35207. switchPanningModelToEqualPower(): void;
  35208. private _switchPanningModel;
  35209. /**
  35210. * Connect this sound to a sound track audio node like gain...
  35211. * @param soundTrackAudioNode the sound track audio node to connect to
  35212. */
  35213. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35214. /**
  35215. * Transform this sound into a directional source
  35216. * @param coneInnerAngle Size of the inner cone in degree
  35217. * @param coneOuterAngle Size of the outer cone in degree
  35218. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35219. */
  35220. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35221. /**
  35222. * Gets or sets the inner angle for the directional cone.
  35223. */
  35224. /**
  35225. * Gets or sets the inner angle for the directional cone.
  35226. */
  35227. directionalConeInnerAngle: number;
  35228. /**
  35229. * Gets or sets the outer angle for the directional cone.
  35230. */
  35231. /**
  35232. * Gets or sets the outer angle for the directional cone.
  35233. */
  35234. directionalConeOuterAngle: number;
  35235. /**
  35236. * Sets the position of the emitter if spatial sound is enabled
  35237. * @param newPosition Defines the new posisiton
  35238. */
  35239. setPosition(newPosition: Vector3): void;
  35240. /**
  35241. * Sets the local direction of the emitter if spatial sound is enabled
  35242. * @param newLocalDirection Defines the new local direction
  35243. */
  35244. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35245. private _updateDirection;
  35246. /** @hidden */
  35247. updateDistanceFromListener(): void;
  35248. /**
  35249. * Sets a new custom attenuation function for the sound.
  35250. * @param callback Defines the function used for the attenuation
  35251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35252. */
  35253. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35254. /**
  35255. * Play the sound
  35256. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35257. * @param offset (optional) Start the sound at a specific time in seconds
  35258. * @param length (optional) Sound duration (in seconds)
  35259. */
  35260. play(time?: number, offset?: number, length?: number): void;
  35261. private _onended;
  35262. /**
  35263. * Stop the sound
  35264. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35265. */
  35266. stop(time?: number): void;
  35267. /**
  35268. * Put the sound in pause
  35269. */
  35270. pause(): void;
  35271. /**
  35272. * Sets a dedicated volume for this sounds
  35273. * @param newVolume Define the new volume of the sound
  35274. * @param time Define time for gradual change to new volume
  35275. */
  35276. setVolume(newVolume: number, time?: number): void;
  35277. /**
  35278. * Set the sound play back rate
  35279. * @param newPlaybackRate Define the playback rate the sound should be played at
  35280. */
  35281. setPlaybackRate(newPlaybackRate: number): void;
  35282. /**
  35283. * Gets the volume of the sound.
  35284. * @returns the volume of the sound
  35285. */
  35286. getVolume(): number;
  35287. /**
  35288. * Attach the sound to a dedicated mesh
  35289. * @param transformNode The transform node to connect the sound with
  35290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35291. */
  35292. attachToMesh(transformNode: TransformNode): void;
  35293. /**
  35294. * Detach the sound from the previously attached mesh
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35296. */
  35297. detachFromMesh(): void;
  35298. private _onRegisterAfterWorldMatrixUpdate;
  35299. /**
  35300. * Clone the current sound in the scene.
  35301. * @returns the new sound clone
  35302. */
  35303. clone(): Nullable<Sound>;
  35304. /**
  35305. * Gets the current underlying audio buffer containing the data
  35306. * @returns the audio buffer
  35307. */
  35308. getAudioBuffer(): Nullable<AudioBuffer>;
  35309. /**
  35310. * Serializes the Sound in a JSON representation
  35311. * @returns the JSON representation of the sound
  35312. */
  35313. serialize(): any;
  35314. /**
  35315. * Parse a JSON representation of a sound to innstantiate in a given scene
  35316. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35317. * @param scene Define the scene the new parsed sound should be created in
  35318. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35319. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35320. * @returns the newly parsed sound
  35321. */
  35322. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35323. }
  35324. }
  35325. declare module BABYLON {
  35326. /**
  35327. * This defines an action helpful to play a defined sound on a triggered action.
  35328. */
  35329. export class PlaySoundAction extends Action {
  35330. private _sound;
  35331. /**
  35332. * Instantiate the action
  35333. * @param triggerOptions defines the trigger options
  35334. * @param sound defines the sound to play
  35335. * @param condition defines the trigger related conditions
  35336. */
  35337. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35338. /** @hidden */
  35339. _prepare(): void;
  35340. /**
  35341. * Execute the action and play the sound.
  35342. */
  35343. execute(): void;
  35344. /**
  35345. * Serializes the actions and its related information.
  35346. * @param parent defines the object to serialize in
  35347. * @returns the serialized object
  35348. */
  35349. serialize(parent: any): any;
  35350. }
  35351. /**
  35352. * This defines an action helpful to stop a defined sound on a triggered action.
  35353. */
  35354. export class StopSoundAction extends Action {
  35355. private _sound;
  35356. /**
  35357. * Instantiate the action
  35358. * @param triggerOptions defines the trigger options
  35359. * @param sound defines the sound to stop
  35360. * @param condition defines the trigger related conditions
  35361. */
  35362. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35363. /** @hidden */
  35364. _prepare(): void;
  35365. /**
  35366. * Execute the action and stop the sound.
  35367. */
  35368. execute(): void;
  35369. /**
  35370. * Serializes the actions and its related information.
  35371. * @param parent defines the object to serialize in
  35372. * @returns the serialized object
  35373. */
  35374. serialize(parent: any): any;
  35375. }
  35376. }
  35377. declare module BABYLON {
  35378. /**
  35379. * This defines an action responsible to change the value of a property
  35380. * by interpolating between its current value and the newly set one once triggered.
  35381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35382. */
  35383. export class InterpolateValueAction extends Action {
  35384. /**
  35385. * Defines the path of the property where the value should be interpolated
  35386. */
  35387. propertyPath: string;
  35388. /**
  35389. * Defines the target value at the end of the interpolation.
  35390. */
  35391. value: any;
  35392. /**
  35393. * Defines the time it will take for the property to interpolate to the value.
  35394. */
  35395. duration: number;
  35396. /**
  35397. * Defines if the other scene animations should be stopped when the action has been triggered
  35398. */
  35399. stopOtherAnimations?: boolean;
  35400. /**
  35401. * Defines a callback raised once the interpolation animation has been done.
  35402. */
  35403. onInterpolationDone?: () => void;
  35404. /**
  35405. * Observable triggered once the interpolation animation has been done.
  35406. */
  35407. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35408. private _target;
  35409. private _effectiveTarget;
  35410. private _property;
  35411. /**
  35412. * Instantiate the action
  35413. * @param triggerOptions defines the trigger options
  35414. * @param target defines the object containing the value to interpolate
  35415. * @param propertyPath defines the path to the property in the target object
  35416. * @param value defines the target value at the end of the interpolation
  35417. * @param duration deines the time it will take for the property to interpolate to the value.
  35418. * @param condition defines the trigger related conditions
  35419. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35420. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35421. */
  35422. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35423. /** @hidden */
  35424. _prepare(): void;
  35425. /**
  35426. * Execute the action starts the value interpolation.
  35427. */
  35428. execute(): void;
  35429. /**
  35430. * Serializes the actions and its related information.
  35431. * @param parent defines the object to serialize in
  35432. * @returns the serialized object
  35433. */
  35434. serialize(parent: any): any;
  35435. }
  35436. }
  35437. declare module BABYLON {
  35438. /**
  35439. * Options allowed during the creation of a sound track.
  35440. */
  35441. export interface ISoundTrackOptions {
  35442. /**
  35443. * The volume the sound track should take during creation
  35444. */
  35445. volume?: number;
  35446. /**
  35447. * Define if the sound track is the main sound track of the scene
  35448. */
  35449. mainTrack?: boolean;
  35450. }
  35451. /**
  35452. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35453. * It will be also used in a future release to apply effects on a specific track.
  35454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35455. */
  35456. export class SoundTrack {
  35457. /**
  35458. * The unique identifier of the sound track in the scene.
  35459. */
  35460. id: number;
  35461. /**
  35462. * The list of sounds included in the sound track.
  35463. */
  35464. soundCollection: Array<Sound>;
  35465. private _outputAudioNode;
  35466. private _scene;
  35467. private _isMainTrack;
  35468. private _connectedAnalyser;
  35469. private _options;
  35470. private _isInitialized;
  35471. /**
  35472. * Creates a new sound track.
  35473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35474. * @param scene Define the scene the sound track belongs to
  35475. * @param options
  35476. */
  35477. constructor(scene: Scene, options?: ISoundTrackOptions);
  35478. private _initializeSoundTrackAudioGraph;
  35479. /**
  35480. * Release the sound track and its associated resources
  35481. */
  35482. dispose(): void;
  35483. /**
  35484. * Adds a sound to this sound track
  35485. * @param sound define the cound to add
  35486. * @ignoreNaming
  35487. */
  35488. AddSound(sound: Sound): void;
  35489. /**
  35490. * Removes a sound to this sound track
  35491. * @param sound define the cound to remove
  35492. * @ignoreNaming
  35493. */
  35494. RemoveSound(sound: Sound): void;
  35495. /**
  35496. * Set a global volume for the full sound track.
  35497. * @param newVolume Define the new volume of the sound track
  35498. */
  35499. setVolume(newVolume: number): void;
  35500. /**
  35501. * Switch the panning model to HRTF:
  35502. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35504. */
  35505. switchPanningModelToHRTF(): void;
  35506. /**
  35507. * Switch the panning model to Equal Power:
  35508. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35510. */
  35511. switchPanningModelToEqualPower(): void;
  35512. /**
  35513. * Connect the sound track to an audio analyser allowing some amazing
  35514. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35516. * @param analyser The analyser to connect to the engine
  35517. */
  35518. connectToAnalyser(analyser: Analyser): void;
  35519. }
  35520. }
  35521. declare module BABYLON {
  35522. interface AbstractScene {
  35523. /**
  35524. * The list of sounds used in the scene.
  35525. */
  35526. sounds: Nullable<Array<Sound>>;
  35527. }
  35528. interface Scene {
  35529. /**
  35530. * @hidden
  35531. * Backing field
  35532. */
  35533. _mainSoundTrack: SoundTrack;
  35534. /**
  35535. * The main sound track played by the scene.
  35536. * It cotains your primary collection of sounds.
  35537. */
  35538. mainSoundTrack: SoundTrack;
  35539. /**
  35540. * The list of sound tracks added to the scene
  35541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35542. */
  35543. soundTracks: Nullable<Array<SoundTrack>>;
  35544. /**
  35545. * Gets a sound using a given name
  35546. * @param name defines the name to search for
  35547. * @return the found sound or null if not found at all.
  35548. */
  35549. getSoundByName(name: string): Nullable<Sound>;
  35550. /**
  35551. * Gets or sets if audio support is enabled
  35552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35553. */
  35554. audioEnabled: boolean;
  35555. /**
  35556. * Gets or sets if audio will be output to headphones
  35557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35558. */
  35559. headphone: boolean;
  35560. /**
  35561. * Gets or sets custom audio listener position provider
  35562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35563. */
  35564. audioListenerPositionProvider: Nullable<() => Vector3>;
  35565. }
  35566. /**
  35567. * Defines the sound scene component responsible to manage any sounds
  35568. * in a given scene.
  35569. */
  35570. export class AudioSceneComponent implements ISceneSerializableComponent {
  35571. /**
  35572. * The component name helpfull to identify the component in the list of scene components.
  35573. */
  35574. readonly name: string;
  35575. /**
  35576. * The scene the component belongs to.
  35577. */
  35578. scene: Scene;
  35579. private _audioEnabled;
  35580. /**
  35581. * Gets whether audio is enabled or not.
  35582. * Please use related enable/disable method to switch state.
  35583. */
  35584. readonly audioEnabled: boolean;
  35585. private _headphone;
  35586. /**
  35587. * Gets whether audio is outputing to headphone or not.
  35588. * Please use the according Switch methods to change output.
  35589. */
  35590. readonly headphone: boolean;
  35591. private _audioListenerPositionProvider;
  35592. /**
  35593. * Gets the current audio listener position provider
  35594. */
  35595. /**
  35596. * Sets a custom listener position for all sounds in the scene
  35597. * By default, this is the position of the first active camera
  35598. */
  35599. audioListenerPositionProvider: Nullable<() => Vector3>;
  35600. /**
  35601. * Creates a new instance of the component for the given scene
  35602. * @param scene Defines the scene to register the component in
  35603. */
  35604. constructor(scene: Scene);
  35605. /**
  35606. * Registers the component in a given scene
  35607. */
  35608. register(): void;
  35609. /**
  35610. * Rebuilds the elements related to this component in case of
  35611. * context lost for instance.
  35612. */
  35613. rebuild(): void;
  35614. /**
  35615. * Serializes the component data to the specified json object
  35616. * @param serializationObject The object to serialize to
  35617. */
  35618. serialize(serializationObject: any): void;
  35619. /**
  35620. * Adds all the elements from the container to the scene
  35621. * @param container the container holding the elements
  35622. */
  35623. addFromContainer(container: AbstractScene): void;
  35624. /**
  35625. * Removes all the elements in the container from the scene
  35626. * @param container contains the elements to remove
  35627. * @param dispose if the removed element should be disposed (default: false)
  35628. */
  35629. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35630. /**
  35631. * Disposes the component and the associated ressources.
  35632. */
  35633. dispose(): void;
  35634. /**
  35635. * Disables audio in the associated scene.
  35636. */
  35637. disableAudio(): void;
  35638. /**
  35639. * Enables audio in the associated scene.
  35640. */
  35641. enableAudio(): void;
  35642. /**
  35643. * Switch audio to headphone output.
  35644. */
  35645. switchAudioModeForHeadphones(): void;
  35646. /**
  35647. * Switch audio to normal speakers.
  35648. */
  35649. switchAudioModeForNormalSpeakers(): void;
  35650. private _afterRender;
  35651. }
  35652. }
  35653. declare module BABYLON {
  35654. /**
  35655. * Wraps one or more Sound objects and selects one with random weight for playback.
  35656. */
  35657. export class WeightedSound {
  35658. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35659. loop: boolean;
  35660. private _coneInnerAngle;
  35661. private _coneOuterAngle;
  35662. private _volume;
  35663. /** A Sound is currently playing. */
  35664. isPlaying: boolean;
  35665. /** A Sound is currently paused. */
  35666. isPaused: boolean;
  35667. private _sounds;
  35668. private _weights;
  35669. private _currentIndex?;
  35670. /**
  35671. * Creates a new WeightedSound from the list of sounds given.
  35672. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35673. * @param sounds Array of Sounds that will be selected from.
  35674. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35675. */
  35676. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35677. /**
  35678. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35679. */
  35680. /**
  35681. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35682. */
  35683. directionalConeInnerAngle: number;
  35684. /**
  35685. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35686. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35687. */
  35688. /**
  35689. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35690. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35691. */
  35692. directionalConeOuterAngle: number;
  35693. /**
  35694. * Playback volume.
  35695. */
  35696. /**
  35697. * Playback volume.
  35698. */
  35699. volume: number;
  35700. private _onended;
  35701. /**
  35702. * Suspend playback
  35703. */
  35704. pause(): void;
  35705. /**
  35706. * Stop playback
  35707. */
  35708. stop(): void;
  35709. /**
  35710. * Start playback.
  35711. * @param startOffset Position the clip head at a specific time in seconds.
  35712. */
  35713. play(startOffset?: number): void;
  35714. }
  35715. }
  35716. declare module BABYLON {
  35717. /**
  35718. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35719. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35720. */
  35721. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35722. /**
  35723. * Gets the name of the behavior.
  35724. */
  35725. readonly name: string;
  35726. /**
  35727. * The easing function used by animations
  35728. */
  35729. static EasingFunction: BackEase;
  35730. /**
  35731. * The easing mode used by animations
  35732. */
  35733. static EasingMode: number;
  35734. /**
  35735. * The duration of the animation, in milliseconds
  35736. */
  35737. transitionDuration: number;
  35738. /**
  35739. * Length of the distance animated by the transition when lower radius is reached
  35740. */
  35741. lowerRadiusTransitionRange: number;
  35742. /**
  35743. * Length of the distance animated by the transition when upper radius is reached
  35744. */
  35745. upperRadiusTransitionRange: number;
  35746. private _autoTransitionRange;
  35747. /**
  35748. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35749. */
  35750. /**
  35751. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35752. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35753. */
  35754. autoTransitionRange: boolean;
  35755. private _attachedCamera;
  35756. private _onAfterCheckInputsObserver;
  35757. private _onMeshTargetChangedObserver;
  35758. /**
  35759. * Initializes the behavior.
  35760. */
  35761. init(): void;
  35762. /**
  35763. * Attaches the behavior to its arc rotate camera.
  35764. * @param camera Defines the camera to attach the behavior to
  35765. */
  35766. attach(camera: ArcRotateCamera): void;
  35767. /**
  35768. * Detaches the behavior from its current arc rotate camera.
  35769. */
  35770. detach(): void;
  35771. private _radiusIsAnimating;
  35772. private _radiusBounceTransition;
  35773. private _animatables;
  35774. private _cachedWheelPrecision;
  35775. /**
  35776. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35777. * @param radiusLimit The limit to check against.
  35778. * @return Bool to indicate if at limit.
  35779. */
  35780. private _isRadiusAtLimit;
  35781. /**
  35782. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35783. * @param radiusDelta The delta by which to animate to. Can be negative.
  35784. */
  35785. private _applyBoundRadiusAnimation;
  35786. /**
  35787. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35788. */
  35789. protected _clearAnimationLocks(): void;
  35790. /**
  35791. * Stops and removes all animations that have been applied to the camera
  35792. */
  35793. stopAllAnimations(): void;
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * 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.
  35799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35800. */
  35801. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35802. /**
  35803. * Gets the name of the behavior.
  35804. */
  35805. readonly name: string;
  35806. private _mode;
  35807. private _radiusScale;
  35808. private _positionScale;
  35809. private _defaultElevation;
  35810. private _elevationReturnTime;
  35811. private _elevationReturnWaitTime;
  35812. private _zoomStopsAnimation;
  35813. private _framingTime;
  35814. /**
  35815. * The easing function used by animations
  35816. */
  35817. static EasingFunction: ExponentialEase;
  35818. /**
  35819. * The easing mode used by animations
  35820. */
  35821. static EasingMode: number;
  35822. /**
  35823. * Sets the current mode used by the behavior
  35824. */
  35825. /**
  35826. * Gets current mode used by the behavior.
  35827. */
  35828. mode: number;
  35829. /**
  35830. * Sets the scale applied to the radius (1 by default)
  35831. */
  35832. /**
  35833. * Gets the scale applied to the radius
  35834. */
  35835. radiusScale: number;
  35836. /**
  35837. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35838. */
  35839. /**
  35840. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35841. */
  35842. positionScale: number;
  35843. /**
  35844. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35845. * behaviour is triggered, in radians.
  35846. */
  35847. /**
  35848. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35849. * behaviour is triggered, in radians.
  35850. */
  35851. defaultElevation: number;
  35852. /**
  35853. * Sets the time (in milliseconds) taken to return to the default beta position.
  35854. * Negative value indicates camera should not return to default.
  35855. */
  35856. /**
  35857. * Gets the time (in milliseconds) taken to return to the default beta position.
  35858. * Negative value indicates camera should not return to default.
  35859. */
  35860. elevationReturnTime: number;
  35861. /**
  35862. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35863. */
  35864. /**
  35865. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35866. */
  35867. elevationReturnWaitTime: number;
  35868. /**
  35869. * Sets the flag that indicates if user zooming should stop animation.
  35870. */
  35871. /**
  35872. * Gets the flag that indicates if user zooming should stop animation.
  35873. */
  35874. zoomStopsAnimation: boolean;
  35875. /**
  35876. * Sets the transition time when framing the mesh, in milliseconds
  35877. */
  35878. /**
  35879. * Gets the transition time when framing the mesh, in milliseconds
  35880. */
  35881. framingTime: number;
  35882. /**
  35883. * Define if the behavior should automatically change the configured
  35884. * camera limits and sensibilities.
  35885. */
  35886. autoCorrectCameraLimitsAndSensibility: boolean;
  35887. private _onPrePointerObservableObserver;
  35888. private _onAfterCheckInputsObserver;
  35889. private _onMeshTargetChangedObserver;
  35890. private _attachedCamera;
  35891. private _isPointerDown;
  35892. private _lastInteractionTime;
  35893. /**
  35894. * Initializes the behavior.
  35895. */
  35896. init(): void;
  35897. /**
  35898. * Attaches the behavior to its arc rotate camera.
  35899. * @param camera Defines the camera to attach the behavior to
  35900. */
  35901. attach(camera: ArcRotateCamera): void;
  35902. /**
  35903. * Detaches the behavior from its current arc rotate camera.
  35904. */
  35905. detach(): void;
  35906. private _animatables;
  35907. private _betaIsAnimating;
  35908. private _betaTransition;
  35909. private _radiusTransition;
  35910. private _vectorTransition;
  35911. /**
  35912. * Targets the given mesh and updates zoom level accordingly.
  35913. * @param mesh The mesh to target.
  35914. * @param radius Optional. If a cached radius position already exists, overrides default.
  35915. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35916. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35917. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35918. */
  35919. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35920. /**
  35921. * Targets the given mesh with its children and updates zoom level accordingly.
  35922. * @param mesh The mesh to target.
  35923. * @param radius Optional. If a cached radius position already exists, overrides default.
  35924. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35925. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35926. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35927. */
  35928. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35929. /**
  35930. * Targets the given meshes with their children and updates zoom level accordingly.
  35931. * @param meshes The mesh to target.
  35932. * @param radius Optional. If a cached radius position already exists, overrides default.
  35933. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35934. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35935. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35936. */
  35937. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35938. /**
  35939. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35940. * @param minimumWorld Determines the smaller position of the bounding box extend
  35941. * @param maximumWorld Determines the bigger position of the bounding box extend
  35942. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35943. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35944. */
  35945. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35946. /**
  35947. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35948. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35949. * frustum width.
  35950. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35951. * to fully enclose the mesh in the viewing frustum.
  35952. */
  35953. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35954. /**
  35955. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35956. * is automatically returned to its default position (expected to be above ground plane).
  35957. */
  35958. private _maintainCameraAboveGround;
  35959. /**
  35960. * Returns the frustum slope based on the canvas ratio and camera FOV
  35961. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35962. */
  35963. private _getFrustumSlope;
  35964. /**
  35965. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35966. */
  35967. private _clearAnimationLocks;
  35968. /**
  35969. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35970. */
  35971. private _applyUserInteraction;
  35972. /**
  35973. * Stops and removes all animations that have been applied to the camera
  35974. */
  35975. stopAllAnimations(): void;
  35976. /**
  35977. * Gets a value indicating if the user is moving the camera
  35978. */
  35979. readonly isUserIsMoving: boolean;
  35980. /**
  35981. * The camera can move all the way towards the mesh.
  35982. */
  35983. static IgnoreBoundsSizeMode: number;
  35984. /**
  35985. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35986. */
  35987. static FitFrustumSidesMode: number;
  35988. }
  35989. }
  35990. declare module BABYLON {
  35991. /**
  35992. * Base class for Camera Pointer Inputs.
  35993. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35994. * for example usage.
  35995. */
  35996. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35997. /**
  35998. * Defines the camera the input is attached to.
  35999. */
  36000. abstract camera: Camera;
  36001. /**
  36002. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36003. */
  36004. protected _altKey: boolean;
  36005. protected _ctrlKey: boolean;
  36006. protected _metaKey: boolean;
  36007. protected _shiftKey: boolean;
  36008. /**
  36009. * Which mouse buttons were pressed at time of last mouse event.
  36010. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36011. */
  36012. protected _buttonsPressed: number;
  36013. /**
  36014. * Defines the buttons associated with the input to handle camera move.
  36015. */
  36016. buttons: number[];
  36017. /**
  36018. * Attach the input controls to a specific dom element to get the input from.
  36019. * @param element Defines the element the controls should be listened from
  36020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36021. */
  36022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36023. /**
  36024. * Detach the current controls from the specified dom element.
  36025. * @param element Defines the element to stop listening the inputs from
  36026. */
  36027. detachControl(element: Nullable<HTMLElement>): void;
  36028. /**
  36029. * Gets the class name of the current input.
  36030. * @returns the class name
  36031. */
  36032. getClassName(): string;
  36033. /**
  36034. * Get the friendly name associated with the input class.
  36035. * @returns the input friendly name
  36036. */
  36037. getSimpleName(): string;
  36038. /**
  36039. * Called on pointer POINTERDOUBLETAP event.
  36040. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36041. */
  36042. protected onDoubleTap(type: string): void;
  36043. /**
  36044. * Called on pointer POINTERMOVE event if only a single touch is active.
  36045. * Override this method to provide functionality.
  36046. */
  36047. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36048. /**
  36049. * Called on pointer POINTERMOVE event if multiple touches are active.
  36050. * Override this method to provide functionality.
  36051. */
  36052. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36053. /**
  36054. * Called on JS contextmenu event.
  36055. * Override this method to provide functionality.
  36056. */
  36057. protected onContextMenu(evt: PointerEvent): void;
  36058. /**
  36059. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36060. * press.
  36061. * Override this method to provide functionality.
  36062. */
  36063. protected onButtonDown(evt: PointerEvent): void;
  36064. /**
  36065. * Called each time a new POINTERUP event occurs. Ie, for each button
  36066. * release.
  36067. * Override this method to provide functionality.
  36068. */
  36069. protected onButtonUp(evt: PointerEvent): void;
  36070. /**
  36071. * Called when window becomes inactive.
  36072. * Override this method to provide functionality.
  36073. */
  36074. protected onLostFocus(): void;
  36075. private _pointerInput;
  36076. private _observer;
  36077. private _onLostFocus;
  36078. private pointA;
  36079. private pointB;
  36080. }
  36081. }
  36082. declare module BABYLON {
  36083. /**
  36084. * Manage the pointers inputs to control an arc rotate camera.
  36085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36086. */
  36087. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36088. /**
  36089. * Defines the camera the input is attached to.
  36090. */
  36091. camera: ArcRotateCamera;
  36092. /**
  36093. * Gets the class name of the current input.
  36094. * @returns the class name
  36095. */
  36096. getClassName(): string;
  36097. /**
  36098. * Defines the buttons associated with the input to handle camera move.
  36099. */
  36100. buttons: number[];
  36101. /**
  36102. * Defines the pointer angular sensibility along the X axis or how fast is
  36103. * the camera rotating.
  36104. */
  36105. angularSensibilityX: number;
  36106. /**
  36107. * Defines the pointer angular sensibility along the Y axis or how fast is
  36108. * the camera rotating.
  36109. */
  36110. angularSensibilityY: number;
  36111. /**
  36112. * Defines the pointer pinch precision or how fast is the camera zooming.
  36113. */
  36114. pinchPrecision: number;
  36115. /**
  36116. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36117. * from 0.
  36118. * It defines the percentage of current camera.radius to use as delta when
  36119. * pinch zoom is used.
  36120. */
  36121. pinchDeltaPercentage: number;
  36122. /**
  36123. * Defines the pointer panning sensibility or how fast is the camera moving.
  36124. */
  36125. panningSensibility: number;
  36126. /**
  36127. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36128. */
  36129. multiTouchPanning: boolean;
  36130. /**
  36131. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36132. * zoom (pinch) through multitouch.
  36133. */
  36134. multiTouchPanAndZoom: boolean;
  36135. /**
  36136. * Revers pinch action direction.
  36137. */
  36138. pinchInwards: boolean;
  36139. private _isPanClick;
  36140. private _twoFingerActivityCount;
  36141. private _isPinching;
  36142. /**
  36143. * Called on pointer POINTERMOVE event if only a single touch is active.
  36144. */
  36145. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36146. /**
  36147. * Called on pointer POINTERDOUBLETAP event.
  36148. */
  36149. protected onDoubleTap(type: string): void;
  36150. /**
  36151. * Called on pointer POINTERMOVE event if multiple touches are active.
  36152. */
  36153. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36154. /**
  36155. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36156. * press.
  36157. */
  36158. protected onButtonDown(evt: PointerEvent): void;
  36159. /**
  36160. * Called each time a new POINTERUP event occurs. Ie, for each button
  36161. * release.
  36162. */
  36163. protected onButtonUp(evt: PointerEvent): void;
  36164. /**
  36165. * Called when window becomes inactive.
  36166. */
  36167. protected onLostFocus(): void;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36174. */
  36175. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36176. /**
  36177. * Defines the camera the input is attached to.
  36178. */
  36179. camera: ArcRotateCamera;
  36180. /**
  36181. * Defines the list of key codes associated with the up action (increase alpha)
  36182. */
  36183. keysUp: number[];
  36184. /**
  36185. * Defines the list of key codes associated with the down action (decrease alpha)
  36186. */
  36187. keysDown: number[];
  36188. /**
  36189. * Defines the list of key codes associated with the left action (increase beta)
  36190. */
  36191. keysLeft: number[];
  36192. /**
  36193. * Defines the list of key codes associated with the right action (decrease beta)
  36194. */
  36195. keysRight: number[];
  36196. /**
  36197. * Defines the list of key codes associated with the reset action.
  36198. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36199. */
  36200. keysReset: number[];
  36201. /**
  36202. * Defines the panning sensibility of the inputs.
  36203. * (How fast is the camera paning)
  36204. */
  36205. panningSensibility: number;
  36206. /**
  36207. * Defines the zooming sensibility of the inputs.
  36208. * (How fast is the camera zooming)
  36209. */
  36210. zoomingSensibility: number;
  36211. /**
  36212. * Defines wether maintaining the alt key down switch the movement mode from
  36213. * orientation to zoom.
  36214. */
  36215. useAltToZoom: boolean;
  36216. /**
  36217. * Rotation speed of the camera
  36218. */
  36219. angularSpeed: number;
  36220. private _keys;
  36221. private _ctrlPressed;
  36222. private _altPressed;
  36223. private _onCanvasBlurObserver;
  36224. private _onKeyboardObserver;
  36225. private _engine;
  36226. private _scene;
  36227. /**
  36228. * Attach the input controls to a specific dom element to get the input from.
  36229. * @param element Defines the element the controls should be listened from
  36230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36231. */
  36232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36233. /**
  36234. * Detach the current controls from the specified dom element.
  36235. * @param element Defines the element to stop listening the inputs from
  36236. */
  36237. detachControl(element: Nullable<HTMLElement>): void;
  36238. /**
  36239. * Update the current camera state depending on the inputs that have been used this frame.
  36240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36241. */
  36242. checkInputs(): void;
  36243. /**
  36244. * Gets the class name of the current intput.
  36245. * @returns the class name
  36246. */
  36247. getClassName(): string;
  36248. /**
  36249. * Get the friendly name associated with the input class.
  36250. * @returns the input friendly name
  36251. */
  36252. getSimpleName(): string;
  36253. }
  36254. }
  36255. declare module BABYLON {
  36256. /**
  36257. * Manage the mouse wheel inputs to control an arc rotate camera.
  36258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36259. */
  36260. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36261. /**
  36262. * Defines the camera the input is attached to.
  36263. */
  36264. camera: ArcRotateCamera;
  36265. /**
  36266. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36267. */
  36268. wheelPrecision: number;
  36269. /**
  36270. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36271. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36272. */
  36273. wheelDeltaPercentage: number;
  36274. private _wheel;
  36275. private _observer;
  36276. private computeDeltaFromMouseWheelLegacyEvent;
  36277. /**
  36278. * Attach the input controls to a specific dom element to get the input from.
  36279. * @param element Defines the element the controls should be listened from
  36280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36281. */
  36282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36283. /**
  36284. * Detach the current controls from the specified dom element.
  36285. * @param element Defines the element to stop listening the inputs from
  36286. */
  36287. detachControl(element: Nullable<HTMLElement>): void;
  36288. /**
  36289. * Gets the class name of the current intput.
  36290. * @returns the class name
  36291. */
  36292. getClassName(): string;
  36293. /**
  36294. * Get the friendly name associated with the input class.
  36295. * @returns the input friendly name
  36296. */
  36297. getSimpleName(): string;
  36298. }
  36299. }
  36300. declare module BABYLON {
  36301. /**
  36302. * Default Inputs manager for the ArcRotateCamera.
  36303. * It groups all the default supported inputs for ease of use.
  36304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36305. */
  36306. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36307. /**
  36308. * Instantiates a new ArcRotateCameraInputsManager.
  36309. * @param camera Defines the camera the inputs belong to
  36310. */
  36311. constructor(camera: ArcRotateCamera);
  36312. /**
  36313. * Add mouse wheel input support to the input manager.
  36314. * @returns the current input manager
  36315. */
  36316. addMouseWheel(): ArcRotateCameraInputsManager;
  36317. /**
  36318. * Add pointers input support to the input manager.
  36319. * @returns the current input manager
  36320. */
  36321. addPointers(): ArcRotateCameraInputsManager;
  36322. /**
  36323. * Add keyboard input support to the input manager.
  36324. * @returns the current input manager
  36325. */
  36326. addKeyboard(): ArcRotateCameraInputsManager;
  36327. }
  36328. }
  36329. declare module BABYLON {
  36330. /**
  36331. * This represents an orbital type of camera.
  36332. *
  36333. * 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.
  36334. * 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.
  36335. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36336. */
  36337. export class ArcRotateCamera extends TargetCamera {
  36338. /**
  36339. * Defines the rotation angle of the camera along the longitudinal axis.
  36340. */
  36341. alpha: number;
  36342. /**
  36343. * Defines the rotation angle of the camera along the latitudinal axis.
  36344. */
  36345. beta: number;
  36346. /**
  36347. * Defines the radius of the camera from it s target point.
  36348. */
  36349. radius: number;
  36350. protected _target: Vector3;
  36351. protected _targetHost: Nullable<AbstractMesh>;
  36352. /**
  36353. * Defines the target point of the camera.
  36354. * The camera looks towards it form the radius distance.
  36355. */
  36356. target: Vector3;
  36357. /**
  36358. * Define the current local position of the camera in the scene
  36359. */
  36360. position: Vector3;
  36361. protected _upVector: Vector3;
  36362. protected _upToYMatrix: Matrix;
  36363. protected _YToUpMatrix: Matrix;
  36364. /**
  36365. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36366. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36367. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36368. */
  36369. upVector: Vector3;
  36370. /**
  36371. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36372. */
  36373. setMatUp(): void;
  36374. /**
  36375. * Current inertia value on the longitudinal axis.
  36376. * The bigger this number the longer it will take for the camera to stop.
  36377. */
  36378. inertialAlphaOffset: number;
  36379. /**
  36380. * Current inertia value on the latitudinal axis.
  36381. * The bigger this number the longer it will take for the camera to stop.
  36382. */
  36383. inertialBetaOffset: number;
  36384. /**
  36385. * Current inertia value on the radius axis.
  36386. * The bigger this number the longer it will take for the camera to stop.
  36387. */
  36388. inertialRadiusOffset: number;
  36389. /**
  36390. * Minimum allowed angle on the longitudinal axis.
  36391. * This can help limiting how the Camera is able to move in the scene.
  36392. */
  36393. lowerAlphaLimit: Nullable<number>;
  36394. /**
  36395. * Maximum allowed angle on the longitudinal axis.
  36396. * This can help limiting how the Camera is able to move in the scene.
  36397. */
  36398. upperAlphaLimit: Nullable<number>;
  36399. /**
  36400. * Minimum allowed angle on the latitudinal axis.
  36401. * This can help limiting how the Camera is able to move in the scene.
  36402. */
  36403. lowerBetaLimit: number;
  36404. /**
  36405. * Maximum allowed angle on the latitudinal axis.
  36406. * This can help limiting how the Camera is able to move in the scene.
  36407. */
  36408. upperBetaLimit: number;
  36409. /**
  36410. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36411. * This can help limiting how the Camera is able to move in the scene.
  36412. */
  36413. lowerRadiusLimit: Nullable<number>;
  36414. /**
  36415. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36416. * This can help limiting how the Camera is able to move in the scene.
  36417. */
  36418. upperRadiusLimit: Nullable<number>;
  36419. /**
  36420. * Defines the current inertia value used during panning of the camera along the X axis.
  36421. */
  36422. inertialPanningX: number;
  36423. /**
  36424. * Defines the current inertia value used during panning of the camera along the Y axis.
  36425. */
  36426. inertialPanningY: number;
  36427. /**
  36428. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36429. * Basically if your fingers moves away from more than this distance you will be considered
  36430. * in pinch mode.
  36431. */
  36432. pinchToPanMaxDistance: number;
  36433. /**
  36434. * Defines the maximum distance the camera can pan.
  36435. * This could help keeping the cammera always in your scene.
  36436. */
  36437. panningDistanceLimit: Nullable<number>;
  36438. /**
  36439. * Defines the target of the camera before paning.
  36440. */
  36441. panningOriginTarget: Vector3;
  36442. /**
  36443. * Defines the value of the inertia used during panning.
  36444. * 0 would mean stop inertia and one would mean no decelleration at all.
  36445. */
  36446. panningInertia: number;
  36447. /**
  36448. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36449. */
  36450. angularSensibilityX: number;
  36451. /**
  36452. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36453. */
  36454. angularSensibilityY: number;
  36455. /**
  36456. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36457. */
  36458. pinchPrecision: number;
  36459. /**
  36460. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36461. * It will be used instead of pinchDeltaPrecision if different from 0.
  36462. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36463. */
  36464. pinchDeltaPercentage: number;
  36465. /**
  36466. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36467. */
  36468. panningSensibility: number;
  36469. /**
  36470. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36471. */
  36472. keysUp: number[];
  36473. /**
  36474. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36475. */
  36476. keysDown: number[];
  36477. /**
  36478. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36479. */
  36480. keysLeft: number[];
  36481. /**
  36482. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36483. */
  36484. keysRight: number[];
  36485. /**
  36486. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36487. */
  36488. wheelPrecision: number;
  36489. /**
  36490. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36491. * It will be used instead of pinchDeltaPrecision if different from 0.
  36492. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36493. */
  36494. wheelDeltaPercentage: number;
  36495. /**
  36496. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36497. */
  36498. zoomOnFactor: number;
  36499. /**
  36500. * Defines a screen offset for the camera position.
  36501. */
  36502. targetScreenOffset: Vector2;
  36503. /**
  36504. * Allows the camera to be completely reversed.
  36505. * If false the camera can not arrive upside down.
  36506. */
  36507. allowUpsideDown: boolean;
  36508. /**
  36509. * Define if double tap/click is used to restore the previously saved state of the camera.
  36510. */
  36511. useInputToRestoreState: boolean;
  36512. /** @hidden */
  36513. _viewMatrix: Matrix;
  36514. /** @hidden */
  36515. _useCtrlForPanning: boolean;
  36516. /** @hidden */
  36517. _panningMouseButton: number;
  36518. /**
  36519. * Defines the input associated to the camera.
  36520. */
  36521. inputs: ArcRotateCameraInputsManager;
  36522. /** @hidden */
  36523. _reset: () => void;
  36524. /**
  36525. * Defines the allowed panning axis.
  36526. */
  36527. panningAxis: Vector3;
  36528. protected _localDirection: Vector3;
  36529. protected _transformedDirection: Vector3;
  36530. private _bouncingBehavior;
  36531. /**
  36532. * Gets the bouncing behavior of the camera if it has been enabled.
  36533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36534. */
  36535. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36536. /**
  36537. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36538. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36539. */
  36540. useBouncingBehavior: boolean;
  36541. private _framingBehavior;
  36542. /**
  36543. * Gets the framing behavior of the camera if it has been enabled.
  36544. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36545. */
  36546. readonly framingBehavior: Nullable<FramingBehavior>;
  36547. /**
  36548. * Defines if the framing behavior of the camera is enabled on the camera.
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36550. */
  36551. useFramingBehavior: boolean;
  36552. private _autoRotationBehavior;
  36553. /**
  36554. * Gets the auto rotation behavior of the camera if it has been enabled.
  36555. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36556. */
  36557. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36558. /**
  36559. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36560. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36561. */
  36562. useAutoRotationBehavior: boolean;
  36563. /**
  36564. * Observable triggered when the mesh target has been changed on the camera.
  36565. */
  36566. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36567. /**
  36568. * Event raised when the camera is colliding with a mesh.
  36569. */
  36570. onCollide: (collidedMesh: AbstractMesh) => void;
  36571. /**
  36572. * Defines whether the camera should check collision with the objects oh the scene.
  36573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36574. */
  36575. checkCollisions: boolean;
  36576. /**
  36577. * Defines the collision radius of the camera.
  36578. * This simulates a sphere around the camera.
  36579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36580. */
  36581. collisionRadius: Vector3;
  36582. protected _collider: Collider;
  36583. protected _previousPosition: Vector3;
  36584. protected _collisionVelocity: Vector3;
  36585. protected _newPosition: Vector3;
  36586. protected _previousAlpha: number;
  36587. protected _previousBeta: number;
  36588. protected _previousRadius: number;
  36589. protected _collisionTriggered: boolean;
  36590. protected _targetBoundingCenter: Nullable<Vector3>;
  36591. private _computationVector;
  36592. /**
  36593. * Instantiates a new ArcRotateCamera in a given scene
  36594. * @param name Defines the name of the camera
  36595. * @param alpha Defines the camera rotation along the logitudinal axis
  36596. * @param beta Defines the camera rotation along the latitudinal axis
  36597. * @param radius Defines the camera distance from its target
  36598. * @param target Defines the camera target
  36599. * @param scene Defines the scene the camera belongs to
  36600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36601. */
  36602. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36603. /** @hidden */
  36604. _initCache(): void;
  36605. /** @hidden */
  36606. _updateCache(ignoreParentClass?: boolean): void;
  36607. protected _getTargetPosition(): Vector3;
  36608. private _storedAlpha;
  36609. private _storedBeta;
  36610. private _storedRadius;
  36611. private _storedTarget;
  36612. private _storedTargetScreenOffset;
  36613. /**
  36614. * Stores the current state of the camera (alpha, beta, radius and target)
  36615. * @returns the camera itself
  36616. */
  36617. storeState(): Camera;
  36618. /**
  36619. * @hidden
  36620. * Restored camera state. You must call storeState() first
  36621. */
  36622. _restoreStateValues(): boolean;
  36623. /** @hidden */
  36624. _isSynchronizedViewMatrix(): boolean;
  36625. /**
  36626. * Attached controls to the current camera.
  36627. * @param element Defines the element the controls should be listened from
  36628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36629. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36630. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36631. */
  36632. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36633. /**
  36634. * Detach the current controls from the camera.
  36635. * The camera will stop reacting to inputs.
  36636. * @param element Defines the element to stop listening the inputs from
  36637. */
  36638. detachControl(element: HTMLElement): void;
  36639. /** @hidden */
  36640. _checkInputs(): void;
  36641. protected _checkLimits(): void;
  36642. /**
  36643. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36644. */
  36645. rebuildAnglesAndRadius(): void;
  36646. /**
  36647. * Use a position to define the current camera related information like aplha, beta and radius
  36648. * @param position Defines the position to set the camera at
  36649. */
  36650. setPosition(position: Vector3): void;
  36651. /**
  36652. * Defines the target the camera should look at.
  36653. * This will automatically adapt alpha beta and radius to fit within the new target.
  36654. * @param target Defines the new target as a Vector or a mesh
  36655. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36656. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36657. */
  36658. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36659. /** @hidden */
  36660. _getViewMatrix(): Matrix;
  36661. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36662. /**
  36663. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36664. * @param meshes Defines the mesh to zoom on
  36665. * @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)
  36666. */
  36667. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36668. /**
  36669. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36670. * The target will be changed but the radius
  36671. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36672. * @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)
  36673. */
  36674. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36675. min: Vector3;
  36676. max: Vector3;
  36677. distance: number;
  36678. }, doNotUpdateMaxZ?: boolean): void;
  36679. /**
  36680. * @override
  36681. * Override Camera.createRigCamera
  36682. */
  36683. createRigCamera(name: string, cameraIndex: number): Camera;
  36684. /**
  36685. * @hidden
  36686. * @override
  36687. * Override Camera._updateRigCameras
  36688. */
  36689. _updateRigCameras(): void;
  36690. /**
  36691. * Destroy the camera and release the current resources hold by it.
  36692. */
  36693. dispose(): void;
  36694. /**
  36695. * Gets the current object class name.
  36696. * @return the class name
  36697. */
  36698. getClassName(): string;
  36699. }
  36700. }
  36701. declare module BABYLON {
  36702. /**
  36703. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36705. */
  36706. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36707. /**
  36708. * Gets the name of the behavior.
  36709. */
  36710. readonly name: string;
  36711. private _zoomStopsAnimation;
  36712. private _idleRotationSpeed;
  36713. private _idleRotationWaitTime;
  36714. private _idleRotationSpinupTime;
  36715. /**
  36716. * Sets the flag that indicates if user zooming should stop animation.
  36717. */
  36718. /**
  36719. * Gets the flag that indicates if user zooming should stop animation.
  36720. */
  36721. zoomStopsAnimation: boolean;
  36722. /**
  36723. * Sets the default speed at which the camera rotates around the model.
  36724. */
  36725. /**
  36726. * Gets the default speed at which the camera rotates around the model.
  36727. */
  36728. idleRotationSpeed: number;
  36729. /**
  36730. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36731. */
  36732. /**
  36733. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36734. */
  36735. idleRotationWaitTime: number;
  36736. /**
  36737. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36738. */
  36739. /**
  36740. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36741. */
  36742. idleRotationSpinupTime: number;
  36743. /**
  36744. * Gets a value indicating if the camera is currently rotating because of this behavior
  36745. */
  36746. readonly rotationInProgress: boolean;
  36747. private _onPrePointerObservableObserver;
  36748. private _onAfterCheckInputsObserver;
  36749. private _attachedCamera;
  36750. private _isPointerDown;
  36751. private _lastFrameTime;
  36752. private _lastInteractionTime;
  36753. private _cameraRotationSpeed;
  36754. /**
  36755. * Initializes the behavior.
  36756. */
  36757. init(): void;
  36758. /**
  36759. * Attaches the behavior to its arc rotate camera.
  36760. * @param camera Defines the camera to attach the behavior to
  36761. */
  36762. attach(camera: ArcRotateCamera): void;
  36763. /**
  36764. * Detaches the behavior from its current arc rotate camera.
  36765. */
  36766. detach(): void;
  36767. /**
  36768. * Returns true if user is scrolling.
  36769. * @return true if user is scrolling.
  36770. */
  36771. private _userIsZooming;
  36772. private _lastFrameRadius;
  36773. private _shouldAnimationStopForInteraction;
  36774. /**
  36775. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36776. */
  36777. private _applyUserInteraction;
  36778. private _userIsMoving;
  36779. }
  36780. }
  36781. declare module BABYLON {
  36782. /**
  36783. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36784. */
  36785. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36786. private ui;
  36787. /**
  36788. * The name of the behavior
  36789. */
  36790. name: string;
  36791. /**
  36792. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36793. */
  36794. distanceAwayFromFace: number;
  36795. /**
  36796. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36797. */
  36798. distanceAwayFromBottomOfFace: number;
  36799. private _faceVectors;
  36800. private _target;
  36801. private _scene;
  36802. private _onRenderObserver;
  36803. private _tmpMatrix;
  36804. private _tmpVector;
  36805. /**
  36806. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36807. * @param ui The transform node that should be attched to the mesh
  36808. */
  36809. constructor(ui: TransformNode);
  36810. /**
  36811. * Initializes the behavior
  36812. */
  36813. init(): void;
  36814. private _closestFace;
  36815. private _zeroVector;
  36816. private _lookAtTmpMatrix;
  36817. private _lookAtToRef;
  36818. /**
  36819. * Attaches the AttachToBoxBehavior to the passed in mesh
  36820. * @param target The mesh that the specified node will be attached to
  36821. */
  36822. attach(target: Mesh): void;
  36823. /**
  36824. * Detaches the behavior from the mesh
  36825. */
  36826. detach(): void;
  36827. }
  36828. }
  36829. declare module BABYLON {
  36830. /**
  36831. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36832. */
  36833. export class FadeInOutBehavior implements Behavior<Mesh> {
  36834. /**
  36835. * Time in milliseconds to delay before fading in (Default: 0)
  36836. */
  36837. delay: number;
  36838. /**
  36839. * Time in milliseconds for the mesh to fade in (Default: 300)
  36840. */
  36841. fadeInTime: number;
  36842. private _millisecondsPerFrame;
  36843. private _hovered;
  36844. private _hoverValue;
  36845. private _ownerNode;
  36846. /**
  36847. * Instatiates the FadeInOutBehavior
  36848. */
  36849. constructor();
  36850. /**
  36851. * The name of the behavior
  36852. */
  36853. readonly name: string;
  36854. /**
  36855. * Initializes the behavior
  36856. */
  36857. init(): void;
  36858. /**
  36859. * Attaches the fade behavior on the passed in mesh
  36860. * @param ownerNode The mesh that will be faded in/out once attached
  36861. */
  36862. attach(ownerNode: Mesh): void;
  36863. /**
  36864. * Detaches the behavior from the mesh
  36865. */
  36866. detach(): void;
  36867. /**
  36868. * Triggers the mesh to begin fading in or out
  36869. * @param value if the object should fade in or out (true to fade in)
  36870. */
  36871. fadeIn(value: boolean): void;
  36872. private _update;
  36873. private _setAllVisibility;
  36874. }
  36875. }
  36876. declare module BABYLON {
  36877. /**
  36878. * Class containing a set of static utilities functions for managing Pivots
  36879. * @hidden
  36880. */
  36881. export class PivotTools {
  36882. private static _PivotCached;
  36883. private static _OldPivotPoint;
  36884. private static _PivotTranslation;
  36885. private static _PivotTmpVector;
  36886. /** @hidden */
  36887. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36888. /** @hidden */
  36889. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36890. }
  36891. }
  36892. declare module BABYLON {
  36893. /**
  36894. * Class containing static functions to help procedurally build meshes
  36895. */
  36896. export class PlaneBuilder {
  36897. /**
  36898. * Creates a plane mesh
  36899. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36900. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36901. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36903. * * 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
  36904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36905. * @param name defines the name of the mesh
  36906. * @param options defines the options used to create the mesh
  36907. * @param scene defines the hosting scene
  36908. * @returns the plane mesh
  36909. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36910. */
  36911. static CreatePlane(name: string, options: {
  36912. size?: number;
  36913. width?: number;
  36914. height?: number;
  36915. sideOrientation?: number;
  36916. frontUVs?: Vector4;
  36917. backUVs?: Vector4;
  36918. updatable?: boolean;
  36919. sourcePlane?: Plane;
  36920. }, scene?: Nullable<Scene>): Mesh;
  36921. }
  36922. }
  36923. declare module BABYLON {
  36924. /**
  36925. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36926. */
  36927. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36928. private static _AnyMouseID;
  36929. /**
  36930. * Abstract mesh the behavior is set on
  36931. */
  36932. attachedNode: AbstractMesh;
  36933. private _dragPlane;
  36934. private _scene;
  36935. private _pointerObserver;
  36936. private _beforeRenderObserver;
  36937. private static _planeScene;
  36938. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36939. /**
  36940. * 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)
  36941. */
  36942. maxDragAngle: number;
  36943. /**
  36944. * @hidden
  36945. */
  36946. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36947. /**
  36948. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36949. */
  36950. currentDraggingPointerID: number;
  36951. /**
  36952. * The last position where the pointer hit the drag plane in world space
  36953. */
  36954. lastDragPosition: Vector3;
  36955. /**
  36956. * If the behavior is currently in a dragging state
  36957. */
  36958. dragging: boolean;
  36959. /**
  36960. * 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)
  36961. */
  36962. dragDeltaRatio: number;
  36963. /**
  36964. * If the drag plane orientation should be updated during the dragging (Default: true)
  36965. */
  36966. updateDragPlane: boolean;
  36967. private _debugMode;
  36968. private _moving;
  36969. /**
  36970. * Fires each time the attached mesh is dragged with the pointer
  36971. * * delta between last drag position and current drag position in world space
  36972. * * dragDistance along the drag axis
  36973. * * dragPlaneNormal normal of the current drag plane used during the drag
  36974. * * dragPlanePoint in world space where the drag intersects the drag plane
  36975. */
  36976. onDragObservable: Observable<{
  36977. delta: Vector3;
  36978. dragPlanePoint: Vector3;
  36979. dragPlaneNormal: Vector3;
  36980. dragDistance: number;
  36981. pointerId: number;
  36982. }>;
  36983. /**
  36984. * Fires each time a drag begins (eg. mouse down on mesh)
  36985. */
  36986. onDragStartObservable: Observable<{
  36987. dragPlanePoint: Vector3;
  36988. pointerId: number;
  36989. }>;
  36990. /**
  36991. * Fires each time a drag ends (eg. mouse release after drag)
  36992. */
  36993. onDragEndObservable: Observable<{
  36994. dragPlanePoint: Vector3;
  36995. pointerId: number;
  36996. }>;
  36997. /**
  36998. * If the attached mesh should be moved when dragged
  36999. */
  37000. moveAttached: boolean;
  37001. /**
  37002. * If the drag behavior will react to drag events (Default: true)
  37003. */
  37004. enabled: boolean;
  37005. /**
  37006. * If pointer events should start and release the drag (Default: true)
  37007. */
  37008. startAndReleaseDragOnPointerEvents: boolean;
  37009. /**
  37010. * If camera controls should be detached during the drag
  37011. */
  37012. detachCameraControls: boolean;
  37013. /**
  37014. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37015. */
  37016. useObjectOrienationForDragging: boolean;
  37017. private _options;
  37018. /**
  37019. * Creates a pointer drag behavior that can be attached to a mesh
  37020. * @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)
  37021. */
  37022. constructor(options?: {
  37023. dragAxis?: Vector3;
  37024. dragPlaneNormal?: Vector3;
  37025. });
  37026. /**
  37027. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37028. */
  37029. validateDrag: (targetPosition: Vector3) => boolean;
  37030. /**
  37031. * The name of the behavior
  37032. */
  37033. readonly name: string;
  37034. /**
  37035. * Initializes the behavior
  37036. */
  37037. init(): void;
  37038. private _tmpVector;
  37039. private _alternatePickedPoint;
  37040. private _worldDragAxis;
  37041. private _targetPosition;
  37042. private _attachedElement;
  37043. /**
  37044. * Attaches the drag behavior the passed in mesh
  37045. * @param ownerNode The mesh that will be dragged around once attached
  37046. * @param predicate Predicate to use for pick filtering
  37047. */
  37048. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37049. /**
  37050. * Force relase the drag action by code.
  37051. */
  37052. releaseDrag(): void;
  37053. private _startDragRay;
  37054. private _lastPointerRay;
  37055. /**
  37056. * Simulates the start of a pointer drag event on the behavior
  37057. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37058. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37059. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37060. */
  37061. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37062. private _startDrag;
  37063. private _dragDelta;
  37064. private _moveDrag;
  37065. private _pickWithRayOnDragPlane;
  37066. private _pointA;
  37067. private _pointB;
  37068. private _pointC;
  37069. private _lineA;
  37070. private _lineB;
  37071. private _localAxis;
  37072. private _lookAt;
  37073. private _updateDragPlanePosition;
  37074. /**
  37075. * Detaches the behavior from the mesh
  37076. */
  37077. detach(): void;
  37078. }
  37079. }
  37080. declare module BABYLON {
  37081. /**
  37082. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37083. */
  37084. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37085. private _dragBehaviorA;
  37086. private _dragBehaviorB;
  37087. private _startDistance;
  37088. private _initialScale;
  37089. private _targetScale;
  37090. private _ownerNode;
  37091. private _sceneRenderObserver;
  37092. /**
  37093. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37094. */
  37095. constructor();
  37096. /**
  37097. * The name of the behavior
  37098. */
  37099. readonly name: string;
  37100. /**
  37101. * Initializes the behavior
  37102. */
  37103. init(): void;
  37104. private _getCurrentDistance;
  37105. /**
  37106. * Attaches the scale behavior the passed in mesh
  37107. * @param ownerNode The mesh that will be scaled around once attached
  37108. */
  37109. attach(ownerNode: Mesh): void;
  37110. /**
  37111. * Detaches the behavior from the mesh
  37112. */
  37113. detach(): void;
  37114. }
  37115. }
  37116. declare module BABYLON {
  37117. /**
  37118. * 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
  37119. */
  37120. export class SixDofDragBehavior implements Behavior<Mesh> {
  37121. private static _virtualScene;
  37122. private _ownerNode;
  37123. private _sceneRenderObserver;
  37124. private _scene;
  37125. private _targetPosition;
  37126. private _virtualOriginMesh;
  37127. private _virtualDragMesh;
  37128. private _pointerObserver;
  37129. private _moving;
  37130. private _startingOrientation;
  37131. /**
  37132. * 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)
  37133. */
  37134. private zDragFactor;
  37135. /**
  37136. * If the object should rotate to face the drag origin
  37137. */
  37138. rotateDraggedObject: boolean;
  37139. /**
  37140. * If the behavior is currently in a dragging state
  37141. */
  37142. dragging: boolean;
  37143. /**
  37144. * 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)
  37145. */
  37146. dragDeltaRatio: number;
  37147. /**
  37148. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37149. */
  37150. currentDraggingPointerID: number;
  37151. /**
  37152. * If camera controls should be detached during the drag
  37153. */
  37154. detachCameraControls: boolean;
  37155. /**
  37156. * Fires each time a drag starts
  37157. */
  37158. onDragStartObservable: Observable<{}>;
  37159. /**
  37160. * Fires each time a drag ends (eg. mouse release after drag)
  37161. */
  37162. onDragEndObservable: Observable<{}>;
  37163. /**
  37164. * 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
  37165. */
  37166. constructor();
  37167. /**
  37168. * The name of the behavior
  37169. */
  37170. readonly name: string;
  37171. /**
  37172. * Initializes the behavior
  37173. */
  37174. init(): void;
  37175. /**
  37176. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37177. */
  37178. private readonly _pointerCamera;
  37179. /**
  37180. * Attaches the scale behavior the passed in mesh
  37181. * @param ownerNode The mesh that will be scaled around once attached
  37182. */
  37183. attach(ownerNode: Mesh): void;
  37184. /**
  37185. * Detaches the behavior from the mesh
  37186. */
  37187. detach(): void;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. /**
  37192. * Class used to apply inverse kinematics to bones
  37193. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37194. */
  37195. export class BoneIKController {
  37196. private static _tmpVecs;
  37197. private static _tmpQuat;
  37198. private static _tmpMats;
  37199. /**
  37200. * Gets or sets the target mesh
  37201. */
  37202. targetMesh: AbstractMesh;
  37203. /** Gets or sets the mesh used as pole */
  37204. poleTargetMesh: AbstractMesh;
  37205. /**
  37206. * Gets or sets the bone used as pole
  37207. */
  37208. poleTargetBone: Nullable<Bone>;
  37209. /**
  37210. * Gets or sets the target position
  37211. */
  37212. targetPosition: Vector3;
  37213. /**
  37214. * Gets or sets the pole target position
  37215. */
  37216. poleTargetPosition: Vector3;
  37217. /**
  37218. * Gets or sets the pole target local offset
  37219. */
  37220. poleTargetLocalOffset: Vector3;
  37221. /**
  37222. * Gets or sets the pole angle
  37223. */
  37224. poleAngle: number;
  37225. /**
  37226. * Gets or sets the mesh associated with the controller
  37227. */
  37228. mesh: AbstractMesh;
  37229. /**
  37230. * 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)
  37231. */
  37232. slerpAmount: number;
  37233. private _bone1Quat;
  37234. private _bone1Mat;
  37235. private _bone2Ang;
  37236. private _bone1;
  37237. private _bone2;
  37238. private _bone1Length;
  37239. private _bone2Length;
  37240. private _maxAngle;
  37241. private _maxReach;
  37242. private _rightHandedSystem;
  37243. private _bendAxis;
  37244. private _slerping;
  37245. private _adjustRoll;
  37246. /**
  37247. * Gets or sets maximum allowed angle
  37248. */
  37249. maxAngle: number;
  37250. /**
  37251. * Creates a new BoneIKController
  37252. * @param mesh defines the mesh to control
  37253. * @param bone defines the bone to control
  37254. * @param options defines options to set up the controller
  37255. */
  37256. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37257. targetMesh?: AbstractMesh;
  37258. poleTargetMesh?: AbstractMesh;
  37259. poleTargetBone?: Bone;
  37260. poleTargetLocalOffset?: Vector3;
  37261. poleAngle?: number;
  37262. bendAxis?: Vector3;
  37263. maxAngle?: number;
  37264. slerpAmount?: number;
  37265. });
  37266. private _setMaxAngle;
  37267. /**
  37268. * Force the controller to update the bones
  37269. */
  37270. update(): void;
  37271. }
  37272. }
  37273. declare module BABYLON {
  37274. /**
  37275. * Class used to make a bone look toward a point in space
  37276. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37277. */
  37278. export class BoneLookController {
  37279. private static _tmpVecs;
  37280. private static _tmpQuat;
  37281. private static _tmpMats;
  37282. /**
  37283. * The target Vector3 that the bone will look at
  37284. */
  37285. target: Vector3;
  37286. /**
  37287. * The mesh that the bone is attached to
  37288. */
  37289. mesh: AbstractMesh;
  37290. /**
  37291. * The bone that will be looking to the target
  37292. */
  37293. bone: Bone;
  37294. /**
  37295. * The up axis of the coordinate system that is used when the bone is rotated
  37296. */
  37297. upAxis: Vector3;
  37298. /**
  37299. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37300. */
  37301. upAxisSpace: Space;
  37302. /**
  37303. * Used to make an adjustment to the yaw of the bone
  37304. */
  37305. adjustYaw: number;
  37306. /**
  37307. * Used to make an adjustment to the pitch of the bone
  37308. */
  37309. adjustPitch: number;
  37310. /**
  37311. * Used to make an adjustment to the roll of the bone
  37312. */
  37313. adjustRoll: number;
  37314. /**
  37315. * 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)
  37316. */
  37317. slerpAmount: number;
  37318. private _minYaw;
  37319. private _maxYaw;
  37320. private _minPitch;
  37321. private _maxPitch;
  37322. private _minYawSin;
  37323. private _minYawCos;
  37324. private _maxYawSin;
  37325. private _maxYawCos;
  37326. private _midYawConstraint;
  37327. private _minPitchTan;
  37328. private _maxPitchTan;
  37329. private _boneQuat;
  37330. private _slerping;
  37331. private _transformYawPitch;
  37332. private _transformYawPitchInv;
  37333. private _firstFrameSkipped;
  37334. private _yawRange;
  37335. private _fowardAxis;
  37336. /**
  37337. * Gets or sets the minimum yaw angle that the bone can look to
  37338. */
  37339. minYaw: number;
  37340. /**
  37341. * Gets or sets the maximum yaw angle that the bone can look to
  37342. */
  37343. maxYaw: number;
  37344. /**
  37345. * Gets or sets the minimum pitch angle that the bone can look to
  37346. */
  37347. minPitch: number;
  37348. /**
  37349. * Gets or sets the maximum pitch angle that the bone can look to
  37350. */
  37351. maxPitch: number;
  37352. /**
  37353. * Create a BoneLookController
  37354. * @param mesh the mesh that the bone belongs to
  37355. * @param bone the bone that will be looking to the target
  37356. * @param target the target Vector3 to look at
  37357. * @param options optional settings:
  37358. * * maxYaw: the maximum angle the bone will yaw to
  37359. * * minYaw: the minimum angle the bone will yaw to
  37360. * * maxPitch: the maximum angle the bone will pitch to
  37361. * * minPitch: the minimum angle the bone will yaw to
  37362. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37363. * * upAxis: the up axis of the coordinate system
  37364. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37365. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37366. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37367. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37368. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37369. * * adjustRoll: used to make an adjustment to the roll of the bone
  37370. **/
  37371. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37372. maxYaw?: number;
  37373. minYaw?: number;
  37374. maxPitch?: number;
  37375. minPitch?: number;
  37376. slerpAmount?: number;
  37377. upAxis?: Vector3;
  37378. upAxisSpace?: Space;
  37379. yawAxis?: Vector3;
  37380. pitchAxis?: Vector3;
  37381. adjustYaw?: number;
  37382. adjustPitch?: number;
  37383. adjustRoll?: number;
  37384. });
  37385. /**
  37386. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37387. */
  37388. update(): void;
  37389. private _getAngleDiff;
  37390. private _getAngleBetween;
  37391. private _isAngleBetween;
  37392. }
  37393. }
  37394. declare module BABYLON {
  37395. /**
  37396. * Manage the gamepad inputs to control an arc rotate camera.
  37397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37398. */
  37399. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37400. /**
  37401. * Defines the camera the input is attached to.
  37402. */
  37403. camera: ArcRotateCamera;
  37404. /**
  37405. * Defines the gamepad the input is gathering event from.
  37406. */
  37407. gamepad: Nullable<Gamepad>;
  37408. /**
  37409. * Defines the gamepad rotation sensiblity.
  37410. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37411. */
  37412. gamepadRotationSensibility: number;
  37413. /**
  37414. * Defines the gamepad move sensiblity.
  37415. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37416. */
  37417. gamepadMoveSensibility: number;
  37418. private _onGamepadConnectedObserver;
  37419. private _onGamepadDisconnectedObserver;
  37420. /**
  37421. * Attach the input controls to a specific dom element to get the input from.
  37422. * @param element Defines the element the controls should be listened from
  37423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37424. */
  37425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37426. /**
  37427. * Detach the current controls from the specified dom element.
  37428. * @param element Defines the element to stop listening the inputs from
  37429. */
  37430. detachControl(element: Nullable<HTMLElement>): void;
  37431. /**
  37432. * Update the current camera state depending on the inputs that have been used this frame.
  37433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37434. */
  37435. checkInputs(): void;
  37436. /**
  37437. * Gets the class name of the current intput.
  37438. * @returns the class name
  37439. */
  37440. getClassName(): string;
  37441. /**
  37442. * Get the friendly name associated with the input class.
  37443. * @returns the input friendly name
  37444. */
  37445. getSimpleName(): string;
  37446. }
  37447. }
  37448. declare module BABYLON {
  37449. interface ArcRotateCameraInputsManager {
  37450. /**
  37451. * Add orientation input support to the input manager.
  37452. * @returns the current input manager
  37453. */
  37454. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37455. }
  37456. /**
  37457. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37459. */
  37460. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37461. /**
  37462. * Defines the camera the input is attached to.
  37463. */
  37464. camera: ArcRotateCamera;
  37465. /**
  37466. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37467. */
  37468. alphaCorrection: number;
  37469. /**
  37470. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37471. */
  37472. gammaCorrection: number;
  37473. private _alpha;
  37474. private _gamma;
  37475. private _dirty;
  37476. private _deviceOrientationHandler;
  37477. /**
  37478. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37479. */
  37480. constructor();
  37481. /**
  37482. * Attach the input controls to a specific dom element to get the input from.
  37483. * @param element Defines the element the controls should be listened from
  37484. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37485. */
  37486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37487. /** @hidden */
  37488. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37489. /**
  37490. * Update the current camera state depending on the inputs that have been used this frame.
  37491. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37492. */
  37493. checkInputs(): void;
  37494. /**
  37495. * Detach the current controls from the specified dom element.
  37496. * @param element Defines the element to stop listening the inputs from
  37497. */
  37498. detachControl(element: Nullable<HTMLElement>): void;
  37499. /**
  37500. * Gets the class name of the current intput.
  37501. * @returns the class name
  37502. */
  37503. getClassName(): string;
  37504. /**
  37505. * Get the friendly name associated with the input class.
  37506. * @returns the input friendly name
  37507. */
  37508. getSimpleName(): string;
  37509. }
  37510. }
  37511. declare module BABYLON {
  37512. /**
  37513. * Listen to mouse events to control the camera.
  37514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37515. */
  37516. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37517. /**
  37518. * Defines the camera the input is attached to.
  37519. */
  37520. camera: FlyCamera;
  37521. /**
  37522. * Defines if touch is enabled. (Default is true.)
  37523. */
  37524. touchEnabled: boolean;
  37525. /**
  37526. * Defines the buttons associated with the input to handle camera rotation.
  37527. */
  37528. buttons: number[];
  37529. /**
  37530. * Assign buttons for Yaw control.
  37531. */
  37532. buttonsYaw: number[];
  37533. /**
  37534. * Assign buttons for Pitch control.
  37535. */
  37536. buttonsPitch: number[];
  37537. /**
  37538. * Assign buttons for Roll control.
  37539. */
  37540. buttonsRoll: number[];
  37541. /**
  37542. * Detect if any button is being pressed while mouse is moved.
  37543. * -1 = Mouse locked.
  37544. * 0 = Left button.
  37545. * 1 = Middle Button.
  37546. * 2 = Right Button.
  37547. */
  37548. activeButton: number;
  37549. /**
  37550. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37551. * Higher values reduce its sensitivity.
  37552. */
  37553. angularSensibility: number;
  37554. private _mousemoveCallback;
  37555. private _observer;
  37556. private _rollObserver;
  37557. private previousPosition;
  37558. private noPreventDefault;
  37559. private element;
  37560. /**
  37561. * Listen to mouse events to control the camera.
  37562. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37564. */
  37565. constructor(touchEnabled?: boolean);
  37566. /**
  37567. * Attach the mouse control to the HTML DOM element.
  37568. * @param element Defines the element that listens to the input events.
  37569. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37570. */
  37571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37572. /**
  37573. * Detach the current controls from the specified dom element.
  37574. * @param element Defines the element to stop listening the inputs from
  37575. */
  37576. detachControl(element: Nullable<HTMLElement>): void;
  37577. /**
  37578. * Gets the class name of the current input.
  37579. * @returns the class name.
  37580. */
  37581. getClassName(): string;
  37582. /**
  37583. * Get the friendly name associated with the input class.
  37584. * @returns the input's friendly name.
  37585. */
  37586. getSimpleName(): string;
  37587. private _pointerInput;
  37588. private _onMouseMove;
  37589. /**
  37590. * Rotate camera by mouse offset.
  37591. */
  37592. private rotateCamera;
  37593. }
  37594. }
  37595. declare module BABYLON {
  37596. /**
  37597. * Default Inputs manager for the FlyCamera.
  37598. * It groups all the default supported inputs for ease of use.
  37599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37600. */
  37601. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37602. /**
  37603. * Instantiates a new FlyCameraInputsManager.
  37604. * @param camera Defines the camera the inputs belong to.
  37605. */
  37606. constructor(camera: FlyCamera);
  37607. /**
  37608. * Add keyboard input support to the input manager.
  37609. * @returns the new FlyCameraKeyboardMoveInput().
  37610. */
  37611. addKeyboard(): FlyCameraInputsManager;
  37612. /**
  37613. * Add mouse input support to the input manager.
  37614. * @param touchEnabled Enable touch screen support.
  37615. * @returns the new FlyCameraMouseInput().
  37616. */
  37617. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37618. }
  37619. }
  37620. declare module BABYLON {
  37621. /**
  37622. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37623. * such as in a 3D Space Shooter or a Flight Simulator.
  37624. */
  37625. export class FlyCamera extends TargetCamera {
  37626. /**
  37627. * Define the collision ellipsoid of the camera.
  37628. * This is helpful for simulating a camera body, like a player's body.
  37629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37630. */
  37631. ellipsoid: Vector3;
  37632. /**
  37633. * Define an offset for the position of the ellipsoid around the camera.
  37634. * This can be helpful if the camera is attached away from the player's body center,
  37635. * such as at its head.
  37636. */
  37637. ellipsoidOffset: Vector3;
  37638. /**
  37639. * Enable or disable collisions of the camera with the rest of the scene objects.
  37640. */
  37641. checkCollisions: boolean;
  37642. /**
  37643. * Enable or disable gravity on the camera.
  37644. */
  37645. applyGravity: boolean;
  37646. /**
  37647. * Define the current direction the camera is moving to.
  37648. */
  37649. cameraDirection: Vector3;
  37650. /**
  37651. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37652. * This overrides and empties cameraRotation.
  37653. */
  37654. rotationQuaternion: Quaternion;
  37655. /**
  37656. * Track Roll to maintain the wanted Rolling when looking around.
  37657. */
  37658. _trackRoll: number;
  37659. /**
  37660. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37661. */
  37662. rollCorrect: number;
  37663. /**
  37664. * Mimic a banked turn, Rolling the camera when Yawing.
  37665. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37666. */
  37667. bankedTurn: boolean;
  37668. /**
  37669. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37670. */
  37671. bankedTurnLimit: number;
  37672. /**
  37673. * Value of 0 disables the banked Roll.
  37674. * Value of 1 is equal to the Yaw angle in radians.
  37675. */
  37676. bankedTurnMultiplier: number;
  37677. /**
  37678. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37679. */
  37680. inputs: FlyCameraInputsManager;
  37681. /**
  37682. * Gets the input sensibility for mouse input.
  37683. * Higher values reduce sensitivity.
  37684. */
  37685. /**
  37686. * Sets the input sensibility for a mouse input.
  37687. * Higher values reduce sensitivity.
  37688. */
  37689. angularSensibility: number;
  37690. /**
  37691. * Get the keys for camera movement forward.
  37692. */
  37693. /**
  37694. * Set the keys for camera movement forward.
  37695. */
  37696. keysForward: number[];
  37697. /**
  37698. * Get the keys for camera movement backward.
  37699. */
  37700. keysBackward: number[];
  37701. /**
  37702. * Get the keys for camera movement up.
  37703. */
  37704. /**
  37705. * Set the keys for camera movement up.
  37706. */
  37707. keysUp: number[];
  37708. /**
  37709. * Get the keys for camera movement down.
  37710. */
  37711. /**
  37712. * Set the keys for camera movement down.
  37713. */
  37714. keysDown: number[];
  37715. /**
  37716. * Get the keys for camera movement left.
  37717. */
  37718. /**
  37719. * Set the keys for camera movement left.
  37720. */
  37721. keysLeft: number[];
  37722. /**
  37723. * Set the keys for camera movement right.
  37724. */
  37725. /**
  37726. * Set the keys for camera movement right.
  37727. */
  37728. keysRight: number[];
  37729. /**
  37730. * Event raised when the camera collides with a mesh in the scene.
  37731. */
  37732. onCollide: (collidedMesh: AbstractMesh) => void;
  37733. private _collider;
  37734. private _needMoveForGravity;
  37735. private _oldPosition;
  37736. private _diffPosition;
  37737. private _newPosition;
  37738. /** @hidden */
  37739. _localDirection: Vector3;
  37740. /** @hidden */
  37741. _transformedDirection: Vector3;
  37742. /**
  37743. * Instantiates a FlyCamera.
  37744. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37745. * such as in a 3D Space Shooter or a Flight Simulator.
  37746. * @param name Define the name of the camera in the scene.
  37747. * @param position Define the starting position of the camera in the scene.
  37748. * @param scene Define the scene the camera belongs to.
  37749. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37750. */
  37751. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37752. /**
  37753. * Attach a control to the HTML DOM element.
  37754. * @param element Defines the element that listens to the input events.
  37755. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37756. */
  37757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37758. /**
  37759. * Detach a control from the HTML DOM element.
  37760. * The camera will stop reacting to that input.
  37761. * @param element Defines the element that listens to the input events.
  37762. */
  37763. detachControl(element: HTMLElement): void;
  37764. private _collisionMask;
  37765. /**
  37766. * Get the mask that the camera ignores in collision events.
  37767. */
  37768. /**
  37769. * Set the mask that the camera ignores in collision events.
  37770. */
  37771. collisionMask: number;
  37772. /** @hidden */
  37773. _collideWithWorld(displacement: Vector3): void;
  37774. /** @hidden */
  37775. private _onCollisionPositionChange;
  37776. /** @hidden */
  37777. _checkInputs(): void;
  37778. /** @hidden */
  37779. _decideIfNeedsToMove(): boolean;
  37780. /** @hidden */
  37781. _updatePosition(): void;
  37782. /**
  37783. * Restore the Roll to its target value at the rate specified.
  37784. * @param rate - Higher means slower restoring.
  37785. * @hidden
  37786. */
  37787. restoreRoll(rate: number): void;
  37788. /**
  37789. * Destroy the camera and release the current resources held by it.
  37790. */
  37791. dispose(): void;
  37792. /**
  37793. * Get the current object class name.
  37794. * @returns the class name.
  37795. */
  37796. getClassName(): string;
  37797. }
  37798. }
  37799. declare module BABYLON {
  37800. /**
  37801. * Listen to keyboard events to control the camera.
  37802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37803. */
  37804. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37805. /**
  37806. * Defines the camera the input is attached to.
  37807. */
  37808. camera: FlyCamera;
  37809. /**
  37810. * The list of keyboard keys used to control the forward move of the camera.
  37811. */
  37812. keysForward: number[];
  37813. /**
  37814. * The list of keyboard keys used to control the backward move of the camera.
  37815. */
  37816. keysBackward: number[];
  37817. /**
  37818. * The list of keyboard keys used to control the forward move of the camera.
  37819. */
  37820. keysUp: number[];
  37821. /**
  37822. * The list of keyboard keys used to control the backward move of the camera.
  37823. */
  37824. keysDown: number[];
  37825. /**
  37826. * The list of keyboard keys used to control the right strafe move of the camera.
  37827. */
  37828. keysRight: number[];
  37829. /**
  37830. * The list of keyboard keys used to control the left strafe move of the camera.
  37831. */
  37832. keysLeft: number[];
  37833. private _keys;
  37834. private _onCanvasBlurObserver;
  37835. private _onKeyboardObserver;
  37836. private _engine;
  37837. private _scene;
  37838. /**
  37839. * Attach the input controls to a specific dom element to get the input from.
  37840. * @param element Defines the element the controls should be listened from
  37841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37842. */
  37843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37844. /**
  37845. * Detach the current controls from the specified dom element.
  37846. * @param element Defines the element to stop listening the inputs from
  37847. */
  37848. detachControl(element: Nullable<HTMLElement>): void;
  37849. /**
  37850. * Gets the class name of the current intput.
  37851. * @returns the class name
  37852. */
  37853. getClassName(): string;
  37854. /** @hidden */
  37855. _onLostFocus(e: FocusEvent): void;
  37856. /**
  37857. * Get the friendly name associated with the input class.
  37858. * @returns the input friendly name
  37859. */
  37860. getSimpleName(): string;
  37861. /**
  37862. * Update the current camera state depending on the inputs that have been used this frame.
  37863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37864. */
  37865. checkInputs(): void;
  37866. }
  37867. }
  37868. declare module BABYLON {
  37869. /**
  37870. * Manage the mouse wheel inputs to control a follow camera.
  37871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37872. */
  37873. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37874. /**
  37875. * Defines the camera the input is attached to.
  37876. */
  37877. camera: FollowCamera;
  37878. /**
  37879. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37880. */
  37881. axisControlRadius: boolean;
  37882. /**
  37883. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37884. */
  37885. axisControlHeight: boolean;
  37886. /**
  37887. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37888. */
  37889. axisControlRotation: boolean;
  37890. /**
  37891. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37892. * relation to mouseWheel events.
  37893. */
  37894. wheelPrecision: number;
  37895. /**
  37896. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37897. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37898. */
  37899. wheelDeltaPercentage: number;
  37900. private _wheel;
  37901. private _observer;
  37902. /**
  37903. * Attach the input controls to a specific dom element to get the input from.
  37904. * @param element Defines the element the controls should be listened from
  37905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37906. */
  37907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37908. /**
  37909. * Detach the current controls from the specified dom element.
  37910. * @param element Defines the element to stop listening the inputs from
  37911. */
  37912. detachControl(element: Nullable<HTMLElement>): void;
  37913. /**
  37914. * Gets the class name of the current intput.
  37915. * @returns the class name
  37916. */
  37917. getClassName(): string;
  37918. /**
  37919. * Get the friendly name associated with the input class.
  37920. * @returns the input friendly name
  37921. */
  37922. getSimpleName(): string;
  37923. }
  37924. }
  37925. declare module BABYLON {
  37926. /**
  37927. * Manage the pointers inputs to control an follow camera.
  37928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37929. */
  37930. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37931. /**
  37932. * Defines the camera the input is attached to.
  37933. */
  37934. camera: FollowCamera;
  37935. /**
  37936. * Gets the class name of the current input.
  37937. * @returns the class name
  37938. */
  37939. getClassName(): string;
  37940. /**
  37941. * Defines the pointer angular sensibility along the X axis or how fast is
  37942. * the camera rotating.
  37943. * A negative number will reverse the axis direction.
  37944. */
  37945. angularSensibilityX: number;
  37946. /**
  37947. * Defines the pointer angular sensibility along the Y axis or how fast is
  37948. * the camera rotating.
  37949. * A negative number will reverse the axis direction.
  37950. */
  37951. angularSensibilityY: number;
  37952. /**
  37953. * Defines the pointer pinch precision or how fast is the camera zooming.
  37954. * A negative number will reverse the axis direction.
  37955. */
  37956. pinchPrecision: number;
  37957. /**
  37958. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37959. * from 0.
  37960. * It defines the percentage of current camera.radius to use as delta when
  37961. * pinch zoom is used.
  37962. */
  37963. pinchDeltaPercentage: number;
  37964. /**
  37965. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37966. */
  37967. axisXControlRadius: boolean;
  37968. /**
  37969. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37970. */
  37971. axisXControlHeight: boolean;
  37972. /**
  37973. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37974. */
  37975. axisXControlRotation: boolean;
  37976. /**
  37977. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37978. */
  37979. axisYControlRadius: boolean;
  37980. /**
  37981. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37982. */
  37983. axisYControlHeight: boolean;
  37984. /**
  37985. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37986. */
  37987. axisYControlRotation: boolean;
  37988. /**
  37989. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37990. */
  37991. axisPinchControlRadius: boolean;
  37992. /**
  37993. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37994. */
  37995. axisPinchControlHeight: boolean;
  37996. /**
  37997. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37998. */
  37999. axisPinchControlRotation: boolean;
  38000. /**
  38001. * Log error messages if basic misconfiguration has occurred.
  38002. */
  38003. warningEnable: boolean;
  38004. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38005. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38006. private _warningCounter;
  38007. private _warning;
  38008. }
  38009. }
  38010. declare module BABYLON {
  38011. /**
  38012. * Default Inputs manager for the FollowCamera.
  38013. * It groups all the default supported inputs for ease of use.
  38014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38015. */
  38016. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38017. /**
  38018. * Instantiates a new FollowCameraInputsManager.
  38019. * @param camera Defines the camera the inputs belong to
  38020. */
  38021. constructor(camera: FollowCamera);
  38022. /**
  38023. * Add keyboard input support to the input manager.
  38024. * @returns the current input manager
  38025. */
  38026. addKeyboard(): FollowCameraInputsManager;
  38027. /**
  38028. * Add mouse wheel input support to the input manager.
  38029. * @returns the current input manager
  38030. */
  38031. addMouseWheel(): FollowCameraInputsManager;
  38032. /**
  38033. * Add pointers input support to the input manager.
  38034. * @returns the current input manager
  38035. */
  38036. addPointers(): FollowCameraInputsManager;
  38037. /**
  38038. * Add orientation input support to the input manager.
  38039. * @returns the current input manager
  38040. */
  38041. addVRDeviceOrientation(): FollowCameraInputsManager;
  38042. }
  38043. }
  38044. declare module BABYLON {
  38045. /**
  38046. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38047. * an arc rotate version arcFollowCamera are available.
  38048. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38049. */
  38050. export class FollowCamera extends TargetCamera {
  38051. /**
  38052. * Distance the follow camera should follow an object at
  38053. */
  38054. radius: number;
  38055. /**
  38056. * Minimum allowed distance of the camera to the axis of rotation
  38057. * (The camera can not get closer).
  38058. * This can help limiting how the Camera is able to move in the scene.
  38059. */
  38060. lowerRadiusLimit: Nullable<number>;
  38061. /**
  38062. * Maximum allowed distance of the camera to the axis of rotation
  38063. * (The camera can not get further).
  38064. * This can help limiting how the Camera is able to move in the scene.
  38065. */
  38066. upperRadiusLimit: Nullable<number>;
  38067. /**
  38068. * Define a rotation offset between the camera and the object it follows
  38069. */
  38070. rotationOffset: number;
  38071. /**
  38072. * Minimum allowed angle to camera position relative to target object.
  38073. * This can help limiting how the Camera is able to move in the scene.
  38074. */
  38075. lowerRotationOffsetLimit: Nullable<number>;
  38076. /**
  38077. * Maximum allowed angle to camera position relative to target object.
  38078. * This can help limiting how the Camera is able to move in the scene.
  38079. */
  38080. upperRotationOffsetLimit: Nullable<number>;
  38081. /**
  38082. * Define a height offset between the camera and the object it follows.
  38083. * It can help following an object from the top (like a car chaing a plane)
  38084. */
  38085. heightOffset: number;
  38086. /**
  38087. * Minimum allowed height of camera position relative to target object.
  38088. * This can help limiting how the Camera is able to move in the scene.
  38089. */
  38090. lowerHeightOffsetLimit: Nullable<number>;
  38091. /**
  38092. * Maximum allowed height of camera position relative to target object.
  38093. * This can help limiting how the Camera is able to move in the scene.
  38094. */
  38095. upperHeightOffsetLimit: Nullable<number>;
  38096. /**
  38097. * Define how fast the camera can accelerate to follow it s target.
  38098. */
  38099. cameraAcceleration: number;
  38100. /**
  38101. * Define the speed limit of the camera following an object.
  38102. */
  38103. maxCameraSpeed: number;
  38104. /**
  38105. * Define the target of the camera.
  38106. */
  38107. lockedTarget: Nullable<AbstractMesh>;
  38108. /**
  38109. * Defines the input associated with the camera.
  38110. */
  38111. inputs: FollowCameraInputsManager;
  38112. /**
  38113. * Instantiates the follow camera.
  38114. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38115. * @param name Define the name of the camera in the scene
  38116. * @param position Define the position of the camera
  38117. * @param scene Define the scene the camera belong to
  38118. * @param lockedTarget Define the target of the camera
  38119. */
  38120. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38121. private _follow;
  38122. /**
  38123. * Attached controls to the current camera.
  38124. * @param element Defines the element the controls should be listened from
  38125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38126. */
  38127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38128. /**
  38129. * Detach the current controls from the camera.
  38130. * The camera will stop reacting to inputs.
  38131. * @param element Defines the element to stop listening the inputs from
  38132. */
  38133. detachControl(element: HTMLElement): void;
  38134. /** @hidden */
  38135. _checkInputs(): void;
  38136. private _checkLimits;
  38137. /**
  38138. * Gets the camera class name.
  38139. * @returns the class name
  38140. */
  38141. getClassName(): string;
  38142. }
  38143. /**
  38144. * Arc Rotate version of the follow camera.
  38145. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38146. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38147. */
  38148. export class ArcFollowCamera extends TargetCamera {
  38149. /** The longitudinal angle of the camera */
  38150. alpha: number;
  38151. /** The latitudinal angle of the camera */
  38152. beta: number;
  38153. /** The radius of the camera from its target */
  38154. radius: number;
  38155. /** Define the camera target (the messh it should follow) */
  38156. target: Nullable<AbstractMesh>;
  38157. private _cartesianCoordinates;
  38158. /**
  38159. * Instantiates a new ArcFollowCamera
  38160. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38161. * @param name Define the name of the camera
  38162. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38163. * @param beta Define the rotation angle of the camera around the elevation axis
  38164. * @param radius Define the radius of the camera from its target point
  38165. * @param target Define the target of the camera
  38166. * @param scene Define the scene the camera belongs to
  38167. */
  38168. constructor(name: string,
  38169. /** The longitudinal angle of the camera */
  38170. alpha: number,
  38171. /** The latitudinal angle of the camera */
  38172. beta: number,
  38173. /** The radius of the camera from its target */
  38174. radius: number,
  38175. /** Define the camera target (the messh it should follow) */
  38176. target: Nullable<AbstractMesh>, scene: Scene);
  38177. private _follow;
  38178. /** @hidden */
  38179. _checkInputs(): void;
  38180. /**
  38181. * Returns the class name of the object.
  38182. * It is mostly used internally for serialization purposes.
  38183. */
  38184. getClassName(): string;
  38185. }
  38186. }
  38187. declare module BABYLON {
  38188. /**
  38189. * Manage the keyboard inputs to control the movement of a follow camera.
  38190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38191. */
  38192. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38193. /**
  38194. * Defines the camera the input is attached to.
  38195. */
  38196. camera: FollowCamera;
  38197. /**
  38198. * Defines the list of key codes associated with the up action (increase heightOffset)
  38199. */
  38200. keysHeightOffsetIncr: number[];
  38201. /**
  38202. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38203. */
  38204. keysHeightOffsetDecr: number[];
  38205. /**
  38206. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38207. */
  38208. keysHeightOffsetModifierAlt: boolean;
  38209. /**
  38210. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38211. */
  38212. keysHeightOffsetModifierCtrl: boolean;
  38213. /**
  38214. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38215. */
  38216. keysHeightOffsetModifierShift: boolean;
  38217. /**
  38218. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38219. */
  38220. keysRotationOffsetIncr: number[];
  38221. /**
  38222. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38223. */
  38224. keysRotationOffsetDecr: number[];
  38225. /**
  38226. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38227. */
  38228. keysRotationOffsetModifierAlt: boolean;
  38229. /**
  38230. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38231. */
  38232. keysRotationOffsetModifierCtrl: boolean;
  38233. /**
  38234. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38235. */
  38236. keysRotationOffsetModifierShift: boolean;
  38237. /**
  38238. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38239. */
  38240. keysRadiusIncr: number[];
  38241. /**
  38242. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38243. */
  38244. keysRadiusDecr: number[];
  38245. /**
  38246. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38247. */
  38248. keysRadiusModifierAlt: boolean;
  38249. /**
  38250. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38251. */
  38252. keysRadiusModifierCtrl: boolean;
  38253. /**
  38254. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38255. */
  38256. keysRadiusModifierShift: boolean;
  38257. /**
  38258. * Defines the rate of change of heightOffset.
  38259. */
  38260. heightSensibility: number;
  38261. /**
  38262. * Defines the rate of change of rotationOffset.
  38263. */
  38264. rotationSensibility: number;
  38265. /**
  38266. * Defines the rate of change of radius.
  38267. */
  38268. radiusSensibility: number;
  38269. private _keys;
  38270. private _ctrlPressed;
  38271. private _altPressed;
  38272. private _shiftPressed;
  38273. private _onCanvasBlurObserver;
  38274. private _onKeyboardObserver;
  38275. private _engine;
  38276. private _scene;
  38277. /**
  38278. * Attach the input controls to a specific dom element to get the input from.
  38279. * @param element Defines the element the controls should be listened from
  38280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38281. */
  38282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38283. /**
  38284. * Detach the current controls from the specified dom element.
  38285. * @param element Defines the element to stop listening the inputs from
  38286. */
  38287. detachControl(element: Nullable<HTMLElement>): void;
  38288. /**
  38289. * Update the current camera state depending on the inputs that have been used this frame.
  38290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38291. */
  38292. checkInputs(): void;
  38293. /**
  38294. * Gets the class name of the current input.
  38295. * @returns the class name
  38296. */
  38297. getClassName(): string;
  38298. /**
  38299. * Get the friendly name associated with the input class.
  38300. * @returns the input friendly name
  38301. */
  38302. getSimpleName(): string;
  38303. /**
  38304. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38305. * allow modification of the heightOffset value.
  38306. */
  38307. private _modifierHeightOffset;
  38308. /**
  38309. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38310. * allow modification of the rotationOffset value.
  38311. */
  38312. private _modifierRotationOffset;
  38313. /**
  38314. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38315. * allow modification of the radius value.
  38316. */
  38317. private _modifierRadius;
  38318. }
  38319. }
  38320. declare module BABYLON {
  38321. interface FreeCameraInputsManager {
  38322. /**
  38323. * @hidden
  38324. */
  38325. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38326. /**
  38327. * Add orientation input support to the input manager.
  38328. * @returns the current input manager
  38329. */
  38330. addDeviceOrientation(): FreeCameraInputsManager;
  38331. }
  38332. /**
  38333. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38334. * Screen rotation is taken into account.
  38335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38336. */
  38337. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38338. private _camera;
  38339. private _screenOrientationAngle;
  38340. private _constantTranform;
  38341. private _screenQuaternion;
  38342. private _alpha;
  38343. private _beta;
  38344. private _gamma;
  38345. /**
  38346. * Can be used to detect if a device orientation sensor is availible on a device
  38347. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38348. * @returns a promise that will resolve on orientation change
  38349. */
  38350. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38351. /**
  38352. * @hidden
  38353. */
  38354. _onDeviceOrientationChangedObservable: Observable<void>;
  38355. /**
  38356. * Instantiates a new input
  38357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38358. */
  38359. constructor();
  38360. /**
  38361. * Define the camera controlled by the input.
  38362. */
  38363. camera: FreeCamera;
  38364. /**
  38365. * Attach the input controls to a specific dom element to get the input from.
  38366. * @param element Defines the element the controls should be listened from
  38367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38368. */
  38369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38370. private _orientationChanged;
  38371. private _deviceOrientation;
  38372. /**
  38373. * Detach the current controls from the specified dom element.
  38374. * @param element Defines the element to stop listening the inputs from
  38375. */
  38376. detachControl(element: Nullable<HTMLElement>): void;
  38377. /**
  38378. * Update the current camera state depending on the inputs that have been used this frame.
  38379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38380. */
  38381. checkInputs(): void;
  38382. /**
  38383. * Gets the class name of the current intput.
  38384. * @returns the class name
  38385. */
  38386. getClassName(): string;
  38387. /**
  38388. * Get the friendly name associated with the input class.
  38389. * @returns the input friendly name
  38390. */
  38391. getSimpleName(): string;
  38392. }
  38393. }
  38394. declare module BABYLON {
  38395. /**
  38396. * Manage the gamepad inputs to control a free camera.
  38397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38398. */
  38399. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38400. /**
  38401. * Define the camera the input is attached to.
  38402. */
  38403. camera: FreeCamera;
  38404. /**
  38405. * Define the Gamepad controlling the input
  38406. */
  38407. gamepad: Nullable<Gamepad>;
  38408. /**
  38409. * Defines the gamepad rotation sensiblity.
  38410. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38411. */
  38412. gamepadAngularSensibility: number;
  38413. /**
  38414. * Defines the gamepad move sensiblity.
  38415. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38416. */
  38417. gamepadMoveSensibility: number;
  38418. private _onGamepadConnectedObserver;
  38419. private _onGamepadDisconnectedObserver;
  38420. private _cameraTransform;
  38421. private _deltaTransform;
  38422. private _vector3;
  38423. private _vector2;
  38424. /**
  38425. * Attach the input controls to a specific dom element to get the input from.
  38426. * @param element Defines the element the controls should be listened from
  38427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38428. */
  38429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38430. /**
  38431. * Detach the current controls from the specified dom element.
  38432. * @param element Defines the element to stop listening the inputs from
  38433. */
  38434. detachControl(element: Nullable<HTMLElement>): void;
  38435. /**
  38436. * Update the current camera state depending on the inputs that have been used this frame.
  38437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38438. */
  38439. checkInputs(): void;
  38440. /**
  38441. * Gets the class name of the current intput.
  38442. * @returns the class name
  38443. */
  38444. getClassName(): string;
  38445. /**
  38446. * Get the friendly name associated with the input class.
  38447. * @returns the input friendly name
  38448. */
  38449. getSimpleName(): string;
  38450. }
  38451. }
  38452. declare module BABYLON {
  38453. /**
  38454. * Defines the potential axis of a Joystick
  38455. */
  38456. export enum JoystickAxis {
  38457. /** X axis */
  38458. X = 0,
  38459. /** Y axis */
  38460. Y = 1,
  38461. /** Z axis */
  38462. Z = 2
  38463. }
  38464. /**
  38465. * Class used to define virtual joystick (used in touch mode)
  38466. */
  38467. export class VirtualJoystick {
  38468. /**
  38469. * Gets or sets a boolean indicating that left and right values must be inverted
  38470. */
  38471. reverseLeftRight: boolean;
  38472. /**
  38473. * Gets or sets a boolean indicating that up and down values must be inverted
  38474. */
  38475. reverseUpDown: boolean;
  38476. /**
  38477. * Gets the offset value for the position (ie. the change of the position value)
  38478. */
  38479. deltaPosition: Vector3;
  38480. /**
  38481. * Gets a boolean indicating if the virtual joystick was pressed
  38482. */
  38483. pressed: boolean;
  38484. /**
  38485. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38486. */
  38487. static Canvas: Nullable<HTMLCanvasElement>;
  38488. private static _globalJoystickIndex;
  38489. private static vjCanvasContext;
  38490. private static vjCanvasWidth;
  38491. private static vjCanvasHeight;
  38492. private static halfWidth;
  38493. private _action;
  38494. private _axisTargetedByLeftAndRight;
  38495. private _axisTargetedByUpAndDown;
  38496. private _joystickSensibility;
  38497. private _inversedSensibility;
  38498. private _joystickPointerID;
  38499. private _joystickColor;
  38500. private _joystickPointerPos;
  38501. private _joystickPreviousPointerPos;
  38502. private _joystickPointerStartPos;
  38503. private _deltaJoystickVector;
  38504. private _leftJoystick;
  38505. private _touches;
  38506. private _onPointerDownHandlerRef;
  38507. private _onPointerMoveHandlerRef;
  38508. private _onPointerUpHandlerRef;
  38509. private _onResize;
  38510. /**
  38511. * Creates a new virtual joystick
  38512. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38513. */
  38514. constructor(leftJoystick?: boolean);
  38515. /**
  38516. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38517. * @param newJoystickSensibility defines the new sensibility
  38518. */
  38519. setJoystickSensibility(newJoystickSensibility: number): void;
  38520. private _onPointerDown;
  38521. private _onPointerMove;
  38522. private _onPointerUp;
  38523. /**
  38524. * Change the color of the virtual joystick
  38525. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38526. */
  38527. setJoystickColor(newColor: string): void;
  38528. /**
  38529. * Defines a callback to call when the joystick is touched
  38530. * @param action defines the callback
  38531. */
  38532. setActionOnTouch(action: () => any): void;
  38533. /**
  38534. * Defines which axis you'd like to control for left & right
  38535. * @param axis defines the axis to use
  38536. */
  38537. setAxisForLeftRight(axis: JoystickAxis): void;
  38538. /**
  38539. * Defines which axis you'd like to control for up & down
  38540. * @param axis defines the axis to use
  38541. */
  38542. setAxisForUpDown(axis: JoystickAxis): void;
  38543. private _drawVirtualJoystick;
  38544. /**
  38545. * Release internal HTML canvas
  38546. */
  38547. releaseCanvas(): void;
  38548. }
  38549. }
  38550. declare module BABYLON {
  38551. interface FreeCameraInputsManager {
  38552. /**
  38553. * Add virtual joystick input support to the input manager.
  38554. * @returns the current input manager
  38555. */
  38556. addVirtualJoystick(): FreeCameraInputsManager;
  38557. }
  38558. /**
  38559. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38561. */
  38562. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38563. /**
  38564. * Defines the camera the input is attached to.
  38565. */
  38566. camera: FreeCamera;
  38567. private _leftjoystick;
  38568. private _rightjoystick;
  38569. /**
  38570. * Gets the left stick of the virtual joystick.
  38571. * @returns The virtual Joystick
  38572. */
  38573. getLeftJoystick(): VirtualJoystick;
  38574. /**
  38575. * Gets the right stick of the virtual joystick.
  38576. * @returns The virtual Joystick
  38577. */
  38578. getRightJoystick(): VirtualJoystick;
  38579. /**
  38580. * Update the current camera state depending on the inputs that have been used this frame.
  38581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38582. */
  38583. checkInputs(): void;
  38584. /**
  38585. * Attach the input controls to a specific dom element to get the input from.
  38586. * @param element Defines the element the controls should be listened from
  38587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38588. */
  38589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38590. /**
  38591. * Detach the current controls from the specified dom element.
  38592. * @param element Defines the element to stop listening the inputs from
  38593. */
  38594. detachControl(element: Nullable<HTMLElement>): void;
  38595. /**
  38596. * Gets the class name of the current intput.
  38597. * @returns the class name
  38598. */
  38599. getClassName(): string;
  38600. /**
  38601. * Get the friendly name associated with the input class.
  38602. * @returns the input friendly name
  38603. */
  38604. getSimpleName(): string;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * This represents a FPS type of camera controlled by touch.
  38610. * This is like a universal camera minus the Gamepad controls.
  38611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38612. */
  38613. export class TouchCamera extends FreeCamera {
  38614. /**
  38615. * Defines the touch sensibility for rotation.
  38616. * The higher the faster.
  38617. */
  38618. touchAngularSensibility: number;
  38619. /**
  38620. * Defines the touch sensibility for move.
  38621. * The higher the faster.
  38622. */
  38623. touchMoveSensibility: number;
  38624. /**
  38625. * Instantiates a new touch camera.
  38626. * This represents a FPS type of camera controlled by touch.
  38627. * This is like a universal camera minus the Gamepad controls.
  38628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38629. * @param name Define the name of the camera in the scene
  38630. * @param position Define the start position of the camera in the scene
  38631. * @param scene Define the scene the camera belongs to
  38632. */
  38633. constructor(name: string, position: Vector3, scene: Scene);
  38634. /**
  38635. * Gets the current object class name.
  38636. * @return the class name
  38637. */
  38638. getClassName(): string;
  38639. /** @hidden */
  38640. _setupInputs(): void;
  38641. }
  38642. }
  38643. declare module BABYLON {
  38644. /**
  38645. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38646. * being tilted forward or back and left or right.
  38647. */
  38648. export class DeviceOrientationCamera extends FreeCamera {
  38649. private _initialQuaternion;
  38650. private _quaternionCache;
  38651. private _tmpDragQuaternion;
  38652. private _disablePointerInputWhenUsingDeviceOrientation;
  38653. /**
  38654. * Creates a new device orientation camera
  38655. * @param name The name of the camera
  38656. * @param position The start position camera
  38657. * @param scene The scene the camera belongs to
  38658. */
  38659. constructor(name: string, position: Vector3, scene: Scene);
  38660. /**
  38661. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38662. */
  38663. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38664. private _dragFactor;
  38665. /**
  38666. * Enabled turning on the y axis when the orientation sensor is active
  38667. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38668. */
  38669. enableHorizontalDragging(dragFactor?: number): void;
  38670. /**
  38671. * Gets the current instance class name ("DeviceOrientationCamera").
  38672. * This helps avoiding instanceof at run time.
  38673. * @returns the class name
  38674. */
  38675. getClassName(): string;
  38676. /**
  38677. * @hidden
  38678. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38679. */
  38680. _checkInputs(): void;
  38681. /**
  38682. * Reset the camera to its default orientation on the specified axis only.
  38683. * @param axis The axis to reset
  38684. */
  38685. resetToCurrentRotation(axis?: Axis): void;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * Defines supported buttons for XBox360 compatible gamepads
  38691. */
  38692. export enum Xbox360Button {
  38693. /** A */
  38694. A = 0,
  38695. /** B */
  38696. B = 1,
  38697. /** X */
  38698. X = 2,
  38699. /** Y */
  38700. Y = 3,
  38701. /** Start */
  38702. Start = 4,
  38703. /** Back */
  38704. Back = 5,
  38705. /** Left button */
  38706. LB = 6,
  38707. /** Right button */
  38708. RB = 7,
  38709. /** Left stick */
  38710. LeftStick = 8,
  38711. /** Right stick */
  38712. RightStick = 9
  38713. }
  38714. /** Defines values for XBox360 DPad */
  38715. export enum Xbox360Dpad {
  38716. /** Up */
  38717. Up = 0,
  38718. /** Down */
  38719. Down = 1,
  38720. /** Left */
  38721. Left = 2,
  38722. /** Right */
  38723. Right = 3
  38724. }
  38725. /**
  38726. * Defines a XBox360 gamepad
  38727. */
  38728. export class Xbox360Pad extends Gamepad {
  38729. private _leftTrigger;
  38730. private _rightTrigger;
  38731. private _onlefttriggerchanged;
  38732. private _onrighttriggerchanged;
  38733. private _onbuttondown;
  38734. private _onbuttonup;
  38735. private _ondpaddown;
  38736. private _ondpadup;
  38737. /** Observable raised when a button is pressed */
  38738. onButtonDownObservable: Observable<Xbox360Button>;
  38739. /** Observable raised when a button is released */
  38740. onButtonUpObservable: Observable<Xbox360Button>;
  38741. /** Observable raised when a pad is pressed */
  38742. onPadDownObservable: Observable<Xbox360Dpad>;
  38743. /** Observable raised when a pad is released */
  38744. onPadUpObservable: Observable<Xbox360Dpad>;
  38745. private _buttonA;
  38746. private _buttonB;
  38747. private _buttonX;
  38748. private _buttonY;
  38749. private _buttonBack;
  38750. private _buttonStart;
  38751. private _buttonLB;
  38752. private _buttonRB;
  38753. private _buttonLeftStick;
  38754. private _buttonRightStick;
  38755. private _dPadUp;
  38756. private _dPadDown;
  38757. private _dPadLeft;
  38758. private _dPadRight;
  38759. private _isXboxOnePad;
  38760. /**
  38761. * Creates a new XBox360 gamepad object
  38762. * @param id defines the id of this gamepad
  38763. * @param index defines its index
  38764. * @param gamepad defines the internal HTML gamepad object
  38765. * @param xboxOne defines if it is a XBox One gamepad
  38766. */
  38767. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38768. /**
  38769. * Defines the callback to call when left trigger is pressed
  38770. * @param callback defines the callback to use
  38771. */
  38772. onlefttriggerchanged(callback: (value: number) => void): void;
  38773. /**
  38774. * Defines the callback to call when right trigger is pressed
  38775. * @param callback defines the callback to use
  38776. */
  38777. onrighttriggerchanged(callback: (value: number) => void): void;
  38778. /**
  38779. * Gets the left trigger value
  38780. */
  38781. /**
  38782. * Sets the left trigger value
  38783. */
  38784. leftTrigger: number;
  38785. /**
  38786. * Gets the right trigger value
  38787. */
  38788. /**
  38789. * Sets the right trigger value
  38790. */
  38791. rightTrigger: number;
  38792. /**
  38793. * Defines the callback to call when a button is pressed
  38794. * @param callback defines the callback to use
  38795. */
  38796. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38797. /**
  38798. * Defines the callback to call when a button is released
  38799. * @param callback defines the callback to use
  38800. */
  38801. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38802. /**
  38803. * Defines the callback to call when a pad is pressed
  38804. * @param callback defines the callback to use
  38805. */
  38806. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38807. /**
  38808. * Defines the callback to call when a pad is released
  38809. * @param callback defines the callback to use
  38810. */
  38811. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38812. private _setButtonValue;
  38813. private _setDPadValue;
  38814. /**
  38815. * Gets the value of the `A` button
  38816. */
  38817. /**
  38818. * Sets the value of the `A` button
  38819. */
  38820. buttonA: number;
  38821. /**
  38822. * Gets the value of the `B` button
  38823. */
  38824. /**
  38825. * Sets the value of the `B` button
  38826. */
  38827. buttonB: number;
  38828. /**
  38829. * Gets the value of the `X` button
  38830. */
  38831. /**
  38832. * Sets the value of the `X` button
  38833. */
  38834. buttonX: number;
  38835. /**
  38836. * Gets the value of the `Y` button
  38837. */
  38838. /**
  38839. * Sets the value of the `Y` button
  38840. */
  38841. buttonY: number;
  38842. /**
  38843. * Gets the value of the `Start` button
  38844. */
  38845. /**
  38846. * Sets the value of the `Start` button
  38847. */
  38848. buttonStart: number;
  38849. /**
  38850. * Gets the value of the `Back` button
  38851. */
  38852. /**
  38853. * Sets the value of the `Back` button
  38854. */
  38855. buttonBack: number;
  38856. /**
  38857. * Gets the value of the `Left` button
  38858. */
  38859. /**
  38860. * Sets the value of the `Left` button
  38861. */
  38862. buttonLB: number;
  38863. /**
  38864. * Gets the value of the `Right` button
  38865. */
  38866. /**
  38867. * Sets the value of the `Right` button
  38868. */
  38869. buttonRB: number;
  38870. /**
  38871. * Gets the value of the Left joystick
  38872. */
  38873. /**
  38874. * Sets the value of the Left joystick
  38875. */
  38876. buttonLeftStick: number;
  38877. /**
  38878. * Gets the value of the Right joystick
  38879. */
  38880. /**
  38881. * Sets the value of the Right joystick
  38882. */
  38883. buttonRightStick: number;
  38884. /**
  38885. * Gets the value of D-pad up
  38886. */
  38887. /**
  38888. * Sets the value of D-pad up
  38889. */
  38890. dPadUp: number;
  38891. /**
  38892. * Gets the value of D-pad down
  38893. */
  38894. /**
  38895. * Sets the value of D-pad down
  38896. */
  38897. dPadDown: number;
  38898. /**
  38899. * Gets the value of D-pad left
  38900. */
  38901. /**
  38902. * Sets the value of D-pad left
  38903. */
  38904. dPadLeft: number;
  38905. /**
  38906. * Gets the value of D-pad right
  38907. */
  38908. /**
  38909. * Sets the value of D-pad right
  38910. */
  38911. dPadRight: number;
  38912. /**
  38913. * Force the gamepad to synchronize with device values
  38914. */
  38915. update(): void;
  38916. /**
  38917. * Disposes the gamepad
  38918. */
  38919. dispose(): void;
  38920. }
  38921. }
  38922. declare module BABYLON {
  38923. /**
  38924. * Defines supported buttons for DualShock compatible gamepads
  38925. */
  38926. export enum DualShockButton {
  38927. /** Cross */
  38928. Cross = 0,
  38929. /** Circle */
  38930. Circle = 1,
  38931. /** Square */
  38932. Square = 2,
  38933. /** Triangle */
  38934. Triangle = 3,
  38935. /** Options */
  38936. Options = 4,
  38937. /** Share */
  38938. Share = 5,
  38939. /** L1 */
  38940. L1 = 6,
  38941. /** R1 */
  38942. R1 = 7,
  38943. /** Left stick */
  38944. LeftStick = 8,
  38945. /** Right stick */
  38946. RightStick = 9
  38947. }
  38948. /** Defines values for DualShock DPad */
  38949. export enum DualShockDpad {
  38950. /** Up */
  38951. Up = 0,
  38952. /** Down */
  38953. Down = 1,
  38954. /** Left */
  38955. Left = 2,
  38956. /** Right */
  38957. Right = 3
  38958. }
  38959. /**
  38960. * Defines a DualShock gamepad
  38961. */
  38962. export class DualShockPad extends Gamepad {
  38963. private _leftTrigger;
  38964. private _rightTrigger;
  38965. private _onlefttriggerchanged;
  38966. private _onrighttriggerchanged;
  38967. private _onbuttondown;
  38968. private _onbuttonup;
  38969. private _ondpaddown;
  38970. private _ondpadup;
  38971. /** Observable raised when a button is pressed */
  38972. onButtonDownObservable: Observable<DualShockButton>;
  38973. /** Observable raised when a button is released */
  38974. onButtonUpObservable: Observable<DualShockButton>;
  38975. /** Observable raised when a pad is pressed */
  38976. onPadDownObservable: Observable<DualShockDpad>;
  38977. /** Observable raised when a pad is released */
  38978. onPadUpObservable: Observable<DualShockDpad>;
  38979. private _buttonCross;
  38980. private _buttonCircle;
  38981. private _buttonSquare;
  38982. private _buttonTriangle;
  38983. private _buttonShare;
  38984. private _buttonOptions;
  38985. private _buttonL1;
  38986. private _buttonR1;
  38987. private _buttonLeftStick;
  38988. private _buttonRightStick;
  38989. private _dPadUp;
  38990. private _dPadDown;
  38991. private _dPadLeft;
  38992. private _dPadRight;
  38993. /**
  38994. * Creates a new DualShock gamepad object
  38995. * @param id defines the id of this gamepad
  38996. * @param index defines its index
  38997. * @param gamepad defines the internal HTML gamepad object
  38998. */
  38999. constructor(id: string, index: number, gamepad: any);
  39000. /**
  39001. * Defines the callback to call when left trigger is pressed
  39002. * @param callback defines the callback to use
  39003. */
  39004. onlefttriggerchanged(callback: (value: number) => void): void;
  39005. /**
  39006. * Defines the callback to call when right trigger is pressed
  39007. * @param callback defines the callback to use
  39008. */
  39009. onrighttriggerchanged(callback: (value: number) => void): void;
  39010. /**
  39011. * Gets the left trigger value
  39012. */
  39013. /**
  39014. * Sets the left trigger value
  39015. */
  39016. leftTrigger: number;
  39017. /**
  39018. * Gets the right trigger value
  39019. */
  39020. /**
  39021. * Sets the right trigger value
  39022. */
  39023. rightTrigger: number;
  39024. /**
  39025. * Defines the callback to call when a button is pressed
  39026. * @param callback defines the callback to use
  39027. */
  39028. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39029. /**
  39030. * Defines the callback to call when a button is released
  39031. * @param callback defines the callback to use
  39032. */
  39033. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39034. /**
  39035. * Defines the callback to call when a pad is pressed
  39036. * @param callback defines the callback to use
  39037. */
  39038. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39039. /**
  39040. * Defines the callback to call when a pad is released
  39041. * @param callback defines the callback to use
  39042. */
  39043. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39044. private _setButtonValue;
  39045. private _setDPadValue;
  39046. /**
  39047. * Gets the value of the `Cross` button
  39048. */
  39049. /**
  39050. * Sets the value of the `Cross` button
  39051. */
  39052. buttonCross: number;
  39053. /**
  39054. * Gets the value of the `Circle` button
  39055. */
  39056. /**
  39057. * Sets the value of the `Circle` button
  39058. */
  39059. buttonCircle: number;
  39060. /**
  39061. * Gets the value of the `Square` button
  39062. */
  39063. /**
  39064. * Sets the value of the `Square` button
  39065. */
  39066. buttonSquare: number;
  39067. /**
  39068. * Gets the value of the `Triangle` button
  39069. */
  39070. /**
  39071. * Sets the value of the `Triangle` button
  39072. */
  39073. buttonTriangle: number;
  39074. /**
  39075. * Gets the value of the `Options` button
  39076. */
  39077. /**
  39078. * Sets the value of the `Options` button
  39079. */
  39080. buttonOptions: number;
  39081. /**
  39082. * Gets the value of the `Share` button
  39083. */
  39084. /**
  39085. * Sets the value of the `Share` button
  39086. */
  39087. buttonShare: number;
  39088. /**
  39089. * Gets the value of the `L1` button
  39090. */
  39091. /**
  39092. * Sets the value of the `L1` button
  39093. */
  39094. buttonL1: number;
  39095. /**
  39096. * Gets the value of the `R1` button
  39097. */
  39098. /**
  39099. * Sets the value of the `R1` button
  39100. */
  39101. buttonR1: number;
  39102. /**
  39103. * Gets the value of the Left joystick
  39104. */
  39105. /**
  39106. * Sets the value of the Left joystick
  39107. */
  39108. buttonLeftStick: number;
  39109. /**
  39110. * Gets the value of the Right joystick
  39111. */
  39112. /**
  39113. * Sets the value of the Right joystick
  39114. */
  39115. buttonRightStick: number;
  39116. /**
  39117. * Gets the value of D-pad up
  39118. */
  39119. /**
  39120. * Sets the value of D-pad up
  39121. */
  39122. dPadUp: number;
  39123. /**
  39124. * Gets the value of D-pad down
  39125. */
  39126. /**
  39127. * Sets the value of D-pad down
  39128. */
  39129. dPadDown: number;
  39130. /**
  39131. * Gets the value of D-pad left
  39132. */
  39133. /**
  39134. * Sets the value of D-pad left
  39135. */
  39136. dPadLeft: number;
  39137. /**
  39138. * Gets the value of D-pad right
  39139. */
  39140. /**
  39141. * Sets the value of D-pad right
  39142. */
  39143. dPadRight: number;
  39144. /**
  39145. * Force the gamepad to synchronize with device values
  39146. */
  39147. update(): void;
  39148. /**
  39149. * Disposes the gamepad
  39150. */
  39151. dispose(): void;
  39152. }
  39153. }
  39154. declare module BABYLON {
  39155. /**
  39156. * Manager for handling gamepads
  39157. */
  39158. export class GamepadManager {
  39159. private _scene?;
  39160. private _babylonGamepads;
  39161. private _oneGamepadConnected;
  39162. /** @hidden */
  39163. _isMonitoring: boolean;
  39164. private _gamepadEventSupported;
  39165. private _gamepadSupport;
  39166. /**
  39167. * observable to be triggered when the gamepad controller has been connected
  39168. */
  39169. onGamepadConnectedObservable: Observable<Gamepad>;
  39170. /**
  39171. * observable to be triggered when the gamepad controller has been disconnected
  39172. */
  39173. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39174. private _onGamepadConnectedEvent;
  39175. private _onGamepadDisconnectedEvent;
  39176. /**
  39177. * Initializes the gamepad manager
  39178. * @param _scene BabylonJS scene
  39179. */
  39180. constructor(_scene?: Scene | undefined);
  39181. /**
  39182. * The gamepads in the game pad manager
  39183. */
  39184. readonly gamepads: Gamepad[];
  39185. /**
  39186. * Get the gamepad controllers based on type
  39187. * @param type The type of gamepad controller
  39188. * @returns Nullable gamepad
  39189. */
  39190. getGamepadByType(type?: number): Nullable<Gamepad>;
  39191. /**
  39192. * Disposes the gamepad manager
  39193. */
  39194. dispose(): void;
  39195. private _addNewGamepad;
  39196. private _startMonitoringGamepads;
  39197. private _stopMonitoringGamepads;
  39198. /** @hidden */
  39199. _checkGamepadsStatus(): void;
  39200. private _updateGamepadObjects;
  39201. }
  39202. }
  39203. declare module BABYLON {
  39204. interface Scene {
  39205. /** @hidden */
  39206. _gamepadManager: Nullable<GamepadManager>;
  39207. /**
  39208. * Gets the gamepad manager associated with the scene
  39209. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39210. */
  39211. gamepadManager: GamepadManager;
  39212. }
  39213. /**
  39214. * Interface representing a free camera inputs manager
  39215. */
  39216. interface FreeCameraInputsManager {
  39217. /**
  39218. * Adds gamepad input support to the FreeCameraInputsManager.
  39219. * @returns the FreeCameraInputsManager
  39220. */
  39221. addGamepad(): FreeCameraInputsManager;
  39222. }
  39223. /**
  39224. * Interface representing an arc rotate camera inputs manager
  39225. */
  39226. interface ArcRotateCameraInputsManager {
  39227. /**
  39228. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39229. * @returns the camera inputs manager
  39230. */
  39231. addGamepad(): ArcRotateCameraInputsManager;
  39232. }
  39233. /**
  39234. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39235. */
  39236. export class GamepadSystemSceneComponent implements ISceneComponent {
  39237. /**
  39238. * The component name helpfull to identify the component in the list of scene components.
  39239. */
  39240. readonly name: string;
  39241. /**
  39242. * The scene the component belongs to.
  39243. */
  39244. scene: Scene;
  39245. /**
  39246. * Creates a new instance of the component for the given scene
  39247. * @param scene Defines the scene to register the component in
  39248. */
  39249. constructor(scene: Scene);
  39250. /**
  39251. * Registers the component in a given scene
  39252. */
  39253. register(): void;
  39254. /**
  39255. * Rebuilds the elements related to this component in case of
  39256. * context lost for instance.
  39257. */
  39258. rebuild(): void;
  39259. /**
  39260. * Disposes the component and the associated ressources
  39261. */
  39262. dispose(): void;
  39263. private _beforeCameraUpdate;
  39264. }
  39265. }
  39266. declare module BABYLON {
  39267. /**
  39268. * 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,
  39269. * which still works and will still be found in many Playgrounds.
  39270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39271. */
  39272. export class UniversalCamera extends TouchCamera {
  39273. /**
  39274. * Defines the gamepad rotation sensiblity.
  39275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39276. */
  39277. gamepadAngularSensibility: number;
  39278. /**
  39279. * Defines the gamepad move sensiblity.
  39280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39281. */
  39282. gamepadMoveSensibility: number;
  39283. /**
  39284. * 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,
  39285. * which still works and will still be found in many Playgrounds.
  39286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39287. * @param name Define the name of the camera in the scene
  39288. * @param position Define the start position of the camera in the scene
  39289. * @param scene Define the scene the camera belongs to
  39290. */
  39291. constructor(name: string, position: Vector3, scene: Scene);
  39292. /**
  39293. * Gets the current object class name.
  39294. * @return the class name
  39295. */
  39296. getClassName(): string;
  39297. }
  39298. }
  39299. declare module BABYLON {
  39300. /**
  39301. * This represents a FPS type of camera. This is only here for back compat purpose.
  39302. * Please use the UniversalCamera instead as both are identical.
  39303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39304. */
  39305. export class GamepadCamera extends UniversalCamera {
  39306. /**
  39307. * Instantiates a new Gamepad Camera
  39308. * This represents a FPS type of camera. This is only here for back compat purpose.
  39309. * Please use the UniversalCamera instead as both are identical.
  39310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39311. * @param name Define the name of the camera in the scene
  39312. * @param position Define the start position of the camera in the scene
  39313. * @param scene Define the scene the camera belongs to
  39314. */
  39315. constructor(name: string, position: Vector3, scene: Scene);
  39316. /**
  39317. * Gets the current object class name.
  39318. * @return the class name
  39319. */
  39320. getClassName(): string;
  39321. }
  39322. }
  39323. declare module BABYLON {
  39324. /** @hidden */
  39325. export var passPixelShader: {
  39326. name: string;
  39327. shader: string;
  39328. };
  39329. }
  39330. declare module BABYLON {
  39331. /** @hidden */
  39332. export var passCubePixelShader: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module BABYLON {
  39338. /**
  39339. * PassPostProcess which produces an output the same as it's input
  39340. */
  39341. export class PassPostProcess extends PostProcess {
  39342. /**
  39343. * Creates the PassPostProcess
  39344. * @param name The name of the effect.
  39345. * @param options The required width/height ratio to downsize to before computing the render pass.
  39346. * @param camera The camera to apply the render pass to.
  39347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39348. * @param engine The engine which the post process will be applied. (default: current engine)
  39349. * @param reusable If the post process can be reused on the same frame. (default: false)
  39350. * @param textureType The type of texture to be used when performing the post processing.
  39351. * @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)
  39352. */
  39353. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39354. }
  39355. /**
  39356. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39357. */
  39358. export class PassCubePostProcess extends PostProcess {
  39359. private _face;
  39360. /**
  39361. * Gets or sets the cube face to display.
  39362. * * 0 is +X
  39363. * * 1 is -X
  39364. * * 2 is +Y
  39365. * * 3 is -Y
  39366. * * 4 is +Z
  39367. * * 5 is -Z
  39368. */
  39369. face: number;
  39370. /**
  39371. * Creates the PassCubePostProcess
  39372. * @param name The name of the effect.
  39373. * @param options The required width/height ratio to downsize to before computing the render pass.
  39374. * @param camera The camera to apply the render pass to.
  39375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39376. * @param engine The engine which the post process will be applied. (default: current engine)
  39377. * @param reusable If the post process can be reused on the same frame. (default: false)
  39378. * @param textureType The type of texture to be used when performing the post processing.
  39379. * @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)
  39380. */
  39381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39382. }
  39383. }
  39384. declare module BABYLON {
  39385. /** @hidden */
  39386. export var anaglyphPixelShader: {
  39387. name: string;
  39388. shader: string;
  39389. };
  39390. }
  39391. declare module BABYLON {
  39392. /**
  39393. * Postprocess used to generate anaglyphic rendering
  39394. */
  39395. export class AnaglyphPostProcess extends PostProcess {
  39396. private _passedProcess;
  39397. /**
  39398. * Creates a new AnaglyphPostProcess
  39399. * @param name defines postprocess name
  39400. * @param options defines creation options or target ratio scale
  39401. * @param rigCameras defines cameras using this postprocess
  39402. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39403. * @param engine defines hosting engine
  39404. * @param reusable defines if the postprocess will be reused multiple times per frame
  39405. */
  39406. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39407. }
  39408. }
  39409. declare module BABYLON {
  39410. /**
  39411. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39412. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39413. */
  39414. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39415. /**
  39416. * Creates a new AnaglyphArcRotateCamera
  39417. * @param name defines camera name
  39418. * @param alpha defines alpha angle (in radians)
  39419. * @param beta defines beta angle (in radians)
  39420. * @param radius defines radius
  39421. * @param target defines camera target
  39422. * @param interaxialDistance defines distance between each color axis
  39423. * @param scene defines the hosting scene
  39424. */
  39425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39426. /**
  39427. * Gets camera class name
  39428. * @returns AnaglyphArcRotateCamera
  39429. */
  39430. getClassName(): string;
  39431. }
  39432. }
  39433. declare module BABYLON {
  39434. /**
  39435. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39437. */
  39438. export class AnaglyphFreeCamera extends FreeCamera {
  39439. /**
  39440. * Creates a new AnaglyphFreeCamera
  39441. * @param name defines camera name
  39442. * @param position defines initial position
  39443. * @param interaxialDistance defines distance between each color axis
  39444. * @param scene defines the hosting scene
  39445. */
  39446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39447. /**
  39448. * Gets camera class name
  39449. * @returns AnaglyphFreeCamera
  39450. */
  39451. getClassName(): string;
  39452. }
  39453. }
  39454. declare module BABYLON {
  39455. /**
  39456. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39458. */
  39459. export class AnaglyphGamepadCamera extends GamepadCamera {
  39460. /**
  39461. * Creates a new AnaglyphGamepadCamera
  39462. * @param name defines camera name
  39463. * @param position defines initial position
  39464. * @param interaxialDistance defines distance between each color axis
  39465. * @param scene defines the hosting scene
  39466. */
  39467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39468. /**
  39469. * Gets camera class name
  39470. * @returns AnaglyphGamepadCamera
  39471. */
  39472. getClassName(): string;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39479. */
  39480. export class AnaglyphUniversalCamera extends UniversalCamera {
  39481. /**
  39482. * Creates a new AnaglyphUniversalCamera
  39483. * @param name defines camera name
  39484. * @param position defines initial position
  39485. * @param interaxialDistance defines distance between each color axis
  39486. * @param scene defines the hosting scene
  39487. */
  39488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39489. /**
  39490. * Gets camera class name
  39491. * @returns AnaglyphUniversalCamera
  39492. */
  39493. getClassName(): string;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /** @hidden */
  39498. export var stereoscopicInterlacePixelShader: {
  39499. name: string;
  39500. shader: string;
  39501. };
  39502. }
  39503. declare module BABYLON {
  39504. /**
  39505. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39506. */
  39507. export class StereoscopicInterlacePostProcess extends PostProcess {
  39508. private _stepSize;
  39509. private _passedProcess;
  39510. /**
  39511. * Initializes a StereoscopicInterlacePostProcess
  39512. * @param name The name of the effect.
  39513. * @param rigCameras The rig cameras to be appled to the post process
  39514. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39516. * @param engine The engine which the post process will be applied. (default: current engine)
  39517. * @param reusable If the post process can be reused on the same frame. (default: false)
  39518. */
  39519. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39520. }
  39521. }
  39522. declare module BABYLON {
  39523. /**
  39524. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39525. * @see http://doc.babylonjs.com/features/cameras
  39526. */
  39527. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39528. /**
  39529. * Creates a new StereoscopicArcRotateCamera
  39530. * @param name defines camera name
  39531. * @param alpha defines alpha angle (in radians)
  39532. * @param beta defines beta angle (in radians)
  39533. * @param radius defines radius
  39534. * @param target defines camera target
  39535. * @param interaxialDistance defines distance between each color axis
  39536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39537. * @param scene defines the hosting scene
  39538. */
  39539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39540. /**
  39541. * Gets camera class name
  39542. * @returns StereoscopicArcRotateCamera
  39543. */
  39544. getClassName(): string;
  39545. }
  39546. }
  39547. declare module BABYLON {
  39548. /**
  39549. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39550. * @see http://doc.babylonjs.com/features/cameras
  39551. */
  39552. export class StereoscopicFreeCamera extends FreeCamera {
  39553. /**
  39554. * Creates a new StereoscopicFreeCamera
  39555. * @param name defines camera name
  39556. * @param position defines initial position
  39557. * @param interaxialDistance defines distance between each color axis
  39558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39559. * @param scene defines the hosting scene
  39560. */
  39561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39562. /**
  39563. * Gets camera class name
  39564. * @returns StereoscopicFreeCamera
  39565. */
  39566. getClassName(): string;
  39567. }
  39568. }
  39569. declare module BABYLON {
  39570. /**
  39571. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39572. * @see http://doc.babylonjs.com/features/cameras
  39573. */
  39574. export class StereoscopicGamepadCamera extends GamepadCamera {
  39575. /**
  39576. * Creates a new StereoscopicGamepadCamera
  39577. * @param name defines camera name
  39578. * @param position defines initial position
  39579. * @param interaxialDistance defines distance between each color axis
  39580. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39581. * @param scene defines the hosting scene
  39582. */
  39583. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39584. /**
  39585. * Gets camera class name
  39586. * @returns StereoscopicGamepadCamera
  39587. */
  39588. getClassName(): string;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39594. * @see http://doc.babylonjs.com/features/cameras
  39595. */
  39596. export class StereoscopicUniversalCamera extends UniversalCamera {
  39597. /**
  39598. * Creates a new StereoscopicUniversalCamera
  39599. * @param name defines camera name
  39600. * @param position defines initial position
  39601. * @param interaxialDistance defines distance between each color axis
  39602. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39603. * @param scene defines the hosting scene
  39604. */
  39605. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39606. /**
  39607. * Gets camera class name
  39608. * @returns StereoscopicUniversalCamera
  39609. */
  39610. getClassName(): string;
  39611. }
  39612. }
  39613. declare module BABYLON {
  39614. /**
  39615. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39616. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39617. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39618. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39619. */
  39620. export class VirtualJoysticksCamera extends FreeCamera {
  39621. /**
  39622. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39623. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39624. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39625. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39626. * @param name Define the name of the camera in the scene
  39627. * @param position Define the start position of the camera in the scene
  39628. * @param scene Define the scene the camera belongs to
  39629. */
  39630. constructor(name: string, position: Vector3, scene: Scene);
  39631. /**
  39632. * Gets the current object class name.
  39633. * @return the class name
  39634. */
  39635. getClassName(): string;
  39636. }
  39637. }
  39638. declare module BABYLON {
  39639. /**
  39640. * This represents all the required metrics to create a VR camera.
  39641. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39642. */
  39643. export class VRCameraMetrics {
  39644. /**
  39645. * Define the horizontal resolution off the screen.
  39646. */
  39647. hResolution: number;
  39648. /**
  39649. * Define the vertical resolution off the screen.
  39650. */
  39651. vResolution: number;
  39652. /**
  39653. * Define the horizontal screen size.
  39654. */
  39655. hScreenSize: number;
  39656. /**
  39657. * Define the vertical screen size.
  39658. */
  39659. vScreenSize: number;
  39660. /**
  39661. * Define the vertical screen center position.
  39662. */
  39663. vScreenCenter: number;
  39664. /**
  39665. * Define the distance of the eyes to the screen.
  39666. */
  39667. eyeToScreenDistance: number;
  39668. /**
  39669. * Define the distance between both lenses
  39670. */
  39671. lensSeparationDistance: number;
  39672. /**
  39673. * Define the distance between both viewer's eyes.
  39674. */
  39675. interpupillaryDistance: number;
  39676. /**
  39677. * Define the distortion factor of the VR postprocess.
  39678. * Please, touch with care.
  39679. */
  39680. distortionK: number[];
  39681. /**
  39682. * Define the chromatic aberration correction factors for the VR post process.
  39683. */
  39684. chromaAbCorrection: number[];
  39685. /**
  39686. * Define the scale factor of the post process.
  39687. * The smaller the better but the slower.
  39688. */
  39689. postProcessScaleFactor: number;
  39690. /**
  39691. * Define an offset for the lens center.
  39692. */
  39693. lensCenterOffset: number;
  39694. /**
  39695. * Define if the current vr camera should compensate the distortion of the lense or not.
  39696. */
  39697. compensateDistortion: boolean;
  39698. /**
  39699. * Defines if multiview should be enabled when rendering (Default: false)
  39700. */
  39701. multiviewEnabled: boolean;
  39702. /**
  39703. * Gets the rendering aspect ratio based on the provided resolutions.
  39704. */
  39705. readonly aspectRatio: number;
  39706. /**
  39707. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39708. */
  39709. readonly aspectRatioFov: number;
  39710. /**
  39711. * @hidden
  39712. */
  39713. readonly leftHMatrix: Matrix;
  39714. /**
  39715. * @hidden
  39716. */
  39717. readonly rightHMatrix: Matrix;
  39718. /**
  39719. * @hidden
  39720. */
  39721. readonly leftPreViewMatrix: Matrix;
  39722. /**
  39723. * @hidden
  39724. */
  39725. readonly rightPreViewMatrix: Matrix;
  39726. /**
  39727. * Get the default VRMetrics based on the most generic setup.
  39728. * @returns the default vr metrics
  39729. */
  39730. static GetDefault(): VRCameraMetrics;
  39731. }
  39732. }
  39733. declare module BABYLON {
  39734. /** @hidden */
  39735. export var vrDistortionCorrectionPixelShader: {
  39736. name: string;
  39737. shader: string;
  39738. };
  39739. }
  39740. declare module BABYLON {
  39741. /**
  39742. * VRDistortionCorrectionPostProcess used for mobile VR
  39743. */
  39744. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39745. private _isRightEye;
  39746. private _distortionFactors;
  39747. private _postProcessScaleFactor;
  39748. private _lensCenterOffset;
  39749. private _scaleIn;
  39750. private _scaleFactor;
  39751. private _lensCenter;
  39752. /**
  39753. * Initializes the VRDistortionCorrectionPostProcess
  39754. * @param name The name of the effect.
  39755. * @param camera The camera to apply the render pass to.
  39756. * @param isRightEye If this is for the right eye distortion
  39757. * @param vrMetrics All the required metrics for the VR camera
  39758. */
  39759. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39760. }
  39761. }
  39762. declare module BABYLON {
  39763. /**
  39764. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39766. */
  39767. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39768. /**
  39769. * Creates a new VRDeviceOrientationArcRotateCamera
  39770. * @param name defines camera name
  39771. * @param alpha defines the camera rotation along the logitudinal axis
  39772. * @param beta defines the camera rotation along the latitudinal axis
  39773. * @param radius defines the camera distance from its target
  39774. * @param target defines the camera target
  39775. * @param scene defines the scene the camera belongs to
  39776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39778. */
  39779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39780. /**
  39781. * Gets camera class name
  39782. * @returns VRDeviceOrientationArcRotateCamera
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. }
  39787. declare module BABYLON {
  39788. /**
  39789. * Camera used to simulate VR rendering (based on FreeCamera)
  39790. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39791. */
  39792. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39793. /**
  39794. * Creates a new VRDeviceOrientationFreeCamera
  39795. * @param name defines camera name
  39796. * @param position defines the start position of the camera
  39797. * @param scene defines the scene the camera belongs to
  39798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39800. */
  39801. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39802. /**
  39803. * Gets camera class name
  39804. * @returns VRDeviceOrientationFreeCamera
  39805. */
  39806. getClassName(): string;
  39807. }
  39808. }
  39809. declare module BABYLON {
  39810. /**
  39811. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39812. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39813. */
  39814. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39815. /**
  39816. * Creates a new VRDeviceOrientationGamepadCamera
  39817. * @param name defines camera name
  39818. * @param position defines the start position of the camera
  39819. * @param scene defines the scene the camera belongs to
  39820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39822. */
  39823. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39824. /**
  39825. * Gets camera class name
  39826. * @returns VRDeviceOrientationGamepadCamera
  39827. */
  39828. getClassName(): string;
  39829. }
  39830. }
  39831. declare module BABYLON {
  39832. /**
  39833. * Base class of materials working in push mode in babylon JS
  39834. * @hidden
  39835. */
  39836. export class PushMaterial extends Material {
  39837. protected _activeEffect: Effect;
  39838. protected _normalMatrix: Matrix;
  39839. /**
  39840. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39841. * This means that the material can keep using a previous shader while a new one is being compiled.
  39842. * This is mostly used when shader parallel compilation is supported (true by default)
  39843. */
  39844. allowShaderHotSwapping: boolean;
  39845. constructor(name: string, scene: Scene);
  39846. getEffect(): Effect;
  39847. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39848. /**
  39849. * Binds the given world matrix to the active effect
  39850. *
  39851. * @param world the matrix to bind
  39852. */
  39853. bindOnlyWorldMatrix(world: Matrix): void;
  39854. /**
  39855. * Binds the given normal matrix to the active effect
  39856. *
  39857. * @param normalMatrix the matrix to bind
  39858. */
  39859. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39860. bind(world: Matrix, mesh?: Mesh): void;
  39861. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39862. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39863. }
  39864. }
  39865. declare module BABYLON {
  39866. /**
  39867. * This groups all the flags used to control the materials channel.
  39868. */
  39869. export class MaterialFlags {
  39870. private static _DiffuseTextureEnabled;
  39871. /**
  39872. * Are diffuse textures enabled in the application.
  39873. */
  39874. static DiffuseTextureEnabled: boolean;
  39875. private static _AmbientTextureEnabled;
  39876. /**
  39877. * Are ambient textures enabled in the application.
  39878. */
  39879. static AmbientTextureEnabled: boolean;
  39880. private static _OpacityTextureEnabled;
  39881. /**
  39882. * Are opacity textures enabled in the application.
  39883. */
  39884. static OpacityTextureEnabled: boolean;
  39885. private static _ReflectionTextureEnabled;
  39886. /**
  39887. * Are reflection textures enabled in the application.
  39888. */
  39889. static ReflectionTextureEnabled: boolean;
  39890. private static _EmissiveTextureEnabled;
  39891. /**
  39892. * Are emissive textures enabled in the application.
  39893. */
  39894. static EmissiveTextureEnabled: boolean;
  39895. private static _SpecularTextureEnabled;
  39896. /**
  39897. * Are specular textures enabled in the application.
  39898. */
  39899. static SpecularTextureEnabled: boolean;
  39900. private static _BumpTextureEnabled;
  39901. /**
  39902. * Are bump textures enabled in the application.
  39903. */
  39904. static BumpTextureEnabled: boolean;
  39905. private static _LightmapTextureEnabled;
  39906. /**
  39907. * Are lightmap textures enabled in the application.
  39908. */
  39909. static LightmapTextureEnabled: boolean;
  39910. private static _RefractionTextureEnabled;
  39911. /**
  39912. * Are refraction textures enabled in the application.
  39913. */
  39914. static RefractionTextureEnabled: boolean;
  39915. private static _ColorGradingTextureEnabled;
  39916. /**
  39917. * Are color grading textures enabled in the application.
  39918. */
  39919. static ColorGradingTextureEnabled: boolean;
  39920. private static _FresnelEnabled;
  39921. /**
  39922. * Are fresnels enabled in the application.
  39923. */
  39924. static FresnelEnabled: boolean;
  39925. private static _ClearCoatTextureEnabled;
  39926. /**
  39927. * Are clear coat textures enabled in the application.
  39928. */
  39929. static ClearCoatTextureEnabled: boolean;
  39930. private static _ClearCoatBumpTextureEnabled;
  39931. /**
  39932. * Are clear coat bump textures enabled in the application.
  39933. */
  39934. static ClearCoatBumpTextureEnabled: boolean;
  39935. private static _ClearCoatTintTextureEnabled;
  39936. /**
  39937. * Are clear coat tint textures enabled in the application.
  39938. */
  39939. static ClearCoatTintTextureEnabled: boolean;
  39940. private static _SheenTextureEnabled;
  39941. /**
  39942. * Are sheen textures enabled in the application.
  39943. */
  39944. static SheenTextureEnabled: boolean;
  39945. private static _AnisotropicTextureEnabled;
  39946. /**
  39947. * Are anisotropic textures enabled in the application.
  39948. */
  39949. static AnisotropicTextureEnabled: boolean;
  39950. private static _ThicknessTextureEnabled;
  39951. /**
  39952. * Are thickness textures enabled in the application.
  39953. */
  39954. static ThicknessTextureEnabled: boolean;
  39955. }
  39956. }
  39957. declare module BABYLON {
  39958. /** @hidden */
  39959. export var defaultFragmentDeclaration: {
  39960. name: string;
  39961. shader: string;
  39962. };
  39963. }
  39964. declare module BABYLON {
  39965. /** @hidden */
  39966. export var defaultUboDeclaration: {
  39967. name: string;
  39968. shader: string;
  39969. };
  39970. }
  39971. declare module BABYLON {
  39972. /** @hidden */
  39973. export var lightFragmentDeclaration: {
  39974. name: string;
  39975. shader: string;
  39976. };
  39977. }
  39978. declare module BABYLON {
  39979. /** @hidden */
  39980. export var lightUboDeclaration: {
  39981. name: string;
  39982. shader: string;
  39983. };
  39984. }
  39985. declare module BABYLON {
  39986. /** @hidden */
  39987. export var lightsFragmentFunctions: {
  39988. name: string;
  39989. shader: string;
  39990. };
  39991. }
  39992. declare module BABYLON {
  39993. /** @hidden */
  39994. export var shadowsFragmentFunctions: {
  39995. name: string;
  39996. shader: string;
  39997. };
  39998. }
  39999. declare module BABYLON {
  40000. /** @hidden */
  40001. export var fresnelFunction: {
  40002. name: string;
  40003. shader: string;
  40004. };
  40005. }
  40006. declare module BABYLON {
  40007. /** @hidden */
  40008. export var reflectionFunction: {
  40009. name: string;
  40010. shader: string;
  40011. };
  40012. }
  40013. declare module BABYLON {
  40014. /** @hidden */
  40015. export var bumpFragmentFunctions: {
  40016. name: string;
  40017. shader: string;
  40018. };
  40019. }
  40020. declare module BABYLON {
  40021. /** @hidden */
  40022. export var logDepthDeclaration: {
  40023. name: string;
  40024. shader: string;
  40025. };
  40026. }
  40027. declare module BABYLON {
  40028. /** @hidden */
  40029. export var bumpFragment: {
  40030. name: string;
  40031. shader: string;
  40032. };
  40033. }
  40034. declare module BABYLON {
  40035. /** @hidden */
  40036. export var depthPrePass: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module BABYLON {
  40042. /** @hidden */
  40043. export var lightFragment: {
  40044. name: string;
  40045. shader: string;
  40046. };
  40047. }
  40048. declare module BABYLON {
  40049. /** @hidden */
  40050. export var logDepthFragment: {
  40051. name: string;
  40052. shader: string;
  40053. };
  40054. }
  40055. declare module BABYLON {
  40056. /** @hidden */
  40057. export var defaultPixelShader: {
  40058. name: string;
  40059. shader: string;
  40060. };
  40061. }
  40062. declare module BABYLON {
  40063. /** @hidden */
  40064. export var defaultVertexDeclaration: {
  40065. name: string;
  40066. shader: string;
  40067. };
  40068. }
  40069. declare module BABYLON {
  40070. /** @hidden */
  40071. export var bumpVertexDeclaration: {
  40072. name: string;
  40073. shader: string;
  40074. };
  40075. }
  40076. declare module BABYLON {
  40077. /** @hidden */
  40078. export var bumpVertex: {
  40079. name: string;
  40080. shader: string;
  40081. };
  40082. }
  40083. declare module BABYLON {
  40084. /** @hidden */
  40085. export var fogVertex: {
  40086. name: string;
  40087. shader: string;
  40088. };
  40089. }
  40090. declare module BABYLON {
  40091. /** @hidden */
  40092. export var shadowsVertex: {
  40093. name: string;
  40094. shader: string;
  40095. };
  40096. }
  40097. declare module BABYLON {
  40098. /** @hidden */
  40099. export var pointCloudVertex: {
  40100. name: string;
  40101. shader: string;
  40102. };
  40103. }
  40104. declare module BABYLON {
  40105. /** @hidden */
  40106. export var logDepthVertex: {
  40107. name: string;
  40108. shader: string;
  40109. };
  40110. }
  40111. declare module BABYLON {
  40112. /** @hidden */
  40113. export var defaultVertexShader: {
  40114. name: string;
  40115. shader: string;
  40116. };
  40117. }
  40118. declare module BABYLON {
  40119. /** @hidden */
  40120. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40121. MAINUV1: boolean;
  40122. MAINUV2: boolean;
  40123. DIFFUSE: boolean;
  40124. DIFFUSEDIRECTUV: number;
  40125. AMBIENT: boolean;
  40126. AMBIENTDIRECTUV: number;
  40127. OPACITY: boolean;
  40128. OPACITYDIRECTUV: number;
  40129. OPACITYRGB: boolean;
  40130. REFLECTION: boolean;
  40131. EMISSIVE: boolean;
  40132. EMISSIVEDIRECTUV: number;
  40133. SPECULAR: boolean;
  40134. SPECULARDIRECTUV: number;
  40135. BUMP: boolean;
  40136. BUMPDIRECTUV: number;
  40137. PARALLAX: boolean;
  40138. PARALLAXOCCLUSION: boolean;
  40139. SPECULAROVERALPHA: boolean;
  40140. CLIPPLANE: boolean;
  40141. CLIPPLANE2: boolean;
  40142. CLIPPLANE3: boolean;
  40143. CLIPPLANE4: boolean;
  40144. ALPHATEST: boolean;
  40145. DEPTHPREPASS: boolean;
  40146. ALPHAFROMDIFFUSE: boolean;
  40147. POINTSIZE: boolean;
  40148. FOG: boolean;
  40149. SPECULARTERM: boolean;
  40150. DIFFUSEFRESNEL: boolean;
  40151. OPACITYFRESNEL: boolean;
  40152. REFLECTIONFRESNEL: boolean;
  40153. REFRACTIONFRESNEL: boolean;
  40154. EMISSIVEFRESNEL: boolean;
  40155. FRESNEL: boolean;
  40156. NORMAL: boolean;
  40157. UV1: boolean;
  40158. UV2: boolean;
  40159. VERTEXCOLOR: boolean;
  40160. VERTEXALPHA: boolean;
  40161. NUM_BONE_INFLUENCERS: number;
  40162. BonesPerMesh: number;
  40163. BONETEXTURE: boolean;
  40164. INSTANCES: boolean;
  40165. GLOSSINESS: boolean;
  40166. ROUGHNESS: boolean;
  40167. EMISSIVEASILLUMINATION: boolean;
  40168. LINKEMISSIVEWITHDIFFUSE: boolean;
  40169. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40170. LIGHTMAP: boolean;
  40171. LIGHTMAPDIRECTUV: number;
  40172. OBJECTSPACE_NORMALMAP: boolean;
  40173. USELIGHTMAPASSHADOWMAP: boolean;
  40174. REFLECTIONMAP_3D: boolean;
  40175. REFLECTIONMAP_SPHERICAL: boolean;
  40176. REFLECTIONMAP_PLANAR: boolean;
  40177. REFLECTIONMAP_CUBIC: boolean;
  40178. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40179. REFLECTIONMAP_PROJECTION: boolean;
  40180. REFLECTIONMAP_SKYBOX: boolean;
  40181. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40182. REFLECTIONMAP_EXPLICIT: boolean;
  40183. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40184. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40185. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40186. INVERTCUBICMAP: boolean;
  40187. LOGARITHMICDEPTH: boolean;
  40188. REFRACTION: boolean;
  40189. REFRACTIONMAP_3D: boolean;
  40190. REFLECTIONOVERALPHA: boolean;
  40191. TWOSIDEDLIGHTING: boolean;
  40192. SHADOWFLOAT: boolean;
  40193. MORPHTARGETS: boolean;
  40194. MORPHTARGETS_NORMAL: boolean;
  40195. MORPHTARGETS_TANGENT: boolean;
  40196. MORPHTARGETS_UV: boolean;
  40197. NUM_MORPH_INFLUENCERS: number;
  40198. NONUNIFORMSCALING: boolean;
  40199. PREMULTIPLYALPHA: boolean;
  40200. IMAGEPROCESSING: boolean;
  40201. VIGNETTE: boolean;
  40202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40203. VIGNETTEBLENDMODEOPAQUE: boolean;
  40204. TONEMAPPING: boolean;
  40205. TONEMAPPING_ACES: boolean;
  40206. CONTRAST: boolean;
  40207. COLORCURVES: boolean;
  40208. COLORGRADING: boolean;
  40209. COLORGRADING3D: boolean;
  40210. SAMPLER3DGREENDEPTH: boolean;
  40211. SAMPLER3DBGRMAP: boolean;
  40212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40213. MULTIVIEW: boolean;
  40214. /**
  40215. * If the reflection texture on this material is in linear color space
  40216. * @hidden
  40217. */
  40218. IS_REFLECTION_LINEAR: boolean;
  40219. /**
  40220. * If the refraction texture on this material is in linear color space
  40221. * @hidden
  40222. */
  40223. IS_REFRACTION_LINEAR: boolean;
  40224. EXPOSURE: boolean;
  40225. constructor();
  40226. setReflectionMode(modeToEnable: string): void;
  40227. }
  40228. /**
  40229. * This is the default material used in Babylon. It is the best trade off between quality
  40230. * and performances.
  40231. * @see http://doc.babylonjs.com/babylon101/materials
  40232. */
  40233. export class StandardMaterial extends PushMaterial {
  40234. private _diffuseTexture;
  40235. /**
  40236. * The basic texture of the material as viewed under a light.
  40237. */
  40238. diffuseTexture: Nullable<BaseTexture>;
  40239. private _ambientTexture;
  40240. /**
  40241. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40242. */
  40243. ambientTexture: Nullable<BaseTexture>;
  40244. private _opacityTexture;
  40245. /**
  40246. * Define the transparency of the material from a texture.
  40247. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40248. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40249. */
  40250. opacityTexture: Nullable<BaseTexture>;
  40251. private _reflectionTexture;
  40252. /**
  40253. * Define the texture used to display the reflection.
  40254. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40255. */
  40256. reflectionTexture: Nullable<BaseTexture>;
  40257. private _emissiveTexture;
  40258. /**
  40259. * Define texture of the material as if self lit.
  40260. * This will be mixed in the final result even in the absence of light.
  40261. */
  40262. emissiveTexture: Nullable<BaseTexture>;
  40263. private _specularTexture;
  40264. /**
  40265. * Define how the color and intensity of the highlight given by the light in the material.
  40266. */
  40267. specularTexture: Nullable<BaseTexture>;
  40268. private _bumpTexture;
  40269. /**
  40270. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40271. * 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.
  40272. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40273. */
  40274. bumpTexture: Nullable<BaseTexture>;
  40275. private _lightmapTexture;
  40276. /**
  40277. * Complex lighting can be computationally expensive to compute at runtime.
  40278. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40279. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40280. */
  40281. lightmapTexture: Nullable<BaseTexture>;
  40282. private _refractionTexture;
  40283. /**
  40284. * Define the texture used to display the refraction.
  40285. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40286. */
  40287. refractionTexture: Nullable<BaseTexture>;
  40288. /**
  40289. * The color of the material lit by the environmental background lighting.
  40290. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40291. */
  40292. ambientColor: Color3;
  40293. /**
  40294. * The basic color of the material as viewed under a light.
  40295. */
  40296. diffuseColor: Color3;
  40297. /**
  40298. * Define how the color and intensity of the highlight given by the light in the material.
  40299. */
  40300. specularColor: Color3;
  40301. /**
  40302. * Define the color of the material as if self lit.
  40303. * This will be mixed in the final result even in the absence of light.
  40304. */
  40305. emissiveColor: Color3;
  40306. /**
  40307. * Defines how sharp are the highlights in the material.
  40308. * The bigger the value the sharper giving a more glossy feeling to the result.
  40309. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40310. */
  40311. specularPower: number;
  40312. private _useAlphaFromDiffuseTexture;
  40313. /**
  40314. * Does the transparency come from the diffuse texture alpha channel.
  40315. */
  40316. useAlphaFromDiffuseTexture: boolean;
  40317. private _useEmissiveAsIllumination;
  40318. /**
  40319. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40320. */
  40321. useEmissiveAsIllumination: boolean;
  40322. private _linkEmissiveWithDiffuse;
  40323. /**
  40324. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40325. * the emissive level when the final color is close to one.
  40326. */
  40327. linkEmissiveWithDiffuse: boolean;
  40328. private _useSpecularOverAlpha;
  40329. /**
  40330. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40332. */
  40333. useSpecularOverAlpha: boolean;
  40334. private _useReflectionOverAlpha;
  40335. /**
  40336. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40337. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40338. */
  40339. useReflectionOverAlpha: boolean;
  40340. private _disableLighting;
  40341. /**
  40342. * Does lights from the scene impacts this material.
  40343. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40344. */
  40345. disableLighting: boolean;
  40346. private _useObjectSpaceNormalMap;
  40347. /**
  40348. * Allows using an object space normal map (instead of tangent space).
  40349. */
  40350. useObjectSpaceNormalMap: boolean;
  40351. private _useParallax;
  40352. /**
  40353. * Is parallax enabled or not.
  40354. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40355. */
  40356. useParallax: boolean;
  40357. private _useParallaxOcclusion;
  40358. /**
  40359. * Is parallax occlusion enabled or not.
  40360. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40361. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40362. */
  40363. useParallaxOcclusion: boolean;
  40364. /**
  40365. * 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.
  40366. */
  40367. parallaxScaleBias: number;
  40368. private _roughness;
  40369. /**
  40370. * Helps to define how blurry the reflections should appears in the material.
  40371. */
  40372. roughness: number;
  40373. /**
  40374. * In case of refraction, define the value of the index of refraction.
  40375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40376. */
  40377. indexOfRefraction: number;
  40378. /**
  40379. * Invert the refraction texture alongside the y axis.
  40380. * It can be useful with procedural textures or probe for instance.
  40381. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40382. */
  40383. invertRefractionY: boolean;
  40384. /**
  40385. * Defines the alpha limits in alpha test mode.
  40386. */
  40387. alphaCutOff: number;
  40388. private _useLightmapAsShadowmap;
  40389. /**
  40390. * In case of light mapping, define whether the map contains light or shadow informations.
  40391. */
  40392. useLightmapAsShadowmap: boolean;
  40393. private _diffuseFresnelParameters;
  40394. /**
  40395. * Define the diffuse fresnel parameters of the material.
  40396. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40397. */
  40398. diffuseFresnelParameters: FresnelParameters;
  40399. private _opacityFresnelParameters;
  40400. /**
  40401. * Define the opacity fresnel parameters of the material.
  40402. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40403. */
  40404. opacityFresnelParameters: FresnelParameters;
  40405. private _reflectionFresnelParameters;
  40406. /**
  40407. * Define the reflection fresnel parameters of the material.
  40408. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40409. */
  40410. reflectionFresnelParameters: FresnelParameters;
  40411. private _refractionFresnelParameters;
  40412. /**
  40413. * Define the refraction fresnel parameters of the material.
  40414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40415. */
  40416. refractionFresnelParameters: FresnelParameters;
  40417. private _emissiveFresnelParameters;
  40418. /**
  40419. * Define the emissive fresnel parameters of the material.
  40420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40421. */
  40422. emissiveFresnelParameters: FresnelParameters;
  40423. private _useReflectionFresnelFromSpecular;
  40424. /**
  40425. * If true automatically deducts the fresnels values from the material specularity.
  40426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40427. */
  40428. useReflectionFresnelFromSpecular: boolean;
  40429. private _useGlossinessFromSpecularMapAlpha;
  40430. /**
  40431. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40432. */
  40433. useGlossinessFromSpecularMapAlpha: boolean;
  40434. private _maxSimultaneousLights;
  40435. /**
  40436. * Defines the maximum number of lights that can be used in the material
  40437. */
  40438. maxSimultaneousLights: number;
  40439. private _invertNormalMapX;
  40440. /**
  40441. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40442. */
  40443. invertNormalMapX: boolean;
  40444. private _invertNormalMapY;
  40445. /**
  40446. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40447. */
  40448. invertNormalMapY: boolean;
  40449. private _twoSidedLighting;
  40450. /**
  40451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40452. */
  40453. twoSidedLighting: boolean;
  40454. /**
  40455. * Default configuration related to image processing available in the standard Material.
  40456. */
  40457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40458. /**
  40459. * Gets the image processing configuration used either in this material.
  40460. */
  40461. /**
  40462. * Sets the Default image processing configuration used either in the this material.
  40463. *
  40464. * If sets to null, the scene one is in use.
  40465. */
  40466. imageProcessingConfiguration: ImageProcessingConfiguration;
  40467. /**
  40468. * Keep track of the image processing observer to allow dispose and replace.
  40469. */
  40470. private _imageProcessingObserver;
  40471. /**
  40472. * Attaches a new image processing configuration to the Standard Material.
  40473. * @param configuration
  40474. */
  40475. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40476. /**
  40477. * Gets wether the color curves effect is enabled.
  40478. */
  40479. /**
  40480. * Sets wether the color curves effect is enabled.
  40481. */
  40482. cameraColorCurvesEnabled: boolean;
  40483. /**
  40484. * Gets wether the color grading effect is enabled.
  40485. */
  40486. /**
  40487. * Gets wether the color grading effect is enabled.
  40488. */
  40489. cameraColorGradingEnabled: boolean;
  40490. /**
  40491. * Gets wether tonemapping is enabled or not.
  40492. */
  40493. /**
  40494. * Sets wether tonemapping is enabled or not
  40495. */
  40496. cameraToneMappingEnabled: boolean;
  40497. /**
  40498. * The camera exposure used on this material.
  40499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40500. * This corresponds to a photographic exposure.
  40501. */
  40502. /**
  40503. * The camera exposure used on this material.
  40504. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40505. * This corresponds to a photographic exposure.
  40506. */
  40507. cameraExposure: number;
  40508. /**
  40509. * Gets The camera contrast used on this material.
  40510. */
  40511. /**
  40512. * Sets The camera contrast used on this material.
  40513. */
  40514. cameraContrast: number;
  40515. /**
  40516. * Gets the Color Grading 2D Lookup Texture.
  40517. */
  40518. /**
  40519. * Sets the Color Grading 2D Lookup Texture.
  40520. */
  40521. cameraColorGradingTexture: Nullable<BaseTexture>;
  40522. /**
  40523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40525. * 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;
  40526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40527. */
  40528. /**
  40529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40531. * 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;
  40532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40533. */
  40534. cameraColorCurves: Nullable<ColorCurves>;
  40535. /**
  40536. * Custom callback helping to override the default shader used in the material.
  40537. */
  40538. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40539. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40540. protected _worldViewProjectionMatrix: Matrix;
  40541. protected _globalAmbientColor: Color3;
  40542. protected _useLogarithmicDepth: boolean;
  40543. protected _rebuildInParallel: boolean;
  40544. /**
  40545. * Instantiates a new standard material.
  40546. * This is the default material used in Babylon. It is the best trade off between quality
  40547. * and performances.
  40548. * @see http://doc.babylonjs.com/babylon101/materials
  40549. * @param name Define the name of the material in the scene
  40550. * @param scene Define the scene the material belong to
  40551. */
  40552. constructor(name: string, scene: Scene);
  40553. /**
  40554. * Gets a boolean indicating that current material needs to register RTT
  40555. */
  40556. readonly hasRenderTargetTextures: boolean;
  40557. /**
  40558. * Gets the current class name of the material e.g. "StandardMaterial"
  40559. * Mainly use in serialization.
  40560. * @returns the class name
  40561. */
  40562. getClassName(): string;
  40563. /**
  40564. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40565. * You can try switching to logarithmic depth.
  40566. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40567. */
  40568. useLogarithmicDepth: boolean;
  40569. /**
  40570. * Specifies if the material will require alpha blending
  40571. * @returns a boolean specifying if alpha blending is needed
  40572. */
  40573. needAlphaBlending(): boolean;
  40574. /**
  40575. * Specifies if this material should be rendered in alpha test mode
  40576. * @returns a boolean specifying if an alpha test is needed.
  40577. */
  40578. needAlphaTesting(): boolean;
  40579. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40580. /**
  40581. * Get the texture used for alpha test purpose.
  40582. * @returns the diffuse texture in case of the standard material.
  40583. */
  40584. getAlphaTestTexture(): Nullable<BaseTexture>;
  40585. /**
  40586. * Get if the submesh is ready to be used and all its information available.
  40587. * Child classes can use it to update shaders
  40588. * @param mesh defines the mesh to check
  40589. * @param subMesh defines which submesh to check
  40590. * @param useInstances specifies that instances should be used
  40591. * @returns a boolean indicating that the submesh is ready or not
  40592. */
  40593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40594. /**
  40595. * Builds the material UBO layouts.
  40596. * Used internally during the effect preparation.
  40597. */
  40598. buildUniformLayout(): void;
  40599. /**
  40600. * Unbinds the material from the mesh
  40601. */
  40602. unbind(): void;
  40603. /**
  40604. * Binds the submesh to this material by preparing the effect and shader to draw
  40605. * @param world defines the world transformation matrix
  40606. * @param mesh defines the mesh containing the submesh
  40607. * @param subMesh defines the submesh to bind the material to
  40608. */
  40609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40610. /**
  40611. * Get the list of animatables in the material.
  40612. * @returns the list of animatables object used in the material
  40613. */
  40614. getAnimatables(): IAnimatable[];
  40615. /**
  40616. * Gets the active textures from the material
  40617. * @returns an array of textures
  40618. */
  40619. getActiveTextures(): BaseTexture[];
  40620. /**
  40621. * Specifies if the material uses a texture
  40622. * @param texture defines the texture to check against the material
  40623. * @returns a boolean specifying if the material uses the texture
  40624. */
  40625. hasTexture(texture: BaseTexture): boolean;
  40626. /**
  40627. * Disposes the material
  40628. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40629. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40630. */
  40631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40632. /**
  40633. * Makes a duplicate of the material, and gives it a new name
  40634. * @param name defines the new name for the duplicated material
  40635. * @returns the cloned material
  40636. */
  40637. clone(name: string): StandardMaterial;
  40638. /**
  40639. * Serializes this material in a JSON representation
  40640. * @returns the serialized material object
  40641. */
  40642. serialize(): any;
  40643. /**
  40644. * Creates a standard material from parsed material data
  40645. * @param source defines the JSON representation of the material
  40646. * @param scene defines the hosting scene
  40647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40648. * @returns a new standard material
  40649. */
  40650. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40651. /**
  40652. * Are diffuse textures enabled in the application.
  40653. */
  40654. static DiffuseTextureEnabled: boolean;
  40655. /**
  40656. * Are ambient textures enabled in the application.
  40657. */
  40658. static AmbientTextureEnabled: boolean;
  40659. /**
  40660. * Are opacity textures enabled in the application.
  40661. */
  40662. static OpacityTextureEnabled: boolean;
  40663. /**
  40664. * Are reflection textures enabled in the application.
  40665. */
  40666. static ReflectionTextureEnabled: boolean;
  40667. /**
  40668. * Are emissive textures enabled in the application.
  40669. */
  40670. static EmissiveTextureEnabled: boolean;
  40671. /**
  40672. * Are specular textures enabled in the application.
  40673. */
  40674. static SpecularTextureEnabled: boolean;
  40675. /**
  40676. * Are bump textures enabled in the application.
  40677. */
  40678. static BumpTextureEnabled: boolean;
  40679. /**
  40680. * Are lightmap textures enabled in the application.
  40681. */
  40682. static LightmapTextureEnabled: boolean;
  40683. /**
  40684. * Are refraction textures enabled in the application.
  40685. */
  40686. static RefractionTextureEnabled: boolean;
  40687. /**
  40688. * Are color grading textures enabled in the application.
  40689. */
  40690. static ColorGradingTextureEnabled: boolean;
  40691. /**
  40692. * Are fresnels enabled in the application.
  40693. */
  40694. static FresnelEnabled: boolean;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. /** @hidden */
  40699. export var imageProcessingPixelShader: {
  40700. name: string;
  40701. shader: string;
  40702. };
  40703. }
  40704. declare module BABYLON {
  40705. /**
  40706. * ImageProcessingPostProcess
  40707. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40708. */
  40709. export class ImageProcessingPostProcess extends PostProcess {
  40710. /**
  40711. * Default configuration related to image processing available in the PBR Material.
  40712. */
  40713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40714. /**
  40715. * Gets the image processing configuration used either in this material.
  40716. */
  40717. /**
  40718. * Sets the Default image processing configuration used either in the this material.
  40719. *
  40720. * If sets to null, the scene one is in use.
  40721. */
  40722. imageProcessingConfiguration: ImageProcessingConfiguration;
  40723. /**
  40724. * Keep track of the image processing observer to allow dispose and replace.
  40725. */
  40726. private _imageProcessingObserver;
  40727. /**
  40728. * Attaches a new image processing configuration to the PBR Material.
  40729. * @param configuration
  40730. */
  40731. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40732. /**
  40733. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40734. */
  40735. /**
  40736. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40737. */
  40738. colorCurves: Nullable<ColorCurves>;
  40739. /**
  40740. * Gets wether the color curves effect is enabled.
  40741. */
  40742. /**
  40743. * Sets wether the color curves effect is enabled.
  40744. */
  40745. colorCurvesEnabled: boolean;
  40746. /**
  40747. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40748. */
  40749. /**
  40750. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40751. */
  40752. colorGradingTexture: Nullable<BaseTexture>;
  40753. /**
  40754. * Gets wether the color grading effect is enabled.
  40755. */
  40756. /**
  40757. * Gets wether the color grading effect is enabled.
  40758. */
  40759. colorGradingEnabled: boolean;
  40760. /**
  40761. * Gets exposure used in the effect.
  40762. */
  40763. /**
  40764. * Sets exposure used in the effect.
  40765. */
  40766. exposure: number;
  40767. /**
  40768. * Gets wether tonemapping is enabled or not.
  40769. */
  40770. /**
  40771. * Sets wether tonemapping is enabled or not
  40772. */
  40773. toneMappingEnabled: boolean;
  40774. /**
  40775. * Gets the type of tone mapping effect.
  40776. */
  40777. /**
  40778. * Sets the type of tone mapping effect.
  40779. */
  40780. toneMappingType: number;
  40781. /**
  40782. * Gets contrast used in the effect.
  40783. */
  40784. /**
  40785. * Sets contrast used in the effect.
  40786. */
  40787. contrast: number;
  40788. /**
  40789. * Gets Vignette stretch size.
  40790. */
  40791. /**
  40792. * Sets Vignette stretch size.
  40793. */
  40794. vignetteStretch: number;
  40795. /**
  40796. * Gets Vignette centre X Offset.
  40797. */
  40798. /**
  40799. * Sets Vignette centre X Offset.
  40800. */
  40801. vignetteCentreX: number;
  40802. /**
  40803. * Gets Vignette centre Y Offset.
  40804. */
  40805. /**
  40806. * Sets Vignette centre Y Offset.
  40807. */
  40808. vignetteCentreY: number;
  40809. /**
  40810. * Gets Vignette weight or intensity of the vignette effect.
  40811. */
  40812. /**
  40813. * Sets Vignette weight or intensity of the vignette effect.
  40814. */
  40815. vignetteWeight: number;
  40816. /**
  40817. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40818. * if vignetteEnabled is set to true.
  40819. */
  40820. /**
  40821. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40822. * if vignetteEnabled is set to true.
  40823. */
  40824. vignetteColor: Color4;
  40825. /**
  40826. * Gets Camera field of view used by the Vignette effect.
  40827. */
  40828. /**
  40829. * Sets Camera field of view used by the Vignette effect.
  40830. */
  40831. vignetteCameraFov: number;
  40832. /**
  40833. * Gets the vignette blend mode allowing different kind of effect.
  40834. */
  40835. /**
  40836. * Sets the vignette blend mode allowing different kind of effect.
  40837. */
  40838. vignetteBlendMode: number;
  40839. /**
  40840. * Gets wether the vignette effect is enabled.
  40841. */
  40842. /**
  40843. * Sets wether the vignette effect is enabled.
  40844. */
  40845. vignetteEnabled: boolean;
  40846. private _fromLinearSpace;
  40847. /**
  40848. * Gets wether the input of the processing is in Gamma or Linear Space.
  40849. */
  40850. /**
  40851. * Sets wether the input of the processing is in Gamma or Linear Space.
  40852. */
  40853. fromLinearSpace: boolean;
  40854. /**
  40855. * Defines cache preventing GC.
  40856. */
  40857. private _defines;
  40858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40859. /**
  40860. * "ImageProcessingPostProcess"
  40861. * @returns "ImageProcessingPostProcess"
  40862. */
  40863. getClassName(): string;
  40864. protected _updateParameters(): void;
  40865. dispose(camera?: Camera): void;
  40866. }
  40867. }
  40868. declare module BABYLON {
  40869. /**
  40870. * Class containing static functions to help procedurally build meshes
  40871. */
  40872. export class GroundBuilder {
  40873. /**
  40874. * Creates a ground mesh
  40875. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40876. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40878. * @param name defines the name of the mesh
  40879. * @param options defines the options used to create the mesh
  40880. * @param scene defines the hosting scene
  40881. * @returns the ground mesh
  40882. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40883. */
  40884. static CreateGround(name: string, options: {
  40885. width?: number;
  40886. height?: number;
  40887. subdivisions?: number;
  40888. subdivisionsX?: number;
  40889. subdivisionsY?: number;
  40890. updatable?: boolean;
  40891. }, scene: any): Mesh;
  40892. /**
  40893. * Creates a tiled ground mesh
  40894. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40895. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40896. * * 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
  40897. * * 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
  40898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40899. * @param name defines the name of the mesh
  40900. * @param options defines the options used to create the mesh
  40901. * @param scene defines the hosting scene
  40902. * @returns the tiled ground mesh
  40903. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40904. */
  40905. static CreateTiledGround(name: string, options: {
  40906. xmin: number;
  40907. zmin: number;
  40908. xmax: number;
  40909. zmax: number;
  40910. subdivisions?: {
  40911. w: number;
  40912. h: number;
  40913. };
  40914. precision?: {
  40915. w: number;
  40916. h: number;
  40917. };
  40918. updatable?: boolean;
  40919. }, scene?: Nullable<Scene>): Mesh;
  40920. /**
  40921. * Creates a ground mesh from a height map
  40922. * * The parameter `url` sets the URL of the height map image resource.
  40923. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40924. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40925. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40926. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40927. * * 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.
  40928. * * 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).
  40929. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40931. * @param name defines the name of the mesh
  40932. * @param url defines the url to the height map
  40933. * @param options defines the options used to create the mesh
  40934. * @param scene defines the hosting scene
  40935. * @returns the ground mesh
  40936. * @see https://doc.babylonjs.com/babylon101/height_map
  40937. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40938. */
  40939. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40940. width?: number;
  40941. height?: number;
  40942. subdivisions?: number;
  40943. minHeight?: number;
  40944. maxHeight?: number;
  40945. colorFilter?: Color3;
  40946. alphaFilter?: number;
  40947. updatable?: boolean;
  40948. onReady?: (mesh: GroundMesh) => void;
  40949. }, scene?: Nullable<Scene>): GroundMesh;
  40950. }
  40951. }
  40952. declare module BABYLON {
  40953. /**
  40954. * Class containing static functions to help procedurally build meshes
  40955. */
  40956. export class TorusBuilder {
  40957. /**
  40958. * Creates a torus mesh
  40959. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40960. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40961. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40963. * * 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
  40964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40965. * @param name defines the name of the mesh
  40966. * @param options defines the options used to create the mesh
  40967. * @param scene defines the hosting scene
  40968. * @returns the torus mesh
  40969. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40970. */
  40971. static CreateTorus(name: string, options: {
  40972. diameter?: number;
  40973. thickness?: number;
  40974. tessellation?: number;
  40975. updatable?: boolean;
  40976. sideOrientation?: number;
  40977. frontUVs?: Vector4;
  40978. backUVs?: Vector4;
  40979. }, scene: any): Mesh;
  40980. }
  40981. }
  40982. declare module BABYLON {
  40983. /**
  40984. * Class containing static functions to help procedurally build meshes
  40985. */
  40986. export class CylinderBuilder {
  40987. /**
  40988. * Creates a cylinder or a cone mesh
  40989. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40990. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40991. * * 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.
  40992. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40993. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40994. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40995. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40996. * * 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).
  40997. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40998. * * 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).
  40999. * * 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
  41000. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41001. * * 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
  41002. * * 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.
  41003. * * If `enclose` is false, a ring surface is one element.
  41004. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41005. * * 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
  41006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41007. * * 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
  41008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41009. * @param name defines the name of the mesh
  41010. * @param options defines the options used to create the mesh
  41011. * @param scene defines the hosting scene
  41012. * @returns the cylinder mesh
  41013. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41014. */
  41015. static CreateCylinder(name: string, options: {
  41016. height?: number;
  41017. diameterTop?: number;
  41018. diameterBottom?: number;
  41019. diameter?: number;
  41020. tessellation?: number;
  41021. subdivisions?: number;
  41022. arc?: number;
  41023. faceColors?: Color4[];
  41024. faceUV?: Vector4[];
  41025. updatable?: boolean;
  41026. hasRings?: boolean;
  41027. enclose?: boolean;
  41028. cap?: number;
  41029. sideOrientation?: number;
  41030. frontUVs?: Vector4;
  41031. backUVs?: Vector4;
  41032. }, scene: any): Mesh;
  41033. }
  41034. }
  41035. declare module BABYLON {
  41036. /**
  41037. * Options to modify the vr teleportation behavior.
  41038. */
  41039. export interface VRTeleportationOptions {
  41040. /**
  41041. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41042. */
  41043. floorMeshName?: string;
  41044. /**
  41045. * A list of meshes to be used as the teleportation floor. (default: empty)
  41046. */
  41047. floorMeshes?: Mesh[];
  41048. }
  41049. /**
  41050. * Options to modify the vr experience helper's behavior.
  41051. */
  41052. export interface VRExperienceHelperOptions extends WebVROptions {
  41053. /**
  41054. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41055. */
  41056. createDeviceOrientationCamera?: boolean;
  41057. /**
  41058. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41059. */
  41060. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41061. /**
  41062. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41063. */
  41064. laserToggle?: boolean;
  41065. /**
  41066. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41067. */
  41068. floorMeshes?: Mesh[];
  41069. /**
  41070. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41071. */
  41072. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41073. }
  41074. /**
  41075. * Event containing information after VR has been entered
  41076. */
  41077. export class OnAfterEnteringVRObservableEvent {
  41078. /**
  41079. * If entering vr was successful
  41080. */
  41081. success: boolean;
  41082. }
  41083. /**
  41084. * Helps to quickly add VR support to an existing scene.
  41085. * See http://doc.babylonjs.com/how_to/webvr_helper
  41086. */
  41087. export class VRExperienceHelper {
  41088. /** Options to modify the vr experience helper's behavior. */
  41089. webVROptions: VRExperienceHelperOptions;
  41090. private _scene;
  41091. private _position;
  41092. private _btnVR;
  41093. private _btnVRDisplayed;
  41094. private _webVRsupported;
  41095. private _webVRready;
  41096. private _webVRrequesting;
  41097. private _webVRpresenting;
  41098. private _hasEnteredVR;
  41099. private _fullscreenVRpresenting;
  41100. private _canvas;
  41101. private _webVRCamera;
  41102. private _vrDeviceOrientationCamera;
  41103. private _deviceOrientationCamera;
  41104. private _existingCamera;
  41105. private _onKeyDown;
  41106. private _onVrDisplayPresentChange;
  41107. private _onVRDisplayChanged;
  41108. private _onVRRequestPresentStart;
  41109. private _onVRRequestPresentComplete;
  41110. /**
  41111. * 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)
  41112. */
  41113. enableGazeEvenWhenNoPointerLock: boolean;
  41114. /**
  41115. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41116. */
  41117. exitVROnDoubleTap: boolean;
  41118. /**
  41119. * Observable raised right before entering VR.
  41120. */
  41121. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41122. /**
  41123. * Observable raised when entering VR has completed.
  41124. */
  41125. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41126. /**
  41127. * Observable raised when exiting VR.
  41128. */
  41129. onExitingVRObservable: Observable<VRExperienceHelper>;
  41130. /**
  41131. * Observable raised when controller mesh is loaded.
  41132. */
  41133. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41134. /** Return this.onEnteringVRObservable
  41135. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41136. */
  41137. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41138. /** Return this.onExitingVRObservable
  41139. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41140. */
  41141. readonly onExitingVR: Observable<VRExperienceHelper>;
  41142. /** Return this.onControllerMeshLoadedObservable
  41143. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41144. */
  41145. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41146. private _rayLength;
  41147. private _useCustomVRButton;
  41148. private _teleportationRequested;
  41149. private _teleportActive;
  41150. private _floorMeshName;
  41151. private _floorMeshesCollection;
  41152. private _rotationAllowed;
  41153. private _teleportBackwardsVector;
  41154. private _teleportationTarget;
  41155. private _isDefaultTeleportationTarget;
  41156. private _postProcessMove;
  41157. private _teleportationFillColor;
  41158. private _teleportationBorderColor;
  41159. private _rotationAngle;
  41160. private _haloCenter;
  41161. private _cameraGazer;
  41162. private _padSensibilityUp;
  41163. private _padSensibilityDown;
  41164. private _leftController;
  41165. private _rightController;
  41166. /**
  41167. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41168. */
  41169. onNewMeshSelected: Observable<AbstractMesh>;
  41170. /**
  41171. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41172. * This observable will provide the mesh and the controller used to select the mesh
  41173. */
  41174. onMeshSelectedWithController: Observable<{
  41175. mesh: AbstractMesh;
  41176. controller: WebVRController;
  41177. }>;
  41178. /**
  41179. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41180. */
  41181. onNewMeshPicked: Observable<PickingInfo>;
  41182. private _circleEase;
  41183. /**
  41184. * Observable raised before camera teleportation
  41185. */
  41186. onBeforeCameraTeleport: Observable<Vector3>;
  41187. /**
  41188. * Observable raised after camera teleportation
  41189. */
  41190. onAfterCameraTeleport: Observable<Vector3>;
  41191. /**
  41192. * Observable raised when current selected mesh gets unselected
  41193. */
  41194. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41195. private _raySelectionPredicate;
  41196. /**
  41197. * To be optionaly changed by user to define custom ray selection
  41198. */
  41199. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41200. /**
  41201. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41202. */
  41203. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41204. /**
  41205. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41206. */
  41207. teleportationEnabled: boolean;
  41208. private _defaultHeight;
  41209. private _teleportationInitialized;
  41210. private _interactionsEnabled;
  41211. private _interactionsRequested;
  41212. private _displayGaze;
  41213. private _displayLaserPointer;
  41214. /**
  41215. * The mesh used to display where the user is going to teleport.
  41216. */
  41217. /**
  41218. * Sets the mesh to be used to display where the user is going to teleport.
  41219. */
  41220. teleportationTarget: Mesh;
  41221. /**
  41222. * 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
  41223. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41224. * See http://doc.babylonjs.com/resources/baking_transformations
  41225. */
  41226. gazeTrackerMesh: Mesh;
  41227. /**
  41228. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41229. */
  41230. updateGazeTrackerScale: boolean;
  41231. /**
  41232. * If the gaze trackers color should be updated when selecting meshes
  41233. */
  41234. updateGazeTrackerColor: boolean;
  41235. /**
  41236. * If the controller laser color should be updated when selecting meshes
  41237. */
  41238. updateControllerLaserColor: boolean;
  41239. /**
  41240. * The gaze tracking mesh corresponding to the left controller
  41241. */
  41242. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41243. /**
  41244. * The gaze tracking mesh corresponding to the right controller
  41245. */
  41246. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41247. /**
  41248. * If the ray of the gaze should be displayed.
  41249. */
  41250. /**
  41251. * Sets if the ray of the gaze should be displayed.
  41252. */
  41253. displayGaze: boolean;
  41254. /**
  41255. * If the ray of the LaserPointer should be displayed.
  41256. */
  41257. /**
  41258. * Sets if the ray of the LaserPointer should be displayed.
  41259. */
  41260. displayLaserPointer: boolean;
  41261. /**
  41262. * The deviceOrientationCamera used as the camera when not in VR.
  41263. */
  41264. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41265. /**
  41266. * Based on the current WebVR support, returns the current VR camera used.
  41267. */
  41268. readonly currentVRCamera: Nullable<Camera>;
  41269. /**
  41270. * The webVRCamera which is used when in VR.
  41271. */
  41272. readonly webVRCamera: WebVRFreeCamera;
  41273. /**
  41274. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41275. */
  41276. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41277. /**
  41278. * The html button that is used to trigger entering into VR.
  41279. */
  41280. readonly vrButton: Nullable<HTMLButtonElement>;
  41281. private readonly _teleportationRequestInitiated;
  41282. /**
  41283. * Defines wether or not Pointer lock should be requested when switching to
  41284. * full screen.
  41285. */
  41286. requestPointerLockOnFullScreen: boolean;
  41287. /**
  41288. * Instantiates a VRExperienceHelper.
  41289. * Helps to quickly add VR support to an existing scene.
  41290. * @param scene The scene the VRExperienceHelper belongs to.
  41291. * @param webVROptions Options to modify the vr experience helper's behavior.
  41292. */
  41293. constructor(scene: Scene,
  41294. /** Options to modify the vr experience helper's behavior. */
  41295. webVROptions?: VRExperienceHelperOptions);
  41296. private _onDefaultMeshLoaded;
  41297. private _onResize;
  41298. private _onFullscreenChange;
  41299. /**
  41300. * Gets a value indicating if we are currently in VR mode.
  41301. */
  41302. readonly isInVRMode: boolean;
  41303. private onVrDisplayPresentChange;
  41304. private onVRDisplayChanged;
  41305. private moveButtonToBottomRight;
  41306. private displayVRButton;
  41307. private updateButtonVisibility;
  41308. private _cachedAngularSensibility;
  41309. /**
  41310. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41311. * Otherwise, will use the fullscreen API.
  41312. */
  41313. enterVR(): void;
  41314. /**
  41315. * Attempt to exit VR, or fullscreen.
  41316. */
  41317. exitVR(): void;
  41318. /**
  41319. * The position of the vr experience helper.
  41320. */
  41321. /**
  41322. * Sets the position of the vr experience helper.
  41323. */
  41324. position: Vector3;
  41325. /**
  41326. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41327. */
  41328. enableInteractions(): void;
  41329. private readonly _noControllerIsActive;
  41330. private beforeRender;
  41331. private _isTeleportationFloor;
  41332. /**
  41333. * Adds a floor mesh to be used for teleportation.
  41334. * @param floorMesh the mesh to be used for teleportation.
  41335. */
  41336. addFloorMesh(floorMesh: Mesh): void;
  41337. /**
  41338. * Removes a floor mesh from being used for teleportation.
  41339. * @param floorMesh the mesh to be removed.
  41340. */
  41341. removeFloorMesh(floorMesh: Mesh): void;
  41342. /**
  41343. * Enables interactions and teleportation using the VR controllers and gaze.
  41344. * @param vrTeleportationOptions options to modify teleportation behavior.
  41345. */
  41346. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41347. private _onNewGamepadConnected;
  41348. private _tryEnableInteractionOnController;
  41349. private _onNewGamepadDisconnected;
  41350. private _enableInteractionOnController;
  41351. private _checkTeleportWithRay;
  41352. private _checkRotate;
  41353. private _checkTeleportBackwards;
  41354. private _enableTeleportationOnController;
  41355. private _createTeleportationCircles;
  41356. private _displayTeleportationTarget;
  41357. private _hideTeleportationTarget;
  41358. private _rotateCamera;
  41359. private _moveTeleportationSelectorTo;
  41360. private _workingVector;
  41361. private _workingQuaternion;
  41362. private _workingMatrix;
  41363. /**
  41364. * Teleports the users feet to the desired location
  41365. * @param location The location where the user's feet should be placed
  41366. */
  41367. teleportCamera(location: Vector3): void;
  41368. private _convertNormalToDirectionOfRay;
  41369. private _castRayAndSelectObject;
  41370. private _notifySelectedMeshUnselected;
  41371. /**
  41372. * Sets the color of the laser ray from the vr controllers.
  41373. * @param color new color for the ray.
  41374. */
  41375. changeLaserColor(color: Color3): void;
  41376. /**
  41377. * Sets the color of the ray from the vr headsets gaze.
  41378. * @param color new color for the ray.
  41379. */
  41380. changeGazeColor(color: Color3): void;
  41381. /**
  41382. * Exits VR and disposes of the vr experience helper
  41383. */
  41384. dispose(): void;
  41385. /**
  41386. * Gets the name of the VRExperienceHelper class
  41387. * @returns "VRExperienceHelper"
  41388. */
  41389. getClassName(): string;
  41390. }
  41391. }
  41392. declare module BABYLON {
  41393. /**
  41394. * Manages an XRSession to work with Babylon's engine
  41395. * @see https://doc.babylonjs.com/how_to/webxr
  41396. */
  41397. export class WebXRSessionManager implements IDisposable {
  41398. private scene;
  41399. /**
  41400. * Fires every time a new xrFrame arrives which can be used to update the camera
  41401. */
  41402. onXRFrameObservable: Observable<any>;
  41403. /**
  41404. * Fires when the xr session is ended either by the device or manually done
  41405. */
  41406. onXRSessionEnded: Observable<any>;
  41407. /**
  41408. * Underlying xr session
  41409. */
  41410. session: XRSession;
  41411. /**
  41412. * Type of reference space used when creating the session
  41413. */
  41414. referenceSpace: XRReferenceSpace;
  41415. /** @hidden */
  41416. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41417. /**
  41418. * Current XR frame
  41419. */
  41420. currentFrame: Nullable<XRFrame>;
  41421. private _xrNavigator;
  41422. private baseLayer;
  41423. /**
  41424. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41425. * @param scene The scene which the session should be created for
  41426. */
  41427. constructor(scene: Scene);
  41428. /**
  41429. * Initializes the manager
  41430. * After initialization enterXR can be called to start an XR session
  41431. * @returns Promise which resolves after it is initialized
  41432. */
  41433. initializeAsync(): Promise<void>;
  41434. /**
  41435. * Initializes an xr session
  41436. * @param xrSessionMode mode to initialize
  41437. * @returns a promise which will resolve once the session has been initialized
  41438. */
  41439. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41440. /**
  41441. * Sets the reference space on the xr session
  41442. * @param referenceSpace space to set
  41443. * @returns a promise that will resolve once the reference space has been set
  41444. */
  41445. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41446. /**
  41447. * Updates the render state of the session
  41448. * @param state state to set
  41449. * @returns a promise that resolves once the render state has been updated
  41450. */
  41451. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41452. /**
  41453. * Starts rendering to the xr layer
  41454. * @returns a promise that will resolve once rendering has started
  41455. */
  41456. startRenderingToXRAsync(): Promise<void>;
  41457. /**
  41458. * Stops the xrSession and restores the renderloop
  41459. * @returns Promise which resolves after it exits XR
  41460. */
  41461. exitXRAsync(): Promise<unknown>;
  41462. /**
  41463. * Checks if a session would be supported for the creation options specified
  41464. * @param sessionMode session mode to check if supported eg. immersive-vr
  41465. * @returns true if supported
  41466. */
  41467. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41468. /**
  41469. * @hidden
  41470. * Converts the render layer of xrSession to a render target
  41471. * @param session session to create render target for
  41472. * @param scene scene the new render target should be created for
  41473. */
  41474. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41475. /**
  41476. * Disposes of the session manager
  41477. */
  41478. dispose(): void;
  41479. }
  41480. }
  41481. declare module BABYLON {
  41482. /**
  41483. * WebXR Camera which holds the views for the xrSession
  41484. * @see https://doc.babylonjs.com/how_to/webxr
  41485. */
  41486. export class WebXRCamera extends FreeCamera {
  41487. private static _TmpMatrix;
  41488. /**
  41489. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41490. * @param name the name of the camera
  41491. * @param scene the scene to add the camera to
  41492. */
  41493. constructor(name: string, scene: Scene);
  41494. private _updateNumberOfRigCameras;
  41495. /** @hidden */
  41496. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41497. /**
  41498. * Updates the cameras position from the current pose information of the XR session
  41499. * @param xrSessionManager the session containing pose information
  41500. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41501. */
  41502. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41503. }
  41504. }
  41505. declare module BABYLON {
  41506. /**
  41507. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41508. */
  41509. export class WebXRManagedOutputCanvas implements IDisposable {
  41510. private helper;
  41511. private _canvas;
  41512. /**
  41513. * xrpresent context of the canvas which can be used to display/mirror xr content
  41514. */
  41515. canvasContext: WebGLRenderingContext;
  41516. /**
  41517. * xr layer for the canvas
  41518. */
  41519. xrLayer: Nullable<XRWebGLLayer>;
  41520. /**
  41521. * Initializes the xr layer for the session
  41522. * @param xrSession xr session
  41523. * @returns a promise that will resolve once the XR Layer has been created
  41524. */
  41525. initializeXRLayerAsync(xrSession: any): any;
  41526. /**
  41527. * Initializes the canvas to be added/removed upon entering/exiting xr
  41528. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41529. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41530. */
  41531. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41532. /**
  41533. * Disposes of the object
  41534. */
  41535. dispose(): void;
  41536. private _setManagedOutputCanvas;
  41537. private _addCanvas;
  41538. private _removeCanvas;
  41539. }
  41540. }
  41541. declare module BABYLON {
  41542. /**
  41543. * States of the webXR experience
  41544. */
  41545. export enum WebXRState {
  41546. /**
  41547. * Transitioning to being in XR mode
  41548. */
  41549. ENTERING_XR = 0,
  41550. /**
  41551. * Transitioning to non XR mode
  41552. */
  41553. EXITING_XR = 1,
  41554. /**
  41555. * In XR mode and presenting
  41556. */
  41557. IN_XR = 2,
  41558. /**
  41559. * Not entered XR mode
  41560. */
  41561. NOT_IN_XR = 3
  41562. }
  41563. /**
  41564. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41565. * @see https://doc.babylonjs.com/how_to/webxr
  41566. */
  41567. export class WebXRExperienceHelper implements IDisposable {
  41568. private scene;
  41569. /**
  41570. * 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
  41571. */
  41572. container: AbstractMesh;
  41573. /**
  41574. * Camera used to render xr content
  41575. */
  41576. camera: WebXRCamera;
  41577. /**
  41578. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41579. */
  41580. state: WebXRState;
  41581. private _setState;
  41582. private static _TmpVector;
  41583. /**
  41584. * Fires when the state of the experience helper has changed
  41585. */
  41586. onStateChangedObservable: Observable<WebXRState>;
  41587. /** Session manager used to keep track of xr session */
  41588. sessionManager: WebXRSessionManager;
  41589. private _nonVRCamera;
  41590. private _originalSceneAutoClear;
  41591. private _supported;
  41592. /**
  41593. * Creates the experience helper
  41594. * @param scene the scene to attach the experience helper to
  41595. * @returns a promise for the experience helper
  41596. */
  41597. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41598. /**
  41599. * Creates a WebXRExperienceHelper
  41600. * @param scene The scene the helper should be created in
  41601. */
  41602. private constructor();
  41603. /**
  41604. * Exits XR mode and returns the scene to its original state
  41605. * @returns promise that resolves after xr mode has exited
  41606. */
  41607. exitXRAsync(): Promise<unknown>;
  41608. /**
  41609. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41610. * @param sessionCreationOptions options for the XR session
  41611. * @param referenceSpaceType frame of reference of the XR session
  41612. * @param outputCanvas the output canvas that will be used to enter XR mode
  41613. * @returns promise that resolves after xr mode has entered
  41614. */
  41615. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41616. /**
  41617. * Updates the global position of the camera by moving the camera's container
  41618. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41619. * @param position The desired global position of the camera
  41620. */
  41621. setPositionOfCameraUsingContainer(position: Vector3): void;
  41622. /**
  41623. * Rotates the xr camera by rotating the camera's container around the camera's position
  41624. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41625. * @param rotation the desired quaternion rotation to apply to the camera
  41626. */
  41627. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41628. /**
  41629. * Disposes of the experience helper
  41630. */
  41631. dispose(): void;
  41632. }
  41633. }
  41634. declare module BABYLON {
  41635. /**
  41636. * Button which can be used to enter a different mode of XR
  41637. */
  41638. export class WebXREnterExitUIButton {
  41639. /** button element */
  41640. element: HTMLElement;
  41641. /** XR initialization options for the button */
  41642. sessionMode: XRSessionMode;
  41643. /** Reference space type */
  41644. referenceSpaceType: XRReferenceSpaceType;
  41645. /**
  41646. * Creates a WebXREnterExitUIButton
  41647. * @param element button element
  41648. * @param sessionMode XR initialization session mode
  41649. * @param referenceSpaceType the type of reference space to be used
  41650. */
  41651. constructor(
  41652. /** button element */
  41653. element: HTMLElement,
  41654. /** XR initialization options for the button */
  41655. sessionMode: XRSessionMode,
  41656. /** Reference space type */
  41657. referenceSpaceType: XRReferenceSpaceType);
  41658. /**
  41659. * Overwritable function which can be used to update the button's visuals when the state changes
  41660. * @param activeButton the current active button in the UI
  41661. */
  41662. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41663. }
  41664. /**
  41665. * Options to create the webXR UI
  41666. */
  41667. export class WebXREnterExitUIOptions {
  41668. /**
  41669. * Context to enter xr with
  41670. */
  41671. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41672. /**
  41673. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41674. */
  41675. customButtons?: Array<WebXREnterExitUIButton>;
  41676. }
  41677. /**
  41678. * UI to allow the user to enter/exit XR mode
  41679. */
  41680. export class WebXREnterExitUI implements IDisposable {
  41681. private scene;
  41682. private _overlay;
  41683. private _buttons;
  41684. private _activeButton;
  41685. /**
  41686. * Fired every time the active button is changed.
  41687. *
  41688. * When xr is entered via a button that launches xr that button will be the callback parameter
  41689. *
  41690. * When exiting xr the callback parameter will be null)
  41691. */
  41692. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41693. /**
  41694. * Creates UI to allow the user to enter/exit XR mode
  41695. * @param scene the scene to add the ui to
  41696. * @param helper the xr experience helper to enter/exit xr with
  41697. * @param options options to configure the UI
  41698. * @returns the created ui
  41699. */
  41700. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41701. private constructor();
  41702. private _updateButtons;
  41703. /**
  41704. * Disposes of the object
  41705. */
  41706. dispose(): void;
  41707. }
  41708. }
  41709. declare module BABYLON {
  41710. /**
  41711. * Represents an XR input
  41712. */
  41713. export class WebXRController {
  41714. private scene;
  41715. /** The underlying input source for the controller */
  41716. inputSource: XRInputSource;
  41717. private parentContainer;
  41718. /**
  41719. * 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
  41720. */
  41721. grip?: AbstractMesh;
  41722. /**
  41723. * Pointer which can be used to select objects or attach a visible laser to
  41724. */
  41725. pointer: AbstractMesh;
  41726. /**
  41727. * Event that fires when the controller is removed/disposed
  41728. */
  41729. onDisposeObservable: Observable<{}>;
  41730. private _tmpMatrix;
  41731. private _tmpQuaternion;
  41732. private _tmpVector;
  41733. /**
  41734. * Creates the controller
  41735. * @see https://doc.babylonjs.com/how_to/webxr
  41736. * @param scene the scene which the controller should be associated to
  41737. * @param inputSource the underlying input source for the controller
  41738. * @param parentContainer parent that the controller meshes should be children of
  41739. */
  41740. constructor(scene: Scene,
  41741. /** The underlying input source for the controller */
  41742. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41743. /**
  41744. * Updates the controller pose based on the given XRFrame
  41745. * @param xrFrame xr frame to update the pose with
  41746. * @param referenceSpace reference space to use
  41747. */
  41748. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41749. /**
  41750. * Gets a world space ray coming from the controller
  41751. * @param result the resulting ray
  41752. */
  41753. getWorldPointerRayToRef(result: Ray): void;
  41754. /**
  41755. * Disposes of the object
  41756. */
  41757. dispose(): void;
  41758. }
  41759. }
  41760. declare module BABYLON {
  41761. /**
  41762. * XR input used to track XR inputs such as controllers/rays
  41763. */
  41764. export class WebXRInput implements IDisposable {
  41765. /**
  41766. * Base experience the input listens to
  41767. */
  41768. baseExperience: WebXRExperienceHelper;
  41769. /**
  41770. * XR controllers being tracked
  41771. */
  41772. controllers: Array<WebXRController>;
  41773. private _frameObserver;
  41774. private _stateObserver;
  41775. /**
  41776. * Event when a controller has been connected/added
  41777. */
  41778. onControllerAddedObservable: Observable<WebXRController>;
  41779. /**
  41780. * Event when a controller has been removed/disconnected
  41781. */
  41782. onControllerRemovedObservable: Observable<WebXRController>;
  41783. /**
  41784. * Initializes the WebXRInput
  41785. * @param baseExperience experience helper which the input should be created for
  41786. */
  41787. constructor(
  41788. /**
  41789. * Base experience the input listens to
  41790. */
  41791. baseExperience: WebXRExperienceHelper);
  41792. private _onInputSourcesChange;
  41793. private _addAndRemoveControllers;
  41794. /**
  41795. * Disposes of the object
  41796. */
  41797. dispose(): void;
  41798. }
  41799. }
  41800. declare module BABYLON {
  41801. /**
  41802. * Enables teleportation
  41803. */
  41804. export class WebXRControllerTeleportation {
  41805. private _teleportationFillColor;
  41806. private _teleportationBorderColor;
  41807. private _tmpRay;
  41808. private _tmpVector;
  41809. /**
  41810. * Creates a WebXRControllerTeleportation
  41811. * @param input input manager to add teleportation to
  41812. * @param floorMeshes floormeshes which can be teleported to
  41813. */
  41814. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41815. }
  41816. }
  41817. declare module BABYLON {
  41818. /**
  41819. * Handles pointer input automatically for the pointer of XR controllers
  41820. */
  41821. export class WebXRControllerPointerSelection {
  41822. private static _idCounter;
  41823. private _tmpRay;
  41824. /**
  41825. * Creates a WebXRControllerPointerSelection
  41826. * @param input input manager to setup pointer selection
  41827. */
  41828. constructor(input: WebXRInput);
  41829. private _convertNormalToDirectionOfRay;
  41830. private _updatePointerDistance;
  41831. }
  41832. }
  41833. declare module BABYLON {
  41834. /**
  41835. * Class used to represent data loading progression
  41836. */
  41837. export class SceneLoaderProgressEvent {
  41838. /** defines if data length to load can be evaluated */
  41839. readonly lengthComputable: boolean;
  41840. /** defines the loaded data length */
  41841. readonly loaded: number;
  41842. /** defines the data length to load */
  41843. readonly total: number;
  41844. /**
  41845. * Create a new progress event
  41846. * @param lengthComputable defines if data length to load can be evaluated
  41847. * @param loaded defines the loaded data length
  41848. * @param total defines the data length to load
  41849. */
  41850. constructor(
  41851. /** defines if data length to load can be evaluated */
  41852. lengthComputable: boolean,
  41853. /** defines the loaded data length */
  41854. loaded: number,
  41855. /** defines the data length to load */
  41856. total: number);
  41857. /**
  41858. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41859. * @param event defines the source event
  41860. * @returns a new SceneLoaderProgressEvent
  41861. */
  41862. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41863. }
  41864. /**
  41865. * Interface used by SceneLoader plugins to define supported file extensions
  41866. */
  41867. export interface ISceneLoaderPluginExtensions {
  41868. /**
  41869. * Defines the list of supported extensions
  41870. */
  41871. [extension: string]: {
  41872. isBinary: boolean;
  41873. };
  41874. }
  41875. /**
  41876. * Interface used by SceneLoader plugin factory
  41877. */
  41878. export interface ISceneLoaderPluginFactory {
  41879. /**
  41880. * Defines the name of the factory
  41881. */
  41882. name: string;
  41883. /**
  41884. * Function called to create a new plugin
  41885. * @return the new plugin
  41886. */
  41887. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41888. /**
  41889. * Boolean indicating if the plugin can direct load specific data
  41890. */
  41891. canDirectLoad?: (data: string) => boolean;
  41892. }
  41893. /**
  41894. * Interface used to define a SceneLoader plugin
  41895. */
  41896. export interface ISceneLoaderPlugin {
  41897. /**
  41898. * The friendly name of this plugin.
  41899. */
  41900. name: string;
  41901. /**
  41902. * The file extensions supported by this plugin.
  41903. */
  41904. extensions: string | ISceneLoaderPluginExtensions;
  41905. /**
  41906. * Import meshes into a scene.
  41907. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41908. * @param scene The scene to import into
  41909. * @param data The data to import
  41910. * @param rootUrl The root url for scene and resources
  41911. * @param meshes The meshes array to import into
  41912. * @param particleSystems The particle systems array to import into
  41913. * @param skeletons The skeletons array to import into
  41914. * @param onError The callback when import fails
  41915. * @returns True if successful or false otherwise
  41916. */
  41917. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41918. /**
  41919. * Load into a scene.
  41920. * @param scene The scene to load into
  41921. * @param data The data to import
  41922. * @param rootUrl The root url for scene and resources
  41923. * @param onError The callback when import fails
  41924. * @returns true if successful or false otherwise
  41925. */
  41926. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41927. /**
  41928. * The callback that returns true if the data can be directly loaded.
  41929. */
  41930. canDirectLoad?: (data: string) => boolean;
  41931. /**
  41932. * The callback that allows custom handling of the root url based on the response url.
  41933. */
  41934. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41935. /**
  41936. * Load into an asset container.
  41937. * @param scene The scene to load into
  41938. * @param data The data to import
  41939. * @param rootUrl The root url for scene and resources
  41940. * @param onError The callback when import fails
  41941. * @returns The loaded asset container
  41942. */
  41943. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41944. }
  41945. /**
  41946. * Interface used to define an async SceneLoader plugin
  41947. */
  41948. export interface ISceneLoaderPluginAsync {
  41949. /**
  41950. * The friendly name of this plugin.
  41951. */
  41952. name: string;
  41953. /**
  41954. * The file extensions supported by this plugin.
  41955. */
  41956. extensions: string | ISceneLoaderPluginExtensions;
  41957. /**
  41958. * Import meshes into a scene.
  41959. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41960. * @param scene The scene to import into
  41961. * @param data The data to import
  41962. * @param rootUrl The root url for scene and resources
  41963. * @param onProgress The callback when the load progresses
  41964. * @param fileName Defines the name of the file to load
  41965. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41966. */
  41967. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41968. meshes: AbstractMesh[];
  41969. particleSystems: IParticleSystem[];
  41970. skeletons: Skeleton[];
  41971. animationGroups: AnimationGroup[];
  41972. }>;
  41973. /**
  41974. * Load into a scene.
  41975. * @param scene The scene to load into
  41976. * @param data The data to import
  41977. * @param rootUrl The root url for scene and resources
  41978. * @param onProgress The callback when the load progresses
  41979. * @param fileName Defines the name of the file to load
  41980. * @returns Nothing
  41981. */
  41982. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41983. /**
  41984. * The callback that returns true if the data can be directly loaded.
  41985. */
  41986. canDirectLoad?: (data: string) => boolean;
  41987. /**
  41988. * The callback that allows custom handling of the root url based on the response url.
  41989. */
  41990. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41991. /**
  41992. * Load into an asset container.
  41993. * @param scene The scene to load into
  41994. * @param data The data to import
  41995. * @param rootUrl The root url for scene and resources
  41996. * @param onProgress The callback when the load progresses
  41997. * @param fileName Defines the name of the file to load
  41998. * @returns The loaded asset container
  41999. */
  42000. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42001. }
  42002. /**
  42003. * Class used to load scene from various file formats using registered plugins
  42004. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42005. */
  42006. export class SceneLoader {
  42007. /**
  42008. * No logging while loading
  42009. */
  42010. static readonly NO_LOGGING: number;
  42011. /**
  42012. * Minimal logging while loading
  42013. */
  42014. static readonly MINIMAL_LOGGING: number;
  42015. /**
  42016. * Summary logging while loading
  42017. */
  42018. static readonly SUMMARY_LOGGING: number;
  42019. /**
  42020. * Detailled logging while loading
  42021. */
  42022. static readonly DETAILED_LOGGING: number;
  42023. /**
  42024. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42025. */
  42026. static ForceFullSceneLoadingForIncremental: boolean;
  42027. /**
  42028. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42029. */
  42030. static ShowLoadingScreen: boolean;
  42031. /**
  42032. * Defines the current logging level (while loading the scene)
  42033. * @ignorenaming
  42034. */
  42035. static loggingLevel: number;
  42036. /**
  42037. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42038. */
  42039. static CleanBoneMatrixWeights: boolean;
  42040. /**
  42041. * Event raised when a plugin is used to load a scene
  42042. */
  42043. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42044. private static _registeredPlugins;
  42045. private static _getDefaultPlugin;
  42046. private static _getPluginForExtension;
  42047. private static _getPluginForDirectLoad;
  42048. private static _getPluginForFilename;
  42049. private static _getDirectLoad;
  42050. private static _loadData;
  42051. private static _getFileInfo;
  42052. /**
  42053. * Gets a plugin that can load the given extension
  42054. * @param extension defines the extension to load
  42055. * @returns a plugin or null if none works
  42056. */
  42057. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42058. /**
  42059. * Gets a boolean indicating that the given extension can be loaded
  42060. * @param extension defines the extension to load
  42061. * @returns true if the extension is supported
  42062. */
  42063. static IsPluginForExtensionAvailable(extension: string): boolean;
  42064. /**
  42065. * Adds a new plugin to the list of registered plugins
  42066. * @param plugin defines the plugin to add
  42067. */
  42068. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42069. /**
  42070. * Import meshes into a scene
  42071. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42072. * @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)
  42073. * @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)
  42074. * @param scene the instance of BABYLON.Scene to append to
  42075. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42076. * @param onProgress a callback with a progress event for each file being loaded
  42077. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42078. * @param pluginExtension the extension used to determine the plugin
  42079. * @returns The loaded plugin
  42080. */
  42081. 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>;
  42082. /**
  42083. * Import meshes into a scene
  42084. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42085. * @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)
  42086. * @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)
  42087. * @param scene the instance of BABYLON.Scene to append to
  42088. * @param onProgress a callback with a progress event for each file being loaded
  42089. * @param pluginExtension the extension used to determine the plugin
  42090. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42091. */
  42092. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42093. meshes: AbstractMesh[];
  42094. particleSystems: IParticleSystem[];
  42095. skeletons: Skeleton[];
  42096. animationGroups: AnimationGroup[];
  42097. }>;
  42098. /**
  42099. * Load a scene
  42100. * @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)
  42101. * @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)
  42102. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42103. * @param onSuccess a callback with the scene when import succeeds
  42104. * @param onProgress a callback with a progress event for each file being loaded
  42105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42106. * @param pluginExtension the extension used to determine the plugin
  42107. * @returns The loaded plugin
  42108. */
  42109. 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>;
  42110. /**
  42111. * Load a scene
  42112. * @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)
  42113. * @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)
  42114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42115. * @param onProgress a callback with a progress event for each file being loaded
  42116. * @param pluginExtension the extension used to determine the plugin
  42117. * @returns The loaded scene
  42118. */
  42119. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42120. /**
  42121. * Append a scene
  42122. * @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)
  42123. * @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)
  42124. * @param scene is the instance of BABYLON.Scene to append to
  42125. * @param onSuccess a callback with the scene when import succeeds
  42126. * @param onProgress a callback with a progress event for each file being loaded
  42127. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42128. * @param pluginExtension the extension used to determine the plugin
  42129. * @returns The loaded plugin
  42130. */
  42131. 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>;
  42132. /**
  42133. * Append a scene
  42134. * @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)
  42135. * @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)
  42136. * @param scene is the instance of BABYLON.Scene to append to
  42137. * @param onProgress a callback with a progress event for each file being loaded
  42138. * @param pluginExtension the extension used to determine the plugin
  42139. * @returns The given scene
  42140. */
  42141. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42142. /**
  42143. * Load a scene into an asset container
  42144. * @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)
  42145. * @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)
  42146. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42147. * @param onSuccess a callback with the scene when import succeeds
  42148. * @param onProgress a callback with a progress event for each file being loaded
  42149. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42150. * @param pluginExtension the extension used to determine the plugin
  42151. * @returns The loaded plugin
  42152. */
  42153. 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>;
  42154. /**
  42155. * Load a scene into an asset container
  42156. * @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)
  42157. * @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)
  42158. * @param scene is the instance of Scene to append to
  42159. * @param onProgress a callback with a progress event for each file being loaded
  42160. * @param pluginExtension the extension used to determine the plugin
  42161. * @returns The loaded asset container
  42162. */
  42163. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * Generic Controller
  42169. */
  42170. export class GenericController extends WebVRController {
  42171. /**
  42172. * Base Url for the controller model.
  42173. */
  42174. static readonly MODEL_BASE_URL: string;
  42175. /**
  42176. * File name for the controller model.
  42177. */
  42178. static readonly MODEL_FILENAME: string;
  42179. /**
  42180. * Creates a new GenericController from a gamepad
  42181. * @param vrGamepad the gamepad that the controller should be created from
  42182. */
  42183. constructor(vrGamepad: any);
  42184. /**
  42185. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42186. * @param scene scene in which to add meshes
  42187. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42188. */
  42189. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42190. /**
  42191. * Called once for each button that changed state since the last frame
  42192. * @param buttonIdx Which button index changed
  42193. * @param state New state of the button
  42194. * @param changes Which properties on the state changed since last frame
  42195. */
  42196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Defines the WindowsMotionController object that the state of the windows motion controller
  42202. */
  42203. export class WindowsMotionController extends WebVRController {
  42204. /**
  42205. * The base url used to load the left and right controller models
  42206. */
  42207. static MODEL_BASE_URL: string;
  42208. /**
  42209. * The name of the left controller model file
  42210. */
  42211. static MODEL_LEFT_FILENAME: string;
  42212. /**
  42213. * The name of the right controller model file
  42214. */
  42215. static MODEL_RIGHT_FILENAME: string;
  42216. /**
  42217. * The controller name prefix for this controller type
  42218. */
  42219. static readonly GAMEPAD_ID_PREFIX: string;
  42220. /**
  42221. * The controller id pattern for this controller type
  42222. */
  42223. private static readonly GAMEPAD_ID_PATTERN;
  42224. private _loadedMeshInfo;
  42225. private readonly _mapping;
  42226. /**
  42227. * Fired when the trackpad on this controller is clicked
  42228. */
  42229. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42230. /**
  42231. * Fired when the trackpad on this controller is modified
  42232. */
  42233. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42234. /**
  42235. * The current x and y values of this controller's trackpad
  42236. */
  42237. trackpad: StickValues;
  42238. /**
  42239. * Creates a new WindowsMotionController from a gamepad
  42240. * @param vrGamepad the gamepad that the controller should be created from
  42241. */
  42242. constructor(vrGamepad: any);
  42243. /**
  42244. * Fired when the trigger on this controller is modified
  42245. */
  42246. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42247. /**
  42248. * Fired when the menu button on this controller is modified
  42249. */
  42250. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42251. /**
  42252. * Fired when the grip button on this controller is modified
  42253. */
  42254. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the thumbstick button on this controller is modified
  42257. */
  42258. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Fired when the touchpad button on this controller is modified
  42261. */
  42262. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42263. /**
  42264. * Fired when the touchpad values on this controller are modified
  42265. */
  42266. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42267. private _updateTrackpad;
  42268. /**
  42269. * Called once per frame by the engine.
  42270. */
  42271. update(): void;
  42272. /**
  42273. * Called once for each button that changed state since the last frame
  42274. * @param buttonIdx Which button index changed
  42275. * @param state New state of the button
  42276. * @param changes Which properties on the state changed since last frame
  42277. */
  42278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42279. /**
  42280. * Moves the buttons on the controller mesh based on their current state
  42281. * @param buttonName the name of the button to move
  42282. * @param buttonValue the value of the button which determines the buttons new position
  42283. */
  42284. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42285. /**
  42286. * Moves the axis on the controller mesh based on its current state
  42287. * @param axis the index of the axis
  42288. * @param axisValue the value of the axis which determines the meshes new position
  42289. * @hidden
  42290. */
  42291. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42292. /**
  42293. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42294. * @param scene scene in which to add meshes
  42295. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42296. */
  42297. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42298. /**
  42299. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42300. * can be transformed by button presses and axes values, based on this._mapping.
  42301. *
  42302. * @param scene scene in which the meshes exist
  42303. * @param meshes list of meshes that make up the controller model to process
  42304. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42305. */
  42306. private processModel;
  42307. private createMeshInfo;
  42308. /**
  42309. * Gets the ray of the controller in the direction the controller is pointing
  42310. * @param length the length the resulting ray should be
  42311. * @returns a ray in the direction the controller is pointing
  42312. */
  42313. getForwardRay(length?: number): Ray;
  42314. /**
  42315. * Disposes of the controller
  42316. */
  42317. dispose(): void;
  42318. }
  42319. }
  42320. declare module BABYLON {
  42321. /**
  42322. * Oculus Touch Controller
  42323. */
  42324. export class OculusTouchController extends WebVRController {
  42325. /**
  42326. * Base Url for the controller model.
  42327. */
  42328. static MODEL_BASE_URL: string;
  42329. /**
  42330. * File name for the left controller model.
  42331. */
  42332. static MODEL_LEFT_FILENAME: string;
  42333. /**
  42334. * File name for the right controller model.
  42335. */
  42336. static MODEL_RIGHT_FILENAME: string;
  42337. /**
  42338. * Base Url for the Quest controller model.
  42339. */
  42340. static QUEST_MODEL_BASE_URL: string;
  42341. /**
  42342. * @hidden
  42343. * If the controllers are running on a device that needs the updated Quest controller models
  42344. */
  42345. static _IsQuest: boolean;
  42346. /**
  42347. * Fired when the secondary trigger on this controller is modified
  42348. */
  42349. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42350. /**
  42351. * Fired when the thumb rest on this controller is modified
  42352. */
  42353. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42354. /**
  42355. * Creates a new OculusTouchController from a gamepad
  42356. * @param vrGamepad the gamepad that the controller should be created from
  42357. */
  42358. constructor(vrGamepad: any);
  42359. /**
  42360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42361. * @param scene scene in which to add meshes
  42362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42363. */
  42364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42365. /**
  42366. * Fired when the A button on this controller is modified
  42367. */
  42368. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42369. /**
  42370. * Fired when the B button on this controller is modified
  42371. */
  42372. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42373. /**
  42374. * Fired when the X button on this controller is modified
  42375. */
  42376. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42377. /**
  42378. * Fired when the Y button on this controller is modified
  42379. */
  42380. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42381. /**
  42382. * Called once for each button that changed state since the last frame
  42383. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42384. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42385. * 2) secondary trigger (same)
  42386. * 3) A (right) X (left), touch, pressed = value
  42387. * 4) B / Y
  42388. * 5) thumb rest
  42389. * @param buttonIdx Which button index changed
  42390. * @param state New state of the button
  42391. * @param changes Which properties on the state changed since last frame
  42392. */
  42393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * Vive Controller
  42399. */
  42400. export class ViveController extends WebVRController {
  42401. /**
  42402. * Base Url for the controller model.
  42403. */
  42404. static MODEL_BASE_URL: string;
  42405. /**
  42406. * File name for the controller model.
  42407. */
  42408. static MODEL_FILENAME: string;
  42409. /**
  42410. * Creates a new ViveController from a gamepad
  42411. * @param vrGamepad the gamepad that the controller should be created from
  42412. */
  42413. constructor(vrGamepad: any);
  42414. /**
  42415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42416. * @param scene scene in which to add meshes
  42417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42418. */
  42419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42420. /**
  42421. * Fired when the left button on this controller is modified
  42422. */
  42423. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42424. /**
  42425. * Fired when the right button on this controller is modified
  42426. */
  42427. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42428. /**
  42429. * Fired when the menu button on this controller is modified
  42430. */
  42431. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42432. /**
  42433. * Called once for each button that changed state since the last frame
  42434. * Vive mapping:
  42435. * 0: touchpad
  42436. * 1: trigger
  42437. * 2: left AND right buttons
  42438. * 3: menu button
  42439. * @param buttonIdx Which button index changed
  42440. * @param state New state of the button
  42441. * @param changes Which properties on the state changed since last frame
  42442. */
  42443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42444. }
  42445. }
  42446. declare module BABYLON {
  42447. /**
  42448. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42449. */
  42450. export class WebXRControllerModelLoader {
  42451. /**
  42452. * Creates the WebXRControllerModelLoader
  42453. * @param input xr input that creates the controllers
  42454. */
  42455. constructor(input: WebXRInput);
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Contains an array of blocks representing the octree
  42461. */
  42462. export interface IOctreeContainer<T> {
  42463. /**
  42464. * Blocks within the octree
  42465. */
  42466. blocks: Array<OctreeBlock<T>>;
  42467. }
  42468. /**
  42469. * Class used to store a cell in an octree
  42470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42471. */
  42472. export class OctreeBlock<T> {
  42473. /**
  42474. * Gets the content of the current block
  42475. */
  42476. entries: T[];
  42477. /**
  42478. * Gets the list of block children
  42479. */
  42480. blocks: Array<OctreeBlock<T>>;
  42481. private _depth;
  42482. private _maxDepth;
  42483. private _capacity;
  42484. private _minPoint;
  42485. private _maxPoint;
  42486. private _boundingVectors;
  42487. private _creationFunc;
  42488. /**
  42489. * Creates a new block
  42490. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42491. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42492. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42493. * @param depth defines the current depth of this block in the octree
  42494. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42495. * @param creationFunc defines a callback to call when an element is added to the block
  42496. */
  42497. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42498. /**
  42499. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42500. */
  42501. readonly capacity: number;
  42502. /**
  42503. * Gets the minimum vector (in world space) of the block's bounding box
  42504. */
  42505. readonly minPoint: Vector3;
  42506. /**
  42507. * Gets the maximum vector (in world space) of the block's bounding box
  42508. */
  42509. readonly maxPoint: Vector3;
  42510. /**
  42511. * Add a new element to this block
  42512. * @param entry defines the element to add
  42513. */
  42514. addEntry(entry: T): void;
  42515. /**
  42516. * Remove an element from this block
  42517. * @param entry defines the element to remove
  42518. */
  42519. removeEntry(entry: T): void;
  42520. /**
  42521. * Add an array of elements to this block
  42522. * @param entries defines the array of elements to add
  42523. */
  42524. addEntries(entries: T[]): void;
  42525. /**
  42526. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42527. * @param frustumPlanes defines the frustum planes to test
  42528. * @param selection defines the array to store current content if selection is positive
  42529. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42530. */
  42531. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42532. /**
  42533. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42534. * @param sphereCenter defines the bounding sphere center
  42535. * @param sphereRadius defines the bounding sphere radius
  42536. * @param selection defines the array to store current content if selection is positive
  42537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42538. */
  42539. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42540. /**
  42541. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42542. * @param ray defines the ray to test with
  42543. * @param selection defines the array to store current content if selection is positive
  42544. */
  42545. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42546. /**
  42547. * Subdivide the content into child blocks (this block will then be empty)
  42548. */
  42549. createInnerBlocks(): void;
  42550. /**
  42551. * @hidden
  42552. */
  42553. 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;
  42554. }
  42555. }
  42556. declare module BABYLON {
  42557. /**
  42558. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42559. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42560. */
  42561. export class Octree<T> {
  42562. /** 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.) */
  42563. maxDepth: number;
  42564. /**
  42565. * Blocks within the octree containing objects
  42566. */
  42567. blocks: Array<OctreeBlock<T>>;
  42568. /**
  42569. * Content stored in the octree
  42570. */
  42571. dynamicContent: T[];
  42572. private _maxBlockCapacity;
  42573. private _selectionContent;
  42574. private _creationFunc;
  42575. /**
  42576. * Creates a octree
  42577. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42578. * @param creationFunc function to be used to instatiate the octree
  42579. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42580. * @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.)
  42581. */
  42582. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42583. /** 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.) */
  42584. maxDepth?: number);
  42585. /**
  42586. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42587. * @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);
  42588. * @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);
  42589. * @param entries meshes to be added to the octree blocks
  42590. */
  42591. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42592. /**
  42593. * Adds a mesh to the octree
  42594. * @param entry Mesh to add to the octree
  42595. */
  42596. addMesh(entry: T): void;
  42597. /**
  42598. * Remove an element from the octree
  42599. * @param entry defines the element to remove
  42600. */
  42601. removeMesh(entry: T): void;
  42602. /**
  42603. * Selects an array of meshes within the frustum
  42604. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42605. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42606. * @returns array of meshes within the frustum
  42607. */
  42608. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42609. /**
  42610. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42611. * @param sphereCenter defines the bounding sphere center
  42612. * @param sphereRadius defines the bounding sphere radius
  42613. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42614. * @returns an array of objects that intersect the sphere
  42615. */
  42616. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42617. /**
  42618. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42619. * @param ray defines the ray to test with
  42620. * @returns array of intersected objects
  42621. */
  42622. intersectsRay(ray: Ray): SmartArray<T>;
  42623. /**
  42624. * Adds a mesh into the octree block if it intersects the block
  42625. */
  42626. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42627. /**
  42628. * Adds a submesh into the octree block if it intersects the block
  42629. */
  42630. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42631. }
  42632. }
  42633. declare module BABYLON {
  42634. interface Scene {
  42635. /**
  42636. * @hidden
  42637. * Backing Filed
  42638. */
  42639. _selectionOctree: Octree<AbstractMesh>;
  42640. /**
  42641. * Gets the octree used to boost mesh selection (picking)
  42642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42643. */
  42644. selectionOctree: Octree<AbstractMesh>;
  42645. /**
  42646. * Creates or updates the octree used to boost selection (picking)
  42647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42648. * @param maxCapacity defines the maximum capacity per leaf
  42649. * @param maxDepth defines the maximum depth of the octree
  42650. * @returns an octree of AbstractMesh
  42651. */
  42652. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42653. }
  42654. interface AbstractMesh {
  42655. /**
  42656. * @hidden
  42657. * Backing Field
  42658. */
  42659. _submeshesOctree: Octree<SubMesh>;
  42660. /**
  42661. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42662. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42663. * @param maxCapacity defines the maximum size of each block (64 by default)
  42664. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42665. * @returns the new octree
  42666. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42668. */
  42669. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42670. }
  42671. /**
  42672. * Defines the octree scene component responsible to manage any octrees
  42673. * in a given scene.
  42674. */
  42675. export class OctreeSceneComponent {
  42676. /**
  42677. * The component name help to identify the component in the list of scene components.
  42678. */
  42679. readonly name: string;
  42680. /**
  42681. * The scene the component belongs to.
  42682. */
  42683. scene: Scene;
  42684. /**
  42685. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42686. */
  42687. readonly checksIsEnabled: boolean;
  42688. /**
  42689. * Creates a new instance of the component for the given scene
  42690. * @param scene Defines the scene to register the component in
  42691. */
  42692. constructor(scene: Scene);
  42693. /**
  42694. * Registers the component in a given scene
  42695. */
  42696. register(): void;
  42697. /**
  42698. * Return the list of active meshes
  42699. * @returns the list of active meshes
  42700. */
  42701. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42702. /**
  42703. * Return the list of active sub meshes
  42704. * @param mesh The mesh to get the candidates sub meshes from
  42705. * @returns the list of active sub meshes
  42706. */
  42707. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42708. private _tempRay;
  42709. /**
  42710. * Return the list of sub meshes intersecting with a given local ray
  42711. * @param mesh defines the mesh to find the submesh for
  42712. * @param localRay defines the ray in local space
  42713. * @returns the list of intersecting sub meshes
  42714. */
  42715. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42716. /**
  42717. * Return the list of sub meshes colliding with a collider
  42718. * @param mesh defines the mesh to find the submesh for
  42719. * @param collider defines the collider to evaluate the collision against
  42720. * @returns the list of colliding sub meshes
  42721. */
  42722. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42723. /**
  42724. * Rebuilds the elements related to this component in case of
  42725. * context lost for instance.
  42726. */
  42727. rebuild(): void;
  42728. /**
  42729. * Disposes the component and the associated ressources.
  42730. */
  42731. dispose(): void;
  42732. }
  42733. }
  42734. declare module BABYLON {
  42735. /**
  42736. * Renders a layer on top of an existing scene
  42737. */
  42738. export class UtilityLayerRenderer implements IDisposable {
  42739. /** the original scene that will be rendered on top of */
  42740. originalScene: Scene;
  42741. private _pointerCaptures;
  42742. private _lastPointerEvents;
  42743. private static _DefaultUtilityLayer;
  42744. private static _DefaultKeepDepthUtilityLayer;
  42745. private _sharedGizmoLight;
  42746. private _renderCamera;
  42747. /**
  42748. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42749. * @returns the camera that is used when rendering the utility layer
  42750. */
  42751. getRenderCamera(): Nullable<Camera>;
  42752. /**
  42753. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42754. * @param cam the camera that should be used when rendering the utility layer
  42755. */
  42756. setRenderCamera(cam: Nullable<Camera>): void;
  42757. /**
  42758. * @hidden
  42759. * Light which used by gizmos to get light shading
  42760. */
  42761. _getSharedGizmoLight(): HemisphericLight;
  42762. /**
  42763. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42764. */
  42765. pickUtilitySceneFirst: boolean;
  42766. /**
  42767. * 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)
  42768. */
  42769. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42770. /**
  42771. * 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)
  42772. */
  42773. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42774. /**
  42775. * The scene that is rendered on top of the original scene
  42776. */
  42777. utilityLayerScene: Scene;
  42778. /**
  42779. * If the utility layer should automatically be rendered on top of existing scene
  42780. */
  42781. shouldRender: boolean;
  42782. /**
  42783. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42784. */
  42785. onlyCheckPointerDownEvents: boolean;
  42786. /**
  42787. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42788. */
  42789. processAllEvents: boolean;
  42790. /**
  42791. * Observable raised when the pointer move from the utility layer scene to the main scene
  42792. */
  42793. onPointerOutObservable: Observable<number>;
  42794. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42795. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42796. private _afterRenderObserver;
  42797. private _sceneDisposeObserver;
  42798. private _originalPointerObserver;
  42799. /**
  42800. * Instantiates a UtilityLayerRenderer
  42801. * @param originalScene the original scene that will be rendered on top of
  42802. * @param handleEvents boolean indicating if the utility layer should handle events
  42803. */
  42804. constructor(
  42805. /** the original scene that will be rendered on top of */
  42806. originalScene: Scene, handleEvents?: boolean);
  42807. private _notifyObservers;
  42808. /**
  42809. * Renders the utility layers scene on top of the original scene
  42810. */
  42811. render(): void;
  42812. /**
  42813. * Disposes of the renderer
  42814. */
  42815. dispose(): void;
  42816. private _updateCamera;
  42817. }
  42818. }
  42819. declare module BABYLON {
  42820. /**
  42821. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42822. */
  42823. export class Gizmo implements IDisposable {
  42824. /** The utility layer the gizmo will be added to */
  42825. gizmoLayer: UtilityLayerRenderer;
  42826. /**
  42827. * The root mesh of the gizmo
  42828. */
  42829. _rootMesh: Mesh;
  42830. private _attachedMesh;
  42831. /**
  42832. * Ratio for the scale of the gizmo (Default: 1)
  42833. */
  42834. scaleRatio: number;
  42835. /**
  42836. * If a custom mesh has been set (Default: false)
  42837. */
  42838. protected _customMeshSet: boolean;
  42839. /**
  42840. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42841. * * When set, interactions will be enabled
  42842. */
  42843. attachedMesh: Nullable<AbstractMesh>;
  42844. /**
  42845. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42846. * @param mesh The mesh to replace the default mesh of the gizmo
  42847. */
  42848. setCustomMesh(mesh: Mesh): void;
  42849. /**
  42850. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42851. */
  42852. updateGizmoRotationToMatchAttachedMesh: boolean;
  42853. /**
  42854. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42855. */
  42856. updateGizmoPositionToMatchAttachedMesh: boolean;
  42857. /**
  42858. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42859. */
  42860. updateScale: boolean;
  42861. protected _interactionsEnabled: boolean;
  42862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42863. private _beforeRenderObserver;
  42864. private _tempVector;
  42865. /**
  42866. * Creates a gizmo
  42867. * @param gizmoLayer The utility layer the gizmo will be added to
  42868. */
  42869. constructor(
  42870. /** The utility layer the gizmo will be added to */
  42871. gizmoLayer?: UtilityLayerRenderer);
  42872. /**
  42873. * Updates the gizmo to match the attached mesh's position/rotation
  42874. */
  42875. protected _update(): void;
  42876. /**
  42877. * Disposes of the gizmo
  42878. */
  42879. dispose(): void;
  42880. }
  42881. }
  42882. declare module BABYLON {
  42883. /**
  42884. * Single plane drag gizmo
  42885. */
  42886. export class PlaneDragGizmo extends Gizmo {
  42887. /**
  42888. * Drag behavior responsible for the gizmos dragging interactions
  42889. */
  42890. dragBehavior: PointerDragBehavior;
  42891. private _pointerObserver;
  42892. /**
  42893. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42894. */
  42895. snapDistance: number;
  42896. /**
  42897. * Event that fires each time the gizmo snaps to a new location.
  42898. * * snapDistance is the the change in distance
  42899. */
  42900. onSnapObservable: Observable<{
  42901. snapDistance: number;
  42902. }>;
  42903. private _plane;
  42904. private _coloredMaterial;
  42905. private _hoverMaterial;
  42906. private _isEnabled;
  42907. private _parent;
  42908. /** @hidden */
  42909. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42910. /** @hidden */
  42911. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42912. /**
  42913. * Creates a PlaneDragGizmo
  42914. * @param gizmoLayer The utility layer the gizmo will be added to
  42915. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42916. * @param color The color of the gizmo
  42917. */
  42918. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42919. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42920. /**
  42921. * If the gizmo is enabled
  42922. */
  42923. isEnabled: boolean;
  42924. /**
  42925. * Disposes of the gizmo
  42926. */
  42927. dispose(): void;
  42928. }
  42929. }
  42930. declare module BABYLON {
  42931. /**
  42932. * Gizmo that enables dragging a mesh along 3 axis
  42933. */
  42934. export class PositionGizmo extends Gizmo {
  42935. /**
  42936. * Internal gizmo used for interactions on the x axis
  42937. */
  42938. xGizmo: AxisDragGizmo;
  42939. /**
  42940. * Internal gizmo used for interactions on the y axis
  42941. */
  42942. yGizmo: AxisDragGizmo;
  42943. /**
  42944. * Internal gizmo used for interactions on the z axis
  42945. */
  42946. zGizmo: AxisDragGizmo;
  42947. /**
  42948. * Internal gizmo used for interactions on the yz plane
  42949. */
  42950. xPlaneGizmo: PlaneDragGizmo;
  42951. /**
  42952. * Internal gizmo used for interactions on the xz plane
  42953. */
  42954. yPlaneGizmo: PlaneDragGizmo;
  42955. /**
  42956. * Internal gizmo used for interactions on the xy plane
  42957. */
  42958. zPlaneGizmo: PlaneDragGizmo;
  42959. /**
  42960. * private variables
  42961. */
  42962. private _meshAttached;
  42963. private _updateGizmoRotationToMatchAttachedMesh;
  42964. private _snapDistance;
  42965. private _scaleRatio;
  42966. /** Fires an event when any of it's sub gizmos are dragged */
  42967. onDragStartObservable: Observable<unknown>;
  42968. /** Fires an event when any of it's sub gizmos are released from dragging */
  42969. onDragEndObservable: Observable<unknown>;
  42970. /**
  42971. * If set to true, planar drag is enabled
  42972. */
  42973. private _planarGizmoEnabled;
  42974. attachedMesh: Nullable<AbstractMesh>;
  42975. /**
  42976. * Creates a PositionGizmo
  42977. * @param gizmoLayer The utility layer the gizmo will be added to
  42978. */
  42979. constructor(gizmoLayer?: UtilityLayerRenderer);
  42980. /**
  42981. * If the planar drag gizmo is enabled
  42982. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42983. */
  42984. planarGizmoEnabled: boolean;
  42985. updateGizmoRotationToMatchAttachedMesh: boolean;
  42986. /**
  42987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42988. */
  42989. snapDistance: number;
  42990. /**
  42991. * Ratio for the scale of the gizmo (Default: 1)
  42992. */
  42993. scaleRatio: number;
  42994. /**
  42995. * Disposes of the gizmo
  42996. */
  42997. dispose(): void;
  42998. /**
  42999. * CustomMeshes are not supported by this gizmo
  43000. * @param mesh The mesh to replace the default mesh of the gizmo
  43001. */
  43002. setCustomMesh(mesh: Mesh): void;
  43003. }
  43004. }
  43005. declare module BABYLON {
  43006. /**
  43007. * Single axis drag gizmo
  43008. */
  43009. export class AxisDragGizmo extends Gizmo {
  43010. /**
  43011. * Drag behavior responsible for the gizmos dragging interactions
  43012. */
  43013. dragBehavior: PointerDragBehavior;
  43014. private _pointerObserver;
  43015. /**
  43016. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43017. */
  43018. snapDistance: number;
  43019. /**
  43020. * Event that fires each time the gizmo snaps to a new location.
  43021. * * snapDistance is the the change in distance
  43022. */
  43023. onSnapObservable: Observable<{
  43024. snapDistance: number;
  43025. }>;
  43026. private _isEnabled;
  43027. private _parent;
  43028. private _arrow;
  43029. private _coloredMaterial;
  43030. private _hoverMaterial;
  43031. /** @hidden */
  43032. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43033. /** @hidden */
  43034. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43035. /**
  43036. * Creates an AxisDragGizmo
  43037. * @param gizmoLayer The utility layer the gizmo will be added to
  43038. * @param dragAxis The axis which the gizmo will be able to drag on
  43039. * @param color The color of the gizmo
  43040. */
  43041. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43043. /**
  43044. * If the gizmo is enabled
  43045. */
  43046. isEnabled: boolean;
  43047. /**
  43048. * Disposes of the gizmo
  43049. */
  43050. dispose(): void;
  43051. }
  43052. }
  43053. declare module BABYLON.Debug {
  43054. /**
  43055. * The Axes viewer will show 3 axes in a specific point in space
  43056. */
  43057. export class AxesViewer {
  43058. private _xAxis;
  43059. private _yAxis;
  43060. private _zAxis;
  43061. private _scaleLinesFactor;
  43062. private _instanced;
  43063. /**
  43064. * Gets the hosting scene
  43065. */
  43066. scene: Scene;
  43067. /**
  43068. * Gets or sets a number used to scale line length
  43069. */
  43070. scaleLines: number;
  43071. /** Gets the node hierarchy used to render x-axis */
  43072. readonly xAxis: TransformNode;
  43073. /** Gets the node hierarchy used to render y-axis */
  43074. readonly yAxis: TransformNode;
  43075. /** Gets the node hierarchy used to render z-axis */
  43076. readonly zAxis: TransformNode;
  43077. /**
  43078. * Creates a new AxesViewer
  43079. * @param scene defines the hosting scene
  43080. * @param scaleLines defines a number used to scale line length (1 by default)
  43081. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43082. * @param xAxis defines the node hierarchy used to render the x-axis
  43083. * @param yAxis defines the node hierarchy used to render the y-axis
  43084. * @param zAxis defines the node hierarchy used to render the z-axis
  43085. */
  43086. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43087. /**
  43088. * Force the viewer to update
  43089. * @param position defines the position of the viewer
  43090. * @param xaxis defines the x axis of the viewer
  43091. * @param yaxis defines the y axis of the viewer
  43092. * @param zaxis defines the z axis of the viewer
  43093. */
  43094. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43095. /**
  43096. * Creates an instance of this axes viewer.
  43097. * @returns a new axes viewer with instanced meshes
  43098. */
  43099. createInstance(): AxesViewer;
  43100. /** Releases resources */
  43101. dispose(): void;
  43102. private static _SetRenderingGroupId;
  43103. }
  43104. }
  43105. declare module BABYLON.Debug {
  43106. /**
  43107. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43108. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43109. */
  43110. export class BoneAxesViewer extends AxesViewer {
  43111. /**
  43112. * Gets or sets the target mesh where to display the axes viewer
  43113. */
  43114. mesh: Nullable<Mesh>;
  43115. /**
  43116. * Gets or sets the target bone where to display the axes viewer
  43117. */
  43118. bone: Nullable<Bone>;
  43119. /** Gets current position */
  43120. pos: Vector3;
  43121. /** Gets direction of X axis */
  43122. xaxis: Vector3;
  43123. /** Gets direction of Y axis */
  43124. yaxis: Vector3;
  43125. /** Gets direction of Z axis */
  43126. zaxis: Vector3;
  43127. /**
  43128. * Creates a new BoneAxesViewer
  43129. * @param scene defines the hosting scene
  43130. * @param bone defines the target bone
  43131. * @param mesh defines the target mesh
  43132. * @param scaleLines defines a scaling factor for line length (1 by default)
  43133. */
  43134. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43135. /**
  43136. * Force the viewer to update
  43137. */
  43138. update(): void;
  43139. /** Releases resources */
  43140. dispose(): void;
  43141. }
  43142. }
  43143. declare module BABYLON {
  43144. /**
  43145. * Interface used to define scene explorer extensibility option
  43146. */
  43147. export interface IExplorerExtensibilityOption {
  43148. /**
  43149. * Define the option label
  43150. */
  43151. label: string;
  43152. /**
  43153. * Defines the action to execute on click
  43154. */
  43155. action: (entity: any) => void;
  43156. }
  43157. /**
  43158. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43159. */
  43160. export interface IExplorerExtensibilityGroup {
  43161. /**
  43162. * Defines a predicate to test if a given type mut be extended
  43163. */
  43164. predicate: (entity: any) => boolean;
  43165. /**
  43166. * Gets the list of options added to a type
  43167. */
  43168. entries: IExplorerExtensibilityOption[];
  43169. }
  43170. /**
  43171. * Interface used to define the options to use to create the Inspector
  43172. */
  43173. export interface IInspectorOptions {
  43174. /**
  43175. * Display in overlay mode (default: false)
  43176. */
  43177. overlay?: boolean;
  43178. /**
  43179. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43180. */
  43181. globalRoot?: HTMLElement;
  43182. /**
  43183. * Display the Scene explorer
  43184. */
  43185. showExplorer?: boolean;
  43186. /**
  43187. * Display the property inspector
  43188. */
  43189. showInspector?: boolean;
  43190. /**
  43191. * Display in embed mode (both panes on the right)
  43192. */
  43193. embedMode?: boolean;
  43194. /**
  43195. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43196. */
  43197. handleResize?: boolean;
  43198. /**
  43199. * Allow the panes to popup (default: true)
  43200. */
  43201. enablePopup?: boolean;
  43202. /**
  43203. * Allow the panes to be closed by users (default: true)
  43204. */
  43205. enableClose?: boolean;
  43206. /**
  43207. * Optional list of extensibility entries
  43208. */
  43209. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43210. /**
  43211. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43212. */
  43213. inspectorURL?: string;
  43214. }
  43215. interface Scene {
  43216. /**
  43217. * @hidden
  43218. * Backing field
  43219. */
  43220. _debugLayer: DebugLayer;
  43221. /**
  43222. * Gets the debug layer (aka Inspector) associated with the scene
  43223. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43224. */
  43225. debugLayer: DebugLayer;
  43226. }
  43227. /**
  43228. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43229. * what is happening in your scene
  43230. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43231. */
  43232. export class DebugLayer {
  43233. /**
  43234. * Define the url to get the inspector script from.
  43235. * By default it uses the babylonjs CDN.
  43236. * @ignoreNaming
  43237. */
  43238. static InspectorURL: string;
  43239. private _scene;
  43240. private BJSINSPECTOR;
  43241. private _onPropertyChangedObservable?;
  43242. /**
  43243. * Observable triggered when a property is changed through the inspector.
  43244. */
  43245. readonly onPropertyChangedObservable: any;
  43246. /**
  43247. * Instantiates a new debug layer.
  43248. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43249. * what is happening in your scene
  43250. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43251. * @param scene Defines the scene to inspect
  43252. */
  43253. constructor(scene: Scene);
  43254. /** Creates the inspector window. */
  43255. private _createInspector;
  43256. /**
  43257. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43258. * @param entity defines the entity to select
  43259. * @param lineContainerTitle defines the specific block to highlight
  43260. */
  43261. select(entity: any, lineContainerTitle?: string): void;
  43262. /** Get the inspector from bundle or global */
  43263. private _getGlobalInspector;
  43264. /**
  43265. * Get if the inspector is visible or not.
  43266. * @returns true if visible otherwise, false
  43267. */
  43268. isVisible(): boolean;
  43269. /**
  43270. * Hide the inspector and close its window.
  43271. */
  43272. hide(): void;
  43273. /**
  43274. * Launch the debugLayer.
  43275. * @param config Define the configuration of the inspector
  43276. * @return a promise fulfilled when the debug layer is visible
  43277. */
  43278. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43279. }
  43280. }
  43281. declare module BABYLON {
  43282. /**
  43283. * Class containing static functions to help procedurally build meshes
  43284. */
  43285. export class BoxBuilder {
  43286. /**
  43287. * Creates a box mesh
  43288. * * The parameter `size` sets the size (float) of each box side (default 1)
  43289. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43290. * * 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)
  43291. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43293. * * 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
  43294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43295. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43296. * @param name defines the name of the mesh
  43297. * @param options defines the options used to create the mesh
  43298. * @param scene defines the hosting scene
  43299. * @returns the box mesh
  43300. */
  43301. static CreateBox(name: string, options: {
  43302. size?: number;
  43303. width?: number;
  43304. height?: number;
  43305. depth?: number;
  43306. faceUV?: Vector4[];
  43307. faceColors?: Color4[];
  43308. sideOrientation?: number;
  43309. frontUVs?: Vector4;
  43310. backUVs?: Vector4;
  43311. wrap?: boolean;
  43312. topBaseAt?: number;
  43313. bottomBaseAt?: number;
  43314. updatable?: boolean;
  43315. }, scene?: Nullable<Scene>): Mesh;
  43316. }
  43317. }
  43318. declare module BABYLON {
  43319. /**
  43320. * Class containing static functions to help procedurally build meshes
  43321. */
  43322. export class SphereBuilder {
  43323. /**
  43324. * Creates a sphere mesh
  43325. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43326. * * 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`)
  43327. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43328. * * 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
  43329. * * 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)
  43330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43331. * * 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
  43332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43333. * @param name defines the name of the mesh
  43334. * @param options defines the options used to create the mesh
  43335. * @param scene defines the hosting scene
  43336. * @returns the sphere mesh
  43337. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43338. */
  43339. static CreateSphere(name: string, options: {
  43340. segments?: number;
  43341. diameter?: number;
  43342. diameterX?: number;
  43343. diameterY?: number;
  43344. diameterZ?: number;
  43345. arc?: number;
  43346. slice?: number;
  43347. sideOrientation?: number;
  43348. frontUVs?: Vector4;
  43349. backUVs?: Vector4;
  43350. updatable?: boolean;
  43351. }, scene?: Nullable<Scene>): Mesh;
  43352. }
  43353. }
  43354. declare module BABYLON.Debug {
  43355. /**
  43356. * Used to show the physics impostor around the specific mesh
  43357. */
  43358. export class PhysicsViewer {
  43359. /** @hidden */
  43360. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43361. /** @hidden */
  43362. protected _meshes: Array<Nullable<AbstractMesh>>;
  43363. /** @hidden */
  43364. protected _scene: Nullable<Scene>;
  43365. /** @hidden */
  43366. protected _numMeshes: number;
  43367. /** @hidden */
  43368. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43369. private _renderFunction;
  43370. private _utilityLayer;
  43371. private _debugBoxMesh;
  43372. private _debugSphereMesh;
  43373. private _debugCylinderMesh;
  43374. private _debugMaterial;
  43375. private _debugMeshMeshes;
  43376. /**
  43377. * Creates a new PhysicsViewer
  43378. * @param scene defines the hosting scene
  43379. */
  43380. constructor(scene: Scene);
  43381. /** @hidden */
  43382. protected _updateDebugMeshes(): void;
  43383. /**
  43384. * Renders a specified physic impostor
  43385. * @param impostor defines the impostor to render
  43386. * @param targetMesh defines the mesh represented by the impostor
  43387. * @returns the new debug mesh used to render the impostor
  43388. */
  43389. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43390. /**
  43391. * Hides a specified physic impostor
  43392. * @param impostor defines the impostor to hide
  43393. */
  43394. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43395. private _getDebugMaterial;
  43396. private _getDebugBoxMesh;
  43397. private _getDebugSphereMesh;
  43398. private _getDebugCylinderMesh;
  43399. private _getDebugMeshMesh;
  43400. private _getDebugMesh;
  43401. /** Releases all resources */
  43402. dispose(): void;
  43403. }
  43404. }
  43405. declare module BABYLON {
  43406. /**
  43407. * Class containing static functions to help procedurally build meshes
  43408. */
  43409. export class LinesBuilder {
  43410. /**
  43411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43412. * * 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
  43413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43418. * * 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
  43419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43422. * @param name defines the name of the new line system
  43423. * @param options defines the options used to create the line system
  43424. * @param scene defines the hosting scene
  43425. * @returns a new line system mesh
  43426. */
  43427. static CreateLineSystem(name: string, options: {
  43428. lines: Vector3[][];
  43429. updatable?: boolean;
  43430. instance?: Nullable<LinesMesh>;
  43431. colors?: Nullable<Color4[][]>;
  43432. useVertexAlpha?: boolean;
  43433. }, scene: Nullable<Scene>): LinesMesh;
  43434. /**
  43435. * Creates a line mesh
  43436. * 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
  43437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43438. * * The parameter `points` is an array successive Vector3
  43439. * * 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
  43440. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43442. * * When updating an instance, remember that only point positions can change, not the number of points
  43443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43445. * @param name defines the name of the new line system
  43446. * @param options defines the options used to create the line system
  43447. * @param scene defines the hosting scene
  43448. * @returns a new line mesh
  43449. */
  43450. static CreateLines(name: string, options: {
  43451. points: Vector3[];
  43452. updatable?: boolean;
  43453. instance?: Nullable<LinesMesh>;
  43454. colors?: Color4[];
  43455. useVertexAlpha?: boolean;
  43456. }, scene?: Nullable<Scene>): LinesMesh;
  43457. /**
  43458. * Creates a dashed line mesh
  43459. * * 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
  43460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43461. * * The parameter `points` is an array successive Vector3
  43462. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43463. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43464. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43465. * * 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
  43466. * * When updating an instance, remember that only point positions can change, not the number of points
  43467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43468. * @param name defines the name of the mesh
  43469. * @param options defines the options used to create the mesh
  43470. * @param scene defines the hosting scene
  43471. * @returns the dashed line mesh
  43472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43473. */
  43474. static CreateDashedLines(name: string, options: {
  43475. points: Vector3[];
  43476. dashSize?: number;
  43477. gapSize?: number;
  43478. dashNb?: number;
  43479. updatable?: boolean;
  43480. instance?: LinesMesh;
  43481. }, scene?: Nullable<Scene>): LinesMesh;
  43482. }
  43483. }
  43484. declare module BABYLON {
  43485. /**
  43486. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43487. * in order to better appreciate the issue one might have.
  43488. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43489. */
  43490. export class RayHelper {
  43491. /**
  43492. * Defines the ray we are currently tryin to visualize.
  43493. */
  43494. ray: Nullable<Ray>;
  43495. private _renderPoints;
  43496. private _renderLine;
  43497. private _renderFunction;
  43498. private _scene;
  43499. private _updateToMeshFunction;
  43500. private _attachedToMesh;
  43501. private _meshSpaceDirection;
  43502. private _meshSpaceOrigin;
  43503. /**
  43504. * Helper function to create a colored helper in a scene in one line.
  43505. * @param ray Defines the ray we are currently tryin to visualize
  43506. * @param scene Defines the scene the ray is used in
  43507. * @param color Defines the color we want to see the ray in
  43508. * @returns The newly created ray helper.
  43509. */
  43510. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43511. /**
  43512. * Instantiate a new ray helper.
  43513. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43514. * in order to better appreciate the issue one might have.
  43515. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43516. * @param ray Defines the ray we are currently tryin to visualize
  43517. */
  43518. constructor(ray: Ray);
  43519. /**
  43520. * Shows the ray we are willing to debug.
  43521. * @param scene Defines the scene the ray needs to be rendered in
  43522. * @param color Defines the color the ray needs to be rendered in
  43523. */
  43524. show(scene: Scene, color?: Color3): void;
  43525. /**
  43526. * Hides the ray we are debugging.
  43527. */
  43528. hide(): void;
  43529. private _render;
  43530. /**
  43531. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43532. * @param mesh Defines the mesh we want the helper attached to
  43533. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43534. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43535. * @param length Defines the length of the ray
  43536. */
  43537. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43538. /**
  43539. * Detach the ray helper from the mesh it has previously been attached to.
  43540. */
  43541. detachFromMesh(): void;
  43542. private _updateToMesh;
  43543. /**
  43544. * Dispose the helper and release its associated resources.
  43545. */
  43546. dispose(): void;
  43547. }
  43548. }
  43549. declare module BABYLON.Debug {
  43550. /**
  43551. * Class used to render a debug view of a given skeleton
  43552. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43553. */
  43554. export class SkeletonViewer {
  43555. /** defines the skeleton to render */
  43556. skeleton: Skeleton;
  43557. /** defines the mesh attached to the skeleton */
  43558. mesh: AbstractMesh;
  43559. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43560. autoUpdateBonesMatrices: boolean;
  43561. /** defines the rendering group id to use with the viewer */
  43562. renderingGroupId: number;
  43563. /** Gets or sets the color used to render the skeleton */
  43564. color: Color3;
  43565. private _scene;
  43566. private _debugLines;
  43567. private _debugMesh;
  43568. private _isEnabled;
  43569. private _renderFunction;
  43570. private _utilityLayer;
  43571. /**
  43572. * Returns the mesh used to render the bones
  43573. */
  43574. readonly debugMesh: Nullable<LinesMesh>;
  43575. /**
  43576. * Creates a new SkeletonViewer
  43577. * @param skeleton defines the skeleton to render
  43578. * @param mesh defines the mesh attached to the skeleton
  43579. * @param scene defines the hosting scene
  43580. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43581. * @param renderingGroupId defines the rendering group id to use with the viewer
  43582. */
  43583. constructor(
  43584. /** defines the skeleton to render */
  43585. skeleton: Skeleton,
  43586. /** defines the mesh attached to the skeleton */
  43587. mesh: AbstractMesh, scene: Scene,
  43588. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43589. autoUpdateBonesMatrices?: boolean,
  43590. /** defines the rendering group id to use with the viewer */
  43591. renderingGroupId?: number);
  43592. /** Gets or sets a boolean indicating if the viewer is enabled */
  43593. isEnabled: boolean;
  43594. private _getBonePosition;
  43595. private _getLinesForBonesWithLength;
  43596. private _getLinesForBonesNoLength;
  43597. /** Update the viewer to sync with current skeleton state */
  43598. update(): void;
  43599. /** Release associated resources */
  43600. dispose(): void;
  43601. }
  43602. }
  43603. declare module BABYLON {
  43604. /**
  43605. * Options to create the null engine
  43606. */
  43607. export class NullEngineOptions {
  43608. /**
  43609. * Render width (Default: 512)
  43610. */
  43611. renderWidth: number;
  43612. /**
  43613. * Render height (Default: 256)
  43614. */
  43615. renderHeight: number;
  43616. /**
  43617. * Texture size (Default: 512)
  43618. */
  43619. textureSize: number;
  43620. /**
  43621. * If delta time between frames should be constant
  43622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43623. */
  43624. deterministicLockstep: boolean;
  43625. /**
  43626. * Maximum about of steps between frames (Default: 4)
  43627. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43628. */
  43629. lockstepMaxSteps: number;
  43630. }
  43631. /**
  43632. * The null engine class provides support for headless version of babylon.js.
  43633. * This can be used in server side scenario or for testing purposes
  43634. */
  43635. export class NullEngine extends Engine {
  43636. private _options;
  43637. /**
  43638. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43640. * @returns true if engine is in deterministic lock step mode
  43641. */
  43642. isDeterministicLockStep(): boolean;
  43643. /**
  43644. * Gets the max steps when engine is running in deterministic lock step
  43645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43646. * @returns the max steps
  43647. */
  43648. getLockstepMaxSteps(): number;
  43649. /**
  43650. * Gets the current hardware scaling level.
  43651. * By default the hardware scaling level is computed from the window device ratio.
  43652. * 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.
  43653. * @returns a number indicating the current hardware scaling level
  43654. */
  43655. getHardwareScalingLevel(): number;
  43656. constructor(options?: NullEngineOptions);
  43657. /**
  43658. * Creates a vertex buffer
  43659. * @param vertices the data for the vertex buffer
  43660. * @returns the new WebGL static buffer
  43661. */
  43662. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43663. /**
  43664. * Creates a new index buffer
  43665. * @param indices defines the content of the index buffer
  43666. * @param updatable defines if the index buffer must be updatable
  43667. * @returns a new webGL buffer
  43668. */
  43669. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43670. /**
  43671. * Clear the current render buffer or the current render target (if any is set up)
  43672. * @param color defines the color to use
  43673. * @param backBuffer defines if the back buffer must be cleared
  43674. * @param depth defines if the depth buffer must be cleared
  43675. * @param stencil defines if the stencil buffer must be cleared
  43676. */
  43677. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43678. /**
  43679. * Gets the current render width
  43680. * @param useScreen defines if screen size must be used (or the current render target if any)
  43681. * @returns a number defining the current render width
  43682. */
  43683. getRenderWidth(useScreen?: boolean): number;
  43684. /**
  43685. * Gets the current render height
  43686. * @param useScreen defines if screen size must be used (or the current render target if any)
  43687. * @returns a number defining the current render height
  43688. */
  43689. getRenderHeight(useScreen?: boolean): number;
  43690. /**
  43691. * Set the WebGL's viewport
  43692. * @param viewport defines the viewport element to be used
  43693. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43694. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43695. */
  43696. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43698. /**
  43699. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43700. * @param pipelineContext defines the pipeline context to use
  43701. * @param uniformsNames defines the list of uniform names
  43702. * @returns an array of webGL uniform locations
  43703. */
  43704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43705. /**
  43706. * Gets the lsit of active attributes for a given webGL program
  43707. * @param pipelineContext defines the pipeline context to use
  43708. * @param attributesNames defines the list of attribute names to get
  43709. * @returns an array of indices indicating the offset of each attribute
  43710. */
  43711. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43712. /**
  43713. * Binds an effect to the webGL context
  43714. * @param effect defines the effect to bind
  43715. */
  43716. bindSamplers(effect: Effect): void;
  43717. /**
  43718. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43719. * @param effect defines the effect to activate
  43720. */
  43721. enableEffect(effect: Effect): void;
  43722. /**
  43723. * Set various states to the webGL context
  43724. * @param culling defines backface culling state
  43725. * @param zOffset defines the value to apply to zOffset (0 by default)
  43726. * @param force defines if states must be applied even if cache is up to date
  43727. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43728. */
  43729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43730. /**
  43731. * Set the value of an uniform to an array of int32
  43732. * @param uniform defines the webGL uniform location where to store the value
  43733. * @param array defines the array of int32 to store
  43734. */
  43735. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43736. /**
  43737. * Set the value of an uniform to an array of int32 (stored as vec2)
  43738. * @param uniform defines the webGL uniform location where to store the value
  43739. * @param array defines the array of int32 to store
  43740. */
  43741. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43742. /**
  43743. * Set the value of an uniform to an array of int32 (stored as vec3)
  43744. * @param uniform defines the webGL uniform location where to store the value
  43745. * @param array defines the array of int32 to store
  43746. */
  43747. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43748. /**
  43749. * Set the value of an uniform to an array of int32 (stored as vec4)
  43750. * @param uniform defines the webGL uniform location where to store the value
  43751. * @param array defines the array of int32 to store
  43752. */
  43753. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43754. /**
  43755. * Set the value of an uniform to an array of float32
  43756. * @param uniform defines the webGL uniform location where to store the value
  43757. * @param array defines the array of float32 to store
  43758. */
  43759. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43760. /**
  43761. * Set the value of an uniform to an array of float32 (stored as vec2)
  43762. * @param uniform defines the webGL uniform location where to store the value
  43763. * @param array defines the array of float32 to store
  43764. */
  43765. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43766. /**
  43767. * Set the value of an uniform to an array of float32 (stored as vec3)
  43768. * @param uniform defines the webGL uniform location where to store the value
  43769. * @param array defines the array of float32 to store
  43770. */
  43771. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43772. /**
  43773. * Set the value of an uniform to an array of float32 (stored as vec4)
  43774. * @param uniform defines the webGL uniform location where to store the value
  43775. * @param array defines the array of float32 to store
  43776. */
  43777. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43778. /**
  43779. * Set the value of an uniform to an array of number
  43780. * @param uniform defines the webGL uniform location where to store the value
  43781. * @param array defines the array of number to store
  43782. */
  43783. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43784. /**
  43785. * Set the value of an uniform to an array of number (stored as vec2)
  43786. * @param uniform defines the webGL uniform location where to store the value
  43787. * @param array defines the array of number to store
  43788. */
  43789. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43790. /**
  43791. * Set the value of an uniform to an array of number (stored as vec3)
  43792. * @param uniform defines the webGL uniform location where to store the value
  43793. * @param array defines the array of number to store
  43794. */
  43795. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43796. /**
  43797. * Set the value of an uniform to an array of number (stored as vec4)
  43798. * @param uniform defines the webGL uniform location where to store the value
  43799. * @param array defines the array of number to store
  43800. */
  43801. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43802. /**
  43803. * Set the value of an uniform to an array of float32 (stored as matrices)
  43804. * @param uniform defines the webGL uniform location where to store the value
  43805. * @param matrices defines the array of float32 to store
  43806. */
  43807. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43808. /**
  43809. * Set the value of an uniform to a matrix (3x3)
  43810. * @param uniform defines the webGL uniform location where to store the value
  43811. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43812. */
  43813. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43814. /**
  43815. * Set the value of an uniform to a matrix (2x2)
  43816. * @param uniform defines the webGL uniform location where to store the value
  43817. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43818. */
  43819. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43820. /**
  43821. * Set the value of an uniform to a number (float)
  43822. * @param uniform defines the webGL uniform location where to store the value
  43823. * @param value defines the float number to store
  43824. */
  43825. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43826. /**
  43827. * Set the value of an uniform to a vec2
  43828. * @param uniform defines the webGL uniform location where to store the value
  43829. * @param x defines the 1st component of the value
  43830. * @param y defines the 2nd component of the value
  43831. */
  43832. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43833. /**
  43834. * Set the value of an uniform to a vec3
  43835. * @param uniform defines the webGL uniform location where to store the value
  43836. * @param x defines the 1st component of the value
  43837. * @param y defines the 2nd component of the value
  43838. * @param z defines the 3rd component of the value
  43839. */
  43840. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43841. /**
  43842. * Set the value of an uniform to a boolean
  43843. * @param uniform defines the webGL uniform location where to store the value
  43844. * @param bool defines the boolean to store
  43845. */
  43846. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43847. /**
  43848. * Set the value of an uniform to a vec4
  43849. * @param uniform defines the webGL uniform location where to store the value
  43850. * @param x defines the 1st component of the value
  43851. * @param y defines the 2nd component of the value
  43852. * @param z defines the 3rd component of the value
  43853. * @param w defines the 4th component of the value
  43854. */
  43855. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43856. /**
  43857. * Sets the current alpha mode
  43858. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43859. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43861. */
  43862. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43863. /**
  43864. * Bind webGl buffers directly to the webGL context
  43865. * @param vertexBuffers defines the vertex buffer to bind
  43866. * @param indexBuffer defines the index buffer to bind
  43867. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43868. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43869. * @param effect defines the effect associated with the vertex buffer
  43870. */
  43871. bindBuffers(vertexBuffers: {
  43872. [key: string]: VertexBuffer;
  43873. }, indexBuffer: DataBuffer, effect: Effect): void;
  43874. /**
  43875. * Force the entire cache to be cleared
  43876. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43877. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43878. */
  43879. wipeCaches(bruteForce?: boolean): void;
  43880. /**
  43881. * Send a draw order
  43882. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43883. * @param indexStart defines the starting index
  43884. * @param indexCount defines the number of index to draw
  43885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43886. */
  43887. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43888. /**
  43889. * Draw a list of indexed primitives
  43890. * @param fillMode defines the primitive to use
  43891. * @param indexStart defines the starting index
  43892. * @param indexCount defines the number of index to draw
  43893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43894. */
  43895. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43896. /**
  43897. * Draw a list of unindexed primitives
  43898. * @param fillMode defines the primitive to use
  43899. * @param verticesStart defines the index of first vertex to draw
  43900. * @param verticesCount defines the count of vertices to draw
  43901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43902. */
  43903. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43904. /** @hidden */
  43905. _createTexture(): WebGLTexture;
  43906. /** @hidden */
  43907. _releaseTexture(texture: InternalTexture): void;
  43908. /**
  43909. * Usually called from Texture.ts.
  43910. * Passed information to create a WebGLTexture
  43911. * @param urlArg defines a value which contains one of the following:
  43912. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43913. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43914. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43915. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43916. * @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)
  43917. * @param scene needed for loading to the correct scene
  43918. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43919. * @param onLoad optional callback to be called upon successful completion
  43920. * @param onError optional callback to be called upon failure
  43921. * @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
  43922. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43923. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43924. * @param forcedExtension defines the extension to use to pick the right loader
  43925. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43926. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43927. */
  43928. 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;
  43929. /**
  43930. * Creates a new render target texture
  43931. * @param size defines the size of the texture
  43932. * @param options defines the options used to create the texture
  43933. * @returns a new render target texture stored in an InternalTexture
  43934. */
  43935. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43936. /**
  43937. * Update the sampling mode of a given texture
  43938. * @param samplingMode defines the required sampling mode
  43939. * @param texture defines the texture to update
  43940. */
  43941. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43942. /**
  43943. * Binds the frame buffer to the specified texture.
  43944. * @param texture The texture to render to or null for the default canvas
  43945. * @param faceIndex The face of the texture to render to in case of cube texture
  43946. * @param requiredWidth The width of the target to render to
  43947. * @param requiredHeight The height of the target to render to
  43948. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43949. * @param depthStencilTexture The depth stencil texture to use to render
  43950. * @param lodLevel defines le lod level to bind to the frame buffer
  43951. */
  43952. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43953. /**
  43954. * Unbind the current render target texture from the webGL context
  43955. * @param texture defines the render target texture to unbind
  43956. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43957. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43958. */
  43959. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43960. /**
  43961. * Creates a dynamic vertex buffer
  43962. * @param vertices the data for the dynamic vertex buffer
  43963. * @returns the new WebGL dynamic buffer
  43964. */
  43965. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43966. /**
  43967. * Update the content of a dynamic texture
  43968. * @param texture defines the texture to update
  43969. * @param canvas defines the canvas containing the source
  43970. * @param invertY defines if data must be stored with Y axis inverted
  43971. * @param premulAlpha defines if alpha is stored as premultiplied
  43972. * @param format defines the format of the data
  43973. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43974. */
  43975. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43976. /**
  43977. * Gets a boolean indicating if all created effects are ready
  43978. * @returns true if all effects are ready
  43979. */
  43980. areAllEffectsReady(): boolean;
  43981. /**
  43982. * @hidden
  43983. * Get the current error code of the webGL context
  43984. * @returns the error code
  43985. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43986. */
  43987. getError(): number;
  43988. /** @hidden */
  43989. _getUnpackAlignement(): number;
  43990. /** @hidden */
  43991. _unpackFlipY(value: boolean): void;
  43992. /**
  43993. * Update a dynamic index buffer
  43994. * @param indexBuffer defines the target index buffer
  43995. * @param indices defines the data to update
  43996. * @param offset defines the offset in the target index buffer where update should start
  43997. */
  43998. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43999. /**
  44000. * Updates a dynamic vertex buffer.
  44001. * @param vertexBuffer the vertex buffer to update
  44002. * @param vertices the data used to update the vertex buffer
  44003. * @param byteOffset the byte offset of the data (optional)
  44004. * @param byteLength the byte length of the data (optional)
  44005. */
  44006. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44007. /** @hidden */
  44008. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44009. /** @hidden */
  44010. _bindTexture(channel: number, texture: InternalTexture): void;
  44011. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44012. /**
  44013. * 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
  44014. */
  44015. releaseEffects(): void;
  44016. displayLoadingUI(): void;
  44017. hideLoadingUI(): void;
  44018. /** @hidden */
  44019. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44020. /** @hidden */
  44021. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44022. /** @hidden */
  44023. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44024. /** @hidden */
  44025. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44026. }
  44027. }
  44028. declare module BABYLON {
  44029. /** @hidden */
  44030. export class _OcclusionDataStorage {
  44031. /** @hidden */
  44032. occlusionInternalRetryCounter: number;
  44033. /** @hidden */
  44034. isOcclusionQueryInProgress: boolean;
  44035. /** @hidden */
  44036. isOccluded: boolean;
  44037. /** @hidden */
  44038. occlusionRetryCount: number;
  44039. /** @hidden */
  44040. occlusionType: number;
  44041. /** @hidden */
  44042. occlusionQueryAlgorithmType: number;
  44043. }
  44044. interface Engine {
  44045. /**
  44046. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44047. * @return the new query
  44048. */
  44049. createQuery(): WebGLQuery;
  44050. /**
  44051. * Delete and release a webGL query
  44052. * @param query defines the query to delete
  44053. * @return the current engine
  44054. */
  44055. deleteQuery(query: WebGLQuery): Engine;
  44056. /**
  44057. * Check if a given query has resolved and got its value
  44058. * @param query defines the query to check
  44059. * @returns true if the query got its value
  44060. */
  44061. isQueryResultAvailable(query: WebGLQuery): boolean;
  44062. /**
  44063. * Gets the value of a given query
  44064. * @param query defines the query to check
  44065. * @returns the value of the query
  44066. */
  44067. getQueryResult(query: WebGLQuery): number;
  44068. /**
  44069. * Initiates an occlusion query
  44070. * @param algorithmType defines the algorithm to use
  44071. * @param query defines the query to use
  44072. * @returns the current engine
  44073. * @see http://doc.babylonjs.com/features/occlusionquery
  44074. */
  44075. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44076. /**
  44077. * Ends an occlusion query
  44078. * @see http://doc.babylonjs.com/features/occlusionquery
  44079. * @param algorithmType defines the algorithm to use
  44080. * @returns the current engine
  44081. */
  44082. endOcclusionQuery(algorithmType: number): Engine;
  44083. /**
  44084. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44085. * Please note that only one query can be issued at a time
  44086. * @returns a time token used to track the time span
  44087. */
  44088. startTimeQuery(): Nullable<_TimeToken>;
  44089. /**
  44090. * Ends a time query
  44091. * @param token defines the token used to measure the time span
  44092. * @returns the time spent (in ns)
  44093. */
  44094. endTimeQuery(token: _TimeToken): int;
  44095. /** @hidden */
  44096. _currentNonTimestampToken: Nullable<_TimeToken>;
  44097. /** @hidden */
  44098. _createTimeQuery(): WebGLQuery;
  44099. /** @hidden */
  44100. _deleteTimeQuery(query: WebGLQuery): void;
  44101. /** @hidden */
  44102. _getGlAlgorithmType(algorithmType: number): number;
  44103. /** @hidden */
  44104. _getTimeQueryResult(query: WebGLQuery): any;
  44105. /** @hidden */
  44106. _getTimeQueryAvailability(query: WebGLQuery): any;
  44107. }
  44108. interface AbstractMesh {
  44109. /**
  44110. * Backing filed
  44111. * @hidden
  44112. */
  44113. __occlusionDataStorage: _OcclusionDataStorage;
  44114. /**
  44115. * Access property
  44116. * @hidden
  44117. */
  44118. _occlusionDataStorage: _OcclusionDataStorage;
  44119. /**
  44120. * 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.
  44121. * The default value is -1 which means don't break the query and wait till the result
  44122. * @see http://doc.babylonjs.com/features/occlusionquery
  44123. */
  44124. occlusionRetryCount: number;
  44125. /**
  44126. * 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:
  44127. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44128. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44129. * * 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.
  44130. * @see http://doc.babylonjs.com/features/occlusionquery
  44131. */
  44132. occlusionType: number;
  44133. /**
  44134. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44135. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44136. * * 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.
  44137. * @see http://doc.babylonjs.com/features/occlusionquery
  44138. */
  44139. occlusionQueryAlgorithmType: number;
  44140. /**
  44141. * 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
  44142. * @see http://doc.babylonjs.com/features/occlusionquery
  44143. */
  44144. isOccluded: boolean;
  44145. /**
  44146. * Flag to check the progress status of the query
  44147. * @see http://doc.babylonjs.com/features/occlusionquery
  44148. */
  44149. isOcclusionQueryInProgress: boolean;
  44150. }
  44151. }
  44152. declare module BABYLON {
  44153. /** @hidden */
  44154. export var _forceTransformFeedbackToBundle: boolean;
  44155. interface Engine {
  44156. /**
  44157. * Creates a webGL transform feedback object
  44158. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44159. * @returns the webGL transform feedback object
  44160. */
  44161. createTransformFeedback(): WebGLTransformFeedback;
  44162. /**
  44163. * Delete a webGL transform feedback object
  44164. * @param value defines the webGL transform feedback object to delete
  44165. */
  44166. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44167. /**
  44168. * Bind a webGL transform feedback object to the webgl context
  44169. * @param value defines the webGL transform feedback object to bind
  44170. */
  44171. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44172. /**
  44173. * Begins a transform feedback operation
  44174. * @param usePoints defines if points or triangles must be used
  44175. */
  44176. beginTransformFeedback(usePoints: boolean): void;
  44177. /**
  44178. * Ends a transform feedback operation
  44179. */
  44180. endTransformFeedback(): void;
  44181. /**
  44182. * Specify the varyings to use with transform feedback
  44183. * @param program defines the associated webGL program
  44184. * @param value defines the list of strings representing the varying names
  44185. */
  44186. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44187. /**
  44188. * Bind a webGL buffer for a transform feedback operation
  44189. * @param value defines the webGL buffer to bind
  44190. */
  44191. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44192. }
  44193. }
  44194. declare module BABYLON {
  44195. /**
  44196. * Creation options of the multi render target texture.
  44197. */
  44198. export interface IMultiRenderTargetOptions {
  44199. /**
  44200. * Define if the texture needs to create mip maps after render.
  44201. */
  44202. generateMipMaps?: boolean;
  44203. /**
  44204. * Define the types of all the draw buffers we want to create
  44205. */
  44206. types?: number[];
  44207. /**
  44208. * Define the sampling modes of all the draw buffers we want to create
  44209. */
  44210. samplingModes?: number[];
  44211. /**
  44212. * Define if a depth buffer is required
  44213. */
  44214. generateDepthBuffer?: boolean;
  44215. /**
  44216. * Define if a stencil buffer is required
  44217. */
  44218. generateStencilBuffer?: boolean;
  44219. /**
  44220. * Define if a depth texture is required instead of a depth buffer
  44221. */
  44222. generateDepthTexture?: boolean;
  44223. /**
  44224. * Define the number of desired draw buffers
  44225. */
  44226. textureCount?: number;
  44227. /**
  44228. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44229. */
  44230. doNotChangeAspectRatio?: boolean;
  44231. /**
  44232. * Define the default type of the buffers we are creating
  44233. */
  44234. defaultType?: number;
  44235. }
  44236. /**
  44237. * A multi render target, like a render target provides the ability to render to a texture.
  44238. * Unlike the render target, it can render to several draw buffers in one draw.
  44239. * This is specially interesting in deferred rendering or for any effects requiring more than
  44240. * just one color from a single pass.
  44241. */
  44242. export class MultiRenderTarget extends RenderTargetTexture {
  44243. private _internalTextures;
  44244. private _textures;
  44245. private _multiRenderTargetOptions;
  44246. /**
  44247. * Get if draw buffers are currently supported by the used hardware and browser.
  44248. */
  44249. readonly isSupported: boolean;
  44250. /**
  44251. * Get the list of textures generated by the multi render target.
  44252. */
  44253. readonly textures: Texture[];
  44254. /**
  44255. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44256. */
  44257. readonly depthTexture: Texture;
  44258. /**
  44259. * Set the wrapping mode on U of all the textures we are rendering to.
  44260. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44261. */
  44262. wrapU: number;
  44263. /**
  44264. * Set the wrapping mode on V of all the textures we are rendering to.
  44265. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44266. */
  44267. wrapV: number;
  44268. /**
  44269. * Instantiate a new multi render target texture.
  44270. * A multi render target, like a render target provides the ability to render to a texture.
  44271. * Unlike the render target, it can render to several draw buffers in one draw.
  44272. * This is specially interesting in deferred rendering or for any effects requiring more than
  44273. * just one color from a single pass.
  44274. * @param name Define the name of the texture
  44275. * @param size Define the size of the buffers to render to
  44276. * @param count Define the number of target we are rendering into
  44277. * @param scene Define the scene the texture belongs to
  44278. * @param options Define the options used to create the multi render target
  44279. */
  44280. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44281. /** @hidden */
  44282. _rebuild(): void;
  44283. private _createInternalTextures;
  44284. private _createTextures;
  44285. /**
  44286. * Define the number of samples used if MSAA is enabled.
  44287. */
  44288. samples: number;
  44289. /**
  44290. * Resize all the textures in the multi render target.
  44291. * Be carrefull as it will recreate all the data in the new texture.
  44292. * @param size Define the new size
  44293. */
  44294. resize(size: any): void;
  44295. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44296. /**
  44297. * Dispose the render targets and their associated resources
  44298. */
  44299. dispose(): void;
  44300. /**
  44301. * Release all the underlying texture used as draw buffers.
  44302. */
  44303. releaseInternalTextures(): void;
  44304. }
  44305. }
  44306. declare module BABYLON {
  44307. interface ThinEngine {
  44308. /**
  44309. * Unbind a list of render target textures from the webGL context
  44310. * This is used only when drawBuffer extension or webGL2 are active
  44311. * @param textures defines the render target textures to unbind
  44312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44314. */
  44315. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44316. /**
  44317. * Create a multi render target texture
  44318. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44319. * @param size defines the size of the texture
  44320. * @param options defines the creation options
  44321. * @returns the cube texture as an InternalTexture
  44322. */
  44323. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44324. /**
  44325. * Update the sample count for a given multiple render target texture
  44326. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44327. * @param textures defines the textures to update
  44328. * @param samples defines the sample count to set
  44329. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44330. */
  44331. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44332. }
  44333. }
  44334. declare module BABYLON {
  44335. /** @hidden */
  44336. export var rgbdEncodePixelShader: {
  44337. name: string;
  44338. shader: string;
  44339. };
  44340. }
  44341. declare module BABYLON {
  44342. /** @hidden */
  44343. export var rgbdDecodePixelShader: {
  44344. name: string;
  44345. shader: string;
  44346. };
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * Raw texture data and descriptor sufficient for WebGL texture upload
  44351. */
  44352. export interface EnvironmentTextureInfo {
  44353. /**
  44354. * Version of the environment map
  44355. */
  44356. version: number;
  44357. /**
  44358. * Width of image
  44359. */
  44360. width: number;
  44361. /**
  44362. * Irradiance information stored in the file.
  44363. */
  44364. irradiance: any;
  44365. /**
  44366. * Specular information stored in the file.
  44367. */
  44368. specular: any;
  44369. }
  44370. /**
  44371. * Defines One Image in the file. It requires only the position in the file
  44372. * as well as the length.
  44373. */
  44374. interface BufferImageData {
  44375. /**
  44376. * Length of the image data.
  44377. */
  44378. length: number;
  44379. /**
  44380. * Position of the data from the null terminator delimiting the end of the JSON.
  44381. */
  44382. position: number;
  44383. }
  44384. /**
  44385. * Defines the specular data enclosed in the file.
  44386. * This corresponds to the version 1 of the data.
  44387. */
  44388. export interface EnvironmentTextureSpecularInfoV1 {
  44389. /**
  44390. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44391. */
  44392. specularDataPosition?: number;
  44393. /**
  44394. * This contains all the images data needed to reconstruct the cubemap.
  44395. */
  44396. mipmaps: Array<BufferImageData>;
  44397. /**
  44398. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44399. */
  44400. lodGenerationScale: number;
  44401. }
  44402. /**
  44403. * Sets of helpers addressing the serialization and deserialization of environment texture
  44404. * stored in a BabylonJS env file.
  44405. * Those files are usually stored as .env files.
  44406. */
  44407. export class EnvironmentTextureTools {
  44408. /**
  44409. * Magic number identifying the env file.
  44410. */
  44411. private static _MagicBytes;
  44412. /**
  44413. * Gets the environment info from an env file.
  44414. * @param data The array buffer containing the .env bytes.
  44415. * @returns the environment file info (the json header) if successfully parsed.
  44416. */
  44417. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44418. /**
  44419. * Creates an environment texture from a loaded cube texture.
  44420. * @param texture defines the cube texture to convert in env file
  44421. * @return a promise containing the environment data if succesfull.
  44422. */
  44423. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44424. /**
  44425. * Creates a JSON representation of the spherical data.
  44426. * @param texture defines the texture containing the polynomials
  44427. * @return the JSON representation of the spherical info
  44428. */
  44429. private static _CreateEnvTextureIrradiance;
  44430. /**
  44431. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44432. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44433. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44434. * @return the views described by info providing access to the underlying buffer
  44435. */
  44436. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44437. /**
  44438. * Uploads the texture info contained in the env file to the GPU.
  44439. * @param texture defines the internal texture to upload to
  44440. * @param arrayBuffer defines the buffer cotaining the data to load
  44441. * @param info defines the texture info retrieved through the GetEnvInfo method
  44442. * @returns a promise
  44443. */
  44444. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44445. /**
  44446. * Uploads the levels of image data to the GPU.
  44447. * @param texture defines the internal texture to upload to
  44448. * @param imageData defines the array buffer views of image data [mipmap][face]
  44449. * @returns a promise
  44450. */
  44451. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44452. /**
  44453. * Uploads spherical polynomials information to the texture.
  44454. * @param texture defines the texture we are trying to upload the information to
  44455. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44456. */
  44457. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44458. /** @hidden */
  44459. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44460. }
  44461. }
  44462. declare module BABYLON {
  44463. /**
  44464. * Contains position and normal vectors for a vertex
  44465. */
  44466. export class PositionNormalVertex {
  44467. /** the position of the vertex (defaut: 0,0,0) */
  44468. position: Vector3;
  44469. /** the normal of the vertex (defaut: 0,1,0) */
  44470. normal: Vector3;
  44471. /**
  44472. * Creates a PositionNormalVertex
  44473. * @param position the position of the vertex (defaut: 0,0,0)
  44474. * @param normal the normal of the vertex (defaut: 0,1,0)
  44475. */
  44476. constructor(
  44477. /** the position of the vertex (defaut: 0,0,0) */
  44478. position?: Vector3,
  44479. /** the normal of the vertex (defaut: 0,1,0) */
  44480. normal?: Vector3);
  44481. /**
  44482. * Clones the PositionNormalVertex
  44483. * @returns the cloned PositionNormalVertex
  44484. */
  44485. clone(): PositionNormalVertex;
  44486. }
  44487. /**
  44488. * Contains position, normal and uv vectors for a vertex
  44489. */
  44490. export class PositionNormalTextureVertex {
  44491. /** the position of the vertex (defaut: 0,0,0) */
  44492. position: Vector3;
  44493. /** the normal of the vertex (defaut: 0,1,0) */
  44494. normal: Vector3;
  44495. /** the uv of the vertex (default: 0,0) */
  44496. uv: Vector2;
  44497. /**
  44498. * Creates a PositionNormalTextureVertex
  44499. * @param position the position of the vertex (defaut: 0,0,0)
  44500. * @param normal the normal of the vertex (defaut: 0,1,0)
  44501. * @param uv the uv of the vertex (default: 0,0)
  44502. */
  44503. constructor(
  44504. /** the position of the vertex (defaut: 0,0,0) */
  44505. position?: Vector3,
  44506. /** the normal of the vertex (defaut: 0,1,0) */
  44507. normal?: Vector3,
  44508. /** the uv of the vertex (default: 0,0) */
  44509. uv?: Vector2);
  44510. /**
  44511. * Clones the PositionNormalTextureVertex
  44512. * @returns the cloned PositionNormalTextureVertex
  44513. */
  44514. clone(): PositionNormalTextureVertex;
  44515. }
  44516. }
  44517. declare module BABYLON {
  44518. /** @hidden */
  44519. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44520. private _genericAttributeLocation;
  44521. private _varyingLocationCount;
  44522. private _varyingLocationMap;
  44523. private _replacements;
  44524. private _textureCount;
  44525. private _uniforms;
  44526. lineProcessor(line: string): string;
  44527. attributeProcessor(attribute: string): string;
  44528. varyingProcessor(varying: string, isFragment: boolean): string;
  44529. uniformProcessor(uniform: string): string;
  44530. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44531. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44532. }
  44533. }
  44534. declare module BABYLON {
  44535. /**
  44536. * Container for accessors for natively-stored mesh data buffers.
  44537. */
  44538. class NativeDataBuffer extends DataBuffer {
  44539. /**
  44540. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44541. */
  44542. nativeIndexBuffer?: any;
  44543. /**
  44544. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44545. */
  44546. nativeVertexBuffer?: any;
  44547. }
  44548. /** @hidden */
  44549. export class NativeEngine extends Engine {
  44550. private readonly _native;
  44551. getHardwareScalingLevel(): number;
  44552. constructor();
  44553. /**
  44554. * Can be used to override the current requestAnimationFrame requester.
  44555. * @hidden
  44556. */
  44557. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44558. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44559. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44560. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44561. recordVertexArrayObject(vertexBuffers: {
  44562. [key: string]: VertexBuffer;
  44563. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44564. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44565. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44566. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44567. /**
  44568. * Draw a list of indexed primitives
  44569. * @param fillMode defines the primitive to use
  44570. * @param indexStart defines the starting index
  44571. * @param indexCount defines the number of index to draw
  44572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44573. */
  44574. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44575. /**
  44576. * Draw a list of unindexed primitives
  44577. * @param fillMode defines the primitive to use
  44578. * @param verticesStart defines the index of first vertex to draw
  44579. * @param verticesCount defines the count of vertices to draw
  44580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44581. */
  44582. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44583. createPipelineContext(): IPipelineContext;
  44584. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44585. /** @hidden */
  44586. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44587. /** @hidden */
  44588. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44589. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44590. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44591. protected _setProgram(program: WebGLProgram): void;
  44592. _releaseEffect(effect: Effect): void;
  44593. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44594. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44595. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44596. bindSamplers(effect: Effect): void;
  44597. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44598. getRenderWidth(useScreen?: boolean): number;
  44599. getRenderHeight(useScreen?: boolean): number;
  44600. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44601. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44602. /**
  44603. * Set the z offset to apply to current rendering
  44604. * @param value defines the offset to apply
  44605. */
  44606. setZOffset(value: number): void;
  44607. /**
  44608. * Gets the current value of the zOffset
  44609. * @returns the current zOffset state
  44610. */
  44611. getZOffset(): number;
  44612. /**
  44613. * Enable or disable depth buffering
  44614. * @param enable defines the state to set
  44615. */
  44616. setDepthBuffer(enable: boolean): void;
  44617. /**
  44618. * Gets a boolean indicating if depth writing is enabled
  44619. * @returns the current depth writing state
  44620. */
  44621. getDepthWrite(): boolean;
  44622. /**
  44623. * Enable or disable depth writing
  44624. * @param enable defines the state to set
  44625. */
  44626. setDepthWrite(enable: boolean): void;
  44627. /**
  44628. * Enable or disable color writing
  44629. * @param enable defines the state to set
  44630. */
  44631. setColorWrite(enable: boolean): void;
  44632. /**
  44633. * Gets a boolean indicating if color writing is enabled
  44634. * @returns the current color writing state
  44635. */
  44636. getColorWrite(): boolean;
  44637. /**
  44638. * Sets alpha constants used by some alpha blending modes
  44639. * @param r defines the red component
  44640. * @param g defines the green component
  44641. * @param b defines the blue component
  44642. * @param a defines the alpha component
  44643. */
  44644. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44645. /**
  44646. * Sets the current alpha mode
  44647. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44648. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44650. */
  44651. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44652. /**
  44653. * Gets the current alpha mode
  44654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44655. * @returns the current alpha mode
  44656. */
  44657. getAlphaMode(): number;
  44658. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44659. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44660. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44661. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44662. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44663. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44664. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44665. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44666. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44667. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44668. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44669. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44670. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44671. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44674. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44676. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44677. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44678. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44679. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44680. wipeCaches(bruteForce?: boolean): void;
  44681. _createTexture(): WebGLTexture;
  44682. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44683. /**
  44684. * Usually called from BABYLON.Texture.ts.
  44685. * Passed information to create a WebGLTexture
  44686. * @param urlArg defines a value which contains one of the following:
  44687. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44688. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44689. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44690. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44691. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44692. * @param scene needed for loading to the correct scene
  44693. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44694. * @param onLoad optional callback to be called upon successful completion
  44695. * @param onError optional callback to be called upon failure
  44696. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44697. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44698. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44699. * @param forcedExtension defines the extension to use to pick the right loader
  44700. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44701. */
  44702. 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;
  44703. /**
  44704. * Creates a cube texture
  44705. * @param rootUrl defines the url where the files to load is located
  44706. * @param scene defines the current scene
  44707. * @param files defines the list of files to load (1 per face)
  44708. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44709. * @param onLoad defines an optional callback raised when the texture is loaded
  44710. * @param onError defines an optional callback raised if there is an issue to load the texture
  44711. * @param format defines the format of the data
  44712. * @param forcedExtension defines the extension to use to pick the right loader
  44713. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44714. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44715. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44716. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44717. * @returns the cube texture as an InternalTexture
  44718. */
  44719. 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;
  44720. private _getSamplingFilter;
  44721. private static _GetNativeTextureFormat;
  44722. createRenderTargetTexture(size: number | {
  44723. width: number;
  44724. height: number;
  44725. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44726. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44727. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44728. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44729. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44730. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44731. /**
  44732. * Updates a dynamic vertex buffer.
  44733. * @param vertexBuffer the vertex buffer to update
  44734. * @param data the data used to update the vertex buffer
  44735. * @param byteOffset the byte offset of the data (optional)
  44736. * @param byteLength the byte length of the data (optional)
  44737. */
  44738. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44739. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44740. private _updateAnisotropicLevel;
  44741. private _getAddressMode;
  44742. /** @hidden */
  44743. _bindTexture(channel: number, texture: InternalTexture): void;
  44744. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44745. releaseEffects(): void;
  44746. /** @hidden */
  44747. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44748. /** @hidden */
  44749. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44750. /** @hidden */
  44751. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44752. /** @hidden */
  44753. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44754. }
  44755. }
  44756. declare module BABYLON {
  44757. /**
  44758. * Gather the list of clipboard event types as constants.
  44759. */
  44760. export class ClipboardEventTypes {
  44761. /**
  44762. * The clipboard event is fired when a copy command is active (pressed).
  44763. */
  44764. static readonly COPY: number;
  44765. /**
  44766. * The clipboard event is fired when a cut command is active (pressed).
  44767. */
  44768. static readonly CUT: number;
  44769. /**
  44770. * The clipboard event is fired when a paste command is active (pressed).
  44771. */
  44772. static readonly PASTE: number;
  44773. }
  44774. /**
  44775. * This class is used to store clipboard related info for the onClipboardObservable event.
  44776. */
  44777. export class ClipboardInfo {
  44778. /**
  44779. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44780. */
  44781. type: number;
  44782. /**
  44783. * Defines the related dom event
  44784. */
  44785. event: ClipboardEvent;
  44786. /**
  44787. *Creates an instance of ClipboardInfo.
  44788. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44789. * @param event Defines the related dom event
  44790. */
  44791. constructor(
  44792. /**
  44793. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44794. */
  44795. type: number,
  44796. /**
  44797. * Defines the related dom event
  44798. */
  44799. event: ClipboardEvent);
  44800. /**
  44801. * Get the clipboard event's type from the keycode.
  44802. * @param keyCode Defines the keyCode for the current keyboard event.
  44803. * @return {number}
  44804. */
  44805. static GetTypeFromCharacter(keyCode: number): number;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /**
  44810. * Google Daydream controller
  44811. */
  44812. export class DaydreamController extends WebVRController {
  44813. /**
  44814. * Base Url for the controller model.
  44815. */
  44816. static MODEL_BASE_URL: string;
  44817. /**
  44818. * File name for the controller model.
  44819. */
  44820. static MODEL_FILENAME: string;
  44821. /**
  44822. * Gamepad Id prefix used to identify Daydream Controller.
  44823. */
  44824. static readonly GAMEPAD_ID_PREFIX: string;
  44825. /**
  44826. * Creates a new DaydreamController from a gamepad
  44827. * @param vrGamepad the gamepad that the controller should be created from
  44828. */
  44829. constructor(vrGamepad: any);
  44830. /**
  44831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44832. * @param scene scene in which to add meshes
  44833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44834. */
  44835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44836. /**
  44837. * Called once for each button that changed state since the last frame
  44838. * @param buttonIdx Which button index changed
  44839. * @param state New state of the button
  44840. * @param changes Which properties on the state changed since last frame
  44841. */
  44842. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44843. }
  44844. }
  44845. declare module BABYLON {
  44846. /**
  44847. * Gear VR Controller
  44848. */
  44849. export class GearVRController extends WebVRController {
  44850. /**
  44851. * Base Url for the controller model.
  44852. */
  44853. static MODEL_BASE_URL: string;
  44854. /**
  44855. * File name for the controller model.
  44856. */
  44857. static MODEL_FILENAME: string;
  44858. /**
  44859. * Gamepad Id prefix used to identify this controller.
  44860. */
  44861. static readonly GAMEPAD_ID_PREFIX: string;
  44862. private readonly _buttonIndexToObservableNameMap;
  44863. /**
  44864. * Creates a new GearVRController from a gamepad
  44865. * @param vrGamepad the gamepad that the controller should be created from
  44866. */
  44867. constructor(vrGamepad: any);
  44868. /**
  44869. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44870. * @param scene scene in which to add meshes
  44871. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44872. */
  44873. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44874. /**
  44875. * Called once for each button that changed state since the last frame
  44876. * @param buttonIdx Which button index changed
  44877. * @param state New state of the button
  44878. * @param changes Which properties on the state changed since last frame
  44879. */
  44880. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44881. }
  44882. }
  44883. declare module BABYLON {
  44884. /**
  44885. * Class containing static functions to help procedurally build meshes
  44886. */
  44887. export class PolyhedronBuilder {
  44888. /**
  44889. * Creates a polyhedron mesh
  44890. * * 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
  44891. * * The parameter `size` (positive float, default 1) sets the polygon size
  44892. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44893. * * 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`
  44894. * * 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
  44895. * * 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)`)
  44896. * * 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
  44897. * * 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
  44898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44899. * * 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
  44900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44901. * @param name defines the name of the mesh
  44902. * @param options defines the options used to create the mesh
  44903. * @param scene defines the hosting scene
  44904. * @returns the polyhedron mesh
  44905. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44906. */
  44907. static CreatePolyhedron(name: string, options: {
  44908. type?: number;
  44909. size?: number;
  44910. sizeX?: number;
  44911. sizeY?: number;
  44912. sizeZ?: number;
  44913. custom?: any;
  44914. faceUV?: Vector4[];
  44915. faceColors?: Color4[];
  44916. flat?: boolean;
  44917. updatable?: boolean;
  44918. sideOrientation?: number;
  44919. frontUVs?: Vector4;
  44920. backUVs?: Vector4;
  44921. }, scene?: Nullable<Scene>): Mesh;
  44922. }
  44923. }
  44924. declare module BABYLON {
  44925. /**
  44926. * Gizmo that enables scaling a mesh along 3 axis
  44927. */
  44928. export class ScaleGizmo extends Gizmo {
  44929. /**
  44930. * Internal gizmo used for interactions on the x axis
  44931. */
  44932. xGizmo: AxisScaleGizmo;
  44933. /**
  44934. * Internal gizmo used for interactions on the y axis
  44935. */
  44936. yGizmo: AxisScaleGizmo;
  44937. /**
  44938. * Internal gizmo used for interactions on the z axis
  44939. */
  44940. zGizmo: AxisScaleGizmo;
  44941. /**
  44942. * Internal gizmo used to scale all axis equally
  44943. */
  44944. uniformScaleGizmo: AxisScaleGizmo;
  44945. private _meshAttached;
  44946. private _updateGizmoRotationToMatchAttachedMesh;
  44947. private _snapDistance;
  44948. private _scaleRatio;
  44949. private _uniformScalingMesh;
  44950. private _octahedron;
  44951. /** Fires an event when any of it's sub gizmos are dragged */
  44952. onDragStartObservable: Observable<unknown>;
  44953. /** Fires an event when any of it's sub gizmos are released from dragging */
  44954. onDragEndObservable: Observable<unknown>;
  44955. attachedMesh: Nullable<AbstractMesh>;
  44956. /**
  44957. * Creates a ScaleGizmo
  44958. * @param gizmoLayer The utility layer the gizmo will be added to
  44959. */
  44960. constructor(gizmoLayer?: UtilityLayerRenderer);
  44961. updateGizmoRotationToMatchAttachedMesh: boolean;
  44962. /**
  44963. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44964. */
  44965. snapDistance: number;
  44966. /**
  44967. * Ratio for the scale of the gizmo (Default: 1)
  44968. */
  44969. scaleRatio: number;
  44970. /**
  44971. * Disposes of the gizmo
  44972. */
  44973. dispose(): void;
  44974. }
  44975. }
  44976. declare module BABYLON {
  44977. /**
  44978. * Single axis scale gizmo
  44979. */
  44980. export class AxisScaleGizmo extends Gizmo {
  44981. /**
  44982. * Drag behavior responsible for the gizmos dragging interactions
  44983. */
  44984. dragBehavior: PointerDragBehavior;
  44985. private _pointerObserver;
  44986. /**
  44987. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44988. */
  44989. snapDistance: number;
  44990. /**
  44991. * Event that fires each time the gizmo snaps to a new location.
  44992. * * snapDistance is the the change in distance
  44993. */
  44994. onSnapObservable: Observable<{
  44995. snapDistance: number;
  44996. }>;
  44997. /**
  44998. * If the scaling operation should be done on all axis (default: false)
  44999. */
  45000. uniformScaling: boolean;
  45001. private _isEnabled;
  45002. private _parent;
  45003. private _arrow;
  45004. private _coloredMaterial;
  45005. private _hoverMaterial;
  45006. /**
  45007. * Creates an AxisScaleGizmo
  45008. * @param gizmoLayer The utility layer the gizmo will be added to
  45009. * @param dragAxis The axis which the gizmo will be able to scale on
  45010. * @param color The color of the gizmo
  45011. */
  45012. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45013. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45014. /**
  45015. * If the gizmo is enabled
  45016. */
  45017. isEnabled: boolean;
  45018. /**
  45019. * Disposes of the gizmo
  45020. */
  45021. dispose(): void;
  45022. /**
  45023. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45024. * @param mesh The mesh to replace the default mesh of the gizmo
  45025. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45026. */
  45027. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. /**
  45032. * Bounding box gizmo
  45033. */
  45034. export class BoundingBoxGizmo extends Gizmo {
  45035. private _lineBoundingBox;
  45036. private _rotateSpheresParent;
  45037. private _scaleBoxesParent;
  45038. private _boundingDimensions;
  45039. private _renderObserver;
  45040. private _pointerObserver;
  45041. private _scaleDragSpeed;
  45042. private _tmpQuaternion;
  45043. private _tmpVector;
  45044. private _tmpRotationMatrix;
  45045. /**
  45046. * 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)
  45047. */
  45048. ignoreChildren: boolean;
  45049. /**
  45050. * 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)
  45051. */
  45052. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45053. /**
  45054. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45055. */
  45056. rotationSphereSize: number;
  45057. /**
  45058. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45059. */
  45060. scaleBoxSize: number;
  45061. /**
  45062. * 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)
  45063. */
  45064. fixedDragMeshScreenSize: boolean;
  45065. /**
  45066. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45067. */
  45068. fixedDragMeshScreenSizeDistanceFactor: number;
  45069. /**
  45070. * Fired when a rotation sphere or scale box is dragged
  45071. */
  45072. onDragStartObservable: Observable<{}>;
  45073. /**
  45074. * Fired when a scale box is dragged
  45075. */
  45076. onScaleBoxDragObservable: Observable<{}>;
  45077. /**
  45078. * Fired when a scale box drag is ended
  45079. */
  45080. onScaleBoxDragEndObservable: Observable<{}>;
  45081. /**
  45082. * Fired when a rotation sphere is dragged
  45083. */
  45084. onRotationSphereDragObservable: Observable<{}>;
  45085. /**
  45086. * Fired when a rotation sphere drag is ended
  45087. */
  45088. onRotationSphereDragEndObservable: Observable<{}>;
  45089. /**
  45090. * 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)
  45091. */
  45092. scalePivot: Nullable<Vector3>;
  45093. /**
  45094. * Mesh used as a pivot to rotate the attached mesh
  45095. */
  45096. private _anchorMesh;
  45097. private _existingMeshScale;
  45098. private _dragMesh;
  45099. private pointerDragBehavior;
  45100. private coloredMaterial;
  45101. private hoverColoredMaterial;
  45102. /**
  45103. * Sets the color of the bounding box gizmo
  45104. * @param color the color to set
  45105. */
  45106. setColor(color: Color3): void;
  45107. /**
  45108. * Creates an BoundingBoxGizmo
  45109. * @param gizmoLayer The utility layer the gizmo will be added to
  45110. * @param color The color of the gizmo
  45111. */
  45112. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45114. private _selectNode;
  45115. /**
  45116. * Updates the bounding box information for the Gizmo
  45117. */
  45118. updateBoundingBox(): void;
  45119. private _updateRotationSpheres;
  45120. private _updateScaleBoxes;
  45121. /**
  45122. * Enables rotation on the specified axis and disables rotation on the others
  45123. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45124. */
  45125. setEnabledRotationAxis(axis: string): void;
  45126. /**
  45127. * Enables/disables scaling
  45128. * @param enable if scaling should be enabled
  45129. */
  45130. setEnabledScaling(enable: boolean): void;
  45131. private _updateDummy;
  45132. /**
  45133. * Enables a pointer drag behavior on the bounding box of the gizmo
  45134. */
  45135. enableDragBehavior(): void;
  45136. /**
  45137. * Disposes of the gizmo
  45138. */
  45139. dispose(): void;
  45140. /**
  45141. * 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)
  45142. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45143. * @returns the bounding box mesh with the passed in mesh as a child
  45144. */
  45145. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45146. /**
  45147. * CustomMeshes are not supported by this gizmo
  45148. * @param mesh The mesh to replace the default mesh of the gizmo
  45149. */
  45150. setCustomMesh(mesh: Mesh): void;
  45151. }
  45152. }
  45153. declare module BABYLON {
  45154. /**
  45155. * Single plane rotation gizmo
  45156. */
  45157. export class PlaneRotationGizmo extends Gizmo {
  45158. /**
  45159. * Drag behavior responsible for the gizmos dragging interactions
  45160. */
  45161. dragBehavior: PointerDragBehavior;
  45162. private _pointerObserver;
  45163. /**
  45164. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45165. */
  45166. snapDistance: number;
  45167. /**
  45168. * Event that fires each time the gizmo snaps to a new location.
  45169. * * snapDistance is the the change in distance
  45170. */
  45171. onSnapObservable: Observable<{
  45172. snapDistance: number;
  45173. }>;
  45174. private _isEnabled;
  45175. private _parent;
  45176. /**
  45177. * Creates a PlaneRotationGizmo
  45178. * @param gizmoLayer The utility layer the gizmo will be added to
  45179. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45180. * @param color The color of the gizmo
  45181. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45182. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45183. */
  45184. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45185. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45186. /**
  45187. * If the gizmo is enabled
  45188. */
  45189. isEnabled: boolean;
  45190. /**
  45191. * Disposes of the gizmo
  45192. */
  45193. dispose(): void;
  45194. }
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * Gizmo that enables rotating a mesh along 3 axis
  45199. */
  45200. export class RotationGizmo extends Gizmo {
  45201. /**
  45202. * Internal gizmo used for interactions on the x axis
  45203. */
  45204. xGizmo: PlaneRotationGizmo;
  45205. /**
  45206. * Internal gizmo used for interactions on the y axis
  45207. */
  45208. yGizmo: PlaneRotationGizmo;
  45209. /**
  45210. * Internal gizmo used for interactions on the z axis
  45211. */
  45212. zGizmo: PlaneRotationGizmo;
  45213. /** Fires an event when any of it's sub gizmos are dragged */
  45214. onDragStartObservable: Observable<unknown>;
  45215. /** Fires an event when any of it's sub gizmos are released from dragging */
  45216. onDragEndObservable: Observable<unknown>;
  45217. private _meshAttached;
  45218. attachedMesh: Nullable<AbstractMesh>;
  45219. /**
  45220. * Creates a RotationGizmo
  45221. * @param gizmoLayer The utility layer the gizmo will be added to
  45222. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45223. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45224. */
  45225. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45226. updateGizmoRotationToMatchAttachedMesh: boolean;
  45227. /**
  45228. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45229. */
  45230. snapDistance: number;
  45231. /**
  45232. * Ratio for the scale of the gizmo (Default: 1)
  45233. */
  45234. scaleRatio: number;
  45235. /**
  45236. * Disposes of the gizmo
  45237. */
  45238. dispose(): void;
  45239. /**
  45240. * CustomMeshes are not supported by this gizmo
  45241. * @param mesh The mesh to replace the default mesh of the gizmo
  45242. */
  45243. setCustomMesh(mesh: Mesh): void;
  45244. }
  45245. }
  45246. declare module BABYLON {
  45247. /**
  45248. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45249. */
  45250. export class GizmoManager implements IDisposable {
  45251. private scene;
  45252. /**
  45253. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45254. */
  45255. gizmos: {
  45256. positionGizmo: Nullable<PositionGizmo>;
  45257. rotationGizmo: Nullable<RotationGizmo>;
  45258. scaleGizmo: Nullable<ScaleGizmo>;
  45259. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45260. };
  45261. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45262. clearGizmoOnEmptyPointerEvent: boolean;
  45263. /** Fires an event when the manager is attached to a mesh */
  45264. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45265. private _gizmosEnabled;
  45266. private _pointerObserver;
  45267. private _attachedMesh;
  45268. private _boundingBoxColor;
  45269. private _defaultUtilityLayer;
  45270. private _defaultKeepDepthUtilityLayer;
  45271. /**
  45272. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45273. */
  45274. boundingBoxDragBehavior: SixDofDragBehavior;
  45275. /**
  45276. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45277. */
  45278. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45279. /**
  45280. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45281. */
  45282. usePointerToAttachGizmos: boolean;
  45283. /**
  45284. * Utility layer that the bounding box gizmo belongs to
  45285. */
  45286. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45287. /**
  45288. * Utility layer that all gizmos besides bounding box belong to
  45289. */
  45290. readonly utilityLayer: UtilityLayerRenderer;
  45291. /**
  45292. * Instatiates a gizmo manager
  45293. * @param scene the scene to overlay the gizmos on top of
  45294. */
  45295. constructor(scene: Scene);
  45296. /**
  45297. * Attaches a set of gizmos to the specified mesh
  45298. * @param mesh The mesh the gizmo's should be attached to
  45299. */
  45300. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45301. /**
  45302. * If the position gizmo is enabled
  45303. */
  45304. positionGizmoEnabled: boolean;
  45305. /**
  45306. * If the rotation gizmo is enabled
  45307. */
  45308. rotationGizmoEnabled: boolean;
  45309. /**
  45310. * If the scale gizmo is enabled
  45311. */
  45312. scaleGizmoEnabled: boolean;
  45313. /**
  45314. * If the boundingBox gizmo is enabled
  45315. */
  45316. boundingBoxGizmoEnabled: boolean;
  45317. /**
  45318. * Disposes of the gizmo manager
  45319. */
  45320. dispose(): void;
  45321. }
  45322. }
  45323. declare module BABYLON {
  45324. /**
  45325. * A directional light is defined by a direction (what a surprise!).
  45326. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45327. * 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.
  45328. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45329. */
  45330. export class DirectionalLight extends ShadowLight {
  45331. private _shadowFrustumSize;
  45332. /**
  45333. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45334. */
  45335. /**
  45336. * Specifies a fix frustum size for the shadow generation.
  45337. */
  45338. shadowFrustumSize: number;
  45339. private _shadowOrthoScale;
  45340. /**
  45341. * Gets the shadow projection scale against the optimal computed one.
  45342. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45343. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45344. */
  45345. /**
  45346. * Sets the shadow projection scale against the optimal computed one.
  45347. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45348. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45349. */
  45350. shadowOrthoScale: number;
  45351. /**
  45352. * Automatically compute the projection matrix to best fit (including all the casters)
  45353. * on each frame.
  45354. */
  45355. autoUpdateExtends: boolean;
  45356. private _orthoLeft;
  45357. private _orthoRight;
  45358. private _orthoTop;
  45359. private _orthoBottom;
  45360. /**
  45361. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45362. * The directional light is emitted from everywhere in the given direction.
  45363. * It can cast shadows.
  45364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45365. * @param name The friendly name of the light
  45366. * @param direction The direction of the light
  45367. * @param scene The scene the light belongs to
  45368. */
  45369. constructor(name: string, direction: Vector3, scene: Scene);
  45370. /**
  45371. * Returns the string "DirectionalLight".
  45372. * @return The class name
  45373. */
  45374. getClassName(): string;
  45375. /**
  45376. * Returns the integer 1.
  45377. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45378. */
  45379. getTypeID(): number;
  45380. /**
  45381. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45382. * Returns the DirectionalLight Shadow projection matrix.
  45383. */
  45384. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45385. /**
  45386. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45387. * Returns the DirectionalLight Shadow projection matrix.
  45388. */
  45389. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45390. /**
  45391. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45392. * Returns the DirectionalLight Shadow projection matrix.
  45393. */
  45394. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45395. protected _buildUniformLayout(): void;
  45396. /**
  45397. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45398. * @param effect The effect to update
  45399. * @param lightIndex The index of the light in the effect to update
  45400. * @returns The directional light
  45401. */
  45402. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45403. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45404. /**
  45405. * Gets the minZ used for shadow according to both the scene and the light.
  45406. *
  45407. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45408. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45409. * @param activeCamera The camera we are returning the min for
  45410. * @returns the depth min z
  45411. */
  45412. getDepthMinZ(activeCamera: Camera): number;
  45413. /**
  45414. * Gets the maxZ used for shadow according to both the scene and the light.
  45415. *
  45416. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45417. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45418. * @param activeCamera The camera we are returning the max for
  45419. * @returns the depth max z
  45420. */
  45421. getDepthMaxZ(activeCamera: Camera): number;
  45422. /**
  45423. * Prepares the list of defines specific to the light type.
  45424. * @param defines the list of defines
  45425. * @param lightIndex defines the index of the light for the effect
  45426. */
  45427. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45428. }
  45429. }
  45430. declare module BABYLON {
  45431. /**
  45432. * Class containing static functions to help procedurally build meshes
  45433. */
  45434. export class HemisphereBuilder {
  45435. /**
  45436. * Creates a hemisphere mesh
  45437. * @param name defines the name of the mesh
  45438. * @param options defines the options used to create the mesh
  45439. * @param scene defines the hosting scene
  45440. * @returns the hemisphere mesh
  45441. */
  45442. static CreateHemisphere(name: string, options: {
  45443. segments?: number;
  45444. diameter?: number;
  45445. sideOrientation?: number;
  45446. }, scene: any): Mesh;
  45447. }
  45448. }
  45449. declare module BABYLON {
  45450. /**
  45451. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45452. * These values define a cone of light starting from the position, emitting toward the direction.
  45453. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45454. * and the exponent defines the speed of the decay of the light with distance (reach).
  45455. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45456. */
  45457. export class SpotLight extends ShadowLight {
  45458. private _angle;
  45459. private _innerAngle;
  45460. private _cosHalfAngle;
  45461. private _lightAngleScale;
  45462. private _lightAngleOffset;
  45463. /**
  45464. * Gets the cone angle of the spot light in Radians.
  45465. */
  45466. /**
  45467. * Sets the cone angle of the spot light in Radians.
  45468. */
  45469. angle: number;
  45470. /**
  45471. * Only used in gltf falloff mode, this defines the angle where
  45472. * the directional falloff will start before cutting at angle which could be seen
  45473. * as outer angle.
  45474. */
  45475. /**
  45476. * Only used in gltf falloff mode, this defines the angle where
  45477. * the directional falloff will start before cutting at angle which could be seen
  45478. * as outer angle.
  45479. */
  45480. innerAngle: number;
  45481. private _shadowAngleScale;
  45482. /**
  45483. * Allows scaling the angle of the light for shadow generation only.
  45484. */
  45485. /**
  45486. * Allows scaling the angle of the light for shadow generation only.
  45487. */
  45488. shadowAngleScale: number;
  45489. /**
  45490. * The light decay speed with the distance from the emission spot.
  45491. */
  45492. exponent: number;
  45493. private _projectionTextureMatrix;
  45494. /**
  45495. * Allows reading the projecton texture
  45496. */
  45497. readonly projectionTextureMatrix: Matrix;
  45498. protected _projectionTextureLightNear: number;
  45499. /**
  45500. * Gets the near clip of the Spotlight for texture projection.
  45501. */
  45502. /**
  45503. * Sets the near clip of the Spotlight for texture projection.
  45504. */
  45505. projectionTextureLightNear: number;
  45506. protected _projectionTextureLightFar: number;
  45507. /**
  45508. * Gets the far clip of the Spotlight for texture projection.
  45509. */
  45510. /**
  45511. * Sets the far clip of the Spotlight for texture projection.
  45512. */
  45513. projectionTextureLightFar: number;
  45514. protected _projectionTextureUpDirection: Vector3;
  45515. /**
  45516. * Gets the Up vector of the Spotlight for texture projection.
  45517. */
  45518. /**
  45519. * Sets the Up vector of the Spotlight for texture projection.
  45520. */
  45521. projectionTextureUpDirection: Vector3;
  45522. private _projectionTexture;
  45523. /**
  45524. * Gets the projection texture of the light.
  45525. */
  45526. /**
  45527. * Sets the projection texture of the light.
  45528. */
  45529. projectionTexture: Nullable<BaseTexture>;
  45530. private _projectionTextureViewLightDirty;
  45531. private _projectionTextureProjectionLightDirty;
  45532. private _projectionTextureDirty;
  45533. private _projectionTextureViewTargetVector;
  45534. private _projectionTextureViewLightMatrix;
  45535. private _projectionTextureProjectionLightMatrix;
  45536. private _projectionTextureScalingMatrix;
  45537. /**
  45538. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45539. * It can cast shadows.
  45540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45541. * @param name The light friendly name
  45542. * @param position The position of the spot light in the scene
  45543. * @param direction The direction of the light in the scene
  45544. * @param angle The cone angle of the light in Radians
  45545. * @param exponent The light decay speed with the distance from the emission spot
  45546. * @param scene The scene the lights belongs to
  45547. */
  45548. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45549. /**
  45550. * Returns the string "SpotLight".
  45551. * @returns the class name
  45552. */
  45553. getClassName(): string;
  45554. /**
  45555. * Returns the integer 2.
  45556. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45557. */
  45558. getTypeID(): number;
  45559. /**
  45560. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45561. */
  45562. protected _setDirection(value: Vector3): void;
  45563. /**
  45564. * Overrides the position setter to recompute the projection texture view light Matrix.
  45565. */
  45566. protected _setPosition(value: Vector3): void;
  45567. /**
  45568. * 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.
  45569. * Returns the SpotLight.
  45570. */
  45571. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45572. protected _computeProjectionTextureViewLightMatrix(): void;
  45573. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45574. /**
  45575. * Main function for light texture projection matrix computing.
  45576. */
  45577. protected _computeProjectionTextureMatrix(): void;
  45578. protected _buildUniformLayout(): void;
  45579. private _computeAngleValues;
  45580. /**
  45581. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45582. * @param effect The effect to update
  45583. * @param lightIndex The index of the light in the effect to update
  45584. * @returns The spot light
  45585. */
  45586. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45587. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45588. /**
  45589. * Disposes the light and the associated resources.
  45590. */
  45591. dispose(): void;
  45592. /**
  45593. * Prepares the list of defines specific to the light type.
  45594. * @param defines the list of defines
  45595. * @param lightIndex defines the index of the light for the effect
  45596. */
  45597. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45598. }
  45599. }
  45600. declare module BABYLON {
  45601. /**
  45602. * Gizmo that enables viewing a light
  45603. */
  45604. export class LightGizmo extends Gizmo {
  45605. private _lightMesh;
  45606. private _material;
  45607. private cachedPosition;
  45608. private cachedForward;
  45609. /**
  45610. * Creates a LightGizmo
  45611. * @param gizmoLayer The utility layer the gizmo will be added to
  45612. */
  45613. constructor(gizmoLayer?: UtilityLayerRenderer);
  45614. private _light;
  45615. /**
  45616. * The light that the gizmo is attached to
  45617. */
  45618. light: Nullable<Light>;
  45619. /**
  45620. * Gets the material used to render the light gizmo
  45621. */
  45622. readonly material: StandardMaterial;
  45623. /**
  45624. * @hidden
  45625. * Updates the gizmo to match the attached mesh's position/rotation
  45626. */
  45627. protected _update(): void;
  45628. private static _Scale;
  45629. /**
  45630. * Creates the lines for a light mesh
  45631. */
  45632. private static _createLightLines;
  45633. /**
  45634. * Disposes of the light gizmo
  45635. */
  45636. dispose(): void;
  45637. private static _CreateHemisphericLightMesh;
  45638. private static _CreatePointLightMesh;
  45639. private static _CreateSpotLightMesh;
  45640. private static _CreateDirectionalLightMesh;
  45641. }
  45642. }
  45643. declare module BABYLON {
  45644. /** @hidden */
  45645. export var backgroundFragmentDeclaration: {
  45646. name: string;
  45647. shader: string;
  45648. };
  45649. }
  45650. declare module BABYLON {
  45651. /** @hidden */
  45652. export var backgroundUboDeclaration: {
  45653. name: string;
  45654. shader: string;
  45655. };
  45656. }
  45657. declare module BABYLON {
  45658. /** @hidden */
  45659. export var backgroundPixelShader: {
  45660. name: string;
  45661. shader: string;
  45662. };
  45663. }
  45664. declare module BABYLON {
  45665. /** @hidden */
  45666. export var backgroundVertexDeclaration: {
  45667. name: string;
  45668. shader: string;
  45669. };
  45670. }
  45671. declare module BABYLON {
  45672. /** @hidden */
  45673. export var backgroundVertexShader: {
  45674. name: string;
  45675. shader: string;
  45676. };
  45677. }
  45678. declare module BABYLON {
  45679. /**
  45680. * Background material used to create an efficient environement around your scene.
  45681. */
  45682. export class BackgroundMaterial extends PushMaterial {
  45683. /**
  45684. * Standard reflectance value at parallel view angle.
  45685. */
  45686. static StandardReflectance0: number;
  45687. /**
  45688. * Standard reflectance value at grazing angle.
  45689. */
  45690. static StandardReflectance90: number;
  45691. protected _primaryColor: Color3;
  45692. /**
  45693. * Key light Color (multiply against the environement texture)
  45694. */
  45695. primaryColor: Color3;
  45696. protected __perceptualColor: Nullable<Color3>;
  45697. /**
  45698. * Experimental Internal Use Only.
  45699. *
  45700. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45701. * This acts as a helper to set the primary color to a more "human friendly" value.
  45702. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45703. * output color as close as possible from the chosen value.
  45704. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45705. * part of lighting setup.)
  45706. */
  45707. _perceptualColor: Nullable<Color3>;
  45708. protected _primaryColorShadowLevel: float;
  45709. /**
  45710. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45711. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45712. */
  45713. primaryColorShadowLevel: float;
  45714. protected _primaryColorHighlightLevel: float;
  45715. /**
  45716. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45717. * The primary color is used at the level chosen to define what the white area would look.
  45718. */
  45719. primaryColorHighlightLevel: float;
  45720. protected _reflectionTexture: Nullable<BaseTexture>;
  45721. /**
  45722. * Reflection Texture used in the material.
  45723. * Should be author in a specific way for the best result (refer to the documentation).
  45724. */
  45725. reflectionTexture: Nullable<BaseTexture>;
  45726. protected _reflectionBlur: float;
  45727. /**
  45728. * Reflection Texture level of blur.
  45729. *
  45730. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45731. * texture twice.
  45732. */
  45733. reflectionBlur: float;
  45734. protected _diffuseTexture: Nullable<BaseTexture>;
  45735. /**
  45736. * Diffuse Texture used in the material.
  45737. * Should be author in a specific way for the best result (refer to the documentation).
  45738. */
  45739. diffuseTexture: Nullable<BaseTexture>;
  45740. protected _shadowLights: Nullable<IShadowLight[]>;
  45741. /**
  45742. * Specify the list of lights casting shadow on the material.
  45743. * All scene shadow lights will be included if null.
  45744. */
  45745. shadowLights: Nullable<IShadowLight[]>;
  45746. protected _shadowLevel: float;
  45747. /**
  45748. * Helps adjusting the shadow to a softer level if required.
  45749. * 0 means black shadows and 1 means no shadows.
  45750. */
  45751. shadowLevel: float;
  45752. protected _sceneCenter: Vector3;
  45753. /**
  45754. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45755. * It is usually zero but might be interesting to modify according to your setup.
  45756. */
  45757. sceneCenter: Vector3;
  45758. protected _opacityFresnel: boolean;
  45759. /**
  45760. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45761. * This helps ensuring a nice transition when the camera goes under the ground.
  45762. */
  45763. opacityFresnel: boolean;
  45764. protected _reflectionFresnel: boolean;
  45765. /**
  45766. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45767. * This helps adding a mirror texture on the ground.
  45768. */
  45769. reflectionFresnel: boolean;
  45770. protected _reflectionFalloffDistance: number;
  45771. /**
  45772. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45773. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45774. */
  45775. reflectionFalloffDistance: number;
  45776. protected _reflectionAmount: number;
  45777. /**
  45778. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45779. */
  45780. reflectionAmount: number;
  45781. protected _reflectionReflectance0: number;
  45782. /**
  45783. * This specifies the weight of the reflection at grazing angle.
  45784. */
  45785. reflectionReflectance0: number;
  45786. protected _reflectionReflectance90: number;
  45787. /**
  45788. * This specifies the weight of the reflection at a perpendicular point of view.
  45789. */
  45790. reflectionReflectance90: number;
  45791. /**
  45792. * Sets the reflection reflectance fresnel values according to the default standard
  45793. * empirically know to work well :-)
  45794. */
  45795. reflectionStandardFresnelWeight: number;
  45796. protected _useRGBColor: boolean;
  45797. /**
  45798. * Helps to directly use the maps channels instead of their level.
  45799. */
  45800. useRGBColor: boolean;
  45801. protected _enableNoise: boolean;
  45802. /**
  45803. * This helps reducing the banding effect that could occur on the background.
  45804. */
  45805. enableNoise: boolean;
  45806. /**
  45807. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45808. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45809. * Recommended to be keep at 1.0 except for special cases.
  45810. */
  45811. fovMultiplier: number;
  45812. private _fovMultiplier;
  45813. /**
  45814. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45815. */
  45816. useEquirectangularFOV: boolean;
  45817. private _maxSimultaneousLights;
  45818. /**
  45819. * Number of Simultaneous lights allowed on the material.
  45820. */
  45821. maxSimultaneousLights: int;
  45822. /**
  45823. * Default configuration related to image processing available in the Background Material.
  45824. */
  45825. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45826. /**
  45827. * Keep track of the image processing observer to allow dispose and replace.
  45828. */
  45829. private _imageProcessingObserver;
  45830. /**
  45831. * Attaches a new image processing configuration to the PBR Material.
  45832. * @param configuration (if null the scene configuration will be use)
  45833. */
  45834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45835. /**
  45836. * Gets the image processing configuration used either in this material.
  45837. */
  45838. /**
  45839. * Sets the Default image processing configuration used either in the this material.
  45840. *
  45841. * If sets to null, the scene one is in use.
  45842. */
  45843. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45844. /**
  45845. * Gets wether the color curves effect is enabled.
  45846. */
  45847. /**
  45848. * Sets wether the color curves effect is enabled.
  45849. */
  45850. cameraColorCurvesEnabled: boolean;
  45851. /**
  45852. * Gets wether the color grading effect is enabled.
  45853. */
  45854. /**
  45855. * Gets wether the color grading effect is enabled.
  45856. */
  45857. cameraColorGradingEnabled: boolean;
  45858. /**
  45859. * Gets wether tonemapping is enabled or not.
  45860. */
  45861. /**
  45862. * Sets wether tonemapping is enabled or not
  45863. */
  45864. cameraToneMappingEnabled: boolean;
  45865. /**
  45866. * The camera exposure used on this material.
  45867. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45868. * This corresponds to a photographic exposure.
  45869. */
  45870. /**
  45871. * The camera exposure used on this material.
  45872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45873. * This corresponds to a photographic exposure.
  45874. */
  45875. cameraExposure: float;
  45876. /**
  45877. * Gets The camera contrast used on this material.
  45878. */
  45879. /**
  45880. * Sets The camera contrast used on this material.
  45881. */
  45882. cameraContrast: float;
  45883. /**
  45884. * Gets the Color Grading 2D Lookup Texture.
  45885. */
  45886. /**
  45887. * Sets the Color Grading 2D Lookup Texture.
  45888. */
  45889. cameraColorGradingTexture: Nullable<BaseTexture>;
  45890. /**
  45891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45893. * 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;
  45894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45895. */
  45896. /**
  45897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45899. * 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;
  45900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45901. */
  45902. cameraColorCurves: Nullable<ColorCurves>;
  45903. /**
  45904. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45905. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45906. */
  45907. switchToBGR: boolean;
  45908. private _renderTargets;
  45909. private _reflectionControls;
  45910. private _white;
  45911. private _primaryShadowColor;
  45912. private _primaryHighlightColor;
  45913. /**
  45914. * Instantiates a Background Material in the given scene
  45915. * @param name The friendly name of the material
  45916. * @param scene The scene to add the material to
  45917. */
  45918. constructor(name: string, scene: Scene);
  45919. /**
  45920. * Gets a boolean indicating that current material needs to register RTT
  45921. */
  45922. readonly hasRenderTargetTextures: boolean;
  45923. /**
  45924. * The entire material has been created in order to prevent overdraw.
  45925. * @returns false
  45926. */
  45927. needAlphaTesting(): boolean;
  45928. /**
  45929. * The entire material has been created in order to prevent overdraw.
  45930. * @returns true if blending is enable
  45931. */
  45932. needAlphaBlending(): boolean;
  45933. /**
  45934. * Checks wether the material is ready to be rendered for a given mesh.
  45935. * @param mesh The mesh to render
  45936. * @param subMesh The submesh to check against
  45937. * @param useInstances Specify wether or not the material is used with instances
  45938. * @returns true if all the dependencies are ready (Textures, Effects...)
  45939. */
  45940. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45941. /**
  45942. * Compute the primary color according to the chosen perceptual color.
  45943. */
  45944. private _computePrimaryColorFromPerceptualColor;
  45945. /**
  45946. * Compute the highlights and shadow colors according to their chosen levels.
  45947. */
  45948. private _computePrimaryColors;
  45949. /**
  45950. * Build the uniform buffer used in the material.
  45951. */
  45952. buildUniformLayout(): void;
  45953. /**
  45954. * Unbind the material.
  45955. */
  45956. unbind(): void;
  45957. /**
  45958. * Bind only the world matrix to the material.
  45959. * @param world The world matrix to bind.
  45960. */
  45961. bindOnlyWorldMatrix(world: Matrix): void;
  45962. /**
  45963. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45964. * @param world The world matrix to bind.
  45965. * @param subMesh The submesh to bind for.
  45966. */
  45967. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45968. /**
  45969. * Checks to see if a texture is used in the material.
  45970. * @param texture - Base texture to use.
  45971. * @returns - Boolean specifying if a texture is used in the material.
  45972. */
  45973. hasTexture(texture: BaseTexture): boolean;
  45974. /**
  45975. * Dispose the material.
  45976. * @param forceDisposeEffect Force disposal of the associated effect.
  45977. * @param forceDisposeTextures Force disposal of the associated textures.
  45978. */
  45979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45980. /**
  45981. * Clones the material.
  45982. * @param name The cloned name.
  45983. * @returns The cloned material.
  45984. */
  45985. clone(name: string): BackgroundMaterial;
  45986. /**
  45987. * Serializes the current material to its JSON representation.
  45988. * @returns The JSON representation.
  45989. */
  45990. serialize(): any;
  45991. /**
  45992. * Gets the class name of the material
  45993. * @returns "BackgroundMaterial"
  45994. */
  45995. getClassName(): string;
  45996. /**
  45997. * Parse a JSON input to create back a background material.
  45998. * @param source The JSON data to parse
  45999. * @param scene The scene to create the parsed material in
  46000. * @param rootUrl The root url of the assets the material depends upon
  46001. * @returns the instantiated BackgroundMaterial.
  46002. */
  46003. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46004. }
  46005. }
  46006. declare module BABYLON {
  46007. /**
  46008. * Represents the different options available during the creation of
  46009. * a Environment helper.
  46010. *
  46011. * This can control the default ground, skybox and image processing setup of your scene.
  46012. */
  46013. export interface IEnvironmentHelperOptions {
  46014. /**
  46015. * Specifies wether or not to create a ground.
  46016. * True by default.
  46017. */
  46018. createGround: boolean;
  46019. /**
  46020. * Specifies the ground size.
  46021. * 15 by default.
  46022. */
  46023. groundSize: number;
  46024. /**
  46025. * The texture used on the ground for the main color.
  46026. * Comes from the BabylonJS CDN by default.
  46027. *
  46028. * Remarks: Can be either a texture or a url.
  46029. */
  46030. groundTexture: string | BaseTexture;
  46031. /**
  46032. * The color mixed in the ground texture by default.
  46033. * BabylonJS clearColor by default.
  46034. */
  46035. groundColor: Color3;
  46036. /**
  46037. * Specifies the ground opacity.
  46038. * 1 by default.
  46039. */
  46040. groundOpacity: number;
  46041. /**
  46042. * Enables the ground to receive shadows.
  46043. * True by default.
  46044. */
  46045. enableGroundShadow: boolean;
  46046. /**
  46047. * Helps preventing the shadow to be fully black on the ground.
  46048. * 0.5 by default.
  46049. */
  46050. groundShadowLevel: number;
  46051. /**
  46052. * Creates a mirror texture attach to the ground.
  46053. * false by default.
  46054. */
  46055. enableGroundMirror: boolean;
  46056. /**
  46057. * Specifies the ground mirror size ratio.
  46058. * 0.3 by default as the default kernel is 64.
  46059. */
  46060. groundMirrorSizeRatio: number;
  46061. /**
  46062. * Specifies the ground mirror blur kernel size.
  46063. * 64 by default.
  46064. */
  46065. groundMirrorBlurKernel: number;
  46066. /**
  46067. * Specifies the ground mirror visibility amount.
  46068. * 1 by default
  46069. */
  46070. groundMirrorAmount: number;
  46071. /**
  46072. * Specifies the ground mirror reflectance weight.
  46073. * This uses the standard weight of the background material to setup the fresnel effect
  46074. * of the mirror.
  46075. * 1 by default.
  46076. */
  46077. groundMirrorFresnelWeight: number;
  46078. /**
  46079. * Specifies the ground mirror Falloff distance.
  46080. * This can helps reducing the size of the reflection.
  46081. * 0 by Default.
  46082. */
  46083. groundMirrorFallOffDistance: number;
  46084. /**
  46085. * Specifies the ground mirror texture type.
  46086. * Unsigned Int by Default.
  46087. */
  46088. groundMirrorTextureType: number;
  46089. /**
  46090. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46091. * the shown objects.
  46092. */
  46093. groundYBias: number;
  46094. /**
  46095. * Specifies wether or not to create a skybox.
  46096. * True by default.
  46097. */
  46098. createSkybox: boolean;
  46099. /**
  46100. * Specifies the skybox size.
  46101. * 20 by default.
  46102. */
  46103. skyboxSize: number;
  46104. /**
  46105. * The texture used on the skybox for the main color.
  46106. * Comes from the BabylonJS CDN by default.
  46107. *
  46108. * Remarks: Can be either a texture or a url.
  46109. */
  46110. skyboxTexture: string | BaseTexture;
  46111. /**
  46112. * The color mixed in the skybox texture by default.
  46113. * BabylonJS clearColor by default.
  46114. */
  46115. skyboxColor: Color3;
  46116. /**
  46117. * The background rotation around the Y axis of the scene.
  46118. * This helps aligning the key lights of your scene with the background.
  46119. * 0 by default.
  46120. */
  46121. backgroundYRotation: number;
  46122. /**
  46123. * Compute automatically the size of the elements to best fit with the scene.
  46124. */
  46125. sizeAuto: boolean;
  46126. /**
  46127. * Default position of the rootMesh if autoSize is not true.
  46128. */
  46129. rootPosition: Vector3;
  46130. /**
  46131. * Sets up the image processing in the scene.
  46132. * true by default.
  46133. */
  46134. setupImageProcessing: boolean;
  46135. /**
  46136. * The texture used as your environment texture in the scene.
  46137. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46138. *
  46139. * Remarks: Can be either a texture or a url.
  46140. */
  46141. environmentTexture: string | BaseTexture;
  46142. /**
  46143. * The value of the exposure to apply to the scene.
  46144. * 0.6 by default if setupImageProcessing is true.
  46145. */
  46146. cameraExposure: number;
  46147. /**
  46148. * The value of the contrast to apply to the scene.
  46149. * 1.6 by default if setupImageProcessing is true.
  46150. */
  46151. cameraContrast: number;
  46152. /**
  46153. * Specifies wether or not tonemapping should be enabled in the scene.
  46154. * true by default if setupImageProcessing is true.
  46155. */
  46156. toneMappingEnabled: boolean;
  46157. }
  46158. /**
  46159. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46160. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46161. * It also helps with the default setup of your imageProcessing configuration.
  46162. */
  46163. export class EnvironmentHelper {
  46164. /**
  46165. * Default ground texture URL.
  46166. */
  46167. private static _groundTextureCDNUrl;
  46168. /**
  46169. * Default skybox texture URL.
  46170. */
  46171. private static _skyboxTextureCDNUrl;
  46172. /**
  46173. * Default environment texture URL.
  46174. */
  46175. private static _environmentTextureCDNUrl;
  46176. /**
  46177. * Creates the default options for the helper.
  46178. */
  46179. private static _getDefaultOptions;
  46180. private _rootMesh;
  46181. /**
  46182. * Gets the root mesh created by the helper.
  46183. */
  46184. readonly rootMesh: Mesh;
  46185. private _skybox;
  46186. /**
  46187. * Gets the skybox created by the helper.
  46188. */
  46189. readonly skybox: Nullable<Mesh>;
  46190. private _skyboxTexture;
  46191. /**
  46192. * Gets the skybox texture created by the helper.
  46193. */
  46194. readonly skyboxTexture: Nullable<BaseTexture>;
  46195. private _skyboxMaterial;
  46196. /**
  46197. * Gets the skybox material created by the helper.
  46198. */
  46199. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46200. private _ground;
  46201. /**
  46202. * Gets the ground mesh created by the helper.
  46203. */
  46204. readonly ground: Nullable<Mesh>;
  46205. private _groundTexture;
  46206. /**
  46207. * Gets the ground texture created by the helper.
  46208. */
  46209. readonly groundTexture: Nullable<BaseTexture>;
  46210. private _groundMirror;
  46211. /**
  46212. * Gets the ground mirror created by the helper.
  46213. */
  46214. readonly groundMirror: Nullable<MirrorTexture>;
  46215. /**
  46216. * Gets the ground mirror render list to helps pushing the meshes
  46217. * you wish in the ground reflection.
  46218. */
  46219. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46220. private _groundMaterial;
  46221. /**
  46222. * Gets the ground material created by the helper.
  46223. */
  46224. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46225. /**
  46226. * Stores the creation options.
  46227. */
  46228. private readonly _scene;
  46229. private _options;
  46230. /**
  46231. * This observable will be notified with any error during the creation of the environment,
  46232. * mainly texture creation errors.
  46233. */
  46234. onErrorObservable: Observable<{
  46235. message?: string;
  46236. exception?: any;
  46237. }>;
  46238. /**
  46239. * constructor
  46240. * @param options Defines the options we want to customize the helper
  46241. * @param scene The scene to add the material to
  46242. */
  46243. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46244. /**
  46245. * Updates the background according to the new options
  46246. * @param options
  46247. */
  46248. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46249. /**
  46250. * Sets the primary color of all the available elements.
  46251. * @param color the main color to affect to the ground and the background
  46252. */
  46253. setMainColor(color: Color3): void;
  46254. /**
  46255. * Setup the image processing according to the specified options.
  46256. */
  46257. private _setupImageProcessing;
  46258. /**
  46259. * Setup the environment texture according to the specified options.
  46260. */
  46261. private _setupEnvironmentTexture;
  46262. /**
  46263. * Setup the background according to the specified options.
  46264. */
  46265. private _setupBackground;
  46266. /**
  46267. * Get the scene sizes according to the setup.
  46268. */
  46269. private _getSceneSize;
  46270. /**
  46271. * Setup the ground according to the specified options.
  46272. */
  46273. private _setupGround;
  46274. /**
  46275. * Setup the ground material according to the specified options.
  46276. */
  46277. private _setupGroundMaterial;
  46278. /**
  46279. * Setup the ground diffuse texture according to the specified options.
  46280. */
  46281. private _setupGroundDiffuseTexture;
  46282. /**
  46283. * Setup the ground mirror texture according to the specified options.
  46284. */
  46285. private _setupGroundMirrorTexture;
  46286. /**
  46287. * Setup the ground to receive the mirror texture.
  46288. */
  46289. private _setupMirrorInGroundMaterial;
  46290. /**
  46291. * Setup the skybox according to the specified options.
  46292. */
  46293. private _setupSkybox;
  46294. /**
  46295. * Setup the skybox material according to the specified options.
  46296. */
  46297. private _setupSkyboxMaterial;
  46298. /**
  46299. * Setup the skybox reflection texture according to the specified options.
  46300. */
  46301. private _setupSkyboxReflectionTexture;
  46302. private _errorHandler;
  46303. /**
  46304. * Dispose all the elements created by the Helper.
  46305. */
  46306. dispose(): void;
  46307. }
  46308. }
  46309. declare module BABYLON {
  46310. /**
  46311. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46312. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46313. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46314. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46315. */
  46316. export class PhotoDome extends TransformNode {
  46317. /**
  46318. * Define the image as a Monoscopic panoramic 360 image.
  46319. */
  46320. static readonly MODE_MONOSCOPIC: number;
  46321. /**
  46322. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46323. */
  46324. static readonly MODE_TOPBOTTOM: number;
  46325. /**
  46326. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46327. */
  46328. static readonly MODE_SIDEBYSIDE: number;
  46329. private _useDirectMapping;
  46330. /**
  46331. * The texture being displayed on the sphere
  46332. */
  46333. protected _photoTexture: Texture;
  46334. /**
  46335. * Gets or sets the texture being displayed on the sphere
  46336. */
  46337. photoTexture: Texture;
  46338. /**
  46339. * Observable raised when an error occured while loading the 360 image
  46340. */
  46341. onLoadErrorObservable: Observable<string>;
  46342. /**
  46343. * The skybox material
  46344. */
  46345. protected _material: BackgroundMaterial;
  46346. /**
  46347. * The surface used for the skybox
  46348. */
  46349. protected _mesh: Mesh;
  46350. /**
  46351. * Gets the mesh used for the skybox.
  46352. */
  46353. readonly mesh: Mesh;
  46354. /**
  46355. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46356. * Also see the options.resolution property.
  46357. */
  46358. fovMultiplier: number;
  46359. private _imageMode;
  46360. /**
  46361. * Gets or set the current video mode for the video. It can be:
  46362. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46363. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46364. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46365. */
  46366. imageMode: number;
  46367. /**
  46368. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46369. * @param name Element's name, child elements will append suffixes for their own names.
  46370. * @param urlsOfPhoto defines the url of the photo to display
  46371. * @param options defines an object containing optional or exposed sub element properties
  46372. * @param onError defines a callback called when an error occured while loading the texture
  46373. */
  46374. constructor(name: string, urlOfPhoto: string, options: {
  46375. resolution?: number;
  46376. size?: number;
  46377. useDirectMapping?: boolean;
  46378. faceForward?: boolean;
  46379. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46380. private _onBeforeCameraRenderObserver;
  46381. private _changeImageMode;
  46382. /**
  46383. * Releases resources associated with this node.
  46384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46386. */
  46387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46388. }
  46389. }
  46390. declare module BABYLON {
  46391. /**
  46392. * Class used to host RGBD texture specific utilities
  46393. */
  46394. export class RGBDTextureTools {
  46395. /**
  46396. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46397. * @param texture the texture to expand.
  46398. */
  46399. static ExpandRGBDTexture(texture: Texture): void;
  46400. }
  46401. }
  46402. declare module BABYLON {
  46403. /**
  46404. * Class used to host texture specific utilities
  46405. */
  46406. export class BRDFTextureTools {
  46407. /**
  46408. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46409. * @param scene defines the hosting scene
  46410. * @returns the environment BRDF texture
  46411. */
  46412. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46413. private static _environmentBRDFBase64Texture;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * @hidden
  46419. */
  46420. export interface IMaterialClearCoatDefines {
  46421. CLEARCOAT: boolean;
  46422. CLEARCOAT_DEFAULTIOR: boolean;
  46423. CLEARCOAT_TEXTURE: boolean;
  46424. CLEARCOAT_TEXTUREDIRECTUV: number;
  46425. CLEARCOAT_BUMP: boolean;
  46426. CLEARCOAT_BUMPDIRECTUV: number;
  46427. CLEARCOAT_TINT: boolean;
  46428. CLEARCOAT_TINT_TEXTURE: boolean;
  46429. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46430. /** @hidden */
  46431. _areTexturesDirty: boolean;
  46432. }
  46433. /**
  46434. * Define the code related to the clear coat parameters of the pbr material.
  46435. */
  46436. export class PBRClearCoatConfiguration {
  46437. /**
  46438. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46439. * The default fits with a polyurethane material.
  46440. */
  46441. private static readonly _DefaultIndexOfRefraction;
  46442. private _isEnabled;
  46443. /**
  46444. * Defines if the clear coat is enabled in the material.
  46445. */
  46446. isEnabled: boolean;
  46447. /**
  46448. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46449. */
  46450. intensity: number;
  46451. /**
  46452. * Defines the clear coat layer roughness.
  46453. */
  46454. roughness: number;
  46455. private _indexOfRefraction;
  46456. /**
  46457. * Defines the index of refraction of the clear coat.
  46458. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46459. * The default fits with a polyurethane material.
  46460. * Changing the default value is more performance intensive.
  46461. */
  46462. indexOfRefraction: number;
  46463. private _texture;
  46464. /**
  46465. * Stores the clear coat values in a texture.
  46466. */
  46467. texture: Nullable<BaseTexture>;
  46468. private _bumpTexture;
  46469. /**
  46470. * Define the clear coat specific bump texture.
  46471. */
  46472. bumpTexture: Nullable<BaseTexture>;
  46473. private _isTintEnabled;
  46474. /**
  46475. * Defines if the clear coat tint is enabled in the material.
  46476. */
  46477. isTintEnabled: boolean;
  46478. /**
  46479. * Defines the clear coat tint of the material.
  46480. * This is only use if tint is enabled
  46481. */
  46482. tintColor: Color3;
  46483. /**
  46484. * Defines the distance at which the tint color should be found in the
  46485. * clear coat media.
  46486. * This is only use if tint is enabled
  46487. */
  46488. tintColorAtDistance: number;
  46489. /**
  46490. * Defines the clear coat layer thickness.
  46491. * This is only use if tint is enabled
  46492. */
  46493. tintThickness: number;
  46494. private _tintTexture;
  46495. /**
  46496. * Stores the clear tint values in a texture.
  46497. * rgb is tint
  46498. * a is a thickness factor
  46499. */
  46500. tintTexture: Nullable<BaseTexture>;
  46501. /** @hidden */
  46502. private _internalMarkAllSubMeshesAsTexturesDirty;
  46503. /** @hidden */
  46504. _markAllSubMeshesAsTexturesDirty(): void;
  46505. /**
  46506. * Instantiate a new istance of clear coat configuration.
  46507. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46508. */
  46509. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46510. /**
  46511. * Gets wehter the submesh is ready to be used or not.
  46512. * @param defines the list of "defines" to update.
  46513. * @param scene defines the scene the material belongs to.
  46514. * @param engine defines the engine the material belongs to.
  46515. * @param disableBumpMap defines wether the material disables bump or not.
  46516. * @returns - boolean indicating that the submesh is ready or not.
  46517. */
  46518. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46519. /**
  46520. * Checks to see if a texture is used in the material.
  46521. * @param defines the list of "defines" to update.
  46522. * @param scene defines the scene to the material belongs to.
  46523. */
  46524. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46525. /**
  46526. * Binds the material data.
  46527. * @param uniformBuffer defines the Uniform buffer to fill in.
  46528. * @param scene defines the scene the material belongs to.
  46529. * @param engine defines the engine the material belongs to.
  46530. * @param disableBumpMap defines wether the material disables bump or not.
  46531. * @param isFrozen defines wether the material is frozen or not.
  46532. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46533. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46534. */
  46535. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46536. /**
  46537. * Checks to see if a texture is used in the material.
  46538. * @param texture - Base texture to use.
  46539. * @returns - Boolean specifying if a texture is used in the material.
  46540. */
  46541. hasTexture(texture: BaseTexture): boolean;
  46542. /**
  46543. * Returns an array of the actively used textures.
  46544. * @param activeTextures Array of BaseTextures
  46545. */
  46546. getActiveTextures(activeTextures: BaseTexture[]): void;
  46547. /**
  46548. * Returns the animatable textures.
  46549. * @param animatables Array of animatable textures.
  46550. */
  46551. getAnimatables(animatables: IAnimatable[]): void;
  46552. /**
  46553. * Disposes the resources of the material.
  46554. * @param forceDisposeTextures - Forces the disposal of all textures.
  46555. */
  46556. dispose(forceDisposeTextures?: boolean): void;
  46557. /**
  46558. * Get the current class name of the texture useful for serialization or dynamic coding.
  46559. * @returns "PBRClearCoatConfiguration"
  46560. */
  46561. getClassName(): string;
  46562. /**
  46563. * Add fallbacks to the effect fallbacks list.
  46564. * @param defines defines the Base texture to use.
  46565. * @param fallbacks defines the current fallback list.
  46566. * @param currentRank defines the current fallback rank.
  46567. * @returns the new fallback rank.
  46568. */
  46569. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46570. /**
  46571. * Add the required uniforms to the current list.
  46572. * @param uniforms defines the current uniform list.
  46573. */
  46574. static AddUniforms(uniforms: string[]): void;
  46575. /**
  46576. * Add the required samplers to the current list.
  46577. * @param samplers defines the current sampler list.
  46578. */
  46579. static AddSamplers(samplers: string[]): void;
  46580. /**
  46581. * Add the required uniforms to the current buffer.
  46582. * @param uniformBuffer defines the current uniform buffer.
  46583. */
  46584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46585. /**
  46586. * Makes a duplicate of the current configuration into another one.
  46587. * @param clearCoatConfiguration define the config where to copy the info
  46588. */
  46589. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46590. /**
  46591. * Serializes this clear coat configuration.
  46592. * @returns - An object with the serialized config.
  46593. */
  46594. serialize(): any;
  46595. /**
  46596. * Parses a anisotropy Configuration from a serialized object.
  46597. * @param source - Serialized object.
  46598. * @param scene Defines the scene we are parsing for
  46599. * @param rootUrl Defines the rootUrl to load from
  46600. */
  46601. parse(source: any, scene: Scene, rootUrl: string): void;
  46602. }
  46603. }
  46604. declare module BABYLON {
  46605. /**
  46606. * @hidden
  46607. */
  46608. export interface IMaterialAnisotropicDefines {
  46609. ANISOTROPIC: boolean;
  46610. ANISOTROPIC_TEXTURE: boolean;
  46611. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46612. MAINUV1: boolean;
  46613. _areTexturesDirty: boolean;
  46614. _needUVs: boolean;
  46615. }
  46616. /**
  46617. * Define the code related to the anisotropic parameters of the pbr material.
  46618. */
  46619. export class PBRAnisotropicConfiguration {
  46620. private _isEnabled;
  46621. /**
  46622. * Defines if the anisotropy is enabled in the material.
  46623. */
  46624. isEnabled: boolean;
  46625. /**
  46626. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46627. */
  46628. intensity: number;
  46629. /**
  46630. * Defines if the effect is along the tangents, bitangents or in between.
  46631. * By default, the effect is "strectching" the highlights along the tangents.
  46632. */
  46633. direction: Vector2;
  46634. private _texture;
  46635. /**
  46636. * Stores the anisotropy values in a texture.
  46637. * rg is direction (like normal from -1 to 1)
  46638. * b is a intensity
  46639. */
  46640. texture: Nullable<BaseTexture>;
  46641. /** @hidden */
  46642. private _internalMarkAllSubMeshesAsTexturesDirty;
  46643. /** @hidden */
  46644. _markAllSubMeshesAsTexturesDirty(): void;
  46645. /**
  46646. * Instantiate a new istance of anisotropy configuration.
  46647. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46648. */
  46649. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46650. /**
  46651. * Specifies that the submesh is ready to be used.
  46652. * @param defines the list of "defines" to update.
  46653. * @param scene defines the scene the material belongs to.
  46654. * @returns - boolean indicating that the submesh is ready or not.
  46655. */
  46656. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46657. /**
  46658. * Checks to see if a texture is used in the material.
  46659. * @param defines the list of "defines" to update.
  46660. * @param mesh the mesh we are preparing the defines for.
  46661. * @param scene defines the scene the material belongs to.
  46662. */
  46663. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46664. /**
  46665. * Binds the material data.
  46666. * @param uniformBuffer defines the Uniform buffer to fill in.
  46667. * @param scene defines the scene the material belongs to.
  46668. * @param isFrozen defines wether the material is frozen or not.
  46669. */
  46670. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46671. /**
  46672. * Checks to see if a texture is used in the material.
  46673. * @param texture - Base texture to use.
  46674. * @returns - Boolean specifying if a texture is used in the material.
  46675. */
  46676. hasTexture(texture: BaseTexture): boolean;
  46677. /**
  46678. * Returns an array of the actively used textures.
  46679. * @param activeTextures Array of BaseTextures
  46680. */
  46681. getActiveTextures(activeTextures: BaseTexture[]): void;
  46682. /**
  46683. * Returns the animatable textures.
  46684. * @param animatables Array of animatable textures.
  46685. */
  46686. getAnimatables(animatables: IAnimatable[]): void;
  46687. /**
  46688. * Disposes the resources of the material.
  46689. * @param forceDisposeTextures - Forces the disposal of all textures.
  46690. */
  46691. dispose(forceDisposeTextures?: boolean): void;
  46692. /**
  46693. * Get the current class name of the texture useful for serialization or dynamic coding.
  46694. * @returns "PBRAnisotropicConfiguration"
  46695. */
  46696. getClassName(): string;
  46697. /**
  46698. * Add fallbacks to the effect fallbacks list.
  46699. * @param defines defines the Base texture to use.
  46700. * @param fallbacks defines the current fallback list.
  46701. * @param currentRank defines the current fallback rank.
  46702. * @returns the new fallback rank.
  46703. */
  46704. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46705. /**
  46706. * Add the required uniforms to the current list.
  46707. * @param uniforms defines the current uniform list.
  46708. */
  46709. static AddUniforms(uniforms: string[]): void;
  46710. /**
  46711. * Add the required uniforms to the current buffer.
  46712. * @param uniformBuffer defines the current uniform buffer.
  46713. */
  46714. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46715. /**
  46716. * Add the required samplers to the current list.
  46717. * @param samplers defines the current sampler list.
  46718. */
  46719. static AddSamplers(samplers: string[]): void;
  46720. /**
  46721. * Makes a duplicate of the current configuration into another one.
  46722. * @param anisotropicConfiguration define the config where to copy the info
  46723. */
  46724. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46725. /**
  46726. * Serializes this anisotropy configuration.
  46727. * @returns - An object with the serialized config.
  46728. */
  46729. serialize(): any;
  46730. /**
  46731. * Parses a anisotropy Configuration from a serialized object.
  46732. * @param source - Serialized object.
  46733. * @param scene Defines the scene we are parsing for
  46734. * @param rootUrl Defines the rootUrl to load from
  46735. */
  46736. parse(source: any, scene: Scene, rootUrl: string): void;
  46737. }
  46738. }
  46739. declare module BABYLON {
  46740. /**
  46741. * @hidden
  46742. */
  46743. export interface IMaterialBRDFDefines {
  46744. BRDF_V_HEIGHT_CORRELATED: boolean;
  46745. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46746. SPHERICAL_HARMONICS: boolean;
  46747. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46748. /** @hidden */
  46749. _areMiscDirty: boolean;
  46750. }
  46751. /**
  46752. * Define the code related to the BRDF parameters of the pbr material.
  46753. */
  46754. export class PBRBRDFConfiguration {
  46755. /**
  46756. * Default value used for the energy conservation.
  46757. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46758. */
  46759. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46760. /**
  46761. * Default value used for the Smith Visibility Height Correlated mode.
  46762. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46763. */
  46764. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46765. /**
  46766. * Default value used for the IBL diffuse part.
  46767. * This can help switching back to the polynomials mode globally which is a tiny bit
  46768. * less GPU intensive at the drawback of a lower quality.
  46769. */
  46770. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46771. /**
  46772. * Default value used for activating energy conservation for the specular workflow.
  46773. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46774. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46775. */
  46776. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46777. private _useEnergyConservation;
  46778. /**
  46779. * Defines if the material uses energy conservation.
  46780. */
  46781. useEnergyConservation: boolean;
  46782. private _useSmithVisibilityHeightCorrelated;
  46783. /**
  46784. * LEGACY Mode set to false
  46785. * Defines if the material uses height smith correlated visibility term.
  46786. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46787. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46788. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46789. * Not relying on height correlated will also disable energy conservation.
  46790. */
  46791. useSmithVisibilityHeightCorrelated: boolean;
  46792. private _useSphericalHarmonics;
  46793. /**
  46794. * LEGACY Mode set to false
  46795. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46796. * diffuse part of the IBL.
  46797. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46798. * to the ground truth.
  46799. */
  46800. useSphericalHarmonics: boolean;
  46801. private _useSpecularGlossinessInputEnergyConservation;
  46802. /**
  46803. * Defines if the material uses energy conservation, when the specular workflow is active.
  46804. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46805. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46806. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46807. */
  46808. useSpecularGlossinessInputEnergyConservation: boolean;
  46809. /** @hidden */
  46810. private _internalMarkAllSubMeshesAsMiscDirty;
  46811. /** @hidden */
  46812. _markAllSubMeshesAsMiscDirty(): void;
  46813. /**
  46814. * Instantiate a new istance of clear coat configuration.
  46815. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46816. */
  46817. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46818. /**
  46819. * Checks to see if a texture is used in the material.
  46820. * @param defines the list of "defines" to update.
  46821. */
  46822. prepareDefines(defines: IMaterialBRDFDefines): void;
  46823. /**
  46824. * Get the current class name of the texture useful for serialization or dynamic coding.
  46825. * @returns "PBRClearCoatConfiguration"
  46826. */
  46827. getClassName(): string;
  46828. /**
  46829. * Makes a duplicate of the current configuration into another one.
  46830. * @param brdfConfiguration define the config where to copy the info
  46831. */
  46832. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46833. /**
  46834. * Serializes this BRDF configuration.
  46835. * @returns - An object with the serialized config.
  46836. */
  46837. serialize(): any;
  46838. /**
  46839. * Parses a anisotropy Configuration from a serialized object.
  46840. * @param source - Serialized object.
  46841. * @param scene Defines the scene we are parsing for
  46842. * @param rootUrl Defines the rootUrl to load from
  46843. */
  46844. parse(source: any, scene: Scene, rootUrl: string): void;
  46845. }
  46846. }
  46847. declare module BABYLON {
  46848. /**
  46849. * @hidden
  46850. */
  46851. export interface IMaterialSheenDefines {
  46852. SHEEN: boolean;
  46853. SHEEN_TEXTURE: boolean;
  46854. SHEEN_TEXTUREDIRECTUV: number;
  46855. SHEEN_LINKWITHALBEDO: boolean;
  46856. /** @hidden */
  46857. _areTexturesDirty: boolean;
  46858. }
  46859. /**
  46860. * Define the code related to the Sheen parameters of the pbr material.
  46861. */
  46862. export class PBRSheenConfiguration {
  46863. private _isEnabled;
  46864. /**
  46865. * Defines if the material uses sheen.
  46866. */
  46867. isEnabled: boolean;
  46868. private _linkSheenWithAlbedo;
  46869. /**
  46870. * Defines if the sheen is linked to the sheen color.
  46871. */
  46872. linkSheenWithAlbedo: boolean;
  46873. /**
  46874. * Defines the sheen intensity.
  46875. */
  46876. intensity: number;
  46877. /**
  46878. * Defines the sheen color.
  46879. */
  46880. color: Color3;
  46881. private _texture;
  46882. /**
  46883. * Stores the sheen tint values in a texture.
  46884. * rgb is tint
  46885. * a is a intensity
  46886. */
  46887. texture: Nullable<BaseTexture>;
  46888. /** @hidden */
  46889. private _internalMarkAllSubMeshesAsTexturesDirty;
  46890. /** @hidden */
  46891. _markAllSubMeshesAsTexturesDirty(): void;
  46892. /**
  46893. * Instantiate a new istance of clear coat configuration.
  46894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46895. */
  46896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46897. /**
  46898. * Specifies that the submesh is ready to be used.
  46899. * @param defines the list of "defines" to update.
  46900. * @param scene defines the scene the material belongs to.
  46901. * @returns - boolean indicating that the submesh is ready or not.
  46902. */
  46903. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46904. /**
  46905. * Checks to see if a texture is used in the material.
  46906. * @param defines the list of "defines" to update.
  46907. * @param scene defines the scene the material belongs to.
  46908. */
  46909. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46910. /**
  46911. * Binds the material data.
  46912. * @param uniformBuffer defines the Uniform buffer to fill in.
  46913. * @param scene defines the scene the material belongs to.
  46914. * @param isFrozen defines wether the material is frozen or not.
  46915. */
  46916. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46917. /**
  46918. * Checks to see if a texture is used in the material.
  46919. * @param texture - Base texture to use.
  46920. * @returns - Boolean specifying if a texture is used in the material.
  46921. */
  46922. hasTexture(texture: BaseTexture): boolean;
  46923. /**
  46924. * Returns an array of the actively used textures.
  46925. * @param activeTextures Array of BaseTextures
  46926. */
  46927. getActiveTextures(activeTextures: BaseTexture[]): void;
  46928. /**
  46929. * Returns the animatable textures.
  46930. * @param animatables Array of animatable textures.
  46931. */
  46932. getAnimatables(animatables: IAnimatable[]): void;
  46933. /**
  46934. * Disposes the resources of the material.
  46935. * @param forceDisposeTextures - Forces the disposal of all textures.
  46936. */
  46937. dispose(forceDisposeTextures?: boolean): void;
  46938. /**
  46939. * Get the current class name of the texture useful for serialization or dynamic coding.
  46940. * @returns "PBRSheenConfiguration"
  46941. */
  46942. getClassName(): string;
  46943. /**
  46944. * Add fallbacks to the effect fallbacks list.
  46945. * @param defines defines the Base texture to use.
  46946. * @param fallbacks defines the current fallback list.
  46947. * @param currentRank defines the current fallback rank.
  46948. * @returns the new fallback rank.
  46949. */
  46950. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46951. /**
  46952. * Add the required uniforms to the current list.
  46953. * @param uniforms defines the current uniform list.
  46954. */
  46955. static AddUniforms(uniforms: string[]): void;
  46956. /**
  46957. * Add the required uniforms to the current buffer.
  46958. * @param uniformBuffer defines the current uniform buffer.
  46959. */
  46960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46961. /**
  46962. * Add the required samplers to the current list.
  46963. * @param samplers defines the current sampler list.
  46964. */
  46965. static AddSamplers(samplers: string[]): void;
  46966. /**
  46967. * Makes a duplicate of the current configuration into another one.
  46968. * @param sheenConfiguration define the config where to copy the info
  46969. */
  46970. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46971. /**
  46972. * Serializes this BRDF configuration.
  46973. * @returns - An object with the serialized config.
  46974. */
  46975. serialize(): any;
  46976. /**
  46977. * Parses a anisotropy Configuration from a serialized object.
  46978. * @param source - Serialized object.
  46979. * @param scene Defines the scene we are parsing for
  46980. * @param rootUrl Defines the rootUrl to load from
  46981. */
  46982. parse(source: any, scene: Scene, rootUrl: string): void;
  46983. }
  46984. }
  46985. declare module BABYLON {
  46986. /**
  46987. * @hidden
  46988. */
  46989. export interface IMaterialSubSurfaceDefines {
  46990. SUBSURFACE: boolean;
  46991. SS_REFRACTION: boolean;
  46992. SS_TRANSLUCENCY: boolean;
  46993. SS_SCATERRING: boolean;
  46994. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46995. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46996. SS_REFRACTIONMAP_3D: boolean;
  46997. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46998. SS_LODINREFRACTIONALPHA: boolean;
  46999. SS_GAMMAREFRACTION: boolean;
  47000. SS_RGBDREFRACTION: boolean;
  47001. SS_LINEARSPECULARREFRACTION: boolean;
  47002. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47003. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47004. /** @hidden */
  47005. _areTexturesDirty: boolean;
  47006. }
  47007. /**
  47008. * Define the code related to the sub surface parameters of the pbr material.
  47009. */
  47010. export class PBRSubSurfaceConfiguration {
  47011. private _isRefractionEnabled;
  47012. /**
  47013. * Defines if the refraction is enabled in the material.
  47014. */
  47015. isRefractionEnabled: boolean;
  47016. private _isTranslucencyEnabled;
  47017. /**
  47018. * Defines if the translucency is enabled in the material.
  47019. */
  47020. isTranslucencyEnabled: boolean;
  47021. private _isScatteringEnabled;
  47022. /**
  47023. * Defines the refraction intensity of the material.
  47024. * The refraction when enabled replaces the Diffuse part of the material.
  47025. * The intensity helps transitionning between diffuse and refraction.
  47026. */
  47027. refractionIntensity: number;
  47028. /**
  47029. * Defines the translucency intensity of the material.
  47030. * When translucency has been enabled, this defines how much of the "translucency"
  47031. * is addded to the diffuse part of the material.
  47032. */
  47033. translucencyIntensity: number;
  47034. /**
  47035. * Defines the scattering intensity of the material.
  47036. * When scattering has been enabled, this defines how much of the "scattered light"
  47037. * is addded to the diffuse part of the material.
  47038. */
  47039. scatteringIntensity: number;
  47040. private _thicknessTexture;
  47041. /**
  47042. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47043. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47044. * 0 would mean minimumThickness
  47045. * 1 would mean maximumThickness
  47046. * The other channels might be use as a mask to vary the different effects intensity.
  47047. */
  47048. thicknessTexture: Nullable<BaseTexture>;
  47049. private _refractionTexture;
  47050. /**
  47051. * Defines the texture to use for refraction.
  47052. */
  47053. refractionTexture: Nullable<BaseTexture>;
  47054. private _indexOfRefraction;
  47055. /**
  47056. * Defines the index of refraction used in the material.
  47057. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47058. */
  47059. indexOfRefraction: number;
  47060. private _invertRefractionY;
  47061. /**
  47062. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47063. */
  47064. invertRefractionY: boolean;
  47065. private _linkRefractionWithTransparency;
  47066. /**
  47067. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47068. * Materials half opaque for instance using refraction could benefit from this control.
  47069. */
  47070. linkRefractionWithTransparency: boolean;
  47071. /**
  47072. * Defines the minimum thickness stored in the thickness map.
  47073. * If no thickness map is defined, this value will be used to simulate thickness.
  47074. */
  47075. minimumThickness: number;
  47076. /**
  47077. * Defines the maximum thickness stored in the thickness map.
  47078. */
  47079. maximumThickness: number;
  47080. /**
  47081. * Defines the volume tint of the material.
  47082. * This is used for both translucency and scattering.
  47083. */
  47084. tintColor: Color3;
  47085. /**
  47086. * Defines the distance at which the tint color should be found in the media.
  47087. * This is used for refraction only.
  47088. */
  47089. tintColorAtDistance: number;
  47090. /**
  47091. * Defines how far each channel transmit through the media.
  47092. * It is defined as a color to simplify it selection.
  47093. */
  47094. diffusionDistance: Color3;
  47095. private _useMaskFromThicknessTexture;
  47096. /**
  47097. * Stores the intensity of the different subsurface effects in the thickness texture.
  47098. * * the green channel is the translucency intensity.
  47099. * * the blue channel is the scattering intensity.
  47100. * * the alpha channel is the refraction intensity.
  47101. */
  47102. useMaskFromThicknessTexture: boolean;
  47103. /** @hidden */
  47104. private _internalMarkAllSubMeshesAsTexturesDirty;
  47105. /** @hidden */
  47106. _markAllSubMeshesAsTexturesDirty(): void;
  47107. /**
  47108. * Instantiate a new istance of sub surface configuration.
  47109. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47110. */
  47111. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47112. /**
  47113. * Gets wehter the submesh is ready to be used or not.
  47114. * @param defines the list of "defines" to update.
  47115. * @param scene defines the scene the material belongs to.
  47116. * @returns - boolean indicating that the submesh is ready or not.
  47117. */
  47118. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47119. /**
  47120. * Checks to see if a texture is used in the material.
  47121. * @param defines the list of "defines" to update.
  47122. * @param scene defines the scene to the material belongs to.
  47123. */
  47124. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47125. /**
  47126. * Binds the material data.
  47127. * @param uniformBuffer defines the Uniform buffer to fill in.
  47128. * @param scene defines the scene the material belongs to.
  47129. * @param engine defines the engine the material belongs to.
  47130. * @param isFrozen defines wether the material is frozen or not.
  47131. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47132. */
  47133. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47134. /**
  47135. * Unbinds the material from the mesh.
  47136. * @param activeEffect defines the effect that should be unbound from.
  47137. * @returns true if unbound, otherwise false
  47138. */
  47139. unbind(activeEffect: Effect): boolean;
  47140. /**
  47141. * Returns the texture used for refraction or null if none is used.
  47142. * @param scene defines the scene the material belongs to.
  47143. * @returns - Refraction texture if present. If no refraction texture and refraction
  47144. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47145. */
  47146. private _getRefractionTexture;
  47147. /**
  47148. * Returns true if alpha blending should be disabled.
  47149. */
  47150. readonly disableAlphaBlending: boolean;
  47151. /**
  47152. * Fills the list of render target textures.
  47153. * @param renderTargets the list of render targets to update
  47154. */
  47155. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47156. /**
  47157. * Checks to see if a texture is used in the material.
  47158. * @param texture - Base texture to use.
  47159. * @returns - Boolean specifying if a texture is used in the material.
  47160. */
  47161. hasTexture(texture: BaseTexture): boolean;
  47162. /**
  47163. * Gets a boolean indicating that current material needs to register RTT
  47164. * @returns true if this uses a render target otherwise false.
  47165. */
  47166. hasRenderTargetTextures(): boolean;
  47167. /**
  47168. * Returns an array of the actively used textures.
  47169. * @param activeTextures Array of BaseTextures
  47170. */
  47171. getActiveTextures(activeTextures: BaseTexture[]): void;
  47172. /**
  47173. * Returns the animatable textures.
  47174. * @param animatables Array of animatable textures.
  47175. */
  47176. getAnimatables(animatables: IAnimatable[]): void;
  47177. /**
  47178. * Disposes the resources of the material.
  47179. * @param forceDisposeTextures - Forces the disposal of all textures.
  47180. */
  47181. dispose(forceDisposeTextures?: boolean): void;
  47182. /**
  47183. * Get the current class name of the texture useful for serialization or dynamic coding.
  47184. * @returns "PBRSubSurfaceConfiguration"
  47185. */
  47186. getClassName(): string;
  47187. /**
  47188. * Add fallbacks to the effect fallbacks list.
  47189. * @param defines defines the Base texture to use.
  47190. * @param fallbacks defines the current fallback list.
  47191. * @param currentRank defines the current fallback rank.
  47192. * @returns the new fallback rank.
  47193. */
  47194. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47195. /**
  47196. * Add the required uniforms to the current list.
  47197. * @param uniforms defines the current uniform list.
  47198. */
  47199. static AddUniforms(uniforms: string[]): void;
  47200. /**
  47201. * Add the required samplers to the current list.
  47202. * @param samplers defines the current sampler list.
  47203. */
  47204. static AddSamplers(samplers: string[]): void;
  47205. /**
  47206. * Add the required uniforms to the current buffer.
  47207. * @param uniformBuffer defines the current uniform buffer.
  47208. */
  47209. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47210. /**
  47211. * Makes a duplicate of the current configuration into another one.
  47212. * @param configuration define the config where to copy the info
  47213. */
  47214. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47215. /**
  47216. * Serializes this Sub Surface configuration.
  47217. * @returns - An object with the serialized config.
  47218. */
  47219. serialize(): any;
  47220. /**
  47221. * Parses a anisotropy Configuration from a serialized object.
  47222. * @param source - Serialized object.
  47223. * @param scene Defines the scene we are parsing for
  47224. * @param rootUrl Defines the rootUrl to load from
  47225. */
  47226. parse(source: any, scene: Scene, rootUrl: string): void;
  47227. }
  47228. }
  47229. declare module BABYLON {
  47230. /** @hidden */
  47231. export var pbrFragmentDeclaration: {
  47232. name: string;
  47233. shader: string;
  47234. };
  47235. }
  47236. declare module BABYLON {
  47237. /** @hidden */
  47238. export var pbrUboDeclaration: {
  47239. name: string;
  47240. shader: string;
  47241. };
  47242. }
  47243. declare module BABYLON {
  47244. /** @hidden */
  47245. export var pbrFragmentExtraDeclaration: {
  47246. name: string;
  47247. shader: string;
  47248. };
  47249. }
  47250. declare module BABYLON {
  47251. /** @hidden */
  47252. export var pbrFragmentSamplersDeclaration: {
  47253. name: string;
  47254. shader: string;
  47255. };
  47256. }
  47257. declare module BABYLON {
  47258. /** @hidden */
  47259. export var pbrHelperFunctions: {
  47260. name: string;
  47261. shader: string;
  47262. };
  47263. }
  47264. declare module BABYLON {
  47265. /** @hidden */
  47266. export var harmonicsFunctions: {
  47267. name: string;
  47268. shader: string;
  47269. };
  47270. }
  47271. declare module BABYLON {
  47272. /** @hidden */
  47273. export var pbrDirectLightingSetupFunctions: {
  47274. name: string;
  47275. shader: string;
  47276. };
  47277. }
  47278. declare module BABYLON {
  47279. /** @hidden */
  47280. export var pbrDirectLightingFalloffFunctions: {
  47281. name: string;
  47282. shader: string;
  47283. };
  47284. }
  47285. declare module BABYLON {
  47286. /** @hidden */
  47287. export var pbrBRDFFunctions: {
  47288. name: string;
  47289. shader: string;
  47290. };
  47291. }
  47292. declare module BABYLON {
  47293. /** @hidden */
  47294. export var pbrDirectLightingFunctions: {
  47295. name: string;
  47296. shader: string;
  47297. };
  47298. }
  47299. declare module BABYLON {
  47300. /** @hidden */
  47301. export var pbrIBLFunctions: {
  47302. name: string;
  47303. shader: string;
  47304. };
  47305. }
  47306. declare module BABYLON {
  47307. /** @hidden */
  47308. export var pbrDebug: {
  47309. name: string;
  47310. shader: string;
  47311. };
  47312. }
  47313. declare module BABYLON {
  47314. /** @hidden */
  47315. export var pbrPixelShader: {
  47316. name: string;
  47317. shader: string;
  47318. };
  47319. }
  47320. declare module BABYLON {
  47321. /** @hidden */
  47322. export var pbrVertexDeclaration: {
  47323. name: string;
  47324. shader: string;
  47325. };
  47326. }
  47327. declare module BABYLON {
  47328. /** @hidden */
  47329. export var pbrVertexShader: {
  47330. name: string;
  47331. shader: string;
  47332. };
  47333. }
  47334. declare module BABYLON {
  47335. /**
  47336. * Manages the defines for the PBR Material.
  47337. * @hidden
  47338. */
  47339. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47340. PBR: boolean;
  47341. MAINUV1: boolean;
  47342. MAINUV2: boolean;
  47343. UV1: boolean;
  47344. UV2: boolean;
  47345. ALBEDO: boolean;
  47346. ALBEDODIRECTUV: number;
  47347. VERTEXCOLOR: boolean;
  47348. AMBIENT: boolean;
  47349. AMBIENTDIRECTUV: number;
  47350. AMBIENTINGRAYSCALE: boolean;
  47351. OPACITY: boolean;
  47352. VERTEXALPHA: boolean;
  47353. OPACITYDIRECTUV: number;
  47354. OPACITYRGB: boolean;
  47355. ALPHATEST: boolean;
  47356. DEPTHPREPASS: boolean;
  47357. ALPHABLEND: boolean;
  47358. ALPHAFROMALBEDO: boolean;
  47359. ALPHATESTVALUE: string;
  47360. SPECULAROVERALPHA: boolean;
  47361. RADIANCEOVERALPHA: boolean;
  47362. ALPHAFRESNEL: boolean;
  47363. LINEARALPHAFRESNEL: boolean;
  47364. PREMULTIPLYALPHA: boolean;
  47365. EMISSIVE: boolean;
  47366. EMISSIVEDIRECTUV: number;
  47367. REFLECTIVITY: boolean;
  47368. REFLECTIVITYDIRECTUV: number;
  47369. SPECULARTERM: boolean;
  47370. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47371. MICROSURFACEAUTOMATIC: boolean;
  47372. LODBASEDMICROSFURACE: boolean;
  47373. MICROSURFACEMAP: boolean;
  47374. MICROSURFACEMAPDIRECTUV: number;
  47375. METALLICWORKFLOW: boolean;
  47376. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47377. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47378. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47379. AOSTOREINMETALMAPRED: boolean;
  47380. ENVIRONMENTBRDF: boolean;
  47381. ENVIRONMENTBRDF_RGBD: boolean;
  47382. NORMAL: boolean;
  47383. TANGENT: boolean;
  47384. BUMP: boolean;
  47385. BUMPDIRECTUV: number;
  47386. OBJECTSPACE_NORMALMAP: boolean;
  47387. PARALLAX: boolean;
  47388. PARALLAXOCCLUSION: boolean;
  47389. NORMALXYSCALE: boolean;
  47390. LIGHTMAP: boolean;
  47391. LIGHTMAPDIRECTUV: number;
  47392. USELIGHTMAPASSHADOWMAP: boolean;
  47393. GAMMALIGHTMAP: boolean;
  47394. RGBDLIGHTMAP: boolean;
  47395. REFLECTION: boolean;
  47396. REFLECTIONMAP_3D: boolean;
  47397. REFLECTIONMAP_SPHERICAL: boolean;
  47398. REFLECTIONMAP_PLANAR: boolean;
  47399. REFLECTIONMAP_CUBIC: boolean;
  47400. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47401. REFLECTIONMAP_PROJECTION: boolean;
  47402. REFLECTIONMAP_SKYBOX: boolean;
  47403. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47404. REFLECTIONMAP_EXPLICIT: boolean;
  47405. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47406. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47407. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47408. INVERTCUBICMAP: boolean;
  47409. USESPHERICALFROMREFLECTIONMAP: boolean;
  47410. USEIRRADIANCEMAP: boolean;
  47411. SPHERICAL_HARMONICS: boolean;
  47412. USESPHERICALINVERTEX: boolean;
  47413. REFLECTIONMAP_OPPOSITEZ: boolean;
  47414. LODINREFLECTIONALPHA: boolean;
  47415. GAMMAREFLECTION: boolean;
  47416. RGBDREFLECTION: boolean;
  47417. LINEARSPECULARREFLECTION: boolean;
  47418. RADIANCEOCCLUSION: boolean;
  47419. HORIZONOCCLUSION: boolean;
  47420. INSTANCES: boolean;
  47421. NUM_BONE_INFLUENCERS: number;
  47422. BonesPerMesh: number;
  47423. BONETEXTURE: boolean;
  47424. NONUNIFORMSCALING: boolean;
  47425. MORPHTARGETS: boolean;
  47426. MORPHTARGETS_NORMAL: boolean;
  47427. MORPHTARGETS_TANGENT: boolean;
  47428. MORPHTARGETS_UV: boolean;
  47429. NUM_MORPH_INFLUENCERS: number;
  47430. IMAGEPROCESSING: boolean;
  47431. VIGNETTE: boolean;
  47432. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47433. VIGNETTEBLENDMODEOPAQUE: boolean;
  47434. TONEMAPPING: boolean;
  47435. TONEMAPPING_ACES: boolean;
  47436. CONTRAST: boolean;
  47437. COLORCURVES: boolean;
  47438. COLORGRADING: boolean;
  47439. COLORGRADING3D: boolean;
  47440. SAMPLER3DGREENDEPTH: boolean;
  47441. SAMPLER3DBGRMAP: boolean;
  47442. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47443. EXPOSURE: boolean;
  47444. MULTIVIEW: boolean;
  47445. USEPHYSICALLIGHTFALLOFF: boolean;
  47446. USEGLTFLIGHTFALLOFF: boolean;
  47447. TWOSIDEDLIGHTING: boolean;
  47448. SHADOWFLOAT: boolean;
  47449. CLIPPLANE: boolean;
  47450. CLIPPLANE2: boolean;
  47451. CLIPPLANE3: boolean;
  47452. CLIPPLANE4: boolean;
  47453. POINTSIZE: boolean;
  47454. FOG: boolean;
  47455. LOGARITHMICDEPTH: boolean;
  47456. FORCENORMALFORWARD: boolean;
  47457. SPECULARAA: boolean;
  47458. CLEARCOAT: boolean;
  47459. CLEARCOAT_DEFAULTIOR: boolean;
  47460. CLEARCOAT_TEXTURE: boolean;
  47461. CLEARCOAT_TEXTUREDIRECTUV: number;
  47462. CLEARCOAT_BUMP: boolean;
  47463. CLEARCOAT_BUMPDIRECTUV: number;
  47464. CLEARCOAT_TINT: boolean;
  47465. CLEARCOAT_TINT_TEXTURE: boolean;
  47466. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47467. ANISOTROPIC: boolean;
  47468. ANISOTROPIC_TEXTURE: boolean;
  47469. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47470. BRDF_V_HEIGHT_CORRELATED: boolean;
  47471. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47472. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47473. SHEEN: boolean;
  47474. SHEEN_TEXTURE: boolean;
  47475. SHEEN_TEXTUREDIRECTUV: number;
  47476. SHEEN_LINKWITHALBEDO: boolean;
  47477. SUBSURFACE: boolean;
  47478. SS_REFRACTION: boolean;
  47479. SS_TRANSLUCENCY: boolean;
  47480. SS_SCATERRING: boolean;
  47481. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47482. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47483. SS_REFRACTIONMAP_3D: boolean;
  47484. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47485. SS_LODINREFRACTIONALPHA: boolean;
  47486. SS_GAMMAREFRACTION: boolean;
  47487. SS_RGBDREFRACTION: boolean;
  47488. SS_LINEARSPECULARREFRACTION: boolean;
  47489. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47490. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47491. UNLIT: boolean;
  47492. DEBUGMODE: number;
  47493. /**
  47494. * Initializes the PBR Material defines.
  47495. */
  47496. constructor();
  47497. /**
  47498. * Resets the PBR Material defines.
  47499. */
  47500. reset(): void;
  47501. }
  47502. /**
  47503. * The Physically based material base class of BJS.
  47504. *
  47505. * This offers the main features of a standard PBR material.
  47506. * For more information, please refer to the documentation :
  47507. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47508. */
  47509. export abstract class PBRBaseMaterial extends PushMaterial {
  47510. /**
  47511. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47512. */
  47513. static readonly PBRMATERIAL_OPAQUE: number;
  47514. /**
  47515. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47516. */
  47517. static readonly PBRMATERIAL_ALPHATEST: number;
  47518. /**
  47519. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47520. */
  47521. static readonly PBRMATERIAL_ALPHABLEND: number;
  47522. /**
  47523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47524. * They are also discarded below the alpha cutoff threshold to improve performances.
  47525. */
  47526. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47527. /**
  47528. * Defines the default value of how much AO map is occluding the analytical lights
  47529. * (point spot...).
  47530. */
  47531. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47532. /**
  47533. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47534. */
  47535. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47536. /**
  47537. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47538. * to enhance interoperability with other engines.
  47539. */
  47540. static readonly LIGHTFALLOFF_GLTF: number;
  47541. /**
  47542. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47543. * to enhance interoperability with other materials.
  47544. */
  47545. static readonly LIGHTFALLOFF_STANDARD: number;
  47546. /**
  47547. * Intensity of the direct lights e.g. the four lights available in your scene.
  47548. * This impacts both the direct diffuse and specular highlights.
  47549. */
  47550. protected _directIntensity: number;
  47551. /**
  47552. * Intensity of the emissive part of the material.
  47553. * This helps controlling the emissive effect without modifying the emissive color.
  47554. */
  47555. protected _emissiveIntensity: number;
  47556. /**
  47557. * Intensity of the environment e.g. how much the environment will light the object
  47558. * either through harmonics for rough material or through the refelction for shiny ones.
  47559. */
  47560. protected _environmentIntensity: number;
  47561. /**
  47562. * This is a special control allowing the reduction of the specular highlights coming from the
  47563. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47564. */
  47565. protected _specularIntensity: number;
  47566. /**
  47567. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47568. */
  47569. private _lightingInfos;
  47570. /**
  47571. * Debug Control allowing disabling the bump map on this material.
  47572. */
  47573. protected _disableBumpMap: boolean;
  47574. /**
  47575. * AKA Diffuse Texture in standard nomenclature.
  47576. */
  47577. protected _albedoTexture: Nullable<BaseTexture>;
  47578. /**
  47579. * AKA Occlusion Texture in other nomenclature.
  47580. */
  47581. protected _ambientTexture: Nullable<BaseTexture>;
  47582. /**
  47583. * AKA Occlusion Texture Intensity in other nomenclature.
  47584. */
  47585. protected _ambientTextureStrength: number;
  47586. /**
  47587. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47588. * 1 means it completely occludes it
  47589. * 0 mean it has no impact
  47590. */
  47591. protected _ambientTextureImpactOnAnalyticalLights: number;
  47592. /**
  47593. * Stores the alpha values in a texture.
  47594. */
  47595. protected _opacityTexture: Nullable<BaseTexture>;
  47596. /**
  47597. * Stores the reflection values in a texture.
  47598. */
  47599. protected _reflectionTexture: Nullable<BaseTexture>;
  47600. /**
  47601. * Stores the emissive values in a texture.
  47602. */
  47603. protected _emissiveTexture: Nullable<BaseTexture>;
  47604. /**
  47605. * AKA Specular texture in other nomenclature.
  47606. */
  47607. protected _reflectivityTexture: Nullable<BaseTexture>;
  47608. /**
  47609. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47610. */
  47611. protected _metallicTexture: Nullable<BaseTexture>;
  47612. /**
  47613. * Specifies the metallic scalar of the metallic/roughness workflow.
  47614. * Can also be used to scale the metalness values of the metallic texture.
  47615. */
  47616. protected _metallic: Nullable<number>;
  47617. /**
  47618. * Specifies the roughness scalar of the metallic/roughness workflow.
  47619. * Can also be used to scale the roughness values of the metallic texture.
  47620. */
  47621. protected _roughness: Nullable<number>;
  47622. /**
  47623. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47624. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47625. */
  47626. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47627. /**
  47628. * Stores surface normal data used to displace a mesh in a texture.
  47629. */
  47630. protected _bumpTexture: Nullable<BaseTexture>;
  47631. /**
  47632. * Stores the pre-calculated light information of a mesh in a texture.
  47633. */
  47634. protected _lightmapTexture: Nullable<BaseTexture>;
  47635. /**
  47636. * The color of a material in ambient lighting.
  47637. */
  47638. protected _ambientColor: Color3;
  47639. /**
  47640. * AKA Diffuse Color in other nomenclature.
  47641. */
  47642. protected _albedoColor: Color3;
  47643. /**
  47644. * AKA Specular Color in other nomenclature.
  47645. */
  47646. protected _reflectivityColor: Color3;
  47647. /**
  47648. * The color applied when light is reflected from a material.
  47649. */
  47650. protected _reflectionColor: Color3;
  47651. /**
  47652. * The color applied when light is emitted from a material.
  47653. */
  47654. protected _emissiveColor: Color3;
  47655. /**
  47656. * AKA Glossiness in other nomenclature.
  47657. */
  47658. protected _microSurface: number;
  47659. /**
  47660. * Specifies that the material will use the light map as a show map.
  47661. */
  47662. protected _useLightmapAsShadowmap: boolean;
  47663. /**
  47664. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47665. * makes the reflect vector face the model (under horizon).
  47666. */
  47667. protected _useHorizonOcclusion: boolean;
  47668. /**
  47669. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47670. * too much the area relying on ambient texture to define their ambient occlusion.
  47671. */
  47672. protected _useRadianceOcclusion: boolean;
  47673. /**
  47674. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47675. */
  47676. protected _useAlphaFromAlbedoTexture: boolean;
  47677. /**
  47678. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47679. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47680. */
  47681. protected _useSpecularOverAlpha: boolean;
  47682. /**
  47683. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47684. */
  47685. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47686. /**
  47687. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47688. */
  47689. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47690. /**
  47691. * Specifies if the metallic texture contains the roughness information in its green channel.
  47692. */
  47693. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47694. /**
  47695. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47696. */
  47697. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47698. /**
  47699. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47700. */
  47701. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47702. /**
  47703. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47704. */
  47705. protected _useAmbientInGrayScale: boolean;
  47706. /**
  47707. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47708. * The material will try to infer what glossiness each pixel should be.
  47709. */
  47710. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47711. /**
  47712. * Defines the falloff type used in this material.
  47713. * It by default is Physical.
  47714. */
  47715. protected _lightFalloff: number;
  47716. /**
  47717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47719. */
  47720. protected _useRadianceOverAlpha: boolean;
  47721. /**
  47722. * Allows using an object space normal map (instead of tangent space).
  47723. */
  47724. protected _useObjectSpaceNormalMap: boolean;
  47725. /**
  47726. * Allows using the bump map in parallax mode.
  47727. */
  47728. protected _useParallax: boolean;
  47729. /**
  47730. * Allows using the bump map in parallax occlusion mode.
  47731. */
  47732. protected _useParallaxOcclusion: boolean;
  47733. /**
  47734. * Controls the scale bias of the parallax mode.
  47735. */
  47736. protected _parallaxScaleBias: number;
  47737. /**
  47738. * If sets to true, disables all the lights affecting the material.
  47739. */
  47740. protected _disableLighting: boolean;
  47741. /**
  47742. * Number of Simultaneous lights allowed on the material.
  47743. */
  47744. protected _maxSimultaneousLights: number;
  47745. /**
  47746. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47747. */
  47748. protected _invertNormalMapX: boolean;
  47749. /**
  47750. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47751. */
  47752. protected _invertNormalMapY: boolean;
  47753. /**
  47754. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47755. */
  47756. protected _twoSidedLighting: boolean;
  47757. /**
  47758. * Defines the alpha limits in alpha test mode.
  47759. */
  47760. protected _alphaCutOff: number;
  47761. /**
  47762. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47763. */
  47764. protected _forceAlphaTest: boolean;
  47765. /**
  47766. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47767. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47768. */
  47769. protected _useAlphaFresnel: boolean;
  47770. /**
  47771. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47772. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47773. */
  47774. protected _useLinearAlphaFresnel: boolean;
  47775. /**
  47776. * The transparency mode of the material.
  47777. */
  47778. protected _transparencyMode: Nullable<number>;
  47779. /**
  47780. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47781. * from cos thetav and roughness:
  47782. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47783. */
  47784. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47785. /**
  47786. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47787. */
  47788. protected _forceIrradianceInFragment: boolean;
  47789. /**
  47790. * Force normal to face away from face.
  47791. */
  47792. protected _forceNormalForward: boolean;
  47793. /**
  47794. * Enables specular anti aliasing in the PBR shader.
  47795. * It will both interacts on the Geometry for analytical and IBL lighting.
  47796. * It also prefilter the roughness map based on the bump values.
  47797. */
  47798. protected _enableSpecularAntiAliasing: boolean;
  47799. /**
  47800. * Default configuration related to image processing available in the PBR Material.
  47801. */
  47802. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47803. /**
  47804. * Keep track of the image processing observer to allow dispose and replace.
  47805. */
  47806. private _imageProcessingObserver;
  47807. /**
  47808. * Attaches a new image processing configuration to the PBR Material.
  47809. * @param configuration
  47810. */
  47811. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47812. /**
  47813. * Stores the available render targets.
  47814. */
  47815. private _renderTargets;
  47816. /**
  47817. * Sets the global ambient color for the material used in lighting calculations.
  47818. */
  47819. private _globalAmbientColor;
  47820. /**
  47821. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47822. */
  47823. private _useLogarithmicDepth;
  47824. /**
  47825. * If set to true, no lighting calculations will be applied.
  47826. */
  47827. private _unlit;
  47828. private _debugMode;
  47829. /**
  47830. * @hidden
  47831. * This is reserved for the inspector.
  47832. * Defines the material debug mode.
  47833. * It helps seeing only some components of the material while troubleshooting.
  47834. */
  47835. debugMode: number;
  47836. /**
  47837. * @hidden
  47838. * This is reserved for the inspector.
  47839. * Specify from where on screen the debug mode should start.
  47840. * The value goes from -1 (full screen) to 1 (not visible)
  47841. * It helps with side by side comparison against the final render
  47842. * This defaults to -1
  47843. */
  47844. private debugLimit;
  47845. /**
  47846. * @hidden
  47847. * This is reserved for the inspector.
  47848. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47849. * You can use the factor to better multiply the final value.
  47850. */
  47851. private debugFactor;
  47852. /**
  47853. * Defines the clear coat layer parameters for the material.
  47854. */
  47855. readonly clearCoat: PBRClearCoatConfiguration;
  47856. /**
  47857. * Defines the anisotropic parameters for the material.
  47858. */
  47859. readonly anisotropy: PBRAnisotropicConfiguration;
  47860. /**
  47861. * Defines the BRDF parameters for the material.
  47862. */
  47863. readonly brdf: PBRBRDFConfiguration;
  47864. /**
  47865. * Defines the Sheen parameters for the material.
  47866. */
  47867. readonly sheen: PBRSheenConfiguration;
  47868. /**
  47869. * Defines the SubSurface parameters for the material.
  47870. */
  47871. readonly subSurface: PBRSubSurfaceConfiguration;
  47872. /**
  47873. * Custom callback helping to override the default shader used in the material.
  47874. */
  47875. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47876. protected _rebuildInParallel: boolean;
  47877. /**
  47878. * Instantiates a new PBRMaterial instance.
  47879. *
  47880. * @param name The material name
  47881. * @param scene The scene the material will be use in.
  47882. */
  47883. constructor(name: string, scene: Scene);
  47884. /**
  47885. * Gets a boolean indicating that current material needs to register RTT
  47886. */
  47887. readonly hasRenderTargetTextures: boolean;
  47888. /**
  47889. * Gets the name of the material class.
  47890. */
  47891. getClassName(): string;
  47892. /**
  47893. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47894. */
  47895. /**
  47896. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47897. */
  47898. useLogarithmicDepth: boolean;
  47899. /**
  47900. * Gets the current transparency mode.
  47901. */
  47902. /**
  47903. * Sets the transparency mode of the material.
  47904. *
  47905. * | Value | Type | Description |
  47906. * | ----- | ----------------------------------- | ----------- |
  47907. * | 0 | OPAQUE | |
  47908. * | 1 | ALPHATEST | |
  47909. * | 2 | ALPHABLEND | |
  47910. * | 3 | ALPHATESTANDBLEND | |
  47911. *
  47912. */
  47913. transparencyMode: Nullable<number>;
  47914. /**
  47915. * Returns true if alpha blending should be disabled.
  47916. */
  47917. private readonly _disableAlphaBlending;
  47918. /**
  47919. * Specifies whether or not this material should be rendered in alpha blend mode.
  47920. */
  47921. needAlphaBlending(): boolean;
  47922. /**
  47923. * Specifies if the mesh will require alpha blending.
  47924. * @param mesh - BJS mesh.
  47925. */
  47926. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47927. /**
  47928. * Specifies whether or not this material should be rendered in alpha test mode.
  47929. */
  47930. needAlphaTesting(): boolean;
  47931. /**
  47932. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47933. */
  47934. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47935. /**
  47936. * Gets the texture used for the alpha test.
  47937. */
  47938. getAlphaTestTexture(): Nullable<BaseTexture>;
  47939. /**
  47940. * Specifies that the submesh is ready to be used.
  47941. * @param mesh - BJS mesh.
  47942. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47943. * @param useInstances - Specifies that instances should be used.
  47944. * @returns - boolean indicating that the submesh is ready or not.
  47945. */
  47946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47947. /**
  47948. * Specifies if the material uses metallic roughness workflow.
  47949. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47950. */
  47951. isMetallicWorkflow(): boolean;
  47952. private _prepareEffect;
  47953. private _prepareDefines;
  47954. /**
  47955. * Force shader compilation
  47956. */
  47957. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47958. clipPlane: boolean;
  47959. }>): void;
  47960. /**
  47961. * Initializes the uniform buffer layout for the shader.
  47962. */
  47963. buildUniformLayout(): void;
  47964. /**
  47965. * Unbinds the material from the mesh
  47966. */
  47967. unbind(): void;
  47968. /**
  47969. * Binds the submesh data.
  47970. * @param world - The world matrix.
  47971. * @param mesh - The BJS mesh.
  47972. * @param subMesh - A submesh of the BJS mesh.
  47973. */
  47974. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47975. /**
  47976. * Returns the animatable textures.
  47977. * @returns - Array of animatable textures.
  47978. */
  47979. getAnimatables(): IAnimatable[];
  47980. /**
  47981. * Returns the texture used for reflections.
  47982. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47983. */
  47984. private _getReflectionTexture;
  47985. /**
  47986. * Returns an array of the actively used textures.
  47987. * @returns - Array of BaseTextures
  47988. */
  47989. getActiveTextures(): BaseTexture[];
  47990. /**
  47991. * Checks to see if a texture is used in the material.
  47992. * @param texture - Base texture to use.
  47993. * @returns - Boolean specifying if a texture is used in the material.
  47994. */
  47995. hasTexture(texture: BaseTexture): boolean;
  47996. /**
  47997. * Disposes the resources of the material.
  47998. * @param forceDisposeEffect - Forces the disposal of effects.
  47999. * @param forceDisposeTextures - Forces the disposal of all textures.
  48000. */
  48001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48002. }
  48003. }
  48004. declare module BABYLON {
  48005. /**
  48006. * The Physically based material of BJS.
  48007. *
  48008. * This offers the main features of a standard PBR material.
  48009. * For more information, please refer to the documentation :
  48010. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48011. */
  48012. export class PBRMaterial extends PBRBaseMaterial {
  48013. /**
  48014. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48015. */
  48016. static readonly PBRMATERIAL_OPAQUE: number;
  48017. /**
  48018. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48019. */
  48020. static readonly PBRMATERIAL_ALPHATEST: number;
  48021. /**
  48022. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48023. */
  48024. static readonly PBRMATERIAL_ALPHABLEND: number;
  48025. /**
  48026. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48027. * They are also discarded below the alpha cutoff threshold to improve performances.
  48028. */
  48029. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48030. /**
  48031. * Defines the default value of how much AO map is occluding the analytical lights
  48032. * (point spot...).
  48033. */
  48034. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48035. /**
  48036. * Intensity of the direct lights e.g. the four lights available in your scene.
  48037. * This impacts both the direct diffuse and specular highlights.
  48038. */
  48039. directIntensity: number;
  48040. /**
  48041. * Intensity of the emissive part of the material.
  48042. * This helps controlling the emissive effect without modifying the emissive color.
  48043. */
  48044. emissiveIntensity: number;
  48045. /**
  48046. * Intensity of the environment e.g. how much the environment will light the object
  48047. * either through harmonics for rough material or through the refelction for shiny ones.
  48048. */
  48049. environmentIntensity: number;
  48050. /**
  48051. * This is a special control allowing the reduction of the specular highlights coming from the
  48052. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48053. */
  48054. specularIntensity: number;
  48055. /**
  48056. * Debug Control allowing disabling the bump map on this material.
  48057. */
  48058. disableBumpMap: boolean;
  48059. /**
  48060. * AKA Diffuse Texture in standard nomenclature.
  48061. */
  48062. albedoTexture: BaseTexture;
  48063. /**
  48064. * AKA Occlusion Texture in other nomenclature.
  48065. */
  48066. ambientTexture: BaseTexture;
  48067. /**
  48068. * AKA Occlusion Texture Intensity in other nomenclature.
  48069. */
  48070. ambientTextureStrength: number;
  48071. /**
  48072. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48073. * 1 means it completely occludes it
  48074. * 0 mean it has no impact
  48075. */
  48076. ambientTextureImpactOnAnalyticalLights: number;
  48077. /**
  48078. * Stores the alpha values in a texture.
  48079. */
  48080. opacityTexture: BaseTexture;
  48081. /**
  48082. * Stores the reflection values in a texture.
  48083. */
  48084. reflectionTexture: Nullable<BaseTexture>;
  48085. /**
  48086. * Stores the emissive values in a texture.
  48087. */
  48088. emissiveTexture: BaseTexture;
  48089. /**
  48090. * AKA Specular texture in other nomenclature.
  48091. */
  48092. reflectivityTexture: BaseTexture;
  48093. /**
  48094. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48095. */
  48096. metallicTexture: BaseTexture;
  48097. /**
  48098. * Specifies the metallic scalar of the metallic/roughness workflow.
  48099. * Can also be used to scale the metalness values of the metallic texture.
  48100. */
  48101. metallic: Nullable<number>;
  48102. /**
  48103. * Specifies the roughness scalar of the metallic/roughness workflow.
  48104. * Can also be used to scale the roughness values of the metallic texture.
  48105. */
  48106. roughness: Nullable<number>;
  48107. /**
  48108. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48109. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48110. */
  48111. microSurfaceTexture: BaseTexture;
  48112. /**
  48113. * Stores surface normal data used to displace a mesh in a texture.
  48114. */
  48115. bumpTexture: BaseTexture;
  48116. /**
  48117. * Stores the pre-calculated light information of a mesh in a texture.
  48118. */
  48119. lightmapTexture: BaseTexture;
  48120. /**
  48121. * Stores the refracted light information in a texture.
  48122. */
  48123. refractionTexture: Nullable<BaseTexture>;
  48124. /**
  48125. * The color of a material in ambient lighting.
  48126. */
  48127. ambientColor: Color3;
  48128. /**
  48129. * AKA Diffuse Color in other nomenclature.
  48130. */
  48131. albedoColor: Color3;
  48132. /**
  48133. * AKA Specular Color in other nomenclature.
  48134. */
  48135. reflectivityColor: Color3;
  48136. /**
  48137. * The color reflected from the material.
  48138. */
  48139. reflectionColor: Color3;
  48140. /**
  48141. * The color emitted from the material.
  48142. */
  48143. emissiveColor: Color3;
  48144. /**
  48145. * AKA Glossiness in other nomenclature.
  48146. */
  48147. microSurface: number;
  48148. /**
  48149. * source material index of refraction (IOR)' / 'destination material IOR.
  48150. */
  48151. indexOfRefraction: number;
  48152. /**
  48153. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48154. */
  48155. invertRefractionY: boolean;
  48156. /**
  48157. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48158. * Materials half opaque for instance using refraction could benefit from this control.
  48159. */
  48160. linkRefractionWithTransparency: boolean;
  48161. /**
  48162. * If true, the light map contains occlusion information instead of lighting info.
  48163. */
  48164. useLightmapAsShadowmap: boolean;
  48165. /**
  48166. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48167. */
  48168. useAlphaFromAlbedoTexture: boolean;
  48169. /**
  48170. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48171. */
  48172. forceAlphaTest: boolean;
  48173. /**
  48174. * Defines the alpha limits in alpha test mode.
  48175. */
  48176. alphaCutOff: number;
  48177. /**
  48178. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48179. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48180. */
  48181. useSpecularOverAlpha: boolean;
  48182. /**
  48183. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48184. */
  48185. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48186. /**
  48187. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48188. */
  48189. useRoughnessFromMetallicTextureAlpha: boolean;
  48190. /**
  48191. * Specifies if the metallic texture contains the roughness information in its green channel.
  48192. */
  48193. useRoughnessFromMetallicTextureGreen: boolean;
  48194. /**
  48195. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48196. */
  48197. useMetallnessFromMetallicTextureBlue: boolean;
  48198. /**
  48199. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48200. */
  48201. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48202. /**
  48203. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48204. */
  48205. useAmbientInGrayScale: boolean;
  48206. /**
  48207. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48208. * The material will try to infer what glossiness each pixel should be.
  48209. */
  48210. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48211. /**
  48212. * BJS is using an harcoded light falloff based on a manually sets up range.
  48213. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48214. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48215. */
  48216. /**
  48217. * BJS is using an harcoded light falloff based on a manually sets up range.
  48218. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48219. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48220. */
  48221. usePhysicalLightFalloff: boolean;
  48222. /**
  48223. * In order to support the falloff compatibility with gltf, a special mode has been added
  48224. * to reproduce the gltf light falloff.
  48225. */
  48226. /**
  48227. * In order to support the falloff compatibility with gltf, a special mode has been added
  48228. * to reproduce the gltf light falloff.
  48229. */
  48230. useGLTFLightFalloff: boolean;
  48231. /**
  48232. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48233. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48234. */
  48235. useRadianceOverAlpha: boolean;
  48236. /**
  48237. * Allows using an object space normal map (instead of tangent space).
  48238. */
  48239. useObjectSpaceNormalMap: boolean;
  48240. /**
  48241. * Allows using the bump map in parallax mode.
  48242. */
  48243. useParallax: boolean;
  48244. /**
  48245. * Allows using the bump map in parallax occlusion mode.
  48246. */
  48247. useParallaxOcclusion: boolean;
  48248. /**
  48249. * Controls the scale bias of the parallax mode.
  48250. */
  48251. parallaxScaleBias: number;
  48252. /**
  48253. * If sets to true, disables all the lights affecting the material.
  48254. */
  48255. disableLighting: boolean;
  48256. /**
  48257. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48258. */
  48259. forceIrradianceInFragment: boolean;
  48260. /**
  48261. * Number of Simultaneous lights allowed on the material.
  48262. */
  48263. maxSimultaneousLights: number;
  48264. /**
  48265. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48266. */
  48267. invertNormalMapX: boolean;
  48268. /**
  48269. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48270. */
  48271. invertNormalMapY: boolean;
  48272. /**
  48273. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48274. */
  48275. twoSidedLighting: boolean;
  48276. /**
  48277. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48278. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48279. */
  48280. useAlphaFresnel: boolean;
  48281. /**
  48282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48283. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48284. */
  48285. useLinearAlphaFresnel: boolean;
  48286. /**
  48287. * Let user defines the brdf lookup texture used for IBL.
  48288. * A default 8bit version is embedded but you could point at :
  48289. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48290. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48291. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48292. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48293. */
  48294. environmentBRDFTexture: Nullable<BaseTexture>;
  48295. /**
  48296. * Force normal to face away from face.
  48297. */
  48298. forceNormalForward: boolean;
  48299. /**
  48300. * Enables specular anti aliasing in the PBR shader.
  48301. * It will both interacts on the Geometry for analytical and IBL lighting.
  48302. * It also prefilter the roughness map based on the bump values.
  48303. */
  48304. enableSpecularAntiAliasing: boolean;
  48305. /**
  48306. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48307. * makes the reflect vector face the model (under horizon).
  48308. */
  48309. useHorizonOcclusion: boolean;
  48310. /**
  48311. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48312. * too much the area relying on ambient texture to define their ambient occlusion.
  48313. */
  48314. useRadianceOcclusion: boolean;
  48315. /**
  48316. * If set to true, no lighting calculations will be applied.
  48317. */
  48318. unlit: boolean;
  48319. /**
  48320. * Gets the image processing configuration used either in this material.
  48321. */
  48322. /**
  48323. * Sets the Default image processing configuration used either in the this material.
  48324. *
  48325. * If sets to null, the scene one is in use.
  48326. */
  48327. imageProcessingConfiguration: ImageProcessingConfiguration;
  48328. /**
  48329. * Gets wether the color curves effect is enabled.
  48330. */
  48331. /**
  48332. * Sets wether the color curves effect is enabled.
  48333. */
  48334. cameraColorCurvesEnabled: boolean;
  48335. /**
  48336. * Gets wether the color grading effect is enabled.
  48337. */
  48338. /**
  48339. * Gets wether the color grading effect is enabled.
  48340. */
  48341. cameraColorGradingEnabled: boolean;
  48342. /**
  48343. * Gets wether tonemapping is enabled or not.
  48344. */
  48345. /**
  48346. * Sets wether tonemapping is enabled or not
  48347. */
  48348. cameraToneMappingEnabled: boolean;
  48349. /**
  48350. * The camera exposure used on this material.
  48351. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48352. * This corresponds to a photographic exposure.
  48353. */
  48354. /**
  48355. * The camera exposure used on this material.
  48356. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48357. * This corresponds to a photographic exposure.
  48358. */
  48359. cameraExposure: number;
  48360. /**
  48361. * Gets The camera contrast used on this material.
  48362. */
  48363. /**
  48364. * Sets The camera contrast used on this material.
  48365. */
  48366. cameraContrast: number;
  48367. /**
  48368. * Gets the Color Grading 2D Lookup Texture.
  48369. */
  48370. /**
  48371. * Sets the Color Grading 2D Lookup Texture.
  48372. */
  48373. cameraColorGradingTexture: Nullable<BaseTexture>;
  48374. /**
  48375. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48376. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48377. * 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;
  48378. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48379. */
  48380. /**
  48381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48383. * 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;
  48384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48385. */
  48386. cameraColorCurves: Nullable<ColorCurves>;
  48387. /**
  48388. * Instantiates a new PBRMaterial instance.
  48389. *
  48390. * @param name The material name
  48391. * @param scene The scene the material will be use in.
  48392. */
  48393. constructor(name: string, scene: Scene);
  48394. /**
  48395. * Returns the name of this material class.
  48396. */
  48397. getClassName(): string;
  48398. /**
  48399. * Makes a duplicate of the current material.
  48400. * @param name - name to use for the new material.
  48401. */
  48402. clone(name: string): PBRMaterial;
  48403. /**
  48404. * Serializes this PBR Material.
  48405. * @returns - An object with the serialized material.
  48406. */
  48407. serialize(): any;
  48408. /**
  48409. * Parses a PBR Material from a serialized object.
  48410. * @param source - Serialized object.
  48411. * @param scene - BJS scene instance.
  48412. * @param rootUrl - url for the scene object
  48413. * @returns - PBRMaterial
  48414. */
  48415. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48416. }
  48417. }
  48418. declare module BABYLON {
  48419. /**
  48420. * Direct draw surface info
  48421. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48422. */
  48423. export interface DDSInfo {
  48424. /**
  48425. * Width of the texture
  48426. */
  48427. width: number;
  48428. /**
  48429. * Width of the texture
  48430. */
  48431. height: number;
  48432. /**
  48433. * Number of Mipmaps for the texture
  48434. * @see https://en.wikipedia.org/wiki/Mipmap
  48435. */
  48436. mipmapCount: number;
  48437. /**
  48438. * If the textures format is a known fourCC format
  48439. * @see https://www.fourcc.org/
  48440. */
  48441. isFourCC: boolean;
  48442. /**
  48443. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48444. */
  48445. isRGB: boolean;
  48446. /**
  48447. * If the texture is a lumincance format
  48448. */
  48449. isLuminance: boolean;
  48450. /**
  48451. * If this is a cube texture
  48452. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48453. */
  48454. isCube: boolean;
  48455. /**
  48456. * If the texture is a compressed format eg. FOURCC_DXT1
  48457. */
  48458. isCompressed: boolean;
  48459. /**
  48460. * The dxgiFormat of the texture
  48461. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48462. */
  48463. dxgiFormat: number;
  48464. /**
  48465. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48466. */
  48467. textureType: number;
  48468. /**
  48469. * Sphericle polynomial created for the dds texture
  48470. */
  48471. sphericalPolynomial?: SphericalPolynomial;
  48472. }
  48473. /**
  48474. * Class used to provide DDS decompression tools
  48475. */
  48476. export class DDSTools {
  48477. /**
  48478. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48479. */
  48480. static StoreLODInAlphaChannel: boolean;
  48481. /**
  48482. * Gets DDS information from an array buffer
  48483. * @param arrayBuffer defines the array buffer to read data from
  48484. * @returns the DDS information
  48485. */
  48486. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48487. private static _FloatView;
  48488. private static _Int32View;
  48489. private static _ToHalfFloat;
  48490. private static _FromHalfFloat;
  48491. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48492. private static _GetHalfFloatRGBAArrayBuffer;
  48493. private static _GetFloatRGBAArrayBuffer;
  48494. private static _GetFloatAsUIntRGBAArrayBuffer;
  48495. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48496. private static _GetRGBAArrayBuffer;
  48497. private static _ExtractLongWordOrder;
  48498. private static _GetRGBArrayBuffer;
  48499. private static _GetLuminanceArrayBuffer;
  48500. /**
  48501. * Uploads DDS Levels to a Babylon Texture
  48502. * @hidden
  48503. */
  48504. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48505. }
  48506. interface ThinEngine {
  48507. /**
  48508. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48509. * @param rootUrl defines the url where the file to load is located
  48510. * @param scene defines the current scene
  48511. * @param lodScale defines scale to apply to the mip map selection
  48512. * @param lodOffset defines offset to apply to the mip map selection
  48513. * @param onLoad defines an optional callback raised when the texture is loaded
  48514. * @param onError defines an optional callback raised if there is an issue to load the texture
  48515. * @param format defines the format of the data
  48516. * @param forcedExtension defines the extension to use to pick the right loader
  48517. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48518. * @returns the cube texture as an InternalTexture
  48519. */
  48520. 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;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * Implementation of the DDS Texture Loader.
  48526. * @hidden
  48527. */
  48528. export class _DDSTextureLoader implements IInternalTextureLoader {
  48529. /**
  48530. * Defines wether the loader supports cascade loading the different faces.
  48531. */
  48532. readonly supportCascades: boolean;
  48533. /**
  48534. * This returns if the loader support the current file information.
  48535. * @param extension defines the file extension of the file being loaded
  48536. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48537. * @param fallback defines the fallback internal texture if any
  48538. * @param isBase64 defines whether the texture is encoded as a base64
  48539. * @param isBuffer defines whether the texture data are stored as a buffer
  48540. * @returns true if the loader can load the specified file
  48541. */
  48542. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48543. /**
  48544. * Transform the url before loading if required.
  48545. * @param rootUrl the url of the texture
  48546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48547. * @returns the transformed texture
  48548. */
  48549. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48550. /**
  48551. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48552. * @param rootUrl the url of the texture
  48553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48554. * @returns the fallback texture
  48555. */
  48556. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48557. /**
  48558. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48559. * @param data contains the texture data
  48560. * @param texture defines the BabylonJS internal texture
  48561. * @param createPolynomials will be true if polynomials have been requested
  48562. * @param onLoad defines the callback to trigger once the texture is ready
  48563. * @param onError defines the callback to trigger in case of error
  48564. */
  48565. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48566. /**
  48567. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48568. * @param data contains the texture data
  48569. * @param texture defines the BabylonJS internal texture
  48570. * @param callback defines the method to call once ready to upload
  48571. */
  48572. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48573. }
  48574. }
  48575. declare module BABYLON {
  48576. /**
  48577. * Implementation of the ENV Texture Loader.
  48578. * @hidden
  48579. */
  48580. export class _ENVTextureLoader implements IInternalTextureLoader {
  48581. /**
  48582. * Defines wether the loader supports cascade loading the different faces.
  48583. */
  48584. readonly supportCascades: boolean;
  48585. /**
  48586. * This returns if the loader support the current file information.
  48587. * @param extension defines the file extension of the file being loaded
  48588. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48589. * @param fallback defines the fallback internal texture if any
  48590. * @param isBase64 defines whether the texture is encoded as a base64
  48591. * @param isBuffer defines whether the texture data are stored as a buffer
  48592. * @returns true if the loader can load the specified file
  48593. */
  48594. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48595. /**
  48596. * Transform the url before loading if required.
  48597. * @param rootUrl the url of the texture
  48598. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48599. * @returns the transformed texture
  48600. */
  48601. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48602. /**
  48603. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48604. * @param rootUrl the url of the texture
  48605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48606. * @returns the fallback texture
  48607. */
  48608. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48609. /**
  48610. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48611. * @param data contains the texture data
  48612. * @param texture defines the BabylonJS internal texture
  48613. * @param createPolynomials will be true if polynomials have been requested
  48614. * @param onLoad defines the callback to trigger once the texture is ready
  48615. * @param onError defines the callback to trigger in case of error
  48616. */
  48617. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48618. /**
  48619. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48620. * @param data contains the texture data
  48621. * @param texture defines the BabylonJS internal texture
  48622. * @param callback defines the method to call once ready to upload
  48623. */
  48624. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. /**
  48629. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48630. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48631. */
  48632. export class KhronosTextureContainer {
  48633. /** contents of the KTX container file */
  48634. arrayBuffer: any;
  48635. private static HEADER_LEN;
  48636. private static COMPRESSED_2D;
  48637. private static COMPRESSED_3D;
  48638. private static TEX_2D;
  48639. private static TEX_3D;
  48640. /**
  48641. * Gets the openGL type
  48642. */
  48643. glType: number;
  48644. /**
  48645. * Gets the openGL type size
  48646. */
  48647. glTypeSize: number;
  48648. /**
  48649. * Gets the openGL format
  48650. */
  48651. glFormat: number;
  48652. /**
  48653. * Gets the openGL internal format
  48654. */
  48655. glInternalFormat: number;
  48656. /**
  48657. * Gets the base internal format
  48658. */
  48659. glBaseInternalFormat: number;
  48660. /**
  48661. * Gets image width in pixel
  48662. */
  48663. pixelWidth: number;
  48664. /**
  48665. * Gets image height in pixel
  48666. */
  48667. pixelHeight: number;
  48668. /**
  48669. * Gets image depth in pixels
  48670. */
  48671. pixelDepth: number;
  48672. /**
  48673. * Gets the number of array elements
  48674. */
  48675. numberOfArrayElements: number;
  48676. /**
  48677. * Gets the number of faces
  48678. */
  48679. numberOfFaces: number;
  48680. /**
  48681. * Gets the number of mipmap levels
  48682. */
  48683. numberOfMipmapLevels: number;
  48684. /**
  48685. * Gets the bytes of key value data
  48686. */
  48687. bytesOfKeyValueData: number;
  48688. /**
  48689. * Gets the load type
  48690. */
  48691. loadType: number;
  48692. /**
  48693. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48694. */
  48695. isInvalid: boolean;
  48696. /**
  48697. * Creates a new KhronosTextureContainer
  48698. * @param arrayBuffer contents of the KTX container file
  48699. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48700. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48701. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48702. */
  48703. constructor(
  48704. /** contents of the KTX container file */
  48705. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48706. /**
  48707. * Uploads KTX content to a Babylon Texture.
  48708. * It is assumed that the texture has already been created & is currently bound
  48709. * @hidden
  48710. */
  48711. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48712. private _upload2DCompressedLevels;
  48713. }
  48714. }
  48715. declare module BABYLON {
  48716. /**
  48717. * Implementation of the KTX Texture Loader.
  48718. * @hidden
  48719. */
  48720. export class _KTXTextureLoader implements IInternalTextureLoader {
  48721. /**
  48722. * Defines wether the loader supports cascade loading the different faces.
  48723. */
  48724. readonly supportCascades: boolean;
  48725. /**
  48726. * This returns if the loader support the current file information.
  48727. * @param extension defines the file extension of the file being loaded
  48728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48729. * @param fallback defines the fallback internal texture if any
  48730. * @param isBase64 defines whether the texture is encoded as a base64
  48731. * @param isBuffer defines whether the texture data are stored as a buffer
  48732. * @returns true if the loader can load the specified file
  48733. */
  48734. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48735. /**
  48736. * Transform the url before loading if required.
  48737. * @param rootUrl the url of the texture
  48738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48739. * @returns the transformed texture
  48740. */
  48741. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48742. /**
  48743. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48744. * @param rootUrl the url of the texture
  48745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48746. * @returns the fallback texture
  48747. */
  48748. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48749. /**
  48750. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48751. * @param data contains the texture data
  48752. * @param texture defines the BabylonJS internal texture
  48753. * @param createPolynomials will be true if polynomials have been requested
  48754. * @param onLoad defines the callback to trigger once the texture is ready
  48755. * @param onError defines the callback to trigger in case of error
  48756. */
  48757. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48758. /**
  48759. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48760. * @param data contains the texture data
  48761. * @param texture defines the BabylonJS internal texture
  48762. * @param callback defines the method to call once ready to upload
  48763. */
  48764. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48765. }
  48766. }
  48767. declare module BABYLON {
  48768. /**
  48769. * Options for the default xr helper
  48770. */
  48771. export class WebXRDefaultExperienceOptions {
  48772. /**
  48773. * Floor meshes that should be used for teleporting
  48774. */
  48775. floorMeshes: Array<AbstractMesh>;
  48776. }
  48777. /**
  48778. * Default experience which provides a similar setup to the previous webVRExperience
  48779. */
  48780. export class WebXRDefaultExperience {
  48781. /**
  48782. * Base experience
  48783. */
  48784. baseExperience: WebXRExperienceHelper;
  48785. /**
  48786. * Input experience extension
  48787. */
  48788. input: WebXRInput;
  48789. /**
  48790. * Loads the controller models
  48791. */
  48792. controllerModelLoader: WebXRControllerModelLoader;
  48793. /**
  48794. * Enables laser pointer and selection
  48795. */
  48796. pointerSelection: WebXRControllerPointerSelection;
  48797. /**
  48798. * Enables teleportation
  48799. */
  48800. teleportation: WebXRControllerTeleportation;
  48801. /**
  48802. * Enables ui for enetering/exiting xr
  48803. */
  48804. enterExitUI: WebXREnterExitUI;
  48805. /**
  48806. * Default output canvas xr should render to
  48807. */
  48808. outputCanvas: WebXRManagedOutputCanvas;
  48809. /**
  48810. * Creates the default xr experience
  48811. * @param scene scene
  48812. * @param options options for basic configuration
  48813. * @returns resulting WebXRDefaultExperience
  48814. */
  48815. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48816. private constructor();
  48817. /**
  48818. * DIsposes of the experience helper
  48819. */
  48820. dispose(): void;
  48821. }
  48822. }
  48823. declare module BABYLON {
  48824. /** @hidden */
  48825. export var _forceSceneHelpersToBundle: boolean;
  48826. interface Scene {
  48827. /**
  48828. * Creates a default light for the scene.
  48829. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48830. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48831. */
  48832. createDefaultLight(replace?: boolean): void;
  48833. /**
  48834. * Creates a default camera for the scene.
  48835. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48836. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48837. * @param replace has default false, when true replaces the active camera in the scene
  48838. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48839. */
  48840. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48841. /**
  48842. * Creates a default camera and a default light.
  48843. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48844. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48845. * @param replace has the default false, when true replaces the active camera/light in the scene
  48846. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48847. */
  48848. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48849. /**
  48850. * Creates a new sky box
  48851. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48852. * @param environmentTexture defines the texture to use as environment texture
  48853. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48854. * @param scale defines the overall scale of the skybox
  48855. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48856. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48857. * @returns a new mesh holding the sky box
  48858. */
  48859. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48860. /**
  48861. * Creates a new environment
  48862. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48863. * @param options defines the options you can use to configure the environment
  48864. * @returns the new EnvironmentHelper
  48865. */
  48866. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48867. /**
  48868. * Creates a new VREXperienceHelper
  48869. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48870. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48871. * @returns a new VREXperienceHelper
  48872. */
  48873. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48874. /**
  48875. * Creates a new WebXRDefaultExperience
  48876. * @see http://doc.babylonjs.com/how_to/webxr
  48877. * @param options experience options
  48878. * @returns a promise for a new WebXRDefaultExperience
  48879. */
  48880. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48881. }
  48882. }
  48883. declare module BABYLON {
  48884. /**
  48885. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48886. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48887. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48888. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48889. */
  48890. export class VideoDome extends TransformNode {
  48891. /**
  48892. * Define the video source as a Monoscopic panoramic 360 video.
  48893. */
  48894. static readonly MODE_MONOSCOPIC: number;
  48895. /**
  48896. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48897. */
  48898. static readonly MODE_TOPBOTTOM: number;
  48899. /**
  48900. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48901. */
  48902. static readonly MODE_SIDEBYSIDE: number;
  48903. private _halfDome;
  48904. private _useDirectMapping;
  48905. /**
  48906. * The video texture being displayed on the sphere
  48907. */
  48908. protected _videoTexture: VideoTexture;
  48909. /**
  48910. * Gets the video texture being displayed on the sphere
  48911. */
  48912. readonly videoTexture: VideoTexture;
  48913. /**
  48914. * The skybox material
  48915. */
  48916. protected _material: BackgroundMaterial;
  48917. /**
  48918. * The surface used for the skybox
  48919. */
  48920. protected _mesh: Mesh;
  48921. /**
  48922. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48923. */
  48924. private _halfDomeMask;
  48925. /**
  48926. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48927. * Also see the options.resolution property.
  48928. */
  48929. fovMultiplier: number;
  48930. private _videoMode;
  48931. /**
  48932. * Gets or set the current video mode for the video. It can be:
  48933. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48934. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48935. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48936. */
  48937. videoMode: number;
  48938. /**
  48939. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48940. *
  48941. */
  48942. /**
  48943. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48944. */
  48945. halfDome: boolean;
  48946. /**
  48947. * Oberserver used in Stereoscopic VR Mode.
  48948. */
  48949. private _onBeforeCameraRenderObserver;
  48950. /**
  48951. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48952. * @param name Element's name, child elements will append suffixes for their own names.
  48953. * @param urlsOrVideo defines the url(s) or the video element to use
  48954. * @param options An object containing optional or exposed sub element properties
  48955. */
  48956. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48957. resolution?: number;
  48958. clickToPlay?: boolean;
  48959. autoPlay?: boolean;
  48960. loop?: boolean;
  48961. size?: number;
  48962. poster?: string;
  48963. faceForward?: boolean;
  48964. useDirectMapping?: boolean;
  48965. halfDomeMode?: boolean;
  48966. }, scene: Scene);
  48967. private _changeVideoMode;
  48968. /**
  48969. * Releases resources associated with this node.
  48970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48972. */
  48973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48974. }
  48975. }
  48976. declare module BABYLON {
  48977. /**
  48978. * This class can be used to get instrumentation data from a Babylon engine
  48979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48980. */
  48981. export class EngineInstrumentation implements IDisposable {
  48982. /**
  48983. * Define the instrumented engine.
  48984. */
  48985. engine: Engine;
  48986. private _captureGPUFrameTime;
  48987. private _gpuFrameTimeToken;
  48988. private _gpuFrameTime;
  48989. private _captureShaderCompilationTime;
  48990. private _shaderCompilationTime;
  48991. private _onBeginFrameObserver;
  48992. private _onEndFrameObserver;
  48993. private _onBeforeShaderCompilationObserver;
  48994. private _onAfterShaderCompilationObserver;
  48995. /**
  48996. * Gets the perf counter used for GPU frame time
  48997. */
  48998. readonly gpuFrameTimeCounter: PerfCounter;
  48999. /**
  49000. * Gets the GPU frame time capture status
  49001. */
  49002. /**
  49003. * Enable or disable the GPU frame time capture
  49004. */
  49005. captureGPUFrameTime: boolean;
  49006. /**
  49007. * Gets the perf counter used for shader compilation time
  49008. */
  49009. readonly shaderCompilationTimeCounter: PerfCounter;
  49010. /**
  49011. * Gets the shader compilation time capture status
  49012. */
  49013. /**
  49014. * Enable or disable the shader compilation time capture
  49015. */
  49016. captureShaderCompilationTime: boolean;
  49017. /**
  49018. * Instantiates a new engine instrumentation.
  49019. * This class can be used to get instrumentation data from a Babylon engine
  49020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49021. * @param engine Defines the engine to instrument
  49022. */
  49023. constructor(
  49024. /**
  49025. * Define the instrumented engine.
  49026. */
  49027. engine: Engine);
  49028. /**
  49029. * Dispose and release associated resources.
  49030. */
  49031. dispose(): void;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /**
  49036. * This class can be used to get instrumentation data from a Babylon engine
  49037. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49038. */
  49039. export class SceneInstrumentation implements IDisposable {
  49040. /**
  49041. * Defines the scene to instrument
  49042. */
  49043. scene: Scene;
  49044. private _captureActiveMeshesEvaluationTime;
  49045. private _activeMeshesEvaluationTime;
  49046. private _captureRenderTargetsRenderTime;
  49047. private _renderTargetsRenderTime;
  49048. private _captureFrameTime;
  49049. private _frameTime;
  49050. private _captureRenderTime;
  49051. private _renderTime;
  49052. private _captureInterFrameTime;
  49053. private _interFrameTime;
  49054. private _captureParticlesRenderTime;
  49055. private _particlesRenderTime;
  49056. private _captureSpritesRenderTime;
  49057. private _spritesRenderTime;
  49058. private _capturePhysicsTime;
  49059. private _physicsTime;
  49060. private _captureAnimationsTime;
  49061. private _animationsTime;
  49062. private _captureCameraRenderTime;
  49063. private _cameraRenderTime;
  49064. private _onBeforeActiveMeshesEvaluationObserver;
  49065. private _onAfterActiveMeshesEvaluationObserver;
  49066. private _onBeforeRenderTargetsRenderObserver;
  49067. private _onAfterRenderTargetsRenderObserver;
  49068. private _onAfterRenderObserver;
  49069. private _onBeforeDrawPhaseObserver;
  49070. private _onAfterDrawPhaseObserver;
  49071. private _onBeforeAnimationsObserver;
  49072. private _onBeforeParticlesRenderingObserver;
  49073. private _onAfterParticlesRenderingObserver;
  49074. private _onBeforeSpritesRenderingObserver;
  49075. private _onAfterSpritesRenderingObserver;
  49076. private _onBeforePhysicsObserver;
  49077. private _onAfterPhysicsObserver;
  49078. private _onAfterAnimationsObserver;
  49079. private _onBeforeCameraRenderObserver;
  49080. private _onAfterCameraRenderObserver;
  49081. /**
  49082. * Gets the perf counter used for active meshes evaluation time
  49083. */
  49084. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49085. /**
  49086. * Gets the active meshes evaluation time capture status
  49087. */
  49088. /**
  49089. * Enable or disable the active meshes evaluation time capture
  49090. */
  49091. captureActiveMeshesEvaluationTime: boolean;
  49092. /**
  49093. * Gets the perf counter used for render targets render time
  49094. */
  49095. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49096. /**
  49097. * Gets the render targets render time capture status
  49098. */
  49099. /**
  49100. * Enable or disable the render targets render time capture
  49101. */
  49102. captureRenderTargetsRenderTime: boolean;
  49103. /**
  49104. * Gets the perf counter used for particles render time
  49105. */
  49106. readonly particlesRenderTimeCounter: PerfCounter;
  49107. /**
  49108. * Gets the particles render time capture status
  49109. */
  49110. /**
  49111. * Enable or disable the particles render time capture
  49112. */
  49113. captureParticlesRenderTime: boolean;
  49114. /**
  49115. * Gets the perf counter used for sprites render time
  49116. */
  49117. readonly spritesRenderTimeCounter: PerfCounter;
  49118. /**
  49119. * Gets the sprites render time capture status
  49120. */
  49121. /**
  49122. * Enable or disable the sprites render time capture
  49123. */
  49124. captureSpritesRenderTime: boolean;
  49125. /**
  49126. * Gets the perf counter used for physics time
  49127. */
  49128. readonly physicsTimeCounter: PerfCounter;
  49129. /**
  49130. * Gets the physics time capture status
  49131. */
  49132. /**
  49133. * Enable or disable the physics time capture
  49134. */
  49135. capturePhysicsTime: boolean;
  49136. /**
  49137. * Gets the perf counter used for animations time
  49138. */
  49139. readonly animationsTimeCounter: PerfCounter;
  49140. /**
  49141. * Gets the animations time capture status
  49142. */
  49143. /**
  49144. * Enable or disable the animations time capture
  49145. */
  49146. captureAnimationsTime: boolean;
  49147. /**
  49148. * Gets the perf counter used for frame time capture
  49149. */
  49150. readonly frameTimeCounter: PerfCounter;
  49151. /**
  49152. * Gets the frame time capture status
  49153. */
  49154. /**
  49155. * Enable or disable the frame time capture
  49156. */
  49157. captureFrameTime: boolean;
  49158. /**
  49159. * Gets the perf counter used for inter-frames time capture
  49160. */
  49161. readonly interFrameTimeCounter: PerfCounter;
  49162. /**
  49163. * Gets the inter-frames time capture status
  49164. */
  49165. /**
  49166. * Enable or disable the inter-frames time capture
  49167. */
  49168. captureInterFrameTime: boolean;
  49169. /**
  49170. * Gets the perf counter used for render time capture
  49171. */
  49172. readonly renderTimeCounter: PerfCounter;
  49173. /**
  49174. * Gets the render time capture status
  49175. */
  49176. /**
  49177. * Enable or disable the render time capture
  49178. */
  49179. captureRenderTime: boolean;
  49180. /**
  49181. * Gets the perf counter used for camera render time capture
  49182. */
  49183. readonly cameraRenderTimeCounter: PerfCounter;
  49184. /**
  49185. * Gets the camera render time capture status
  49186. */
  49187. /**
  49188. * Enable or disable the camera render time capture
  49189. */
  49190. captureCameraRenderTime: boolean;
  49191. /**
  49192. * Gets the perf counter used for draw calls
  49193. */
  49194. readonly drawCallsCounter: PerfCounter;
  49195. /**
  49196. * Instantiates a new scene instrumentation.
  49197. * This class can be used to get instrumentation data from a Babylon engine
  49198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49199. * @param scene Defines the scene to instrument
  49200. */
  49201. constructor(
  49202. /**
  49203. * Defines the scene to instrument
  49204. */
  49205. scene: Scene);
  49206. /**
  49207. * Dispose and release associated resources.
  49208. */
  49209. dispose(): void;
  49210. }
  49211. }
  49212. declare module BABYLON {
  49213. /** @hidden */
  49214. export var glowMapGenerationPixelShader: {
  49215. name: string;
  49216. shader: string;
  49217. };
  49218. }
  49219. declare module BABYLON {
  49220. /** @hidden */
  49221. export var glowMapGenerationVertexShader: {
  49222. name: string;
  49223. shader: string;
  49224. };
  49225. }
  49226. declare module BABYLON {
  49227. /**
  49228. * Effect layer options. This helps customizing the behaviour
  49229. * of the effect layer.
  49230. */
  49231. export interface IEffectLayerOptions {
  49232. /**
  49233. * Multiplication factor apply to the canvas size to compute the render target size
  49234. * used to generated the objects (the smaller the faster).
  49235. */
  49236. mainTextureRatio: number;
  49237. /**
  49238. * Enforces a fixed size texture to ensure effect stability across devices.
  49239. */
  49240. mainTextureFixedSize?: number;
  49241. /**
  49242. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49243. */
  49244. alphaBlendingMode: number;
  49245. /**
  49246. * The camera attached to the layer.
  49247. */
  49248. camera: Nullable<Camera>;
  49249. /**
  49250. * The rendering group to draw the layer in.
  49251. */
  49252. renderingGroupId: number;
  49253. }
  49254. /**
  49255. * The effect layer Helps adding post process effect blended with the main pass.
  49256. *
  49257. * This can be for instance use to generate glow or higlight effects on the scene.
  49258. *
  49259. * The effect layer class can not be used directly and is intented to inherited from to be
  49260. * customized per effects.
  49261. */
  49262. export abstract class EffectLayer {
  49263. private _vertexBuffers;
  49264. private _indexBuffer;
  49265. private _cachedDefines;
  49266. private _effectLayerMapGenerationEffect;
  49267. private _effectLayerOptions;
  49268. private _mergeEffect;
  49269. protected _scene: Scene;
  49270. protected _engine: Engine;
  49271. protected _maxSize: number;
  49272. protected _mainTextureDesiredSize: ISize;
  49273. protected _mainTexture: RenderTargetTexture;
  49274. protected _shouldRender: boolean;
  49275. protected _postProcesses: PostProcess[];
  49276. protected _textures: BaseTexture[];
  49277. protected _emissiveTextureAndColor: {
  49278. texture: Nullable<BaseTexture>;
  49279. color: Color4;
  49280. };
  49281. /**
  49282. * The name of the layer
  49283. */
  49284. name: string;
  49285. /**
  49286. * The clear color of the texture used to generate the glow map.
  49287. */
  49288. neutralColor: Color4;
  49289. /**
  49290. * Specifies wether the highlight layer is enabled or not.
  49291. */
  49292. isEnabled: boolean;
  49293. /**
  49294. * Gets the camera attached to the layer.
  49295. */
  49296. readonly camera: Nullable<Camera>;
  49297. /**
  49298. * Gets the rendering group id the layer should render in.
  49299. */
  49300. renderingGroupId: number;
  49301. /**
  49302. * An event triggered when the effect layer has been disposed.
  49303. */
  49304. onDisposeObservable: Observable<EffectLayer>;
  49305. /**
  49306. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49307. */
  49308. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49309. /**
  49310. * An event triggered when the generated texture is being merged in the scene.
  49311. */
  49312. onBeforeComposeObservable: Observable<EffectLayer>;
  49313. /**
  49314. * An event triggered when the generated texture has been merged in the scene.
  49315. */
  49316. onAfterComposeObservable: Observable<EffectLayer>;
  49317. /**
  49318. * An event triggered when the efffect layer changes its size.
  49319. */
  49320. onSizeChangedObservable: Observable<EffectLayer>;
  49321. /** @hidden */
  49322. static _SceneComponentInitialization: (scene: Scene) => void;
  49323. /**
  49324. * Instantiates a new effect Layer and references it in the scene.
  49325. * @param name The name of the layer
  49326. * @param scene The scene to use the layer in
  49327. */
  49328. constructor(
  49329. /** The Friendly of the effect in the scene */
  49330. name: string, scene: Scene);
  49331. /**
  49332. * Get the effect name of the layer.
  49333. * @return The effect name
  49334. */
  49335. abstract getEffectName(): string;
  49336. /**
  49337. * Checks for the readiness of the element composing the layer.
  49338. * @param subMesh the mesh to check for
  49339. * @param useInstances specify wether or not to use instances to render the mesh
  49340. * @return true if ready otherwise, false
  49341. */
  49342. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49343. /**
  49344. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49345. * @returns true if the effect requires stencil during the main canvas render pass.
  49346. */
  49347. abstract needStencil(): boolean;
  49348. /**
  49349. * Create the merge effect. This is the shader use to blit the information back
  49350. * to the main canvas at the end of the scene rendering.
  49351. * @returns The effect containing the shader used to merge the effect on the main canvas
  49352. */
  49353. protected abstract _createMergeEffect(): Effect;
  49354. /**
  49355. * Creates the render target textures and post processes used in the effect layer.
  49356. */
  49357. protected abstract _createTextureAndPostProcesses(): void;
  49358. /**
  49359. * Implementation specific of rendering the generating effect on the main canvas.
  49360. * @param effect The effect used to render through
  49361. */
  49362. protected abstract _internalRender(effect: Effect): void;
  49363. /**
  49364. * Sets the required values for both the emissive texture and and the main color.
  49365. */
  49366. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49367. /**
  49368. * Free any resources and references associated to a mesh.
  49369. * Internal use
  49370. * @param mesh The mesh to free.
  49371. */
  49372. abstract _disposeMesh(mesh: Mesh): void;
  49373. /**
  49374. * Serializes this layer (Glow or Highlight for example)
  49375. * @returns a serialized layer object
  49376. */
  49377. abstract serialize?(): any;
  49378. /**
  49379. * Initializes the effect layer with the required options.
  49380. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49381. */
  49382. protected _init(options: Partial<IEffectLayerOptions>): void;
  49383. /**
  49384. * Generates the index buffer of the full screen quad blending to the main canvas.
  49385. */
  49386. private _generateIndexBuffer;
  49387. /**
  49388. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49389. */
  49390. private _generateVertexBuffer;
  49391. /**
  49392. * Sets the main texture desired size which is the closest power of two
  49393. * of the engine canvas size.
  49394. */
  49395. private _setMainTextureSize;
  49396. /**
  49397. * Creates the main texture for the effect layer.
  49398. */
  49399. protected _createMainTexture(): void;
  49400. /**
  49401. * Adds specific effects defines.
  49402. * @param defines The defines to add specifics to.
  49403. */
  49404. protected _addCustomEffectDefines(defines: string[]): void;
  49405. /**
  49406. * Checks for the readiness of the element composing the layer.
  49407. * @param subMesh the mesh to check for
  49408. * @param useInstances specify wether or not to use instances to render the mesh
  49409. * @param emissiveTexture the associated emissive texture used to generate the glow
  49410. * @return true if ready otherwise, false
  49411. */
  49412. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49413. /**
  49414. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49415. */
  49416. render(): void;
  49417. /**
  49418. * Determine if a given mesh will be used in the current effect.
  49419. * @param mesh mesh to test
  49420. * @returns true if the mesh will be used
  49421. */
  49422. hasMesh(mesh: AbstractMesh): boolean;
  49423. /**
  49424. * Returns true if the layer contains information to display, otherwise false.
  49425. * @returns true if the glow layer should be rendered
  49426. */
  49427. shouldRender(): boolean;
  49428. /**
  49429. * Returns true if the mesh should render, otherwise false.
  49430. * @param mesh The mesh to render
  49431. * @returns true if it should render otherwise false
  49432. */
  49433. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49434. /**
  49435. * Returns true if the mesh can be rendered, otherwise false.
  49436. * @param mesh The mesh to render
  49437. * @param material The material used on the mesh
  49438. * @returns true if it can be rendered otherwise false
  49439. */
  49440. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49441. /**
  49442. * Returns true if the mesh should render, otherwise false.
  49443. * @param mesh The mesh to render
  49444. * @returns true if it should render otherwise false
  49445. */
  49446. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49447. /**
  49448. * Renders the submesh passed in parameter to the generation map.
  49449. */
  49450. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49451. /**
  49452. * Rebuild the required buffers.
  49453. * @hidden Internal use only.
  49454. */
  49455. _rebuild(): void;
  49456. /**
  49457. * Dispose only the render target textures and post process.
  49458. */
  49459. private _disposeTextureAndPostProcesses;
  49460. /**
  49461. * Dispose the highlight layer and free resources.
  49462. */
  49463. dispose(): void;
  49464. /**
  49465. * Gets the class name of the effect layer
  49466. * @returns the string with the class name of the effect layer
  49467. */
  49468. getClassName(): string;
  49469. /**
  49470. * Creates an effect layer from parsed effect layer data
  49471. * @param parsedEffectLayer defines effect layer data
  49472. * @param scene defines the current scene
  49473. * @param rootUrl defines the root URL containing the effect layer information
  49474. * @returns a parsed effect Layer
  49475. */
  49476. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49477. }
  49478. }
  49479. declare module BABYLON {
  49480. interface AbstractScene {
  49481. /**
  49482. * The list of effect layers (highlights/glow) added to the scene
  49483. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49484. * @see http://doc.babylonjs.com/how_to/glow_layer
  49485. */
  49486. effectLayers: Array<EffectLayer>;
  49487. /**
  49488. * Removes the given effect layer from this scene.
  49489. * @param toRemove defines the effect layer to remove
  49490. * @returns the index of the removed effect layer
  49491. */
  49492. removeEffectLayer(toRemove: EffectLayer): number;
  49493. /**
  49494. * Adds the given effect layer to this scene
  49495. * @param newEffectLayer defines the effect layer to add
  49496. */
  49497. addEffectLayer(newEffectLayer: EffectLayer): void;
  49498. }
  49499. /**
  49500. * Defines the layer scene component responsible to manage any effect layers
  49501. * in a given scene.
  49502. */
  49503. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49504. /**
  49505. * The component name helpfull to identify the component in the list of scene components.
  49506. */
  49507. readonly name: string;
  49508. /**
  49509. * The scene the component belongs to.
  49510. */
  49511. scene: Scene;
  49512. private _engine;
  49513. private _renderEffects;
  49514. private _needStencil;
  49515. private _previousStencilState;
  49516. /**
  49517. * Creates a new instance of the component for the given scene
  49518. * @param scene Defines the scene to register the component in
  49519. */
  49520. constructor(scene: Scene);
  49521. /**
  49522. * Registers the component in a given scene
  49523. */
  49524. register(): void;
  49525. /**
  49526. * Rebuilds the elements related to this component in case of
  49527. * context lost for instance.
  49528. */
  49529. rebuild(): void;
  49530. /**
  49531. * Serializes the component data to the specified json object
  49532. * @param serializationObject The object to serialize to
  49533. */
  49534. serialize(serializationObject: any): void;
  49535. /**
  49536. * Adds all the elements from the container to the scene
  49537. * @param container the container holding the elements
  49538. */
  49539. addFromContainer(container: AbstractScene): void;
  49540. /**
  49541. * Removes all the elements in the container from the scene
  49542. * @param container contains the elements to remove
  49543. * @param dispose if the removed element should be disposed (default: false)
  49544. */
  49545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49546. /**
  49547. * Disposes the component and the associated ressources.
  49548. */
  49549. dispose(): void;
  49550. private _isReadyForMesh;
  49551. private _renderMainTexture;
  49552. private _setStencil;
  49553. private _setStencilBack;
  49554. private _draw;
  49555. private _drawCamera;
  49556. private _drawRenderingGroup;
  49557. }
  49558. }
  49559. declare module BABYLON {
  49560. /** @hidden */
  49561. export var glowMapMergePixelShader: {
  49562. name: string;
  49563. shader: string;
  49564. };
  49565. }
  49566. declare module BABYLON {
  49567. /** @hidden */
  49568. export var glowMapMergeVertexShader: {
  49569. name: string;
  49570. shader: string;
  49571. };
  49572. }
  49573. declare module BABYLON {
  49574. interface AbstractScene {
  49575. /**
  49576. * Return a the first highlight layer of the scene with a given name.
  49577. * @param name The name of the highlight layer to look for.
  49578. * @return The highlight layer if found otherwise null.
  49579. */
  49580. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49581. }
  49582. /**
  49583. * Glow layer options. This helps customizing the behaviour
  49584. * of the glow layer.
  49585. */
  49586. export interface IGlowLayerOptions {
  49587. /**
  49588. * Multiplication factor apply to the canvas size to compute the render target size
  49589. * used to generated the glowing objects (the smaller the faster).
  49590. */
  49591. mainTextureRatio: number;
  49592. /**
  49593. * Enforces a fixed size texture to ensure resize independant blur.
  49594. */
  49595. mainTextureFixedSize?: number;
  49596. /**
  49597. * How big is the kernel of the blur texture.
  49598. */
  49599. blurKernelSize: number;
  49600. /**
  49601. * The camera attached to the layer.
  49602. */
  49603. camera: Nullable<Camera>;
  49604. /**
  49605. * Enable MSAA by chosing the number of samples.
  49606. */
  49607. mainTextureSamples?: number;
  49608. /**
  49609. * The rendering group to draw the layer in.
  49610. */
  49611. renderingGroupId: number;
  49612. }
  49613. /**
  49614. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49615. *
  49616. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49617. * glowy meshes to your scene.
  49618. *
  49619. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49620. */
  49621. export class GlowLayer extends EffectLayer {
  49622. /**
  49623. * Effect Name of the layer.
  49624. */
  49625. static readonly EffectName: string;
  49626. /**
  49627. * The default blur kernel size used for the glow.
  49628. */
  49629. static DefaultBlurKernelSize: number;
  49630. /**
  49631. * The default texture size ratio used for the glow.
  49632. */
  49633. static DefaultTextureRatio: number;
  49634. /**
  49635. * Sets the kernel size of the blur.
  49636. */
  49637. /**
  49638. * Gets the kernel size of the blur.
  49639. */
  49640. blurKernelSize: number;
  49641. /**
  49642. * Sets the glow intensity.
  49643. */
  49644. /**
  49645. * Gets the glow intensity.
  49646. */
  49647. intensity: number;
  49648. private _options;
  49649. private _intensity;
  49650. private _horizontalBlurPostprocess1;
  49651. private _verticalBlurPostprocess1;
  49652. private _horizontalBlurPostprocess2;
  49653. private _verticalBlurPostprocess2;
  49654. private _blurTexture1;
  49655. private _blurTexture2;
  49656. private _postProcesses1;
  49657. private _postProcesses2;
  49658. private _includedOnlyMeshes;
  49659. private _excludedMeshes;
  49660. /**
  49661. * Callback used to let the user override the color selection on a per mesh basis
  49662. */
  49663. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49664. /**
  49665. * Callback used to let the user override the texture selection on a per mesh basis
  49666. */
  49667. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49668. /**
  49669. * Instantiates a new glow Layer and references it to the scene.
  49670. * @param name The name of the layer
  49671. * @param scene The scene to use the layer in
  49672. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49673. */
  49674. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49675. /**
  49676. * Get the effect name of the layer.
  49677. * @return The effect name
  49678. */
  49679. getEffectName(): string;
  49680. /**
  49681. * Create the merge effect. This is the shader use to blit the information back
  49682. * to the main canvas at the end of the scene rendering.
  49683. */
  49684. protected _createMergeEffect(): Effect;
  49685. /**
  49686. * Creates the render target textures and post processes used in the glow layer.
  49687. */
  49688. protected _createTextureAndPostProcesses(): void;
  49689. /**
  49690. * Checks for the readiness of the element composing the layer.
  49691. * @param subMesh the mesh to check for
  49692. * @param useInstances specify wether or not to use instances to render the mesh
  49693. * @param emissiveTexture the associated emissive texture used to generate the glow
  49694. * @return true if ready otherwise, false
  49695. */
  49696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49697. /**
  49698. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49699. */
  49700. needStencil(): boolean;
  49701. /**
  49702. * Returns true if the mesh can be rendered, otherwise false.
  49703. * @param mesh The mesh to render
  49704. * @param material The material used on the mesh
  49705. * @returns true if it can be rendered otherwise false
  49706. */
  49707. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49708. /**
  49709. * Implementation specific of rendering the generating effect on the main canvas.
  49710. * @param effect The effect used to render through
  49711. */
  49712. protected _internalRender(effect: Effect): void;
  49713. /**
  49714. * Sets the required values for both the emissive texture and and the main color.
  49715. */
  49716. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49717. /**
  49718. * Returns true if the mesh should render, otherwise false.
  49719. * @param mesh The mesh to render
  49720. * @returns true if it should render otherwise false
  49721. */
  49722. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49723. /**
  49724. * Adds specific effects defines.
  49725. * @param defines The defines to add specifics to.
  49726. */
  49727. protected _addCustomEffectDefines(defines: string[]): void;
  49728. /**
  49729. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49730. * @param mesh The mesh to exclude from the glow layer
  49731. */
  49732. addExcludedMesh(mesh: Mesh): void;
  49733. /**
  49734. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49735. * @param mesh The mesh to remove
  49736. */
  49737. removeExcludedMesh(mesh: Mesh): void;
  49738. /**
  49739. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49740. * @param mesh The mesh to include in the glow layer
  49741. */
  49742. addIncludedOnlyMesh(mesh: Mesh): void;
  49743. /**
  49744. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49745. * @param mesh The mesh to remove
  49746. */
  49747. removeIncludedOnlyMesh(mesh: Mesh): void;
  49748. /**
  49749. * Determine if a given mesh will be used in the glow layer
  49750. * @param mesh The mesh to test
  49751. * @returns true if the mesh will be highlighted by the current glow layer
  49752. */
  49753. hasMesh(mesh: AbstractMesh): boolean;
  49754. /**
  49755. * Free any resources and references associated to a mesh.
  49756. * Internal use
  49757. * @param mesh The mesh to free.
  49758. * @hidden
  49759. */
  49760. _disposeMesh(mesh: Mesh): void;
  49761. /**
  49762. * Gets the class name of the effect layer
  49763. * @returns the string with the class name of the effect layer
  49764. */
  49765. getClassName(): string;
  49766. /**
  49767. * Serializes this glow layer
  49768. * @returns a serialized glow layer object
  49769. */
  49770. serialize(): any;
  49771. /**
  49772. * Creates a Glow Layer from parsed glow layer data
  49773. * @param parsedGlowLayer defines glow layer data
  49774. * @param scene defines the current scene
  49775. * @param rootUrl defines the root URL containing the glow layer information
  49776. * @returns a parsed Glow Layer
  49777. */
  49778. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49779. }
  49780. }
  49781. declare module BABYLON {
  49782. /** @hidden */
  49783. export var glowBlurPostProcessPixelShader: {
  49784. name: string;
  49785. shader: string;
  49786. };
  49787. }
  49788. declare module BABYLON {
  49789. interface AbstractScene {
  49790. /**
  49791. * Return a the first highlight layer of the scene with a given name.
  49792. * @param name The name of the highlight layer to look for.
  49793. * @return The highlight layer if found otherwise null.
  49794. */
  49795. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49796. }
  49797. /**
  49798. * Highlight layer options. This helps customizing the behaviour
  49799. * of the highlight layer.
  49800. */
  49801. export interface IHighlightLayerOptions {
  49802. /**
  49803. * Multiplication factor apply to the canvas size to compute the render target size
  49804. * used to generated the glowing objects (the smaller the faster).
  49805. */
  49806. mainTextureRatio: number;
  49807. /**
  49808. * Enforces a fixed size texture to ensure resize independant blur.
  49809. */
  49810. mainTextureFixedSize?: number;
  49811. /**
  49812. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49813. * of the picture to blur (the smaller the faster).
  49814. */
  49815. blurTextureSizeRatio: number;
  49816. /**
  49817. * How big in texel of the blur texture is the vertical blur.
  49818. */
  49819. blurVerticalSize: number;
  49820. /**
  49821. * How big in texel of the blur texture is the horizontal blur.
  49822. */
  49823. blurHorizontalSize: number;
  49824. /**
  49825. * Alpha blending mode used to apply the blur. Default is combine.
  49826. */
  49827. alphaBlendingMode: number;
  49828. /**
  49829. * The camera attached to the layer.
  49830. */
  49831. camera: Nullable<Camera>;
  49832. /**
  49833. * Should we display highlight as a solid stroke?
  49834. */
  49835. isStroke?: boolean;
  49836. /**
  49837. * The rendering group to draw the layer in.
  49838. */
  49839. renderingGroupId: number;
  49840. }
  49841. /**
  49842. * The highlight layer Helps adding a glow effect around a mesh.
  49843. *
  49844. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49845. * glowy meshes to your scene.
  49846. *
  49847. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49848. */
  49849. export class HighlightLayer extends EffectLayer {
  49850. name: string;
  49851. /**
  49852. * Effect Name of the highlight layer.
  49853. */
  49854. static readonly EffectName: string;
  49855. /**
  49856. * The neutral color used during the preparation of the glow effect.
  49857. * This is black by default as the blend operation is a blend operation.
  49858. */
  49859. static NeutralColor: Color4;
  49860. /**
  49861. * Stencil value used for glowing meshes.
  49862. */
  49863. static GlowingMeshStencilReference: number;
  49864. /**
  49865. * Stencil value used for the other meshes in the scene.
  49866. */
  49867. static NormalMeshStencilReference: number;
  49868. /**
  49869. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49870. */
  49871. innerGlow: boolean;
  49872. /**
  49873. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49874. */
  49875. outerGlow: boolean;
  49876. /**
  49877. * Specifies the horizontal size of the blur.
  49878. */
  49879. /**
  49880. * Gets the horizontal size of the blur.
  49881. */
  49882. blurHorizontalSize: number;
  49883. /**
  49884. * Specifies the vertical size of the blur.
  49885. */
  49886. /**
  49887. * Gets the vertical size of the blur.
  49888. */
  49889. blurVerticalSize: number;
  49890. /**
  49891. * An event triggered when the highlight layer is being blurred.
  49892. */
  49893. onBeforeBlurObservable: Observable<HighlightLayer>;
  49894. /**
  49895. * An event triggered when the highlight layer has been blurred.
  49896. */
  49897. onAfterBlurObservable: Observable<HighlightLayer>;
  49898. private _instanceGlowingMeshStencilReference;
  49899. private _options;
  49900. private _downSamplePostprocess;
  49901. private _horizontalBlurPostprocess;
  49902. private _verticalBlurPostprocess;
  49903. private _blurTexture;
  49904. private _meshes;
  49905. private _excludedMeshes;
  49906. /**
  49907. * Instantiates a new highlight Layer and references it to the scene..
  49908. * @param name The name of the layer
  49909. * @param scene The scene to use the layer in
  49910. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49911. */
  49912. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49913. /**
  49914. * Get the effect name of the layer.
  49915. * @return The effect name
  49916. */
  49917. getEffectName(): string;
  49918. /**
  49919. * Create the merge effect. This is the shader use to blit the information back
  49920. * to the main canvas at the end of the scene rendering.
  49921. */
  49922. protected _createMergeEffect(): Effect;
  49923. /**
  49924. * Creates the render target textures and post processes used in the highlight layer.
  49925. */
  49926. protected _createTextureAndPostProcesses(): void;
  49927. /**
  49928. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49929. */
  49930. needStencil(): boolean;
  49931. /**
  49932. * Checks for the readiness of the element composing the layer.
  49933. * @param subMesh the mesh to check for
  49934. * @param useInstances specify wether or not to use instances to render the mesh
  49935. * @param emissiveTexture the associated emissive texture used to generate the glow
  49936. * @return true if ready otherwise, false
  49937. */
  49938. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49939. /**
  49940. * Implementation specific of rendering the generating effect on the main canvas.
  49941. * @param effect The effect used to render through
  49942. */
  49943. protected _internalRender(effect: Effect): void;
  49944. /**
  49945. * Returns true if the layer contains information to display, otherwise false.
  49946. */
  49947. shouldRender(): boolean;
  49948. /**
  49949. * Returns true if the mesh should render, otherwise false.
  49950. * @param mesh The mesh to render
  49951. * @returns true if it should render otherwise false
  49952. */
  49953. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49954. /**
  49955. * Sets the required values for both the emissive texture and and the main color.
  49956. */
  49957. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49958. /**
  49959. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49960. * @param mesh The mesh to exclude from the highlight layer
  49961. */
  49962. addExcludedMesh(mesh: Mesh): void;
  49963. /**
  49964. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49965. * @param mesh The mesh to highlight
  49966. */
  49967. removeExcludedMesh(mesh: Mesh): void;
  49968. /**
  49969. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49970. * @param mesh mesh to test
  49971. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49972. */
  49973. hasMesh(mesh: AbstractMesh): boolean;
  49974. /**
  49975. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49976. * @param mesh The mesh to highlight
  49977. * @param color The color of the highlight
  49978. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49979. */
  49980. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49981. /**
  49982. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49983. * @param mesh The mesh to highlight
  49984. */
  49985. removeMesh(mesh: Mesh): void;
  49986. /**
  49987. * Force the stencil to the normal expected value for none glowing parts
  49988. */
  49989. private _defaultStencilReference;
  49990. /**
  49991. * Free any resources and references associated to a mesh.
  49992. * Internal use
  49993. * @param mesh The mesh to free.
  49994. * @hidden
  49995. */
  49996. _disposeMesh(mesh: Mesh): void;
  49997. /**
  49998. * Dispose the highlight layer and free resources.
  49999. */
  50000. dispose(): void;
  50001. /**
  50002. * Gets the class name of the effect layer
  50003. * @returns the string with the class name of the effect layer
  50004. */
  50005. getClassName(): string;
  50006. /**
  50007. * Serializes this Highlight layer
  50008. * @returns a serialized Highlight layer object
  50009. */
  50010. serialize(): any;
  50011. /**
  50012. * Creates a Highlight layer from parsed Highlight layer data
  50013. * @param parsedHightlightLayer defines the Highlight layer data
  50014. * @param scene defines the current scene
  50015. * @param rootUrl defines the root URL containing the Highlight layer information
  50016. * @returns a parsed Highlight layer
  50017. */
  50018. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50019. }
  50020. }
  50021. declare module BABYLON {
  50022. interface AbstractScene {
  50023. /**
  50024. * The list of layers (background and foreground) of the scene
  50025. */
  50026. layers: Array<Layer>;
  50027. }
  50028. /**
  50029. * Defines the layer scene component responsible to manage any layers
  50030. * in a given scene.
  50031. */
  50032. export class LayerSceneComponent implements ISceneComponent {
  50033. /**
  50034. * The component name helpfull to identify the component in the list of scene components.
  50035. */
  50036. readonly name: string;
  50037. /**
  50038. * The scene the component belongs to.
  50039. */
  50040. scene: Scene;
  50041. private _engine;
  50042. /**
  50043. * Creates a new instance of the component for the given scene
  50044. * @param scene Defines the scene to register the component in
  50045. */
  50046. constructor(scene: Scene);
  50047. /**
  50048. * Registers the component in a given scene
  50049. */
  50050. register(): void;
  50051. /**
  50052. * Rebuilds the elements related to this component in case of
  50053. * context lost for instance.
  50054. */
  50055. rebuild(): void;
  50056. /**
  50057. * Disposes the component and the associated ressources.
  50058. */
  50059. dispose(): void;
  50060. private _draw;
  50061. private _drawCameraPredicate;
  50062. private _drawCameraBackground;
  50063. private _drawCameraForeground;
  50064. private _drawRenderTargetPredicate;
  50065. private _drawRenderTargetBackground;
  50066. private _drawRenderTargetForeground;
  50067. /**
  50068. * Adds all the elements from the container to the scene
  50069. * @param container the container holding the elements
  50070. */
  50071. addFromContainer(container: AbstractScene): void;
  50072. /**
  50073. * Removes all the elements in the container from the scene
  50074. * @param container contains the elements to remove
  50075. * @param dispose if the removed element should be disposed (default: false)
  50076. */
  50077. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50078. }
  50079. }
  50080. declare module BABYLON {
  50081. /** @hidden */
  50082. export var layerPixelShader: {
  50083. name: string;
  50084. shader: string;
  50085. };
  50086. }
  50087. declare module BABYLON {
  50088. /** @hidden */
  50089. export var layerVertexShader: {
  50090. name: string;
  50091. shader: string;
  50092. };
  50093. }
  50094. declare module BABYLON {
  50095. /**
  50096. * This represents a full screen 2d layer.
  50097. * This can be useful to display a picture in the background of your scene for instance.
  50098. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50099. */
  50100. export class Layer {
  50101. /**
  50102. * Define the name of the layer.
  50103. */
  50104. name: string;
  50105. /**
  50106. * Define the texture the layer should display.
  50107. */
  50108. texture: Nullable<Texture>;
  50109. /**
  50110. * Is the layer in background or foreground.
  50111. */
  50112. isBackground: boolean;
  50113. /**
  50114. * Define the color of the layer (instead of texture).
  50115. */
  50116. color: Color4;
  50117. /**
  50118. * Define the scale of the layer in order to zoom in out of the texture.
  50119. */
  50120. scale: Vector2;
  50121. /**
  50122. * Define an offset for the layer in order to shift the texture.
  50123. */
  50124. offset: Vector2;
  50125. /**
  50126. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50127. */
  50128. alphaBlendingMode: number;
  50129. /**
  50130. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50131. * Alpha test will not mix with the background color in case of transparency.
  50132. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50133. */
  50134. alphaTest: boolean;
  50135. /**
  50136. * Define a mask to restrict the layer to only some of the scene cameras.
  50137. */
  50138. layerMask: number;
  50139. /**
  50140. * Define the list of render target the layer is visible into.
  50141. */
  50142. renderTargetTextures: RenderTargetTexture[];
  50143. /**
  50144. * Define if the layer is only used in renderTarget or if it also
  50145. * renders in the main frame buffer of the canvas.
  50146. */
  50147. renderOnlyInRenderTargetTextures: boolean;
  50148. private _scene;
  50149. private _vertexBuffers;
  50150. private _indexBuffer;
  50151. private _effect;
  50152. private _alphaTestEffect;
  50153. /**
  50154. * An event triggered when the layer is disposed.
  50155. */
  50156. onDisposeObservable: Observable<Layer>;
  50157. private _onDisposeObserver;
  50158. /**
  50159. * Back compatibility with callback before the onDisposeObservable existed.
  50160. * The set callback will be triggered when the layer has been disposed.
  50161. */
  50162. onDispose: () => void;
  50163. /**
  50164. * An event triggered before rendering the scene
  50165. */
  50166. onBeforeRenderObservable: Observable<Layer>;
  50167. private _onBeforeRenderObserver;
  50168. /**
  50169. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50170. * The set callback will be triggered just before rendering the layer.
  50171. */
  50172. onBeforeRender: () => void;
  50173. /**
  50174. * An event triggered after rendering the scene
  50175. */
  50176. onAfterRenderObservable: Observable<Layer>;
  50177. private _onAfterRenderObserver;
  50178. /**
  50179. * Back compatibility with callback before the onAfterRenderObservable existed.
  50180. * The set callback will be triggered just after rendering the layer.
  50181. */
  50182. onAfterRender: () => void;
  50183. /**
  50184. * Instantiates a new layer.
  50185. * This represents a full screen 2d layer.
  50186. * This can be useful to display a picture in the background of your scene for instance.
  50187. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50188. * @param name Define the name of the layer in the scene
  50189. * @param imgUrl Define the url of the texture to display in the layer
  50190. * @param scene Define the scene the layer belongs to
  50191. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50192. * @param color Defines a color for the layer
  50193. */
  50194. constructor(
  50195. /**
  50196. * Define the name of the layer.
  50197. */
  50198. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50199. private _createIndexBuffer;
  50200. /** @hidden */
  50201. _rebuild(): void;
  50202. /**
  50203. * Renders the layer in the scene.
  50204. */
  50205. render(): void;
  50206. /**
  50207. * Disposes and releases the associated ressources.
  50208. */
  50209. dispose(): void;
  50210. }
  50211. }
  50212. declare module BABYLON {
  50213. /** @hidden */
  50214. export var lensFlarePixelShader: {
  50215. name: string;
  50216. shader: string;
  50217. };
  50218. }
  50219. declare module BABYLON {
  50220. /** @hidden */
  50221. export var lensFlareVertexShader: {
  50222. name: string;
  50223. shader: string;
  50224. };
  50225. }
  50226. declare module BABYLON {
  50227. /**
  50228. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50229. * It is usually composed of several `lensFlare`.
  50230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50231. */
  50232. export class LensFlareSystem {
  50233. /**
  50234. * Define the name of the lens flare system
  50235. */
  50236. name: string;
  50237. /**
  50238. * List of lens flares used in this system.
  50239. */
  50240. lensFlares: LensFlare[];
  50241. /**
  50242. * Define a limit from the border the lens flare can be visible.
  50243. */
  50244. borderLimit: number;
  50245. /**
  50246. * Define a viewport border we do not want to see the lens flare in.
  50247. */
  50248. viewportBorder: number;
  50249. /**
  50250. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50251. */
  50252. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50253. /**
  50254. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50255. */
  50256. layerMask: number;
  50257. /**
  50258. * Define the id of the lens flare system in the scene.
  50259. * (equal to name by default)
  50260. */
  50261. id: string;
  50262. private _scene;
  50263. private _emitter;
  50264. private _vertexBuffers;
  50265. private _indexBuffer;
  50266. private _effect;
  50267. private _positionX;
  50268. private _positionY;
  50269. private _isEnabled;
  50270. /** @hidden */
  50271. static _SceneComponentInitialization: (scene: Scene) => void;
  50272. /**
  50273. * Instantiates a lens flare system.
  50274. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50275. * It is usually composed of several `lensFlare`.
  50276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50277. * @param name Define the name of the lens flare system in the scene
  50278. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50279. * @param scene Define the scene the lens flare system belongs to
  50280. */
  50281. constructor(
  50282. /**
  50283. * Define the name of the lens flare system
  50284. */
  50285. name: string, emitter: any, scene: Scene);
  50286. /**
  50287. * Define if the lens flare system is enabled.
  50288. */
  50289. isEnabled: boolean;
  50290. /**
  50291. * Get the scene the effects belongs to.
  50292. * @returns the scene holding the lens flare system
  50293. */
  50294. getScene(): Scene;
  50295. /**
  50296. * Get the emitter of the lens flare system.
  50297. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50298. * @returns the emitter of the lens flare system
  50299. */
  50300. getEmitter(): any;
  50301. /**
  50302. * Set the emitter of the lens flare system.
  50303. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50304. * @param newEmitter Define the new emitter of the system
  50305. */
  50306. setEmitter(newEmitter: any): void;
  50307. /**
  50308. * Get the lens flare system emitter position.
  50309. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50310. * @returns the position
  50311. */
  50312. getEmitterPosition(): Vector3;
  50313. /**
  50314. * @hidden
  50315. */
  50316. computeEffectivePosition(globalViewport: Viewport): boolean;
  50317. /** @hidden */
  50318. _isVisible(): boolean;
  50319. /**
  50320. * @hidden
  50321. */
  50322. render(): boolean;
  50323. /**
  50324. * Dispose and release the lens flare with its associated resources.
  50325. */
  50326. dispose(): void;
  50327. /**
  50328. * Parse a lens flare system from a JSON repressentation
  50329. * @param parsedLensFlareSystem Define the JSON to parse
  50330. * @param scene Define the scene the parsed system should be instantiated in
  50331. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50332. * @returns the parsed system
  50333. */
  50334. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50335. /**
  50336. * Serialize the current Lens Flare System into a JSON representation.
  50337. * @returns the serialized JSON
  50338. */
  50339. serialize(): any;
  50340. }
  50341. }
  50342. declare module BABYLON {
  50343. /**
  50344. * This represents one of the lens effect in a `lensFlareSystem`.
  50345. * It controls one of the indiviual texture used in the effect.
  50346. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50347. */
  50348. export class LensFlare {
  50349. /**
  50350. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50351. */
  50352. size: number;
  50353. /**
  50354. * 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.
  50355. */
  50356. position: number;
  50357. /**
  50358. * Define the lens color.
  50359. */
  50360. color: Color3;
  50361. /**
  50362. * Define the lens texture.
  50363. */
  50364. texture: Nullable<Texture>;
  50365. /**
  50366. * Define the alpha mode to render this particular lens.
  50367. */
  50368. alphaMode: number;
  50369. private _system;
  50370. /**
  50371. * Creates a new Lens Flare.
  50372. * This represents one of the lens effect in a `lensFlareSystem`.
  50373. * It controls one of the indiviual texture used in the effect.
  50374. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50375. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50376. * @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.
  50377. * @param color Define the lens color
  50378. * @param imgUrl Define the lens texture url
  50379. * @param system Define the `lensFlareSystem` this flare is part of
  50380. * @returns The newly created Lens Flare
  50381. */
  50382. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50383. /**
  50384. * Instantiates a new Lens Flare.
  50385. * This represents one of the lens effect in a `lensFlareSystem`.
  50386. * It controls one of the indiviual texture used in the effect.
  50387. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50388. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50389. * @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.
  50390. * @param color Define the lens color
  50391. * @param imgUrl Define the lens texture url
  50392. * @param system Define the `lensFlareSystem` this flare is part of
  50393. */
  50394. constructor(
  50395. /**
  50396. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50397. */
  50398. size: number,
  50399. /**
  50400. * 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.
  50401. */
  50402. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50403. /**
  50404. * Dispose and release the lens flare with its associated resources.
  50405. */
  50406. dispose(): void;
  50407. }
  50408. }
  50409. declare module BABYLON {
  50410. interface AbstractScene {
  50411. /**
  50412. * The list of lens flare system added to the scene
  50413. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50414. */
  50415. lensFlareSystems: Array<LensFlareSystem>;
  50416. /**
  50417. * Removes the given lens flare system from this scene.
  50418. * @param toRemove The lens flare system to remove
  50419. * @returns The index of the removed lens flare system
  50420. */
  50421. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50422. /**
  50423. * Adds the given lens flare system to this scene
  50424. * @param newLensFlareSystem The lens flare system to add
  50425. */
  50426. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50427. /**
  50428. * Gets a lens flare system using its name
  50429. * @param name defines the name to look for
  50430. * @returns the lens flare system or null if not found
  50431. */
  50432. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50433. /**
  50434. * Gets a lens flare system using its id
  50435. * @param id defines the id to look for
  50436. * @returns the lens flare system or null if not found
  50437. */
  50438. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50439. }
  50440. /**
  50441. * Defines the lens flare scene component responsible to manage any lens flares
  50442. * in a given scene.
  50443. */
  50444. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50445. /**
  50446. * The component name helpfull to identify the component in the list of scene components.
  50447. */
  50448. readonly name: string;
  50449. /**
  50450. * The scene the component belongs to.
  50451. */
  50452. scene: Scene;
  50453. /**
  50454. * Creates a new instance of the component for the given scene
  50455. * @param scene Defines the scene to register the component in
  50456. */
  50457. constructor(scene: Scene);
  50458. /**
  50459. * Registers the component in a given scene
  50460. */
  50461. register(): void;
  50462. /**
  50463. * Rebuilds the elements related to this component in case of
  50464. * context lost for instance.
  50465. */
  50466. rebuild(): void;
  50467. /**
  50468. * Adds all the elements from the container to the scene
  50469. * @param container the container holding the elements
  50470. */
  50471. addFromContainer(container: AbstractScene): void;
  50472. /**
  50473. * Removes all the elements in the container from the scene
  50474. * @param container contains the elements to remove
  50475. * @param dispose if the removed element should be disposed (default: false)
  50476. */
  50477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50478. /**
  50479. * Serializes the component data to the specified json object
  50480. * @param serializationObject The object to serialize to
  50481. */
  50482. serialize(serializationObject: any): void;
  50483. /**
  50484. * Disposes the component and the associated ressources.
  50485. */
  50486. dispose(): void;
  50487. private _draw;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * Defines the shadow generator component responsible to manage any shadow generators
  50493. * in a given scene.
  50494. */
  50495. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50496. /**
  50497. * The component name helpfull to identify the component in the list of scene components.
  50498. */
  50499. readonly name: string;
  50500. /**
  50501. * The scene the component belongs to.
  50502. */
  50503. scene: Scene;
  50504. /**
  50505. * Creates a new instance of the component for the given scene
  50506. * @param scene Defines the scene to register the component in
  50507. */
  50508. constructor(scene: Scene);
  50509. /**
  50510. * Registers the component in a given scene
  50511. */
  50512. register(): void;
  50513. /**
  50514. * Rebuilds the elements related to this component in case of
  50515. * context lost for instance.
  50516. */
  50517. rebuild(): void;
  50518. /**
  50519. * Serializes the component data to the specified json object
  50520. * @param serializationObject The object to serialize to
  50521. */
  50522. serialize(serializationObject: any): void;
  50523. /**
  50524. * Adds all the elements from the container to the scene
  50525. * @param container the container holding the elements
  50526. */
  50527. addFromContainer(container: AbstractScene): void;
  50528. /**
  50529. * Removes all the elements in the container from the scene
  50530. * @param container contains the elements to remove
  50531. * @param dispose if the removed element should be disposed (default: false)
  50532. */
  50533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50534. /**
  50535. * Rebuilds the elements related to this component in case of
  50536. * context lost for instance.
  50537. */
  50538. dispose(): void;
  50539. private _gatherRenderTargets;
  50540. }
  50541. }
  50542. declare module BABYLON {
  50543. /**
  50544. * A point light is a light defined by an unique point in world space.
  50545. * The light is emitted in every direction from this point.
  50546. * A good example of a point light is a standard light bulb.
  50547. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50548. */
  50549. export class PointLight extends ShadowLight {
  50550. private _shadowAngle;
  50551. /**
  50552. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50553. * This specifies what angle the shadow will use to be created.
  50554. *
  50555. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50556. */
  50557. /**
  50558. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50559. * This specifies what angle the shadow will use to be created.
  50560. *
  50561. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50562. */
  50563. shadowAngle: number;
  50564. /**
  50565. * Gets the direction if it has been set.
  50566. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50567. */
  50568. /**
  50569. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50570. */
  50571. direction: Vector3;
  50572. /**
  50573. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50574. * A PointLight emits the light in every direction.
  50575. * It can cast shadows.
  50576. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50577. * ```javascript
  50578. * var pointLight = new PointLight("pl", camera.position, scene);
  50579. * ```
  50580. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50581. * @param name The light friendly name
  50582. * @param position The position of the point light in the scene
  50583. * @param scene The scene the lights belongs to
  50584. */
  50585. constructor(name: string, position: Vector3, scene: Scene);
  50586. /**
  50587. * Returns the string "PointLight"
  50588. * @returns the class name
  50589. */
  50590. getClassName(): string;
  50591. /**
  50592. * Returns the integer 0.
  50593. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50594. */
  50595. getTypeID(): number;
  50596. /**
  50597. * Specifies wether or not the shadowmap should be a cube texture.
  50598. * @returns true if the shadowmap needs to be a cube texture.
  50599. */
  50600. needCube(): boolean;
  50601. /**
  50602. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50603. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50604. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50605. */
  50606. getShadowDirection(faceIndex?: number): Vector3;
  50607. /**
  50608. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50609. * - fov = PI / 2
  50610. * - aspect ratio : 1.0
  50611. * - z-near and far equal to the active camera minZ and maxZ.
  50612. * Returns the PointLight.
  50613. */
  50614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50615. protected _buildUniformLayout(): void;
  50616. /**
  50617. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50618. * @param effect The effect to update
  50619. * @param lightIndex The index of the light in the effect to update
  50620. * @returns The point light
  50621. */
  50622. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50623. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50624. /**
  50625. * Prepares the list of defines specific to the light type.
  50626. * @param defines the list of defines
  50627. * @param lightIndex defines the index of the light for the effect
  50628. */
  50629. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50630. }
  50631. }
  50632. declare module BABYLON {
  50633. /**
  50634. * Header information of HDR texture files.
  50635. */
  50636. export interface HDRInfo {
  50637. /**
  50638. * The height of the texture in pixels.
  50639. */
  50640. height: number;
  50641. /**
  50642. * The width of the texture in pixels.
  50643. */
  50644. width: number;
  50645. /**
  50646. * The index of the beginning of the data in the binary file.
  50647. */
  50648. dataPosition: number;
  50649. }
  50650. /**
  50651. * This groups tools to convert HDR texture to native colors array.
  50652. */
  50653. export class HDRTools {
  50654. private static Ldexp;
  50655. private static Rgbe2float;
  50656. private static readStringLine;
  50657. /**
  50658. * Reads header information from an RGBE texture stored in a native array.
  50659. * More information on this format are available here:
  50660. * https://en.wikipedia.org/wiki/RGBE_image_format
  50661. *
  50662. * @param uint8array The binary file stored in native array.
  50663. * @return The header information.
  50664. */
  50665. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50666. /**
  50667. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50668. * This RGBE texture needs to store the information as a panorama.
  50669. *
  50670. * More information on this format are available here:
  50671. * https://en.wikipedia.org/wiki/RGBE_image_format
  50672. *
  50673. * @param buffer The binary file stored in an array buffer.
  50674. * @param size The expected size of the extracted cubemap.
  50675. * @return The Cube Map information.
  50676. */
  50677. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50678. /**
  50679. * Returns the pixels data extracted from an RGBE texture.
  50680. * This pixels will be stored left to right up to down in the R G B order in one array.
  50681. *
  50682. * More information on this format are available here:
  50683. * https://en.wikipedia.org/wiki/RGBE_image_format
  50684. *
  50685. * @param uint8array The binary file stored in an array buffer.
  50686. * @param hdrInfo The header information of the file.
  50687. * @return The pixels data in RGB right to left up to down order.
  50688. */
  50689. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50690. private static RGBE_ReadPixels_RLE;
  50691. }
  50692. }
  50693. declare module BABYLON {
  50694. /**
  50695. * This represents a texture coming from an HDR input.
  50696. *
  50697. * The only supported format is currently panorama picture stored in RGBE format.
  50698. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50699. */
  50700. export class HDRCubeTexture extends BaseTexture {
  50701. private static _facesMapping;
  50702. private _generateHarmonics;
  50703. private _noMipmap;
  50704. private _textureMatrix;
  50705. private _size;
  50706. private _onLoad;
  50707. private _onError;
  50708. /**
  50709. * The texture URL.
  50710. */
  50711. url: string;
  50712. /**
  50713. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50714. */
  50715. coordinatesMode: number;
  50716. protected _isBlocking: boolean;
  50717. /**
  50718. * Sets wether or not the texture is blocking during loading.
  50719. */
  50720. /**
  50721. * Gets wether or not the texture is blocking during loading.
  50722. */
  50723. isBlocking: boolean;
  50724. protected _rotationY: number;
  50725. /**
  50726. * Sets texture matrix rotation angle around Y axis in radians.
  50727. */
  50728. /**
  50729. * Gets texture matrix rotation angle around Y axis radians.
  50730. */
  50731. rotationY: number;
  50732. /**
  50733. * Gets or sets the center of the bounding box associated with the cube texture
  50734. * It must define where the camera used to render the texture was set
  50735. */
  50736. boundingBoxPosition: Vector3;
  50737. private _boundingBoxSize;
  50738. /**
  50739. * Gets or sets the size of the bounding box associated with the cube texture
  50740. * When defined, the cubemap will switch to local mode
  50741. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50742. * @example https://www.babylonjs-playground.com/#RNASML
  50743. */
  50744. boundingBoxSize: Vector3;
  50745. /**
  50746. * Instantiates an HDRTexture from the following parameters.
  50747. *
  50748. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50749. * @param scene The scene the texture will be used in
  50750. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50751. * @param noMipmap Forces to not generate the mipmap if true
  50752. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50753. * @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)
  50754. * @param reserved Reserved flag for internal use.
  50755. */
  50756. 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>);
  50757. /**
  50758. * Get the current class name of the texture useful for serialization or dynamic coding.
  50759. * @returns "HDRCubeTexture"
  50760. */
  50761. getClassName(): string;
  50762. /**
  50763. * Occurs when the file is raw .hdr file.
  50764. */
  50765. private loadTexture;
  50766. clone(): HDRCubeTexture;
  50767. delayLoad(): void;
  50768. /**
  50769. * Get the texture reflection matrix used to rotate/transform the reflection.
  50770. * @returns the reflection matrix
  50771. */
  50772. getReflectionTextureMatrix(): Matrix;
  50773. /**
  50774. * Set the texture reflection matrix used to rotate/transform the reflection.
  50775. * @param value Define the reflection matrix to set
  50776. */
  50777. setReflectionTextureMatrix(value: Matrix): void;
  50778. /**
  50779. * Parses a JSON representation of an HDR Texture in order to create the texture
  50780. * @param parsedTexture Define the JSON representation
  50781. * @param scene Define the scene the texture should be created in
  50782. * @param rootUrl Define the root url in case we need to load relative dependencies
  50783. * @returns the newly created texture after parsing
  50784. */
  50785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50786. serialize(): any;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. /**
  50791. * Class used to control physics engine
  50792. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50793. */
  50794. export class PhysicsEngine implements IPhysicsEngine {
  50795. private _physicsPlugin;
  50796. /**
  50797. * Global value used to control the smallest number supported by the simulation
  50798. */
  50799. static Epsilon: number;
  50800. private _impostors;
  50801. private _joints;
  50802. /**
  50803. * Gets the gravity vector used by the simulation
  50804. */
  50805. gravity: Vector3;
  50806. /**
  50807. * Factory used to create the default physics plugin.
  50808. * @returns The default physics plugin
  50809. */
  50810. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50811. /**
  50812. * Creates a new Physics Engine
  50813. * @param gravity defines the gravity vector used by the simulation
  50814. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50815. */
  50816. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50817. /**
  50818. * Sets the gravity vector used by the simulation
  50819. * @param gravity defines the gravity vector to use
  50820. */
  50821. setGravity(gravity: Vector3): void;
  50822. /**
  50823. * Set the time step of the physics engine.
  50824. * Default is 1/60.
  50825. * To slow it down, enter 1/600 for example.
  50826. * To speed it up, 1/30
  50827. * @param newTimeStep defines the new timestep to apply to this world.
  50828. */
  50829. setTimeStep(newTimeStep?: number): void;
  50830. /**
  50831. * Get the time step of the physics engine.
  50832. * @returns the current time step
  50833. */
  50834. getTimeStep(): number;
  50835. /**
  50836. * Release all resources
  50837. */
  50838. dispose(): void;
  50839. /**
  50840. * Gets the name of the current physics plugin
  50841. * @returns the name of the plugin
  50842. */
  50843. getPhysicsPluginName(): string;
  50844. /**
  50845. * Adding a new impostor for the impostor tracking.
  50846. * This will be done by the impostor itself.
  50847. * @param impostor the impostor to add
  50848. */
  50849. addImpostor(impostor: PhysicsImpostor): void;
  50850. /**
  50851. * Remove an impostor from the engine.
  50852. * This impostor and its mesh will not longer be updated by the physics engine.
  50853. * @param impostor the impostor to remove
  50854. */
  50855. removeImpostor(impostor: PhysicsImpostor): void;
  50856. /**
  50857. * Add a joint to the physics engine
  50858. * @param mainImpostor defines the main impostor to which the joint is added.
  50859. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50860. * @param joint defines the joint that will connect both impostors.
  50861. */
  50862. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50863. /**
  50864. * Removes a joint from the simulation
  50865. * @param mainImpostor defines the impostor used with the joint
  50866. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50867. * @param joint defines the joint to remove
  50868. */
  50869. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50870. /**
  50871. * Called by the scene. No need to call it.
  50872. * @param delta defines the timespam between frames
  50873. */
  50874. _step(delta: number): void;
  50875. /**
  50876. * Gets the current plugin used to run the simulation
  50877. * @returns current plugin
  50878. */
  50879. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50880. /**
  50881. * Gets the list of physic impostors
  50882. * @returns an array of PhysicsImpostor
  50883. */
  50884. getImpostors(): Array<PhysicsImpostor>;
  50885. /**
  50886. * Gets the impostor for a physics enabled object
  50887. * @param object defines the object impersonated by the impostor
  50888. * @returns the PhysicsImpostor or null if not found
  50889. */
  50890. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50891. /**
  50892. * Gets the impostor for a physics body object
  50893. * @param body defines physics body used by the impostor
  50894. * @returns the PhysicsImpostor or null if not found
  50895. */
  50896. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50897. /**
  50898. * Does a raycast in the physics world
  50899. * @param from when should the ray start?
  50900. * @param to when should the ray end?
  50901. * @returns PhysicsRaycastResult
  50902. */
  50903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /** @hidden */
  50908. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50909. private _useDeltaForWorldStep;
  50910. world: any;
  50911. name: string;
  50912. private _physicsMaterials;
  50913. private _fixedTimeStep;
  50914. private _cannonRaycastResult;
  50915. private _raycastResult;
  50916. private _physicsBodysToRemoveAfterStep;
  50917. BJSCANNON: any;
  50918. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50919. setGravity(gravity: Vector3): void;
  50920. setTimeStep(timeStep: number): void;
  50921. getTimeStep(): number;
  50922. executeStep(delta: number): void;
  50923. private _removeMarkedPhysicsBodiesFromWorld;
  50924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50927. private _processChildMeshes;
  50928. removePhysicsBody(impostor: PhysicsImpostor): void;
  50929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50931. private _addMaterial;
  50932. private _checkWithEpsilon;
  50933. private _createShape;
  50934. private _createHeightmap;
  50935. private _minus90X;
  50936. private _plus90X;
  50937. private _tmpPosition;
  50938. private _tmpDeltaPosition;
  50939. private _tmpUnityRotation;
  50940. private _updatePhysicsBodyTransformation;
  50941. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50942. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50943. isSupported(): boolean;
  50944. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50945. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50946. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50947. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50948. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50949. getBodyMass(impostor: PhysicsImpostor): number;
  50950. getBodyFriction(impostor: PhysicsImpostor): number;
  50951. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50952. getBodyRestitution(impostor: PhysicsImpostor): number;
  50953. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50954. sleepBody(impostor: PhysicsImpostor): void;
  50955. wakeUpBody(impostor: PhysicsImpostor): void;
  50956. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50957. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50958. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50959. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50960. getRadius(impostor: PhysicsImpostor): number;
  50961. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50962. dispose(): void;
  50963. private _extendNamespace;
  50964. /**
  50965. * Does a raycast in the physics world
  50966. * @param from when should the ray start?
  50967. * @param to when should the ray end?
  50968. * @returns PhysicsRaycastResult
  50969. */
  50970. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50971. }
  50972. }
  50973. declare module BABYLON {
  50974. /** @hidden */
  50975. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50976. world: any;
  50977. name: string;
  50978. BJSOIMO: any;
  50979. private _raycastResult;
  50980. constructor(iterations?: number, oimoInjection?: any);
  50981. setGravity(gravity: Vector3): void;
  50982. setTimeStep(timeStep: number): void;
  50983. getTimeStep(): number;
  50984. private _tmpImpostorsArray;
  50985. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50986. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50987. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50988. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50989. private _tmpPositionVector;
  50990. removePhysicsBody(impostor: PhysicsImpostor): void;
  50991. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50992. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50993. isSupported(): boolean;
  50994. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50995. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50996. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50997. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50998. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50999. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51000. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51001. getBodyMass(impostor: PhysicsImpostor): number;
  51002. getBodyFriction(impostor: PhysicsImpostor): number;
  51003. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51004. getBodyRestitution(impostor: PhysicsImpostor): number;
  51005. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51006. sleepBody(impostor: PhysicsImpostor): void;
  51007. wakeUpBody(impostor: PhysicsImpostor): void;
  51008. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51009. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51010. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51011. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51012. getRadius(impostor: PhysicsImpostor): number;
  51013. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51014. dispose(): void;
  51015. /**
  51016. * Does a raycast in the physics world
  51017. * @param from when should the ray start?
  51018. * @param to when should the ray end?
  51019. * @returns PhysicsRaycastResult
  51020. */
  51021. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51022. }
  51023. }
  51024. declare module BABYLON {
  51025. /**
  51026. * Class containing static functions to help procedurally build meshes
  51027. */
  51028. export class RibbonBuilder {
  51029. /**
  51030. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51031. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51032. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51033. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51034. * * 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
  51035. * * 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
  51036. * * 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
  51037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51038. * * 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
  51039. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51040. * * 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
  51041. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51042. * * 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
  51043. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51045. * @param name defines the name of the mesh
  51046. * @param options defines the options used to create the mesh
  51047. * @param scene defines the hosting scene
  51048. * @returns the ribbon mesh
  51049. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51050. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51051. */
  51052. static CreateRibbon(name: string, options: {
  51053. pathArray: Vector3[][];
  51054. closeArray?: boolean;
  51055. closePath?: boolean;
  51056. offset?: number;
  51057. updatable?: boolean;
  51058. sideOrientation?: number;
  51059. frontUVs?: Vector4;
  51060. backUVs?: Vector4;
  51061. instance?: Mesh;
  51062. invertUV?: boolean;
  51063. uvs?: Vector2[];
  51064. colors?: Color4[];
  51065. }, scene?: Nullable<Scene>): Mesh;
  51066. }
  51067. }
  51068. declare module BABYLON {
  51069. /**
  51070. * Class containing static functions to help procedurally build meshes
  51071. */
  51072. export class ShapeBuilder {
  51073. /**
  51074. * 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.
  51075. * * 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.
  51076. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51077. * * 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.
  51078. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51079. * * 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
  51080. * * 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
  51081. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51083. * * 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
  51084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51086. * @param name defines the name of the mesh
  51087. * @param options defines the options used to create the mesh
  51088. * @param scene defines the hosting scene
  51089. * @returns the extruded shape mesh
  51090. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51092. */
  51093. static ExtrudeShape(name: string, options: {
  51094. shape: Vector3[];
  51095. path: Vector3[];
  51096. scale?: number;
  51097. rotation?: number;
  51098. cap?: number;
  51099. updatable?: boolean;
  51100. sideOrientation?: number;
  51101. frontUVs?: Vector4;
  51102. backUVs?: Vector4;
  51103. instance?: Mesh;
  51104. invertUV?: boolean;
  51105. }, scene?: Nullable<Scene>): Mesh;
  51106. /**
  51107. * Creates an custom extruded shape mesh.
  51108. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51109. * * 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.
  51110. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51111. * * 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
  51112. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51113. * * 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
  51114. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51115. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51116. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51117. * * 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
  51118. * * 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
  51119. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51121. * * 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
  51122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51124. * @param name defines the name of the mesh
  51125. * @param options defines the options used to create the mesh
  51126. * @param scene defines the hosting scene
  51127. * @returns the custom extruded shape mesh
  51128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51131. */
  51132. static ExtrudeShapeCustom(name: string, options: {
  51133. shape: Vector3[];
  51134. path: Vector3[];
  51135. scaleFunction?: any;
  51136. rotationFunction?: any;
  51137. ribbonCloseArray?: boolean;
  51138. ribbonClosePath?: boolean;
  51139. cap?: number;
  51140. updatable?: boolean;
  51141. sideOrientation?: number;
  51142. frontUVs?: Vector4;
  51143. backUVs?: Vector4;
  51144. instance?: Mesh;
  51145. invertUV?: boolean;
  51146. }, scene?: Nullable<Scene>): Mesh;
  51147. private static _ExtrudeShapeGeneric;
  51148. }
  51149. }
  51150. declare module BABYLON {
  51151. /**
  51152. * AmmoJS Physics plugin
  51153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51154. * @see https://github.com/kripken/ammo.js/
  51155. */
  51156. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51157. private _useDeltaForWorldStep;
  51158. /**
  51159. * Reference to the Ammo library
  51160. */
  51161. bjsAMMO: any;
  51162. /**
  51163. * Created ammoJS world which physics bodies are added to
  51164. */
  51165. world: any;
  51166. /**
  51167. * Name of the plugin
  51168. */
  51169. name: string;
  51170. private _timeStep;
  51171. private _fixedTimeStep;
  51172. private _maxSteps;
  51173. private _tmpQuaternion;
  51174. private _tmpAmmoTransform;
  51175. private _tmpAmmoQuaternion;
  51176. private _tmpAmmoConcreteContactResultCallback;
  51177. private _collisionConfiguration;
  51178. private _dispatcher;
  51179. private _overlappingPairCache;
  51180. private _solver;
  51181. private _softBodySolver;
  51182. private _tmpAmmoVectorA;
  51183. private _tmpAmmoVectorB;
  51184. private _tmpAmmoVectorC;
  51185. private _tmpAmmoVectorD;
  51186. private _tmpContactCallbackResult;
  51187. private _tmpAmmoVectorRCA;
  51188. private _tmpAmmoVectorRCB;
  51189. private _raycastResult;
  51190. private static readonly DISABLE_COLLISION_FLAG;
  51191. private static readonly KINEMATIC_FLAG;
  51192. private static readonly DISABLE_DEACTIVATION_FLAG;
  51193. /**
  51194. * Initializes the ammoJS plugin
  51195. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51196. * @param ammoInjection can be used to inject your own ammo reference
  51197. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51198. */
  51199. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51200. /**
  51201. * Sets the gravity of the physics world (m/(s^2))
  51202. * @param gravity Gravity to set
  51203. */
  51204. setGravity(gravity: Vector3): void;
  51205. /**
  51206. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51207. * @param timeStep timestep to use in seconds
  51208. */
  51209. setTimeStep(timeStep: number): void;
  51210. /**
  51211. * 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)
  51212. * @param fixedTimeStep fixedTimeStep to use in seconds
  51213. */
  51214. setFixedTimeStep(fixedTimeStep: number): void;
  51215. /**
  51216. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51217. * @param maxSteps the maximum number of steps by the physics engine per frame
  51218. */
  51219. setMaxSteps(maxSteps: number): void;
  51220. /**
  51221. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51222. * @returns the current timestep in seconds
  51223. */
  51224. getTimeStep(): number;
  51225. private _isImpostorInContact;
  51226. private _isImpostorPairInContact;
  51227. private _stepSimulation;
  51228. /**
  51229. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51230. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51231. * After the step the babylon meshes are set to the position of the physics imposters
  51232. * @param delta amount of time to step forward
  51233. * @param impostors array of imposters to update before/after the step
  51234. */
  51235. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51236. /**
  51237. * Update babylon mesh to match physics world object
  51238. * @param impostor imposter to match
  51239. */
  51240. private _afterSoftStep;
  51241. /**
  51242. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51243. * @param impostor imposter to match
  51244. */
  51245. private _ropeStep;
  51246. /**
  51247. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51248. * @param impostor imposter to match
  51249. */
  51250. private _softbodyOrClothStep;
  51251. private _tmpVector;
  51252. private _tmpMatrix;
  51253. /**
  51254. * Applies an impulse on the imposter
  51255. * @param impostor imposter to apply impulse to
  51256. * @param force amount of force to be applied to the imposter
  51257. * @param contactPoint the location to apply the impulse on the imposter
  51258. */
  51259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51260. /**
  51261. * Applies a force on the imposter
  51262. * @param impostor imposter to apply force
  51263. * @param force amount of force to be applied to the imposter
  51264. * @param contactPoint the location to apply the force on the imposter
  51265. */
  51266. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51267. /**
  51268. * Creates a physics body using the plugin
  51269. * @param impostor the imposter to create the physics body on
  51270. */
  51271. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51272. /**
  51273. * Removes the physics body from the imposter and disposes of the body's memory
  51274. * @param impostor imposter to remove the physics body from
  51275. */
  51276. removePhysicsBody(impostor: PhysicsImpostor): void;
  51277. /**
  51278. * Generates a joint
  51279. * @param impostorJoint the imposter joint to create the joint with
  51280. */
  51281. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51282. /**
  51283. * Removes a joint
  51284. * @param impostorJoint the imposter joint to remove the joint from
  51285. */
  51286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51287. private _addMeshVerts;
  51288. /**
  51289. * Initialise the soft body vertices to match its object's (mesh) vertices
  51290. * Softbody vertices (nodes) are in world space and to match this
  51291. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51292. * @param impostor to create the softbody for
  51293. */
  51294. private _softVertexData;
  51295. /**
  51296. * Create an impostor's soft body
  51297. * @param impostor to create the softbody for
  51298. */
  51299. private _createSoftbody;
  51300. /**
  51301. * Create cloth for an impostor
  51302. * @param impostor to create the softbody for
  51303. */
  51304. private _createCloth;
  51305. /**
  51306. * Create rope for an impostor
  51307. * @param impostor to create the softbody for
  51308. */
  51309. private _createRope;
  51310. private _addHullVerts;
  51311. private _createShape;
  51312. /**
  51313. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51314. * @param impostor imposter containing the physics body and babylon object
  51315. */
  51316. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51317. /**
  51318. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51319. * @param impostor imposter containing the physics body and babylon object
  51320. * @param newPosition new position
  51321. * @param newRotation new rotation
  51322. */
  51323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51324. /**
  51325. * If this plugin is supported
  51326. * @returns true if its supported
  51327. */
  51328. isSupported(): boolean;
  51329. /**
  51330. * Sets the linear velocity of the physics body
  51331. * @param impostor imposter to set the velocity on
  51332. * @param velocity velocity to set
  51333. */
  51334. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51335. /**
  51336. * Sets the angular velocity of the physics body
  51337. * @param impostor imposter to set the velocity on
  51338. * @param velocity velocity to set
  51339. */
  51340. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51341. /**
  51342. * gets the linear velocity
  51343. * @param impostor imposter to get linear velocity from
  51344. * @returns linear velocity
  51345. */
  51346. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51347. /**
  51348. * gets the angular velocity
  51349. * @param impostor imposter to get angular velocity from
  51350. * @returns angular velocity
  51351. */
  51352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51353. /**
  51354. * Sets the mass of physics body
  51355. * @param impostor imposter to set the mass on
  51356. * @param mass mass to set
  51357. */
  51358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51359. /**
  51360. * Gets the mass of the physics body
  51361. * @param impostor imposter to get the mass from
  51362. * @returns mass
  51363. */
  51364. getBodyMass(impostor: PhysicsImpostor): number;
  51365. /**
  51366. * Gets friction of the impostor
  51367. * @param impostor impostor to get friction from
  51368. * @returns friction value
  51369. */
  51370. getBodyFriction(impostor: PhysicsImpostor): number;
  51371. /**
  51372. * Sets friction of the impostor
  51373. * @param impostor impostor to set friction on
  51374. * @param friction friction value
  51375. */
  51376. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51377. /**
  51378. * Gets restitution of the impostor
  51379. * @param impostor impostor to get restitution from
  51380. * @returns restitution value
  51381. */
  51382. getBodyRestitution(impostor: PhysicsImpostor): number;
  51383. /**
  51384. * Sets resitution of the impostor
  51385. * @param impostor impostor to set resitution on
  51386. * @param restitution resitution value
  51387. */
  51388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51389. /**
  51390. * Gets pressure inside the impostor
  51391. * @param impostor impostor to get pressure from
  51392. * @returns pressure value
  51393. */
  51394. getBodyPressure(impostor: PhysicsImpostor): number;
  51395. /**
  51396. * Sets pressure inside a soft body impostor
  51397. * Cloth and rope must remain 0 pressure
  51398. * @param impostor impostor to set pressure on
  51399. * @param pressure pressure value
  51400. */
  51401. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51402. /**
  51403. * Gets stiffness of the impostor
  51404. * @param impostor impostor to get stiffness from
  51405. * @returns pressure value
  51406. */
  51407. getBodyStiffness(impostor: PhysicsImpostor): number;
  51408. /**
  51409. * Sets stiffness of the impostor
  51410. * @param impostor impostor to set stiffness on
  51411. * @param stiffness stiffness value from 0 to 1
  51412. */
  51413. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51414. /**
  51415. * Gets velocityIterations of the impostor
  51416. * @param impostor impostor to get velocity iterations from
  51417. * @returns velocityIterations value
  51418. */
  51419. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51420. /**
  51421. * Sets velocityIterations of the impostor
  51422. * @param impostor impostor to set velocity iterations on
  51423. * @param velocityIterations velocityIterations value
  51424. */
  51425. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51426. /**
  51427. * Gets positionIterations of the impostor
  51428. * @param impostor impostor to get position iterations from
  51429. * @returns positionIterations value
  51430. */
  51431. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51432. /**
  51433. * Sets positionIterations of the impostor
  51434. * @param impostor impostor to set position on
  51435. * @param positionIterations positionIterations value
  51436. */
  51437. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51438. /**
  51439. * Append an anchor to a cloth object
  51440. * @param impostor is the cloth impostor to add anchor to
  51441. * @param otherImpostor is the rigid impostor to anchor to
  51442. * @param width ratio across width from 0 to 1
  51443. * @param height ratio up height from 0 to 1
  51444. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51445. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51446. */
  51447. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51448. /**
  51449. * Append an hook to a rope object
  51450. * @param impostor is the rope impostor to add hook to
  51451. * @param otherImpostor is the rigid impostor to hook to
  51452. * @param length ratio along the rope from 0 to 1
  51453. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51454. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51455. */
  51456. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51457. /**
  51458. * Sleeps the physics body and stops it from being active
  51459. * @param impostor impostor to sleep
  51460. */
  51461. sleepBody(impostor: PhysicsImpostor): void;
  51462. /**
  51463. * Activates the physics body
  51464. * @param impostor impostor to activate
  51465. */
  51466. wakeUpBody(impostor: PhysicsImpostor): void;
  51467. /**
  51468. * Updates the distance parameters of the joint
  51469. * @param joint joint to update
  51470. * @param maxDistance maximum distance of the joint
  51471. * @param minDistance minimum distance of the joint
  51472. */
  51473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51474. /**
  51475. * Sets a motor on the joint
  51476. * @param joint joint to set motor on
  51477. * @param speed speed of the motor
  51478. * @param maxForce maximum force of the motor
  51479. * @param motorIndex index of the motor
  51480. */
  51481. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51482. /**
  51483. * Sets the motors limit
  51484. * @param joint joint to set limit on
  51485. * @param upperLimit upper limit
  51486. * @param lowerLimit lower limit
  51487. */
  51488. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51489. /**
  51490. * Syncs the position and rotation of a mesh with the impostor
  51491. * @param mesh mesh to sync
  51492. * @param impostor impostor to update the mesh with
  51493. */
  51494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51495. /**
  51496. * Gets the radius of the impostor
  51497. * @param impostor impostor to get radius from
  51498. * @returns the radius
  51499. */
  51500. getRadius(impostor: PhysicsImpostor): number;
  51501. /**
  51502. * Gets the box size of the impostor
  51503. * @param impostor impostor to get box size from
  51504. * @param result the resulting box size
  51505. */
  51506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51507. /**
  51508. * Disposes of the impostor
  51509. */
  51510. dispose(): void;
  51511. /**
  51512. * Does a raycast in the physics world
  51513. * @param from when should the ray start?
  51514. * @param to when should the ray end?
  51515. * @returns PhysicsRaycastResult
  51516. */
  51517. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51518. }
  51519. }
  51520. declare module BABYLON {
  51521. interface AbstractScene {
  51522. /**
  51523. * The list of reflection probes added to the scene
  51524. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51525. */
  51526. reflectionProbes: Array<ReflectionProbe>;
  51527. /**
  51528. * Removes the given reflection probe from this scene.
  51529. * @param toRemove The reflection probe to remove
  51530. * @returns The index of the removed reflection probe
  51531. */
  51532. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51533. /**
  51534. * Adds the given reflection probe to this scene.
  51535. * @param newReflectionProbe The reflection probe to add
  51536. */
  51537. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51538. }
  51539. /**
  51540. * Class used to generate realtime reflection / refraction cube textures
  51541. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51542. */
  51543. export class ReflectionProbe {
  51544. /** defines the name of the probe */
  51545. name: string;
  51546. private _scene;
  51547. private _renderTargetTexture;
  51548. private _projectionMatrix;
  51549. private _viewMatrix;
  51550. private _target;
  51551. private _add;
  51552. private _attachedMesh;
  51553. private _invertYAxis;
  51554. /** Gets or sets probe position (center of the cube map) */
  51555. position: Vector3;
  51556. /**
  51557. * Creates a new reflection probe
  51558. * @param name defines the name of the probe
  51559. * @param size defines the texture resolution (for each face)
  51560. * @param scene defines the hosting scene
  51561. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51562. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51563. */
  51564. constructor(
  51565. /** defines the name of the probe */
  51566. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51567. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51568. samples: number;
  51569. /** Gets or sets the refresh rate to use (on every frame by default) */
  51570. refreshRate: number;
  51571. /**
  51572. * Gets the hosting scene
  51573. * @returns a Scene
  51574. */
  51575. getScene(): Scene;
  51576. /** Gets the internal CubeTexture used to render to */
  51577. readonly cubeTexture: RenderTargetTexture;
  51578. /** Gets the list of meshes to render */
  51579. readonly renderList: Nullable<AbstractMesh[]>;
  51580. /**
  51581. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51582. * @param mesh defines the mesh to attach to
  51583. */
  51584. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51585. /**
  51586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51587. * @param renderingGroupId The rendering group id corresponding to its index
  51588. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51589. */
  51590. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51591. /**
  51592. * Clean all associated resources
  51593. */
  51594. dispose(): void;
  51595. /**
  51596. * Converts the reflection probe information to a readable string for debug purpose.
  51597. * @param fullDetails Supports for multiple levels of logging within scene loading
  51598. * @returns the human readable reflection probe info
  51599. */
  51600. toString(fullDetails?: boolean): string;
  51601. /**
  51602. * Get the class name of the relfection probe.
  51603. * @returns "ReflectionProbe"
  51604. */
  51605. getClassName(): string;
  51606. /**
  51607. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51608. * @returns The JSON representation of the texture
  51609. */
  51610. serialize(): any;
  51611. /**
  51612. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51613. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51614. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51615. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51616. * @returns The parsed reflection probe if successful
  51617. */
  51618. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51619. }
  51620. }
  51621. declare module BABYLON {
  51622. /** @hidden */
  51623. export var _BabylonLoaderRegistered: boolean;
  51624. }
  51625. declare module BABYLON {
  51626. /**
  51627. * The Physically based simple base material of BJS.
  51628. *
  51629. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51630. * It is used as the base class for both the specGloss and metalRough conventions.
  51631. */
  51632. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51633. /**
  51634. * Number of Simultaneous lights allowed on the material.
  51635. */
  51636. maxSimultaneousLights: number;
  51637. /**
  51638. * If sets to true, disables all the lights affecting the material.
  51639. */
  51640. disableLighting: boolean;
  51641. /**
  51642. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51643. */
  51644. environmentTexture: BaseTexture;
  51645. /**
  51646. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51647. */
  51648. invertNormalMapX: boolean;
  51649. /**
  51650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51651. */
  51652. invertNormalMapY: boolean;
  51653. /**
  51654. * Normal map used in the model.
  51655. */
  51656. normalTexture: BaseTexture;
  51657. /**
  51658. * Emissivie color used to self-illuminate the model.
  51659. */
  51660. emissiveColor: Color3;
  51661. /**
  51662. * Emissivie texture used to self-illuminate the model.
  51663. */
  51664. emissiveTexture: BaseTexture;
  51665. /**
  51666. * Occlusion Channel Strenght.
  51667. */
  51668. occlusionStrength: number;
  51669. /**
  51670. * Occlusion Texture of the material (adding extra occlusion effects).
  51671. */
  51672. occlusionTexture: BaseTexture;
  51673. /**
  51674. * Defines the alpha limits in alpha test mode.
  51675. */
  51676. alphaCutOff: number;
  51677. /**
  51678. * Gets the current double sided mode.
  51679. */
  51680. /**
  51681. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51682. */
  51683. doubleSided: boolean;
  51684. /**
  51685. * Stores the pre-calculated light information of a mesh in a texture.
  51686. */
  51687. lightmapTexture: BaseTexture;
  51688. /**
  51689. * If true, the light map contains occlusion information instead of lighting info.
  51690. */
  51691. useLightmapAsShadowmap: boolean;
  51692. /**
  51693. * Instantiates a new PBRMaterial instance.
  51694. *
  51695. * @param name The material name
  51696. * @param scene The scene the material will be use in.
  51697. */
  51698. constructor(name: string, scene: Scene);
  51699. getClassName(): string;
  51700. }
  51701. }
  51702. declare module BABYLON {
  51703. /**
  51704. * The PBR material of BJS following the metal roughness convention.
  51705. *
  51706. * This fits to the PBR convention in the GLTF definition:
  51707. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51708. */
  51709. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51710. /**
  51711. * The base color has two different interpretations depending on the value of metalness.
  51712. * When the material is a metal, the base color is the specific measured reflectance value
  51713. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51714. * of the material.
  51715. */
  51716. baseColor: Color3;
  51717. /**
  51718. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51719. * well as opacity information in the alpha channel.
  51720. */
  51721. baseTexture: BaseTexture;
  51722. /**
  51723. * Specifies the metallic scalar value of the material.
  51724. * Can also be used to scale the metalness values of the metallic texture.
  51725. */
  51726. metallic: number;
  51727. /**
  51728. * Specifies the roughness scalar value of the material.
  51729. * Can also be used to scale the roughness values of the metallic texture.
  51730. */
  51731. roughness: number;
  51732. /**
  51733. * Texture containing both the metallic value in the B channel and the
  51734. * roughness value in the G channel to keep better precision.
  51735. */
  51736. metallicRoughnessTexture: BaseTexture;
  51737. /**
  51738. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51739. *
  51740. * @param name The material name
  51741. * @param scene The scene the material will be use in.
  51742. */
  51743. constructor(name: string, scene: Scene);
  51744. /**
  51745. * Return the currrent class name of the material.
  51746. */
  51747. getClassName(): string;
  51748. /**
  51749. * Makes a duplicate of the current material.
  51750. * @param name - name to use for the new material.
  51751. */
  51752. clone(name: string): PBRMetallicRoughnessMaterial;
  51753. /**
  51754. * Serialize the material to a parsable JSON object.
  51755. */
  51756. serialize(): any;
  51757. /**
  51758. * Parses a JSON object correponding to the serialize function.
  51759. */
  51760. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51761. }
  51762. }
  51763. declare module BABYLON {
  51764. /**
  51765. * The PBR material of BJS following the specular glossiness convention.
  51766. *
  51767. * This fits to the PBR convention in the GLTF definition:
  51768. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51769. */
  51770. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51771. /**
  51772. * Specifies the diffuse color of the material.
  51773. */
  51774. diffuseColor: Color3;
  51775. /**
  51776. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51777. * channel.
  51778. */
  51779. diffuseTexture: BaseTexture;
  51780. /**
  51781. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51782. */
  51783. specularColor: Color3;
  51784. /**
  51785. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51786. */
  51787. glossiness: number;
  51788. /**
  51789. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51790. */
  51791. specularGlossinessTexture: BaseTexture;
  51792. /**
  51793. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51794. *
  51795. * @param name The material name
  51796. * @param scene The scene the material will be use in.
  51797. */
  51798. constructor(name: string, scene: Scene);
  51799. /**
  51800. * Return the currrent class name of the material.
  51801. */
  51802. getClassName(): string;
  51803. /**
  51804. * Makes a duplicate of the current material.
  51805. * @param name - name to use for the new material.
  51806. */
  51807. clone(name: string): PBRSpecularGlossinessMaterial;
  51808. /**
  51809. * Serialize the material to a parsable JSON object.
  51810. */
  51811. serialize(): any;
  51812. /**
  51813. * Parses a JSON object correponding to the serialize function.
  51814. */
  51815. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51816. }
  51817. }
  51818. declare module BABYLON {
  51819. /**
  51820. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51821. * It can help converting any input color in a desired output one. This can then be used to create effects
  51822. * from sepia, black and white to sixties or futuristic rendering...
  51823. *
  51824. * The only supported format is currently 3dl.
  51825. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51826. */
  51827. export class ColorGradingTexture extends BaseTexture {
  51828. /**
  51829. * The current texture matrix. (will always be identity in color grading texture)
  51830. */
  51831. private _textureMatrix;
  51832. /**
  51833. * The texture URL.
  51834. */
  51835. url: string;
  51836. /**
  51837. * Empty line regex stored for GC.
  51838. */
  51839. private static _noneEmptyLineRegex;
  51840. private _engine;
  51841. /**
  51842. * Instantiates a ColorGradingTexture from the following parameters.
  51843. *
  51844. * @param url The location of the color gradind data (currently only supporting 3dl)
  51845. * @param scene The scene the texture will be used in
  51846. */
  51847. constructor(url: string, scene: Scene);
  51848. /**
  51849. * Returns the texture matrix used in most of the material.
  51850. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51851. */
  51852. getTextureMatrix(): Matrix;
  51853. /**
  51854. * Occurs when the file being loaded is a .3dl LUT file.
  51855. */
  51856. private load3dlTexture;
  51857. /**
  51858. * Starts the loading process of the texture.
  51859. */
  51860. private loadTexture;
  51861. /**
  51862. * Clones the color gradind texture.
  51863. */
  51864. clone(): ColorGradingTexture;
  51865. /**
  51866. * Called during delayed load for textures.
  51867. */
  51868. delayLoad(): void;
  51869. /**
  51870. * Parses a color grading texture serialized by Babylon.
  51871. * @param parsedTexture The texture information being parsedTexture
  51872. * @param scene The scene to load the texture in
  51873. * @param rootUrl The root url of the data assets to load
  51874. * @return A color gradind texture
  51875. */
  51876. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51877. /**
  51878. * Serializes the LUT texture to json format.
  51879. */
  51880. serialize(): any;
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51886. */
  51887. export class EquiRectangularCubeTexture extends BaseTexture {
  51888. /** The six faces of the cube. */
  51889. private static _FacesMapping;
  51890. private _noMipmap;
  51891. private _onLoad;
  51892. private _onError;
  51893. /** The size of the cubemap. */
  51894. private _size;
  51895. /** The buffer of the image. */
  51896. private _buffer;
  51897. /** The width of the input image. */
  51898. private _width;
  51899. /** The height of the input image. */
  51900. private _height;
  51901. /** The URL to the image. */
  51902. url: string;
  51903. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51904. coordinatesMode: number;
  51905. /**
  51906. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51907. * @param url The location of the image
  51908. * @param scene The scene the texture will be used in
  51909. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51910. * @param noMipmap Forces to not generate the mipmap if true
  51911. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51912. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51913. * @param onLoad — defines a callback called when texture is loaded
  51914. * @param onError — defines a callback called if there is an error
  51915. */
  51916. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51917. /**
  51918. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51919. */
  51920. private loadImage;
  51921. /**
  51922. * Convert the image buffer into a cubemap and create a CubeTexture.
  51923. */
  51924. private loadTexture;
  51925. /**
  51926. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51927. * @param buffer The ArrayBuffer that should be converted.
  51928. * @returns The buffer as Float32Array.
  51929. */
  51930. private getFloat32ArrayFromArrayBuffer;
  51931. /**
  51932. * Get the current class name of the texture useful for serialization or dynamic coding.
  51933. * @returns "EquiRectangularCubeTexture"
  51934. */
  51935. getClassName(): string;
  51936. /**
  51937. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51938. * @returns A clone of the current EquiRectangularCubeTexture.
  51939. */
  51940. clone(): EquiRectangularCubeTexture;
  51941. }
  51942. }
  51943. declare module BABYLON {
  51944. /**
  51945. * Based on jsTGALoader - Javascript loader for TGA file
  51946. * By Vincent Thibault
  51947. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51948. */
  51949. export class TGATools {
  51950. private static _TYPE_INDEXED;
  51951. private static _TYPE_RGB;
  51952. private static _TYPE_GREY;
  51953. private static _TYPE_RLE_INDEXED;
  51954. private static _TYPE_RLE_RGB;
  51955. private static _TYPE_RLE_GREY;
  51956. private static _ORIGIN_MASK;
  51957. private static _ORIGIN_SHIFT;
  51958. private static _ORIGIN_BL;
  51959. private static _ORIGIN_BR;
  51960. private static _ORIGIN_UL;
  51961. private static _ORIGIN_UR;
  51962. /**
  51963. * Gets the header of a TGA file
  51964. * @param data defines the TGA data
  51965. * @returns the header
  51966. */
  51967. static GetTGAHeader(data: Uint8Array): any;
  51968. /**
  51969. * Uploads TGA content to a Babylon Texture
  51970. * @hidden
  51971. */
  51972. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51973. /** @hidden */
  51974. 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;
  51975. /** @hidden */
  51976. 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;
  51977. /** @hidden */
  51978. 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;
  51979. /** @hidden */
  51980. 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;
  51981. /** @hidden */
  51982. 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;
  51983. /** @hidden */
  51984. 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;
  51985. }
  51986. }
  51987. declare module BABYLON {
  51988. /**
  51989. * Implementation of the TGA Texture Loader.
  51990. * @hidden
  51991. */
  51992. export class _TGATextureLoader implements IInternalTextureLoader {
  51993. /**
  51994. * Defines wether the loader supports cascade loading the different faces.
  51995. */
  51996. readonly supportCascades: boolean;
  51997. /**
  51998. * This returns if the loader support the current file information.
  51999. * @param extension defines the file extension of the file being loaded
  52000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52001. * @param fallback defines the fallback internal texture if any
  52002. * @param isBase64 defines whether the texture is encoded as a base64
  52003. * @param isBuffer defines whether the texture data are stored as a buffer
  52004. * @returns true if the loader can load the specified file
  52005. */
  52006. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52007. /**
  52008. * Transform the url before loading if required.
  52009. * @param rootUrl the url of the texture
  52010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52011. * @returns the transformed texture
  52012. */
  52013. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52014. /**
  52015. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52016. * @param rootUrl the url of the texture
  52017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52018. * @returns the fallback texture
  52019. */
  52020. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52021. /**
  52022. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52023. * @param data contains the texture data
  52024. * @param texture defines the BabylonJS internal texture
  52025. * @param createPolynomials will be true if polynomials have been requested
  52026. * @param onLoad defines the callback to trigger once the texture is ready
  52027. * @param onError defines the callback to trigger in case of error
  52028. */
  52029. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52030. /**
  52031. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52032. * @param data contains the texture data
  52033. * @param texture defines the BabylonJS internal texture
  52034. * @param callback defines the method to call once ready to upload
  52035. */
  52036. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52037. }
  52038. }
  52039. declare module BABYLON {
  52040. /**
  52041. * Info about the .basis files
  52042. */
  52043. class BasisFileInfo {
  52044. /**
  52045. * If the file has alpha
  52046. */
  52047. hasAlpha: boolean;
  52048. /**
  52049. * Info about each image of the basis file
  52050. */
  52051. images: Array<{
  52052. levels: Array<{
  52053. width: number;
  52054. height: number;
  52055. transcodedPixels: ArrayBufferView;
  52056. }>;
  52057. }>;
  52058. }
  52059. /**
  52060. * Result of transcoding a basis file
  52061. */
  52062. class TranscodeResult {
  52063. /**
  52064. * Info about the .basis file
  52065. */
  52066. fileInfo: BasisFileInfo;
  52067. /**
  52068. * Format to use when loading the file
  52069. */
  52070. format: number;
  52071. }
  52072. /**
  52073. * Configuration options for the Basis transcoder
  52074. */
  52075. export class BasisTranscodeConfiguration {
  52076. /**
  52077. * Supported compression formats used to determine the supported output format of the transcoder
  52078. */
  52079. supportedCompressionFormats?: {
  52080. /**
  52081. * etc1 compression format
  52082. */
  52083. etc1?: boolean;
  52084. /**
  52085. * s3tc compression format
  52086. */
  52087. s3tc?: boolean;
  52088. /**
  52089. * pvrtc compression format
  52090. */
  52091. pvrtc?: boolean;
  52092. /**
  52093. * etc2 compression format
  52094. */
  52095. etc2?: boolean;
  52096. };
  52097. /**
  52098. * If mipmap levels should be loaded for transcoded images (Default: true)
  52099. */
  52100. loadMipmapLevels?: boolean;
  52101. /**
  52102. * Index of a single image to load (Default: all images)
  52103. */
  52104. loadSingleImage?: number;
  52105. }
  52106. /**
  52107. * Used to load .Basis files
  52108. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52109. */
  52110. export class BasisTools {
  52111. private static _IgnoreSupportedFormats;
  52112. /**
  52113. * URL to use when loading the basis transcoder
  52114. */
  52115. static JSModuleURL: string;
  52116. /**
  52117. * URL to use when loading the wasm module for the transcoder
  52118. */
  52119. static WasmModuleURL: string;
  52120. /**
  52121. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52122. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52123. * @returns internal format corresponding to the Basis format
  52124. */
  52125. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52126. private static _WorkerPromise;
  52127. private static _Worker;
  52128. private static _actionId;
  52129. private static _CreateWorkerAsync;
  52130. /**
  52131. * Transcodes a loaded image file to compressed pixel data
  52132. * @param imageData image data to transcode
  52133. * @param config configuration options for the transcoding
  52134. * @returns a promise resulting in the transcoded image
  52135. */
  52136. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52137. /**
  52138. * Loads a texture from the transcode result
  52139. * @param texture texture load to
  52140. * @param transcodeResult the result of transcoding the basis file to load from
  52141. */
  52142. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52143. }
  52144. }
  52145. declare module BABYLON {
  52146. /**
  52147. * Loader for .basis file format
  52148. */
  52149. export class _BasisTextureLoader implements IInternalTextureLoader {
  52150. /**
  52151. * Defines whether the loader supports cascade loading the different faces.
  52152. */
  52153. readonly supportCascades: boolean;
  52154. /**
  52155. * This returns if the loader support the current file information.
  52156. * @param extension defines the file extension of the file being loaded
  52157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52158. * @param fallback defines the fallback internal texture if any
  52159. * @param isBase64 defines whether the texture is encoded as a base64
  52160. * @param isBuffer defines whether the texture data are stored as a buffer
  52161. * @returns true if the loader can load the specified file
  52162. */
  52163. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52164. /**
  52165. * Transform the url before loading if required.
  52166. * @param rootUrl the url of the texture
  52167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52168. * @returns the transformed texture
  52169. */
  52170. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52171. /**
  52172. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52173. * @param rootUrl the url of the texture
  52174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52175. * @returns the fallback texture
  52176. */
  52177. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52178. /**
  52179. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52180. * @param data contains the texture data
  52181. * @param texture defines the BabylonJS internal texture
  52182. * @param createPolynomials will be true if polynomials have been requested
  52183. * @param onLoad defines the callback to trigger once the texture is ready
  52184. * @param onError defines the callback to trigger in case of error
  52185. */
  52186. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52187. /**
  52188. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52189. * @param data contains the texture data
  52190. * @param texture defines the BabylonJS internal texture
  52191. * @param callback defines the method to call once ready to upload
  52192. */
  52193. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * 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.
  52199. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52200. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52201. */
  52202. export class CustomProceduralTexture extends ProceduralTexture {
  52203. private _animate;
  52204. private _time;
  52205. private _config;
  52206. private _texturePath;
  52207. /**
  52208. * Instantiates a new Custom Procedural Texture.
  52209. * 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.
  52210. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52211. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52212. * @param name Define the name of the texture
  52213. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52214. * @param size Define the size of the texture to create
  52215. * @param scene Define the scene the texture belongs to
  52216. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52217. * @param generateMipMaps Define if the texture should creates mip maps or not
  52218. */
  52219. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52220. private _loadJson;
  52221. /**
  52222. * Is the texture ready to be used ? (rendered at least once)
  52223. * @returns true if ready, otherwise, false.
  52224. */
  52225. isReady(): boolean;
  52226. /**
  52227. * Render the texture to its associated render target.
  52228. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52229. */
  52230. render(useCameraPostProcess?: boolean): void;
  52231. /**
  52232. * Update the list of dependant textures samplers in the shader.
  52233. */
  52234. updateTextures(): void;
  52235. /**
  52236. * Update the uniform values of the procedural texture in the shader.
  52237. */
  52238. updateShaderUniforms(): void;
  52239. /**
  52240. * Define if the texture animates or not.
  52241. */
  52242. animate: boolean;
  52243. }
  52244. }
  52245. declare module BABYLON {
  52246. /** @hidden */
  52247. export var noisePixelShader: {
  52248. name: string;
  52249. shader: string;
  52250. };
  52251. }
  52252. declare module BABYLON {
  52253. /**
  52254. * Class used to generate noise procedural textures
  52255. */
  52256. export class NoiseProceduralTexture extends ProceduralTexture {
  52257. private _time;
  52258. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52259. brightness: number;
  52260. /** Defines the number of octaves to process */
  52261. octaves: number;
  52262. /** Defines the level of persistence (0.8 by default) */
  52263. persistence: number;
  52264. /** Gets or sets animation speed factor (default is 1) */
  52265. animationSpeedFactor: number;
  52266. /**
  52267. * Creates a new NoiseProceduralTexture
  52268. * @param name defines the name fo the texture
  52269. * @param size defines the size of the texture (default is 256)
  52270. * @param scene defines the hosting scene
  52271. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52272. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52273. */
  52274. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52275. private _updateShaderUniforms;
  52276. protected _getDefines(): string;
  52277. /** Generate the current state of the procedural texture */
  52278. render(useCameraPostProcess?: boolean): void;
  52279. /**
  52280. * Serializes this noise procedural texture
  52281. * @returns a serialized noise procedural texture object
  52282. */
  52283. serialize(): any;
  52284. /**
  52285. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52286. * @param parsedTexture defines parsed texture data
  52287. * @param scene defines the current scene
  52288. * @param rootUrl defines the root URL containing noise procedural texture information
  52289. * @returns a parsed NoiseProceduralTexture
  52290. */
  52291. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52292. }
  52293. }
  52294. declare module BABYLON {
  52295. /**
  52296. * Raw cube texture where the raw buffers are passed in
  52297. */
  52298. export class RawCubeTexture extends CubeTexture {
  52299. /**
  52300. * Creates a cube texture where the raw buffers are passed in.
  52301. * @param scene defines the scene the texture is attached to
  52302. * @param data defines the array of data to use to create each face
  52303. * @param size defines the size of the textures
  52304. * @param format defines the format of the data
  52305. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52306. * @param generateMipMaps defines if the engine should generate the mip levels
  52307. * @param invertY defines if data must be stored with Y axis inverted
  52308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52309. * @param compression defines the compression used (null by default)
  52310. */
  52311. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52312. /**
  52313. * Updates the raw cube texture.
  52314. * @param data defines the data to store
  52315. * @param format defines the data format
  52316. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52317. * @param invertY defines if data must be stored with Y axis inverted
  52318. * @param compression defines the compression used (null by default)
  52319. * @param level defines which level of the texture to update
  52320. */
  52321. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52322. /**
  52323. * Updates a raw cube texture with RGBD encoded data.
  52324. * @param data defines the array of data [mipmap][face] to use to create each face
  52325. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52328. * @returns a promsie that resolves when the operation is complete
  52329. */
  52330. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52331. /**
  52332. * Clones the raw cube texture.
  52333. * @return a new cube texture
  52334. */
  52335. clone(): CubeTexture;
  52336. /** @hidden */
  52337. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52338. }
  52339. }
  52340. declare module BABYLON {
  52341. /**
  52342. * Class used to store 3D textures containing user data
  52343. */
  52344. export class RawTexture3D extends Texture {
  52345. /** Gets or sets the texture format to use */
  52346. format: number;
  52347. private _engine;
  52348. /**
  52349. * Create a new RawTexture3D
  52350. * @param data defines the data of the texture
  52351. * @param width defines the width of the texture
  52352. * @param height defines the height of the texture
  52353. * @param depth defines the depth of the texture
  52354. * @param format defines the texture format to use
  52355. * @param scene defines the hosting scene
  52356. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52357. * @param invertY defines if texture must be stored with Y axis inverted
  52358. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52359. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52360. */
  52361. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52362. /** Gets or sets the texture format to use */
  52363. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52364. /**
  52365. * Update the texture with new data
  52366. * @param data defines the data to store in the texture
  52367. */
  52368. update(data: ArrayBufferView): void;
  52369. }
  52370. }
  52371. declare module BABYLON {
  52372. /**
  52373. * Creates a refraction texture used by refraction channel of the standard material.
  52374. * It is like a mirror but to see through a material.
  52375. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52376. */
  52377. export class RefractionTexture extends RenderTargetTexture {
  52378. /**
  52379. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52380. * 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.
  52381. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52382. */
  52383. refractionPlane: Plane;
  52384. /**
  52385. * Define how deep under the surface we should see.
  52386. */
  52387. depth: number;
  52388. /**
  52389. * Creates a refraction texture used by refraction channel of the standard material.
  52390. * It is like a mirror but to see through a material.
  52391. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52392. * @param name Define the texture name
  52393. * @param size Define the size of the underlying texture
  52394. * @param scene Define the scene the refraction belongs to
  52395. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52396. */
  52397. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52398. /**
  52399. * Clone the refraction texture.
  52400. * @returns the cloned texture
  52401. */
  52402. clone(): RefractionTexture;
  52403. /**
  52404. * Serialize the texture to a JSON representation you could use in Parse later on
  52405. * @returns the serialized JSON representation
  52406. */
  52407. serialize(): any;
  52408. }
  52409. }
  52410. declare module BABYLON {
  52411. /**
  52412. * Defines the options related to the creation of an HtmlElementTexture
  52413. */
  52414. export interface IHtmlElementTextureOptions {
  52415. /**
  52416. * Defines wether mip maps should be created or not.
  52417. */
  52418. generateMipMaps?: boolean;
  52419. /**
  52420. * Defines the sampling mode of the texture.
  52421. */
  52422. samplingMode?: number;
  52423. /**
  52424. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52425. */
  52426. engine: Nullable<Engine>;
  52427. /**
  52428. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52429. */
  52430. scene: Nullable<Scene>;
  52431. }
  52432. /**
  52433. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52434. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52435. * is automatically managed.
  52436. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52437. * in your application.
  52438. *
  52439. * As the update is not automatic, you need to call them manually.
  52440. */
  52441. export class HtmlElementTexture extends BaseTexture {
  52442. /**
  52443. * The texture URL.
  52444. */
  52445. element: HTMLVideoElement | HTMLCanvasElement;
  52446. private static readonly DefaultOptions;
  52447. private _textureMatrix;
  52448. private _engine;
  52449. private _isVideo;
  52450. private _generateMipMaps;
  52451. private _samplingMode;
  52452. /**
  52453. * Instantiates a HtmlElementTexture from the following parameters.
  52454. *
  52455. * @param name Defines the name of the texture
  52456. * @param element Defines the video or canvas the texture is filled with
  52457. * @param options Defines the other none mandatory texture creation options
  52458. */
  52459. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52460. private _createInternalTexture;
  52461. /**
  52462. * Returns the texture matrix used in most of the material.
  52463. */
  52464. getTextureMatrix(): Matrix;
  52465. /**
  52466. * Updates the content of the texture.
  52467. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52468. */
  52469. update(invertY?: Nullable<boolean>): void;
  52470. }
  52471. }
  52472. declare module BABYLON {
  52473. /**
  52474. * Enum used to define the target of a block
  52475. */
  52476. export enum NodeMaterialBlockTargets {
  52477. /** Vertex shader */
  52478. Vertex = 1,
  52479. /** Fragment shader */
  52480. Fragment = 2,
  52481. /** Neutral */
  52482. Neutral = 4,
  52483. /** Vertex and Fragment */
  52484. VertexAndFragment = 3
  52485. }
  52486. }
  52487. declare module BABYLON {
  52488. /**
  52489. * Defines the kind of connection point for node based material
  52490. */
  52491. export enum NodeMaterialBlockConnectionPointTypes {
  52492. /** Float */
  52493. Float = 1,
  52494. /** Int */
  52495. Int = 2,
  52496. /** Vector2 */
  52497. Vector2 = 4,
  52498. /** Vector3 */
  52499. Vector3 = 8,
  52500. /** Vector4 */
  52501. Vector4 = 16,
  52502. /** Color3 */
  52503. Color3 = 32,
  52504. /** Color4 */
  52505. Color4 = 64,
  52506. /** Matrix */
  52507. Matrix = 128,
  52508. /** Detect type based on connection */
  52509. AutoDetect = 1024,
  52510. /** Output type that will be defined by input type */
  52511. BasedOnInput = 2048
  52512. }
  52513. }
  52514. declare module BABYLON {
  52515. /**
  52516. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52517. */
  52518. export enum NodeMaterialBlockConnectionPointMode {
  52519. /** Value is an uniform */
  52520. Uniform = 0,
  52521. /** Value is a mesh attribute */
  52522. Attribute = 1,
  52523. /** Value is a varying between vertex and fragment shaders */
  52524. Varying = 2,
  52525. /** Mode is undefined */
  52526. Undefined = 3
  52527. }
  52528. }
  52529. declare module BABYLON {
  52530. /**
  52531. * Enum used to define system values e.g. values automatically provided by the system
  52532. */
  52533. export enum NodeMaterialSystemValues {
  52534. /** World */
  52535. World = 1,
  52536. /** View */
  52537. View = 2,
  52538. /** Projection */
  52539. Projection = 3,
  52540. /** ViewProjection */
  52541. ViewProjection = 4,
  52542. /** WorldView */
  52543. WorldView = 5,
  52544. /** WorldViewProjection */
  52545. WorldViewProjection = 6,
  52546. /** CameraPosition */
  52547. CameraPosition = 7,
  52548. /** Fog Color */
  52549. FogColor = 8,
  52550. /** Delta time */
  52551. DeltaTime = 9
  52552. }
  52553. }
  52554. declare module BABYLON {
  52555. /**
  52556. * Root class for all node material optimizers
  52557. */
  52558. export class NodeMaterialOptimizer {
  52559. /**
  52560. * Function used to optimize a NodeMaterial graph
  52561. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52562. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52563. */
  52564. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /**
  52569. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52570. */
  52571. export class TransformBlock extends NodeMaterialBlock {
  52572. /**
  52573. * Defines the value to use to complement W value to transform it to a Vector4
  52574. */
  52575. complementW: number;
  52576. /**
  52577. * Defines the value to use to complement z value to transform it to a Vector4
  52578. */
  52579. complementZ: number;
  52580. /**
  52581. * Creates a new TransformBlock
  52582. * @param name defines the block name
  52583. */
  52584. constructor(name: string);
  52585. /**
  52586. * Gets the current class name
  52587. * @returns the class name
  52588. */
  52589. getClassName(): string;
  52590. /**
  52591. * Gets the vector input
  52592. */
  52593. readonly vector: NodeMaterialConnectionPoint;
  52594. /**
  52595. * Gets the output component
  52596. */
  52597. readonly output: NodeMaterialConnectionPoint;
  52598. /**
  52599. * Gets the matrix transform input
  52600. */
  52601. readonly transform: NodeMaterialConnectionPoint;
  52602. protected _buildBlock(state: NodeMaterialBuildState): this;
  52603. serialize(): any;
  52604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52605. protected _dumpPropertiesCode(): string;
  52606. }
  52607. }
  52608. declare module BABYLON {
  52609. /**
  52610. * Block used to output the vertex position
  52611. */
  52612. export class VertexOutputBlock extends NodeMaterialBlock {
  52613. /**
  52614. * Creates a new VertexOutputBlock
  52615. * @param name defines the block name
  52616. */
  52617. constructor(name: string);
  52618. /**
  52619. * Gets the current class name
  52620. * @returns the class name
  52621. */
  52622. getClassName(): string;
  52623. /**
  52624. * Gets the vector input component
  52625. */
  52626. readonly vector: NodeMaterialConnectionPoint;
  52627. protected _buildBlock(state: NodeMaterialBuildState): this;
  52628. }
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * Block used to output the final color
  52633. */
  52634. export class FragmentOutputBlock extends NodeMaterialBlock {
  52635. /**
  52636. * Create a new FragmentOutputBlock
  52637. * @param name defines the block name
  52638. */
  52639. constructor(name: string);
  52640. /**
  52641. * Gets the current class name
  52642. * @returns the class name
  52643. */
  52644. getClassName(): string;
  52645. /**
  52646. * Gets the rgba input component
  52647. */
  52648. readonly rgba: NodeMaterialConnectionPoint;
  52649. /**
  52650. * Gets the rgb input component
  52651. */
  52652. readonly rgb: NodeMaterialConnectionPoint;
  52653. /**
  52654. * Gets the a input component
  52655. */
  52656. readonly a: NodeMaterialConnectionPoint;
  52657. protected _buildBlock(state: NodeMaterialBuildState): this;
  52658. }
  52659. }
  52660. declare module BABYLON {
  52661. /**
  52662. * Block used to read a reflection texture from a sampler
  52663. */
  52664. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52665. private _define3DName;
  52666. private _defineCubicName;
  52667. private _defineExplicitName;
  52668. private _defineProjectionName;
  52669. private _defineLocalCubicName;
  52670. private _defineSphericalName;
  52671. private _definePlanarName;
  52672. private _defineEquirectangularName;
  52673. private _defineMirroredEquirectangularFixedName;
  52674. private _defineEquirectangularFixedName;
  52675. private _defineSkyboxName;
  52676. private _cubeSamplerName;
  52677. private _2DSamplerName;
  52678. private _positionUVWName;
  52679. private _directionWName;
  52680. private _reflectionCoordsName;
  52681. private _reflection2DCoordsName;
  52682. private _reflectionColorName;
  52683. private _reflectionMatrixName;
  52684. /**
  52685. * Gets or sets the texture associated with the node
  52686. */
  52687. texture: Nullable<BaseTexture>;
  52688. /**
  52689. * Create a new TextureBlock
  52690. * @param name defines the block name
  52691. */
  52692. constructor(name: string);
  52693. /**
  52694. * Gets the current class name
  52695. * @returns the class name
  52696. */
  52697. getClassName(): string;
  52698. /**
  52699. * Gets the world position input component
  52700. */
  52701. readonly position: NodeMaterialConnectionPoint;
  52702. /**
  52703. * Gets the world position input component
  52704. */
  52705. readonly worldPosition: NodeMaterialConnectionPoint;
  52706. /**
  52707. * Gets the world normal input component
  52708. */
  52709. readonly worldNormal: NodeMaterialConnectionPoint;
  52710. /**
  52711. * Gets the world input component
  52712. */
  52713. readonly world: NodeMaterialConnectionPoint;
  52714. /**
  52715. * Gets the camera (or eye) position component
  52716. */
  52717. readonly cameraPosition: NodeMaterialConnectionPoint;
  52718. /**
  52719. * Gets the view input component
  52720. */
  52721. readonly view: NodeMaterialConnectionPoint;
  52722. /**
  52723. * Gets the rgb output component
  52724. */
  52725. readonly rgb: NodeMaterialConnectionPoint;
  52726. /**
  52727. * Gets the r output component
  52728. */
  52729. readonly r: NodeMaterialConnectionPoint;
  52730. /**
  52731. * Gets the g output component
  52732. */
  52733. readonly g: NodeMaterialConnectionPoint;
  52734. /**
  52735. * Gets the b output component
  52736. */
  52737. readonly b: NodeMaterialConnectionPoint;
  52738. autoConfigure(material: NodeMaterial): void;
  52739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52740. isReady(): boolean;
  52741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52742. private _injectVertexCode;
  52743. private _writeOutput;
  52744. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52745. serialize(): any;
  52746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52747. }
  52748. }
  52749. declare module BABYLON {
  52750. /**
  52751. * Interface used to configure the node material editor
  52752. */
  52753. export interface INodeMaterialEditorOptions {
  52754. /** Define the URl to load node editor script */
  52755. editorURL?: string;
  52756. }
  52757. /** @hidden */
  52758. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52759. /** BONES */
  52760. NUM_BONE_INFLUENCERS: number;
  52761. BonesPerMesh: number;
  52762. BONETEXTURE: boolean;
  52763. /** MORPH TARGETS */
  52764. MORPHTARGETS: boolean;
  52765. MORPHTARGETS_NORMAL: boolean;
  52766. MORPHTARGETS_TANGENT: boolean;
  52767. MORPHTARGETS_UV: boolean;
  52768. NUM_MORPH_INFLUENCERS: number;
  52769. /** IMAGE PROCESSING */
  52770. IMAGEPROCESSING: boolean;
  52771. VIGNETTE: boolean;
  52772. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52773. VIGNETTEBLENDMODEOPAQUE: boolean;
  52774. TONEMAPPING: boolean;
  52775. TONEMAPPING_ACES: boolean;
  52776. CONTRAST: boolean;
  52777. EXPOSURE: boolean;
  52778. COLORCURVES: boolean;
  52779. COLORGRADING: boolean;
  52780. COLORGRADING3D: boolean;
  52781. SAMPLER3DGREENDEPTH: boolean;
  52782. SAMPLER3DBGRMAP: boolean;
  52783. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52784. /** MISC. */
  52785. BUMPDIRECTUV: number;
  52786. constructor();
  52787. setValue(name: string, value: boolean): void;
  52788. }
  52789. /**
  52790. * Class used to configure NodeMaterial
  52791. */
  52792. export interface INodeMaterialOptions {
  52793. /**
  52794. * Defines if blocks should emit comments
  52795. */
  52796. emitComments: boolean;
  52797. }
  52798. /**
  52799. * Class used to create a node based material built by assembling shader blocks
  52800. */
  52801. export class NodeMaterial extends PushMaterial {
  52802. private static _BuildIdGenerator;
  52803. private _options;
  52804. private _vertexCompilationState;
  52805. private _fragmentCompilationState;
  52806. private _sharedData;
  52807. private _buildId;
  52808. private _buildWasSuccessful;
  52809. private _cachedWorldViewMatrix;
  52810. private _cachedWorldViewProjectionMatrix;
  52811. private _optimizers;
  52812. private _animationFrame;
  52813. /** Define the URl to load node editor script */
  52814. static EditorURL: string;
  52815. private BJSNODEMATERIALEDITOR;
  52816. /** Get the inspector from bundle or global */
  52817. private _getGlobalNodeMaterialEditor;
  52818. /**
  52819. * 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)
  52820. */
  52821. ignoreAlpha: boolean;
  52822. /**
  52823. * Defines the maximum number of lights that can be used in the material
  52824. */
  52825. maxSimultaneousLights: number;
  52826. /**
  52827. * Observable raised when the material is built
  52828. */
  52829. onBuildObservable: Observable<NodeMaterial>;
  52830. /**
  52831. * Gets or sets the root nodes of the material vertex shader
  52832. */
  52833. _vertexOutputNodes: NodeMaterialBlock[];
  52834. /**
  52835. * Gets or sets the root nodes of the material fragment (pixel) shader
  52836. */
  52837. _fragmentOutputNodes: NodeMaterialBlock[];
  52838. /** Gets or sets options to control the node material overall behavior */
  52839. options: INodeMaterialOptions;
  52840. /**
  52841. * Default configuration related to image processing available in the standard Material.
  52842. */
  52843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52844. /**
  52845. * Gets the image processing configuration used either in this material.
  52846. */
  52847. /**
  52848. * Sets the Default image processing configuration used either in the this material.
  52849. *
  52850. * If sets to null, the scene one is in use.
  52851. */
  52852. imageProcessingConfiguration: ImageProcessingConfiguration;
  52853. /**
  52854. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52855. */
  52856. attachedBlocks: NodeMaterialBlock[];
  52857. /**
  52858. * Create a new node based material
  52859. * @param name defines the material name
  52860. * @param scene defines the hosting scene
  52861. * @param options defines creation option
  52862. */
  52863. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52864. /**
  52865. * Gets the current class name of the material e.g. "NodeMaterial"
  52866. * @returns the class name
  52867. */
  52868. getClassName(): string;
  52869. /**
  52870. * Keep track of the image processing observer to allow dispose and replace.
  52871. */
  52872. private _imageProcessingObserver;
  52873. /**
  52874. * Attaches a new image processing configuration to the Standard Material.
  52875. * @param configuration
  52876. */
  52877. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52878. /**
  52879. * Get a block by its name
  52880. * @param name defines the name of the block to retrieve
  52881. * @returns the required block or null if not found
  52882. */
  52883. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52884. /**
  52885. * Get a block by its name
  52886. * @param predicate defines the predicate used to find the good candidate
  52887. * @returns the required block or null if not found
  52888. */
  52889. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52890. /**
  52891. * Get an input block by its name
  52892. * @param predicate defines the predicate used to find the good candidate
  52893. * @returns the required input block or null if not found
  52894. */
  52895. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52896. /**
  52897. * Gets the list of input blocks attached to this material
  52898. * @returns an array of InputBlocks
  52899. */
  52900. getInputBlocks(): InputBlock[];
  52901. /**
  52902. * Adds a new optimizer to the list of optimizers
  52903. * @param optimizer defines the optimizers to add
  52904. * @returns the current material
  52905. */
  52906. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52907. /**
  52908. * Remove an optimizer from the list of optimizers
  52909. * @param optimizer defines the optimizers to remove
  52910. * @returns the current material
  52911. */
  52912. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52913. /**
  52914. * Add a new block to the list of output nodes
  52915. * @param node defines the node to add
  52916. * @returns the current material
  52917. */
  52918. addOutputNode(node: NodeMaterialBlock): this;
  52919. /**
  52920. * Remove a block from the list of root nodes
  52921. * @param node defines the node to remove
  52922. * @returns the current material
  52923. */
  52924. removeOutputNode(node: NodeMaterialBlock): this;
  52925. private _addVertexOutputNode;
  52926. private _removeVertexOutputNode;
  52927. private _addFragmentOutputNode;
  52928. private _removeFragmentOutputNode;
  52929. /**
  52930. * Specifies if the material will require alpha blending
  52931. * @returns a boolean specifying if alpha blending is needed
  52932. */
  52933. needAlphaBlending(): boolean;
  52934. /**
  52935. * Specifies if this material should be rendered in alpha test mode
  52936. * @returns a boolean specifying if an alpha test is needed.
  52937. */
  52938. needAlphaTesting(): boolean;
  52939. private _initializeBlock;
  52940. private _resetDualBlocks;
  52941. /**
  52942. * Build the material and generates the inner effect
  52943. * @param verbose defines if the build should log activity
  52944. */
  52945. build(verbose?: boolean): void;
  52946. /**
  52947. * Runs an otpimization phase to try to improve the shader code
  52948. */
  52949. optimize(): void;
  52950. private _prepareDefinesForAttributes;
  52951. /**
  52952. * Get if the submesh is ready to be used and all its information available.
  52953. * Child classes can use it to update shaders
  52954. * @param mesh defines the mesh to check
  52955. * @param subMesh defines which submesh to check
  52956. * @param useInstances specifies that instances should be used
  52957. * @returns a boolean indicating that the submesh is ready or not
  52958. */
  52959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52960. /**
  52961. * Get a string representing the shaders built by the current node graph
  52962. */
  52963. readonly compiledShaders: string;
  52964. /**
  52965. * Binds the world matrix to the material
  52966. * @param world defines the world transformation matrix
  52967. */
  52968. bindOnlyWorldMatrix(world: Matrix): void;
  52969. /**
  52970. * Binds the submesh to this material by preparing the effect and shader to draw
  52971. * @param world defines the world transformation matrix
  52972. * @param mesh defines the mesh containing the submesh
  52973. * @param subMesh defines the submesh to bind the material to
  52974. */
  52975. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52976. /**
  52977. * Gets the active textures from the material
  52978. * @returns an array of textures
  52979. */
  52980. getActiveTextures(): BaseTexture[];
  52981. /**
  52982. * Gets the list of texture blocks
  52983. * @returns an array of texture blocks
  52984. */
  52985. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52986. /**
  52987. * Specifies if the material uses a texture
  52988. * @param texture defines the texture to check against the material
  52989. * @returns a boolean specifying if the material uses the texture
  52990. */
  52991. hasTexture(texture: BaseTexture): boolean;
  52992. /**
  52993. * Disposes the material
  52994. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52995. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52996. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52997. */
  52998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52999. /** Creates the node editor window. */
  53000. private _createNodeEditor;
  53001. /**
  53002. * Launch the node material editor
  53003. * @param config Define the configuration of the editor
  53004. * @return a promise fulfilled when the node editor is visible
  53005. */
  53006. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53007. /**
  53008. * Clear the current material
  53009. */
  53010. clear(): void;
  53011. /**
  53012. * Clear the current material and set it to a default state
  53013. */
  53014. setToDefault(): void;
  53015. /**
  53016. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53017. * @param url defines the url to load from
  53018. * @returns a promise that will fullfil when the material is fully loaded
  53019. */
  53020. loadAsync(url: string): Promise<unknown>;
  53021. private _gatherBlocks;
  53022. /**
  53023. * Generate a string containing the code declaration required to create an equivalent of this material
  53024. * @returns a string
  53025. */
  53026. generateCode(): string;
  53027. /**
  53028. * Serializes this material in a JSON representation
  53029. * @returns the serialized material object
  53030. */
  53031. serialize(): any;
  53032. private _restoreConnections;
  53033. /**
  53034. * Clear the current graph and load a new one from a serialization object
  53035. * @param source defines the JSON representation of the material
  53036. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53037. */
  53038. loadFromSerialization(source: any, rootUrl?: string): void;
  53039. /**
  53040. * Creates a node material from parsed material data
  53041. * @param source defines the JSON representation of the material
  53042. * @param scene defines the hosting scene
  53043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53044. * @returns a new node material
  53045. */
  53046. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53047. /**
  53048. * Creates a new node material set to default basic configuration
  53049. * @param name defines the name of the material
  53050. * @param scene defines the hosting scene
  53051. * @returns a new NodeMaterial
  53052. */
  53053. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53054. }
  53055. }
  53056. declare module BABYLON {
  53057. /**
  53058. * Block used to read a texture from a sampler
  53059. */
  53060. export class TextureBlock extends NodeMaterialBlock {
  53061. private _defineName;
  53062. private _linearDefineName;
  53063. private _samplerName;
  53064. private _transformedUVName;
  53065. private _textureTransformName;
  53066. private _textureInfoName;
  53067. private _mainUVName;
  53068. private _mainUVDefineName;
  53069. /**
  53070. * Gets or sets the texture associated with the node
  53071. */
  53072. texture: Nullable<Texture>;
  53073. /**
  53074. * Create a new TextureBlock
  53075. * @param name defines the block name
  53076. */
  53077. constructor(name: string);
  53078. /**
  53079. * Gets the current class name
  53080. * @returns the class name
  53081. */
  53082. getClassName(): string;
  53083. /**
  53084. * Gets the uv input component
  53085. */
  53086. readonly uv: NodeMaterialConnectionPoint;
  53087. /**
  53088. * Gets the rgba output component
  53089. */
  53090. readonly rgba: NodeMaterialConnectionPoint;
  53091. /**
  53092. * Gets the rgb output component
  53093. */
  53094. readonly rgb: NodeMaterialConnectionPoint;
  53095. /**
  53096. * Gets the r output component
  53097. */
  53098. readonly r: NodeMaterialConnectionPoint;
  53099. /**
  53100. * Gets the g output component
  53101. */
  53102. readonly g: NodeMaterialConnectionPoint;
  53103. /**
  53104. * Gets the b output component
  53105. */
  53106. readonly b: NodeMaterialConnectionPoint;
  53107. /**
  53108. * Gets the a output component
  53109. */
  53110. readonly a: NodeMaterialConnectionPoint;
  53111. readonly target: NodeMaterialBlockTargets;
  53112. autoConfigure(material: NodeMaterial): void;
  53113. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53115. isReady(): boolean;
  53116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53117. private readonly _isMixed;
  53118. private _injectVertexCode;
  53119. private _writeOutput;
  53120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53121. protected _dumpPropertiesCode(): string;
  53122. serialize(): any;
  53123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53124. }
  53125. }
  53126. declare module BABYLON {
  53127. /**
  53128. * Class used to store shared data between 2 NodeMaterialBuildState
  53129. */
  53130. export class NodeMaterialBuildStateSharedData {
  53131. /**
  53132. * Gets the list of emitted varyings
  53133. */
  53134. temps: string[];
  53135. /**
  53136. * Gets the list of emitted varyings
  53137. */
  53138. varyings: string[];
  53139. /**
  53140. * Gets the varying declaration string
  53141. */
  53142. varyingDeclaration: string;
  53143. /**
  53144. * Input blocks
  53145. */
  53146. inputBlocks: InputBlock[];
  53147. /**
  53148. * Input blocks
  53149. */
  53150. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53151. /**
  53152. * Bindable blocks (Blocks that need to set data to the effect)
  53153. */
  53154. bindableBlocks: NodeMaterialBlock[];
  53155. /**
  53156. * List of blocks that can provide a compilation fallback
  53157. */
  53158. blocksWithFallbacks: NodeMaterialBlock[];
  53159. /**
  53160. * List of blocks that can provide a define update
  53161. */
  53162. blocksWithDefines: NodeMaterialBlock[];
  53163. /**
  53164. * List of blocks that can provide a repeatable content
  53165. */
  53166. repeatableContentBlocks: NodeMaterialBlock[];
  53167. /**
  53168. * List of blocks that can provide a dynamic list of uniforms
  53169. */
  53170. dynamicUniformBlocks: NodeMaterialBlock[];
  53171. /**
  53172. * List of blocks that can block the isReady function for the material
  53173. */
  53174. blockingBlocks: NodeMaterialBlock[];
  53175. /**
  53176. * Gets the list of animated inputs
  53177. */
  53178. animatedInputs: InputBlock[];
  53179. /**
  53180. * Build Id used to avoid multiple recompilations
  53181. */
  53182. buildId: number;
  53183. /** List of emitted variables */
  53184. variableNames: {
  53185. [key: string]: number;
  53186. };
  53187. /** List of emitted defines */
  53188. defineNames: {
  53189. [key: string]: number;
  53190. };
  53191. /** Should emit comments? */
  53192. emitComments: boolean;
  53193. /** Emit build activity */
  53194. verbose: boolean;
  53195. /** Gets or sets the hosting scene */
  53196. scene: Scene;
  53197. /**
  53198. * Gets the compilation hints emitted at compilation time
  53199. */
  53200. hints: {
  53201. needWorldViewMatrix: boolean;
  53202. needWorldViewProjectionMatrix: boolean;
  53203. needAlphaBlending: boolean;
  53204. needAlphaTesting: boolean;
  53205. };
  53206. /**
  53207. * List of compilation checks
  53208. */
  53209. checks: {
  53210. emitVertex: boolean;
  53211. emitFragment: boolean;
  53212. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53213. };
  53214. /** Creates a new shared data */
  53215. constructor();
  53216. /**
  53217. * Emits console errors and exceptions if there is a failing check
  53218. */
  53219. emitErrors(): void;
  53220. }
  53221. }
  53222. declare module BABYLON {
  53223. /**
  53224. * Class used to store node based material build state
  53225. */
  53226. export class NodeMaterialBuildState {
  53227. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53228. supportUniformBuffers: boolean;
  53229. /**
  53230. * Gets the list of emitted attributes
  53231. */
  53232. attributes: string[];
  53233. /**
  53234. * Gets the list of emitted uniforms
  53235. */
  53236. uniforms: string[];
  53237. /**
  53238. * Gets the list of emitted constants
  53239. */
  53240. constants: string[];
  53241. /**
  53242. * Gets the list of emitted uniform buffers
  53243. */
  53244. uniformBuffers: string[];
  53245. /**
  53246. * Gets the list of emitted samplers
  53247. */
  53248. samplers: string[];
  53249. /**
  53250. * Gets the list of emitted functions
  53251. */
  53252. functions: {
  53253. [key: string]: string;
  53254. };
  53255. /**
  53256. * Gets the list of emitted extensions
  53257. */
  53258. extensions: {
  53259. [key: string]: string;
  53260. };
  53261. /**
  53262. * Gets the target of the compilation state
  53263. */
  53264. target: NodeMaterialBlockTargets;
  53265. /**
  53266. * Gets the list of emitted counters
  53267. */
  53268. counters: {
  53269. [key: string]: number;
  53270. };
  53271. /**
  53272. * Shared data between multiple NodeMaterialBuildState instances
  53273. */
  53274. sharedData: NodeMaterialBuildStateSharedData;
  53275. /** @hidden */
  53276. _vertexState: NodeMaterialBuildState;
  53277. /** @hidden */
  53278. _attributeDeclaration: string;
  53279. /** @hidden */
  53280. _uniformDeclaration: string;
  53281. /** @hidden */
  53282. _constantDeclaration: string;
  53283. /** @hidden */
  53284. _samplerDeclaration: string;
  53285. /** @hidden */
  53286. _varyingTransfer: string;
  53287. private _repeatableContentAnchorIndex;
  53288. /** @hidden */
  53289. _builtCompilationString: string;
  53290. /**
  53291. * Gets the emitted compilation strings
  53292. */
  53293. compilationString: string;
  53294. /**
  53295. * Finalize the compilation strings
  53296. * @param state defines the current compilation state
  53297. */
  53298. finalize(state: NodeMaterialBuildState): void;
  53299. /** @hidden */
  53300. readonly _repeatableContentAnchor: string;
  53301. /** @hidden */
  53302. _getFreeVariableName(prefix: string): string;
  53303. /** @hidden */
  53304. _getFreeDefineName(prefix: string): string;
  53305. /** @hidden */
  53306. _excludeVariableName(name: string): void;
  53307. /** @hidden */
  53308. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53309. /** @hidden */
  53310. _emitExtension(name: string, extension: string): void;
  53311. /** @hidden */
  53312. _emitFunction(name: string, code: string, comments: string): void;
  53313. /** @hidden */
  53314. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53315. replaceStrings?: {
  53316. search: RegExp;
  53317. replace: string;
  53318. }[];
  53319. repeatKey?: string;
  53320. }): string;
  53321. /** @hidden */
  53322. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53323. repeatKey?: string;
  53324. removeAttributes?: boolean;
  53325. removeUniforms?: boolean;
  53326. removeVaryings?: boolean;
  53327. removeIfDef?: boolean;
  53328. replaceStrings?: {
  53329. search: RegExp;
  53330. replace: string;
  53331. }[];
  53332. }, storeKey?: string): void;
  53333. /** @hidden */
  53334. _registerTempVariable(name: string): boolean;
  53335. /** @hidden */
  53336. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53337. /** @hidden */
  53338. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53339. /** @hidden */
  53340. _emitFloat(value: number): string;
  53341. }
  53342. }
  53343. declare module BABYLON {
  53344. /**
  53345. * Defines a block that can be used inside a node based material
  53346. */
  53347. export class NodeMaterialBlock {
  53348. private _buildId;
  53349. private _buildTarget;
  53350. private _target;
  53351. private _isFinalMerger;
  53352. private _isInput;
  53353. /** @hidden */
  53354. _codeVariableName: string;
  53355. /** @hidden */
  53356. _inputs: NodeMaterialConnectionPoint[];
  53357. /** @hidden */
  53358. _outputs: NodeMaterialConnectionPoint[];
  53359. /** @hidden */
  53360. _preparationId: number;
  53361. /**
  53362. * Gets or sets the name of the block
  53363. */
  53364. name: string;
  53365. /**
  53366. * Gets or sets the unique id of the node
  53367. */
  53368. uniqueId: number;
  53369. /**
  53370. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53371. */
  53372. readonly isFinalMerger: boolean;
  53373. /**
  53374. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53375. */
  53376. readonly isInput: boolean;
  53377. /**
  53378. * Gets or sets the build Id
  53379. */
  53380. buildId: number;
  53381. /**
  53382. * Gets or sets the target of the block
  53383. */
  53384. target: NodeMaterialBlockTargets;
  53385. /**
  53386. * Gets the list of input points
  53387. */
  53388. readonly inputs: NodeMaterialConnectionPoint[];
  53389. /** Gets the list of output points */
  53390. readonly outputs: NodeMaterialConnectionPoint[];
  53391. /**
  53392. * Find an input by its name
  53393. * @param name defines the name of the input to look for
  53394. * @returns the input or null if not found
  53395. */
  53396. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53397. /**
  53398. * Find an output by its name
  53399. * @param name defines the name of the outputto look for
  53400. * @returns the output or null if not found
  53401. */
  53402. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53403. /**
  53404. * Creates a new NodeMaterialBlock
  53405. * @param name defines the block name
  53406. * @param target defines the target of that block (Vertex by default)
  53407. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53408. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53409. */
  53410. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53411. /**
  53412. * Initialize the block and prepare the context for build
  53413. * @param state defines the state that will be used for the build
  53414. */
  53415. initialize(state: NodeMaterialBuildState): void;
  53416. /**
  53417. * Bind data to effect. Will only be called for blocks with isBindable === true
  53418. * @param effect defines the effect to bind data to
  53419. * @param nodeMaterial defines the hosting NodeMaterial
  53420. * @param mesh defines the mesh that will be rendered
  53421. */
  53422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53423. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53424. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53425. protected _writeFloat(value: number): string;
  53426. /**
  53427. * Gets the current class name e.g. "NodeMaterialBlock"
  53428. * @returns the class name
  53429. */
  53430. getClassName(): string;
  53431. /**
  53432. * Register a new input. Must be called inside a block constructor
  53433. * @param name defines the connection point name
  53434. * @param type defines the connection point type
  53435. * @param isOptional defines a boolean indicating that this input can be omitted
  53436. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53437. * @returns the current block
  53438. */
  53439. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53440. /**
  53441. * Register a new output. Must be called inside a block constructor
  53442. * @param name defines the connection point name
  53443. * @param type defines the connection point type
  53444. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53445. * @returns the current block
  53446. */
  53447. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53448. /**
  53449. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53450. * @param forOutput defines an optional connection point to check compatibility with
  53451. * @returns the first available input or null
  53452. */
  53453. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53454. /**
  53455. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53456. * @param forBlock defines an optional block to check compatibility with
  53457. * @returns the first available input or null
  53458. */
  53459. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53460. /**
  53461. * Gets the sibling of the given output
  53462. * @param current defines the current output
  53463. * @returns the next output in the list or null
  53464. */
  53465. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53466. /**
  53467. * Connect current block with another block
  53468. * @param other defines the block to connect with
  53469. * @param options define the various options to help pick the right connections
  53470. * @returns the current block
  53471. */
  53472. connectTo(other: NodeMaterialBlock, options?: {
  53473. input?: string;
  53474. output?: string;
  53475. outputSwizzle?: string;
  53476. }): this | undefined;
  53477. protected _buildBlock(state: NodeMaterialBuildState): void;
  53478. /**
  53479. * Add uniforms, samplers and uniform buffers at compilation time
  53480. * @param state defines the state to update
  53481. * @param nodeMaterial defines the node material requesting the update
  53482. * @param defines defines the material defines to update
  53483. */
  53484. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53485. /**
  53486. * Add potential fallbacks if shader compilation fails
  53487. * @param mesh defines the mesh to be rendered
  53488. * @param fallbacks defines the current prioritized list of fallbacks
  53489. */
  53490. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53491. /**
  53492. * Initialize defines for shader compilation
  53493. * @param mesh defines the mesh to be rendered
  53494. * @param nodeMaterial defines the node material requesting the update
  53495. * @param defines defines the material defines to update
  53496. * @param useInstances specifies that instances should be used
  53497. */
  53498. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53499. /**
  53500. * Update defines for shader compilation
  53501. * @param mesh defines the mesh to be rendered
  53502. * @param nodeMaterial defines the node material requesting the update
  53503. * @param defines defines the material defines to update
  53504. * @param useInstances specifies that instances should be used
  53505. */
  53506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53507. /**
  53508. * Lets the block try to connect some inputs automatically
  53509. * @param material defines the hosting NodeMaterial
  53510. */
  53511. autoConfigure(material: NodeMaterial): void;
  53512. /**
  53513. * Function called when a block is declared as repeatable content generator
  53514. * @param vertexShaderState defines the current compilation state for the vertex shader
  53515. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53516. * @param mesh defines the mesh to be rendered
  53517. * @param defines defines the material defines to update
  53518. */
  53519. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53520. /**
  53521. * Checks if the block is ready
  53522. * @param mesh defines the mesh to be rendered
  53523. * @param nodeMaterial defines the node material requesting the update
  53524. * @param defines defines the material defines to update
  53525. * @param useInstances specifies that instances should be used
  53526. * @returns true if the block is ready
  53527. */
  53528. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53529. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53530. private _processBuild;
  53531. /**
  53532. * Compile the current node and generate the shader code
  53533. * @param state defines the current compilation state (uniforms, samplers, current string)
  53534. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53535. * @returns true if already built
  53536. */
  53537. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53538. protected _inputRename(name: string): string;
  53539. protected _outputRename(name: string): string;
  53540. protected _dumpPropertiesCode(): string;
  53541. /** @hidden */
  53542. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53543. /**
  53544. * Clone the current block to a new identical block
  53545. * @param scene defines the hosting scene
  53546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53547. * @returns a copy of the current block
  53548. */
  53549. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53550. /**
  53551. * Serializes this block in a JSON representation
  53552. * @returns the serialized block object
  53553. */
  53554. serialize(): any;
  53555. /** @hidden */
  53556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53557. }
  53558. }
  53559. declare module BABYLON {
  53560. /**
  53561. * Enum defining the type of animations supported by InputBlock
  53562. */
  53563. export enum AnimatedInputBlockTypes {
  53564. /** No animation */
  53565. None = 0,
  53566. /** Time based animation. Will only work for floats */
  53567. Time = 1
  53568. }
  53569. }
  53570. declare module BABYLON {
  53571. /**
  53572. * Block used to expose an input value
  53573. */
  53574. export class InputBlock extends NodeMaterialBlock {
  53575. private _mode;
  53576. private _associatedVariableName;
  53577. private _storedValue;
  53578. private _valueCallback;
  53579. private _type;
  53580. private _animationType;
  53581. /** Gets or set a value used to limit the range of float values */
  53582. min: number;
  53583. /** Gets or set a value used to limit the range of float values */
  53584. max: number;
  53585. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53586. matrixMode: number;
  53587. /** @hidden */
  53588. _systemValue: Nullable<NodeMaterialSystemValues>;
  53589. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53590. visibleInInspector: boolean;
  53591. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53592. isConstant: boolean;
  53593. /**
  53594. * Gets or sets the connection point type (default is float)
  53595. */
  53596. readonly type: NodeMaterialBlockConnectionPointTypes;
  53597. /**
  53598. * Creates a new InputBlock
  53599. * @param name defines the block name
  53600. * @param target defines the target of that block (Vertex by default)
  53601. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53602. */
  53603. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53604. /**
  53605. * Gets the output component
  53606. */
  53607. readonly output: NodeMaterialConnectionPoint;
  53608. /**
  53609. * Set the source of this connection point to a vertex attribute
  53610. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53611. * @returns the current connection point
  53612. */
  53613. setAsAttribute(attributeName?: string): InputBlock;
  53614. /**
  53615. * Set the source of this connection point to a system value
  53616. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53617. * @returns the current connection point
  53618. */
  53619. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53620. /**
  53621. * Gets or sets the value of that point.
  53622. * Please note that this value will be ignored if valueCallback is defined
  53623. */
  53624. value: any;
  53625. /**
  53626. * Gets or sets a callback used to get the value of that point.
  53627. * Please note that setting this value will force the connection point to ignore the value property
  53628. */
  53629. valueCallback: () => any;
  53630. /**
  53631. * Gets or sets the associated variable name in the shader
  53632. */
  53633. associatedVariableName: string;
  53634. /** Gets or sets the type of animation applied to the input */
  53635. animationType: AnimatedInputBlockTypes;
  53636. /**
  53637. * Gets a boolean indicating that this connection point not defined yet
  53638. */
  53639. readonly isUndefined: boolean;
  53640. /**
  53641. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53642. * In this case the connection point name must be the name of the uniform to use.
  53643. * Can only be set on inputs
  53644. */
  53645. isUniform: boolean;
  53646. /**
  53647. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53648. * In this case the connection point name must be the name of the attribute to use
  53649. * Can only be set on inputs
  53650. */
  53651. isAttribute: boolean;
  53652. /**
  53653. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53654. * Can only be set on exit points
  53655. */
  53656. isVarying: boolean;
  53657. /**
  53658. * Gets a boolean indicating that the current connection point is a system value
  53659. */
  53660. readonly isSystemValue: boolean;
  53661. /**
  53662. * Gets or sets the current well known value or null if not defined as a system value
  53663. */
  53664. systemValue: Nullable<NodeMaterialSystemValues>;
  53665. /**
  53666. * Gets the current class name
  53667. * @returns the class name
  53668. */
  53669. getClassName(): string;
  53670. /**
  53671. * Animate the input if animationType !== None
  53672. * @param scene defines the rendering scene
  53673. */
  53674. animate(scene: Scene): void;
  53675. private _emitDefine;
  53676. initialize(state: NodeMaterialBuildState): void;
  53677. /**
  53678. * Set the input block to its default value (based on its type)
  53679. */
  53680. setDefaultValue(): void;
  53681. private _emitConstant;
  53682. private _emit;
  53683. /** @hidden */
  53684. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53685. /** @hidden */
  53686. _transmit(effect: Effect, scene: Scene): void;
  53687. protected _buildBlock(state: NodeMaterialBuildState): void;
  53688. protected _dumpPropertiesCode(): string;
  53689. serialize(): any;
  53690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53691. }
  53692. }
  53693. declare module BABYLON {
  53694. /**
  53695. * Defines a connection point for a block
  53696. */
  53697. export class NodeMaterialConnectionPoint {
  53698. /** @hidden */
  53699. _ownerBlock: NodeMaterialBlock;
  53700. /** @hidden */
  53701. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53702. private _endpoints;
  53703. private _associatedVariableName;
  53704. /** @hidden */
  53705. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53706. /** @hidden */
  53707. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53708. private _type;
  53709. /** @hidden */
  53710. _enforceAssociatedVariableName: boolean;
  53711. /**
  53712. * Gets or sets the additional types supported by this connection point
  53713. */
  53714. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53715. /**
  53716. * Gets or sets the additional types excluded by this connection point
  53717. */
  53718. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53719. /**
  53720. * Gets or sets the associated variable name in the shader
  53721. */
  53722. associatedVariableName: string;
  53723. /**
  53724. * Gets or sets the connection point type (default is float)
  53725. */
  53726. type: NodeMaterialBlockConnectionPointTypes;
  53727. /**
  53728. * Gets or sets the connection point name
  53729. */
  53730. name: string;
  53731. /**
  53732. * Gets or sets a boolean indicating that this connection point can be omitted
  53733. */
  53734. isOptional: boolean;
  53735. /**
  53736. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53737. */
  53738. define: string;
  53739. /** Gets or sets the target of that connection point */
  53740. target: NodeMaterialBlockTargets;
  53741. /**
  53742. * Gets a boolean indicating that the current point is connected
  53743. */
  53744. readonly isConnected: boolean;
  53745. /**
  53746. * Gets a boolean indicating that the current point is connected to an input block
  53747. */
  53748. readonly isConnectedToInputBlock: boolean;
  53749. /**
  53750. * Gets a the connected input block (if any)
  53751. */
  53752. readonly connectInputBlock: Nullable<InputBlock>;
  53753. /** Get the other side of the connection (if any) */
  53754. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53755. /** Get the block that owns this connection point */
  53756. readonly ownerBlock: NodeMaterialBlock;
  53757. /** Get the block connected on the other side of this connection (if any) */
  53758. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53759. /** Get the block connected on the endpoints of this connection (if any) */
  53760. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53761. /** Gets the list of connected endpoints */
  53762. readonly endpoints: NodeMaterialConnectionPoint[];
  53763. /** Gets a boolean indicating if that output point is connected to at least one input */
  53764. readonly hasEndpoints: boolean;
  53765. /**
  53766. * Creates a new connection point
  53767. * @param name defines the connection point name
  53768. * @param ownerBlock defines the block hosting this connection point
  53769. */
  53770. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53771. /**
  53772. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53773. * @returns the class name
  53774. */
  53775. getClassName(): string;
  53776. /**
  53777. * Gets an boolean indicating if the current point can be connected to another point
  53778. * @param connectionPoint defines the other connection point
  53779. * @returns true if the connection is possible
  53780. */
  53781. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53782. /**
  53783. * Connect this point to another connection point
  53784. * @param connectionPoint defines the other connection point
  53785. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53786. * @returns the current connection point
  53787. */
  53788. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53789. /**
  53790. * Disconnect this point from one of his endpoint
  53791. * @param endpoint defines the other connection point
  53792. * @returns the current connection point
  53793. */
  53794. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53795. /**
  53796. * Serializes this point in a JSON representation
  53797. * @returns the serialized point object
  53798. */
  53799. serialize(): any;
  53800. }
  53801. }
  53802. declare module BABYLON {
  53803. /**
  53804. * Block used to add support for vertex skinning (bones)
  53805. */
  53806. export class BonesBlock extends NodeMaterialBlock {
  53807. /**
  53808. * Creates a new BonesBlock
  53809. * @param name defines the block name
  53810. */
  53811. constructor(name: string);
  53812. /**
  53813. * Initialize the block and prepare the context for build
  53814. * @param state defines the state that will be used for the build
  53815. */
  53816. initialize(state: NodeMaterialBuildState): void;
  53817. /**
  53818. * Gets the current class name
  53819. * @returns the class name
  53820. */
  53821. getClassName(): string;
  53822. /**
  53823. * Gets the matrix indices input component
  53824. */
  53825. readonly matricesIndices: NodeMaterialConnectionPoint;
  53826. /**
  53827. * Gets the matrix weights input component
  53828. */
  53829. readonly matricesWeights: NodeMaterialConnectionPoint;
  53830. /**
  53831. * Gets the extra matrix indices input component
  53832. */
  53833. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53834. /**
  53835. * Gets the extra matrix weights input component
  53836. */
  53837. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53838. /**
  53839. * Gets the world input component
  53840. */
  53841. readonly world: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Gets the output component
  53844. */
  53845. readonly output: NodeMaterialConnectionPoint;
  53846. autoConfigure(material: NodeMaterial): void;
  53847. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53850. protected _buildBlock(state: NodeMaterialBuildState): this;
  53851. }
  53852. }
  53853. declare module BABYLON {
  53854. /**
  53855. * Block used to add support for instances
  53856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53857. */
  53858. export class InstancesBlock extends NodeMaterialBlock {
  53859. /**
  53860. * Creates a new InstancesBlock
  53861. * @param name defines the block name
  53862. */
  53863. constructor(name: string);
  53864. /**
  53865. * Gets the current class name
  53866. * @returns the class name
  53867. */
  53868. getClassName(): string;
  53869. /**
  53870. * Gets the first world row input component
  53871. */
  53872. readonly world0: NodeMaterialConnectionPoint;
  53873. /**
  53874. * Gets the second world row input component
  53875. */
  53876. readonly world1: NodeMaterialConnectionPoint;
  53877. /**
  53878. * Gets the third world row input component
  53879. */
  53880. readonly world2: NodeMaterialConnectionPoint;
  53881. /**
  53882. * Gets the forth world row input component
  53883. */
  53884. readonly world3: NodeMaterialConnectionPoint;
  53885. /**
  53886. * Gets the world input component
  53887. */
  53888. readonly world: NodeMaterialConnectionPoint;
  53889. /**
  53890. * Gets the output component
  53891. */
  53892. readonly output: NodeMaterialConnectionPoint;
  53893. autoConfigure(material: NodeMaterial): void;
  53894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53895. protected _buildBlock(state: NodeMaterialBuildState): this;
  53896. }
  53897. }
  53898. declare module BABYLON {
  53899. /**
  53900. * Block used to add morph targets support to vertex shader
  53901. */
  53902. export class MorphTargetsBlock extends NodeMaterialBlock {
  53903. private _repeatableContentAnchor;
  53904. private _repeatebleContentGenerated;
  53905. /**
  53906. * Create a new MorphTargetsBlock
  53907. * @param name defines the block name
  53908. */
  53909. constructor(name: string);
  53910. /**
  53911. * Gets the current class name
  53912. * @returns the class name
  53913. */
  53914. getClassName(): string;
  53915. /**
  53916. * Gets the position input component
  53917. */
  53918. readonly position: NodeMaterialConnectionPoint;
  53919. /**
  53920. * Gets the normal input component
  53921. */
  53922. readonly normal: NodeMaterialConnectionPoint;
  53923. /**
  53924. * Gets the tangent input component
  53925. */
  53926. readonly tangent: NodeMaterialConnectionPoint;
  53927. /**
  53928. * Gets the tangent input component
  53929. */
  53930. readonly uv: NodeMaterialConnectionPoint;
  53931. /**
  53932. * Gets the position output component
  53933. */
  53934. readonly positionOutput: NodeMaterialConnectionPoint;
  53935. /**
  53936. * Gets the normal output component
  53937. */
  53938. readonly normalOutput: NodeMaterialConnectionPoint;
  53939. /**
  53940. * Gets the tangent output component
  53941. */
  53942. readonly tangentOutput: NodeMaterialConnectionPoint;
  53943. /**
  53944. * Gets the tangent output component
  53945. */
  53946. readonly uvOutput: NodeMaterialConnectionPoint;
  53947. initialize(state: NodeMaterialBuildState): void;
  53948. autoConfigure(material: NodeMaterial): void;
  53949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53951. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53952. protected _buildBlock(state: NodeMaterialBuildState): this;
  53953. }
  53954. }
  53955. declare module BABYLON {
  53956. /**
  53957. * Block used to get data information from a light
  53958. */
  53959. export class LightInformationBlock extends NodeMaterialBlock {
  53960. private _lightDataUniformName;
  53961. private _lightColorUniformName;
  53962. private _lightTypeDefineName;
  53963. /**
  53964. * Gets or sets the light associated with this block
  53965. */
  53966. light: Nullable<Light>;
  53967. /**
  53968. * Creates a new LightInformationBlock
  53969. * @param name defines the block name
  53970. */
  53971. constructor(name: string);
  53972. /**
  53973. * Gets the current class name
  53974. * @returns the class name
  53975. */
  53976. getClassName(): string;
  53977. /**
  53978. * Gets the world position input component
  53979. */
  53980. readonly worldPosition: NodeMaterialConnectionPoint;
  53981. /**
  53982. * Gets the direction output component
  53983. */
  53984. readonly direction: NodeMaterialConnectionPoint;
  53985. /**
  53986. * Gets the direction output component
  53987. */
  53988. readonly color: NodeMaterialConnectionPoint;
  53989. /**
  53990. * Gets the direction output component
  53991. */
  53992. readonly intensity: NodeMaterialConnectionPoint;
  53993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53995. protected _buildBlock(state: NodeMaterialBuildState): this;
  53996. serialize(): any;
  53997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53998. }
  53999. }
  54000. declare module BABYLON {
  54001. /**
  54002. * Block used to add image processing support to fragment shader
  54003. */
  54004. export class ImageProcessingBlock extends NodeMaterialBlock {
  54005. /**
  54006. * Create a new ImageProcessingBlock
  54007. * @param name defines the block name
  54008. */
  54009. constructor(name: string);
  54010. /**
  54011. * Gets the current class name
  54012. * @returns the class name
  54013. */
  54014. getClassName(): string;
  54015. /**
  54016. * Gets the color input component
  54017. */
  54018. readonly color: NodeMaterialConnectionPoint;
  54019. /**
  54020. * Gets the output component
  54021. */
  54022. readonly output: NodeMaterialConnectionPoint;
  54023. /**
  54024. * Initialize the block and prepare the context for build
  54025. * @param state defines the state that will be used for the build
  54026. */
  54027. initialize(state: NodeMaterialBuildState): void;
  54028. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54031. protected _buildBlock(state: NodeMaterialBuildState): this;
  54032. }
  54033. }
  54034. declare module BABYLON {
  54035. /**
  54036. * Block used to pertub normals based on a normal map
  54037. */
  54038. export class PerturbNormalBlock extends NodeMaterialBlock {
  54039. private _tangentSpaceParameterName;
  54040. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54041. invertX: boolean;
  54042. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54043. invertY: boolean;
  54044. /**
  54045. * Create a new PerturbNormalBlock
  54046. * @param name defines the block name
  54047. */
  54048. constructor(name: string);
  54049. /**
  54050. * Gets the current class name
  54051. * @returns the class name
  54052. */
  54053. getClassName(): string;
  54054. /**
  54055. * Gets the world position input component
  54056. */
  54057. readonly worldPosition: NodeMaterialConnectionPoint;
  54058. /**
  54059. * Gets the world normal input component
  54060. */
  54061. readonly worldNormal: NodeMaterialConnectionPoint;
  54062. /**
  54063. * Gets the uv input component
  54064. */
  54065. readonly uv: NodeMaterialConnectionPoint;
  54066. /**
  54067. * Gets the normal map color input component
  54068. */
  54069. readonly normalMapColor: NodeMaterialConnectionPoint;
  54070. /**
  54071. * Gets the strength input component
  54072. */
  54073. readonly strength: NodeMaterialConnectionPoint;
  54074. /**
  54075. * Gets the output component
  54076. */
  54077. readonly output: NodeMaterialConnectionPoint;
  54078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54079. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54080. autoConfigure(material: NodeMaterial): void;
  54081. protected _buildBlock(state: NodeMaterialBuildState): this;
  54082. protected _dumpPropertiesCode(): string;
  54083. serialize(): any;
  54084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54085. }
  54086. }
  54087. declare module BABYLON {
  54088. /**
  54089. * Block used to discard a pixel if a value is smaller than a cutoff
  54090. */
  54091. export class DiscardBlock extends NodeMaterialBlock {
  54092. /**
  54093. * Create a new DiscardBlock
  54094. * @param name defines the block name
  54095. */
  54096. constructor(name: string);
  54097. /**
  54098. * Gets the current class name
  54099. * @returns the class name
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Gets the color input component
  54104. */
  54105. readonly value: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Gets the cutoff input component
  54108. */
  54109. readonly cutoff: NodeMaterialConnectionPoint;
  54110. protected _buildBlock(state: NodeMaterialBuildState): this;
  54111. }
  54112. }
  54113. declare module BABYLON {
  54114. /**
  54115. * Block used to add support for scene fog
  54116. */
  54117. export class FogBlock extends NodeMaterialBlock {
  54118. private _fogDistanceName;
  54119. private _fogParameters;
  54120. /**
  54121. * Create a new FogBlock
  54122. * @param name defines the block name
  54123. */
  54124. constructor(name: string);
  54125. /**
  54126. * Gets the current class name
  54127. * @returns the class name
  54128. */
  54129. getClassName(): string;
  54130. /**
  54131. * Gets the world position input component
  54132. */
  54133. readonly worldPosition: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the view input component
  54136. */
  54137. readonly view: NodeMaterialConnectionPoint;
  54138. /**
  54139. * Gets the color input component
  54140. */
  54141. readonly input: NodeMaterialConnectionPoint;
  54142. /**
  54143. * Gets the fog color input component
  54144. */
  54145. readonly fogColor: NodeMaterialConnectionPoint;
  54146. /**
  54147. * Gets the output component
  54148. */
  54149. readonly output: NodeMaterialConnectionPoint;
  54150. autoConfigure(material: NodeMaterial): void;
  54151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54152. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54153. protected _buildBlock(state: NodeMaterialBuildState): this;
  54154. }
  54155. }
  54156. declare module BABYLON {
  54157. /**
  54158. * Block used to add light in the fragment shader
  54159. */
  54160. export class LightBlock extends NodeMaterialBlock {
  54161. private _lightId;
  54162. /**
  54163. * Gets or sets the light associated with this block
  54164. */
  54165. light: Nullable<Light>;
  54166. /**
  54167. * Create a new LightBlock
  54168. * @param name defines the block name
  54169. */
  54170. constructor(name: string);
  54171. /**
  54172. * Gets the current class name
  54173. * @returns the class name
  54174. */
  54175. getClassName(): string;
  54176. /**
  54177. * Gets the world position input component
  54178. */
  54179. readonly worldPosition: NodeMaterialConnectionPoint;
  54180. /**
  54181. * Gets the world normal input component
  54182. */
  54183. readonly worldNormal: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the camera (or eye) position component
  54186. */
  54187. readonly cameraPosition: NodeMaterialConnectionPoint;
  54188. /**
  54189. * Gets the glossiness component
  54190. */
  54191. readonly glossiness: NodeMaterialConnectionPoint;
  54192. /**
  54193. * Gets the glossinness power component
  54194. */
  54195. readonly glossPower: NodeMaterialConnectionPoint;
  54196. /**
  54197. * Gets the diffuse color component
  54198. */
  54199. readonly diffuseColor: NodeMaterialConnectionPoint;
  54200. /**
  54201. * Gets the specular color component
  54202. */
  54203. readonly specularColor: NodeMaterialConnectionPoint;
  54204. /**
  54205. * Gets the diffuse output component
  54206. */
  54207. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54208. /**
  54209. * Gets the specular output component
  54210. */
  54211. readonly specularOutput: NodeMaterialConnectionPoint;
  54212. autoConfigure(material: NodeMaterial): void;
  54213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54214. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54216. private _injectVertexCode;
  54217. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54218. serialize(): any;
  54219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54220. }
  54221. }
  54222. declare module BABYLON {
  54223. /**
  54224. * Block used to multiply 2 values
  54225. */
  54226. export class MultiplyBlock extends NodeMaterialBlock {
  54227. /**
  54228. * Creates a new MultiplyBlock
  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 left operand input component
  54239. */
  54240. readonly left: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the right operand input component
  54243. */
  54244. readonly right: NodeMaterialConnectionPoint;
  54245. /**
  54246. * Gets the output component
  54247. */
  54248. readonly output: NodeMaterialConnectionPoint;
  54249. protected _buildBlock(state: NodeMaterialBuildState): this;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * Block used to add 2 vectors
  54255. */
  54256. export class AddBlock extends NodeMaterialBlock {
  54257. /**
  54258. * Creates a new AddBlock
  54259. * @param name defines the block name
  54260. */
  54261. constructor(name: string);
  54262. /**
  54263. * Gets the current class name
  54264. * @returns the class name
  54265. */
  54266. getClassName(): string;
  54267. /**
  54268. * Gets the left operand input component
  54269. */
  54270. readonly left: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the right operand input component
  54273. */
  54274. readonly right: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the output component
  54277. */
  54278. readonly output: NodeMaterialConnectionPoint;
  54279. protected _buildBlock(state: NodeMaterialBuildState): this;
  54280. }
  54281. }
  54282. declare module BABYLON {
  54283. /**
  54284. * Block used to scale a vector by a float
  54285. */
  54286. export class ScaleBlock extends NodeMaterialBlock {
  54287. /**
  54288. * Creates a new ScaleBlock
  54289. * @param name defines the block name
  54290. */
  54291. constructor(name: string);
  54292. /**
  54293. * Gets the current class name
  54294. * @returns the class name
  54295. */
  54296. getClassName(): string;
  54297. /**
  54298. * Gets the input component
  54299. */
  54300. readonly input: NodeMaterialConnectionPoint;
  54301. /**
  54302. * Gets the factor input component
  54303. */
  54304. readonly factor: NodeMaterialConnectionPoint;
  54305. /**
  54306. * Gets the output component
  54307. */
  54308. readonly output: NodeMaterialConnectionPoint;
  54309. protected _buildBlock(state: NodeMaterialBuildState): this;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * Block used to clamp a float
  54315. */
  54316. export class ClampBlock extends NodeMaterialBlock {
  54317. /** Gets or sets the minimum range */
  54318. minimum: number;
  54319. /** Gets or sets the maximum range */
  54320. maximum: number;
  54321. /**
  54322. * Creates a new ClampBlock
  54323. * @param name defines the block name
  54324. */
  54325. constructor(name: string);
  54326. /**
  54327. * Gets the current class name
  54328. * @returns the class name
  54329. */
  54330. getClassName(): string;
  54331. /**
  54332. * Gets the value input component
  54333. */
  54334. readonly value: NodeMaterialConnectionPoint;
  54335. /**
  54336. * Gets the output component
  54337. */
  54338. readonly output: NodeMaterialConnectionPoint;
  54339. protected _buildBlock(state: NodeMaterialBuildState): this;
  54340. protected _dumpPropertiesCode(): string;
  54341. serialize(): any;
  54342. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54343. }
  54344. }
  54345. declare module BABYLON {
  54346. /**
  54347. * Block used to apply a cross product between 2 vectors
  54348. */
  54349. export class CrossBlock extends NodeMaterialBlock {
  54350. /**
  54351. * Creates a new CrossBlock
  54352. * @param name defines the block name
  54353. */
  54354. constructor(name: string);
  54355. /**
  54356. * Gets the current class name
  54357. * @returns the class name
  54358. */
  54359. getClassName(): string;
  54360. /**
  54361. * Gets the left operand input component
  54362. */
  54363. readonly left: NodeMaterialConnectionPoint;
  54364. /**
  54365. * Gets the right operand input component
  54366. */
  54367. readonly right: NodeMaterialConnectionPoint;
  54368. /**
  54369. * Gets the output component
  54370. */
  54371. readonly output: NodeMaterialConnectionPoint;
  54372. protected _buildBlock(state: NodeMaterialBuildState): this;
  54373. }
  54374. }
  54375. declare module BABYLON {
  54376. /**
  54377. * Block used to apply a dot product between 2 vectors
  54378. */
  54379. export class DotBlock extends NodeMaterialBlock {
  54380. /**
  54381. * Creates a new DotBlock
  54382. * @param name defines the block name
  54383. */
  54384. constructor(name: string);
  54385. /**
  54386. * Gets the current class name
  54387. * @returns the class name
  54388. */
  54389. getClassName(): string;
  54390. /**
  54391. * Gets the left operand input component
  54392. */
  54393. readonly left: NodeMaterialConnectionPoint;
  54394. /**
  54395. * Gets the right operand input component
  54396. */
  54397. readonly right: NodeMaterialConnectionPoint;
  54398. /**
  54399. * Gets the output component
  54400. */
  54401. readonly output: NodeMaterialConnectionPoint;
  54402. protected _buildBlock(state: NodeMaterialBuildState): this;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Block used to remap a float from a range to a new one
  54408. */
  54409. export class RemapBlock extends NodeMaterialBlock {
  54410. /**
  54411. * Gets or sets the source range
  54412. */
  54413. sourceRange: Vector2;
  54414. /**
  54415. * Gets or sets the target range
  54416. */
  54417. targetRange: Vector2;
  54418. /**
  54419. * Creates a new RemapBlock
  54420. * @param name defines the block name
  54421. */
  54422. constructor(name: string);
  54423. /**
  54424. * Gets the current class name
  54425. * @returns the class name
  54426. */
  54427. getClassName(): string;
  54428. /**
  54429. * Gets the input component
  54430. */
  54431. readonly input: NodeMaterialConnectionPoint;
  54432. /**
  54433. * Gets the source min input component
  54434. */
  54435. readonly sourceMin: NodeMaterialConnectionPoint;
  54436. /**
  54437. * Gets the source max input component
  54438. */
  54439. readonly sourceMax: NodeMaterialConnectionPoint;
  54440. /**
  54441. * Gets the target min input component
  54442. */
  54443. readonly targetMin: NodeMaterialConnectionPoint;
  54444. /**
  54445. * Gets the target max input component
  54446. */
  54447. readonly targetMax: NodeMaterialConnectionPoint;
  54448. /**
  54449. * Gets the output component
  54450. */
  54451. readonly output: NodeMaterialConnectionPoint;
  54452. protected _buildBlock(state: NodeMaterialBuildState): this;
  54453. protected _dumpPropertiesCode(): string;
  54454. serialize(): any;
  54455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * Block used to normalize a vector
  54461. */
  54462. export class NormalizeBlock extends NodeMaterialBlock {
  54463. /**
  54464. * Creates a new NormalizeBlock
  54465. * @param name defines the block name
  54466. */
  54467. constructor(name: string);
  54468. /**
  54469. * Gets the current class name
  54470. * @returns the class name
  54471. */
  54472. getClassName(): string;
  54473. /**
  54474. * Gets the input component
  54475. */
  54476. readonly input: NodeMaterialConnectionPoint;
  54477. /**
  54478. * Gets the output component
  54479. */
  54480. readonly output: NodeMaterialConnectionPoint;
  54481. protected _buildBlock(state: NodeMaterialBuildState): this;
  54482. }
  54483. }
  54484. declare module BABYLON {
  54485. /**
  54486. * Operations supported by the Trigonometry block
  54487. */
  54488. export enum TrigonometryBlockOperations {
  54489. /** Cos */
  54490. Cos = 0,
  54491. /** Sin */
  54492. Sin = 1,
  54493. /** Abs */
  54494. Abs = 2,
  54495. /** Exp */
  54496. Exp = 3,
  54497. /** Exp2 */
  54498. Exp2 = 4,
  54499. /** Round */
  54500. Round = 5,
  54501. /** Floor */
  54502. Floor = 6,
  54503. /** Ceiling */
  54504. Ceiling = 7,
  54505. /** Square root */
  54506. Sqrt = 8,
  54507. /** Log */
  54508. Log = 9,
  54509. /** Tangent */
  54510. Tan = 10,
  54511. /** Arc tangent */
  54512. ArcTan = 11,
  54513. /** Arc cosinus */
  54514. ArcCos = 12,
  54515. /** Arc sinus */
  54516. ArcSin = 13,
  54517. /** Fraction */
  54518. Fract = 14,
  54519. /** Sign */
  54520. Sign = 15,
  54521. /** To radians (from degrees) */
  54522. Radians = 16,
  54523. /** To degrees (from radians) */
  54524. Degrees = 17
  54525. }
  54526. /**
  54527. * Block used to apply trigonometry operation to floats
  54528. */
  54529. export class TrigonometryBlock extends NodeMaterialBlock {
  54530. /**
  54531. * Gets or sets the operation applied by the block
  54532. */
  54533. operation: TrigonometryBlockOperations;
  54534. /**
  54535. * Creates a new TrigonometryBlock
  54536. * @param name defines the block name
  54537. */
  54538. constructor(name: string);
  54539. /**
  54540. * Gets the current class name
  54541. * @returns the class name
  54542. */
  54543. getClassName(): string;
  54544. /**
  54545. * Gets the input component
  54546. */
  54547. readonly input: NodeMaterialConnectionPoint;
  54548. /**
  54549. * Gets the output component
  54550. */
  54551. readonly output: NodeMaterialConnectionPoint;
  54552. protected _buildBlock(state: NodeMaterialBuildState): this;
  54553. serialize(): any;
  54554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54555. }
  54556. }
  54557. declare module BABYLON {
  54558. /**
  54559. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54560. */
  54561. export class ColorMergerBlock extends NodeMaterialBlock {
  54562. /**
  54563. * Create a new ColorMergerBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the r component (input)
  54574. */
  54575. readonly r: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the g component (input)
  54578. */
  54579. readonly g: NodeMaterialConnectionPoint;
  54580. /**
  54581. * Gets the b component (input)
  54582. */
  54583. readonly b: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the a component (input)
  54586. */
  54587. readonly a: NodeMaterialConnectionPoint;
  54588. /**
  54589. * Gets the rgba component (output)
  54590. */
  54591. readonly rgba: NodeMaterialConnectionPoint;
  54592. /**
  54593. * Gets the rgb component (output)
  54594. */
  54595. readonly rgb: NodeMaterialConnectionPoint;
  54596. protected _buildBlock(state: NodeMaterialBuildState): this;
  54597. }
  54598. }
  54599. declare module BABYLON {
  54600. /**
  54601. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54602. */
  54603. export class VectorMergerBlock extends NodeMaterialBlock {
  54604. /**
  54605. * Create a new VectorMergerBlock
  54606. * @param name defines the block name
  54607. */
  54608. constructor(name: string);
  54609. /**
  54610. * Gets the current class name
  54611. * @returns the class name
  54612. */
  54613. getClassName(): string;
  54614. /**
  54615. * Gets the x component (input)
  54616. */
  54617. readonly x: NodeMaterialConnectionPoint;
  54618. /**
  54619. * Gets the y component (input)
  54620. */
  54621. readonly y: NodeMaterialConnectionPoint;
  54622. /**
  54623. * Gets the z component (input)
  54624. */
  54625. readonly z: NodeMaterialConnectionPoint;
  54626. /**
  54627. * Gets the w component (input)
  54628. */
  54629. readonly w: NodeMaterialConnectionPoint;
  54630. /**
  54631. * Gets the xyzw component (output)
  54632. */
  54633. readonly xyzw: NodeMaterialConnectionPoint;
  54634. /**
  54635. * Gets the xyz component (output)
  54636. */
  54637. readonly xyz: NodeMaterialConnectionPoint;
  54638. /**
  54639. * Gets the xy component (output)
  54640. */
  54641. readonly xy: NodeMaterialConnectionPoint;
  54642. protected _buildBlock(state: NodeMaterialBuildState): this;
  54643. }
  54644. }
  54645. declare module BABYLON {
  54646. /**
  54647. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54648. */
  54649. export class ColorSplitterBlock extends NodeMaterialBlock {
  54650. /**
  54651. * Create a new ColorSplitterBlock
  54652. * @param name defines the block name
  54653. */
  54654. constructor(name: string);
  54655. /**
  54656. * Gets the current class name
  54657. * @returns the class name
  54658. */
  54659. getClassName(): string;
  54660. /**
  54661. * Gets the rgba component (input)
  54662. */
  54663. readonly rgba: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the rgb component (input)
  54666. */
  54667. readonly rgbIn: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the rgb component (output)
  54670. */
  54671. readonly rgbOut: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the r component (output)
  54674. */
  54675. readonly r: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the g component (output)
  54678. */
  54679. readonly g: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the b component (output)
  54682. */
  54683. readonly b: NodeMaterialConnectionPoint;
  54684. /**
  54685. * Gets the a component (output)
  54686. */
  54687. readonly a: NodeMaterialConnectionPoint;
  54688. protected _inputRename(name: string): string;
  54689. protected _outputRename(name: string): string;
  54690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54691. }
  54692. }
  54693. declare module BABYLON {
  54694. /**
  54695. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54696. */
  54697. export class VectorSplitterBlock extends NodeMaterialBlock {
  54698. /**
  54699. * Create a new VectorSplitterBlock
  54700. * @param name defines the block name
  54701. */
  54702. constructor(name: string);
  54703. /**
  54704. * Gets the current class name
  54705. * @returns the class name
  54706. */
  54707. getClassName(): string;
  54708. /**
  54709. * Gets the xyzw component (input)
  54710. */
  54711. readonly xyzw: NodeMaterialConnectionPoint;
  54712. /**
  54713. * Gets the xyz component (input)
  54714. */
  54715. readonly xyzIn: NodeMaterialConnectionPoint;
  54716. /**
  54717. * Gets the xy component (input)
  54718. */
  54719. readonly xyIn: NodeMaterialConnectionPoint;
  54720. /**
  54721. * Gets the xyz component (output)
  54722. */
  54723. readonly xyzOut: NodeMaterialConnectionPoint;
  54724. /**
  54725. * Gets the xy component (output)
  54726. */
  54727. readonly xyOut: NodeMaterialConnectionPoint;
  54728. /**
  54729. * Gets the x component (output)
  54730. */
  54731. readonly x: NodeMaterialConnectionPoint;
  54732. /**
  54733. * Gets the y component (output)
  54734. */
  54735. readonly y: NodeMaterialConnectionPoint;
  54736. /**
  54737. * Gets the z component (output)
  54738. */
  54739. readonly z: NodeMaterialConnectionPoint;
  54740. /**
  54741. * Gets the w component (output)
  54742. */
  54743. readonly w: NodeMaterialConnectionPoint;
  54744. protected _inputRename(name: string): string;
  54745. protected _outputRename(name: string): string;
  54746. protected _buildBlock(state: NodeMaterialBuildState): this;
  54747. }
  54748. }
  54749. declare module BABYLON {
  54750. /**
  54751. * Block used to lerp 2 values
  54752. */
  54753. export class LerpBlock extends NodeMaterialBlock {
  54754. /**
  54755. * Creates a new LerpBlock
  54756. * @param name defines the block name
  54757. */
  54758. constructor(name: string);
  54759. /**
  54760. * Gets the current class name
  54761. * @returns the class name
  54762. */
  54763. getClassName(): string;
  54764. /**
  54765. * Gets the left operand input component
  54766. */
  54767. readonly left: NodeMaterialConnectionPoint;
  54768. /**
  54769. * Gets the right operand input component
  54770. */
  54771. readonly right: NodeMaterialConnectionPoint;
  54772. /**
  54773. * Gets the gradient operand input component
  54774. */
  54775. readonly gradient: NodeMaterialConnectionPoint;
  54776. /**
  54777. * Gets the output component
  54778. */
  54779. readonly output: NodeMaterialConnectionPoint;
  54780. protected _buildBlock(state: NodeMaterialBuildState): this;
  54781. }
  54782. }
  54783. declare module BABYLON {
  54784. /**
  54785. * Block used to divide 2 vectors
  54786. */
  54787. export class DivideBlock extends NodeMaterialBlock {
  54788. /**
  54789. * Creates a new DivideBlock
  54790. * @param name defines the block name
  54791. */
  54792. constructor(name: string);
  54793. /**
  54794. * Gets the current class name
  54795. * @returns the class name
  54796. */
  54797. getClassName(): string;
  54798. /**
  54799. * Gets the left operand input component
  54800. */
  54801. readonly left: NodeMaterialConnectionPoint;
  54802. /**
  54803. * Gets the right operand input component
  54804. */
  54805. readonly right: NodeMaterialConnectionPoint;
  54806. /**
  54807. * Gets the output component
  54808. */
  54809. readonly output: NodeMaterialConnectionPoint;
  54810. protected _buildBlock(state: NodeMaterialBuildState): this;
  54811. }
  54812. }
  54813. declare module BABYLON {
  54814. /**
  54815. * Block used to subtract 2 vectors
  54816. */
  54817. export class SubtractBlock extends NodeMaterialBlock {
  54818. /**
  54819. * Creates a new SubtractBlock
  54820. * @param name defines the block name
  54821. */
  54822. constructor(name: string);
  54823. /**
  54824. * Gets the current class name
  54825. * @returns the class name
  54826. */
  54827. getClassName(): string;
  54828. /**
  54829. * Gets the left operand input component
  54830. */
  54831. readonly left: NodeMaterialConnectionPoint;
  54832. /**
  54833. * Gets the right operand input component
  54834. */
  54835. readonly right: NodeMaterialConnectionPoint;
  54836. /**
  54837. * Gets the output component
  54838. */
  54839. readonly output: NodeMaterialConnectionPoint;
  54840. protected _buildBlock(state: NodeMaterialBuildState): this;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /**
  54845. * Block used to step a value
  54846. */
  54847. export class StepBlock extends NodeMaterialBlock {
  54848. /**
  54849. * Creates a new StepBlock
  54850. * @param name defines the block name
  54851. */
  54852. constructor(name: string);
  54853. /**
  54854. * Gets the current class name
  54855. * @returns the class name
  54856. */
  54857. getClassName(): string;
  54858. /**
  54859. * Gets the value operand input component
  54860. */
  54861. readonly value: NodeMaterialConnectionPoint;
  54862. /**
  54863. * Gets the edge operand input component
  54864. */
  54865. readonly edge: NodeMaterialConnectionPoint;
  54866. /**
  54867. * Gets the output component
  54868. */
  54869. readonly output: NodeMaterialConnectionPoint;
  54870. protected _buildBlock(state: NodeMaterialBuildState): this;
  54871. }
  54872. }
  54873. declare module BABYLON {
  54874. /**
  54875. * Block used to get the opposite (1 - x) of a value
  54876. */
  54877. export class OneMinusBlock extends NodeMaterialBlock {
  54878. /**
  54879. * Creates a new OneMinusBlock
  54880. * @param name defines the block name
  54881. */
  54882. constructor(name: string);
  54883. /**
  54884. * Gets the current class name
  54885. * @returns the class name
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Gets the input component
  54890. */
  54891. readonly input: NodeMaterialConnectionPoint;
  54892. /**
  54893. * Gets the output component
  54894. */
  54895. readonly output: NodeMaterialConnectionPoint;
  54896. protected _buildBlock(state: NodeMaterialBuildState): this;
  54897. }
  54898. }
  54899. declare module BABYLON {
  54900. /**
  54901. * Block used to get the view direction
  54902. */
  54903. export class ViewDirectionBlock extends NodeMaterialBlock {
  54904. /**
  54905. * Creates a new ViewDirectionBlock
  54906. * @param name defines the block name
  54907. */
  54908. constructor(name: string);
  54909. /**
  54910. * Gets the current class name
  54911. * @returns the class name
  54912. */
  54913. getClassName(): string;
  54914. /**
  54915. * Gets the world position component
  54916. */
  54917. readonly worldPosition: NodeMaterialConnectionPoint;
  54918. /**
  54919. * Gets the camera position component
  54920. */
  54921. readonly cameraPosition: NodeMaterialConnectionPoint;
  54922. /**
  54923. * Gets the output component
  54924. */
  54925. readonly output: NodeMaterialConnectionPoint;
  54926. autoConfigure(material: NodeMaterial): void;
  54927. protected _buildBlock(state: NodeMaterialBuildState): this;
  54928. }
  54929. }
  54930. declare module BABYLON {
  54931. /**
  54932. * Block used to compute fresnel value
  54933. */
  54934. export class FresnelBlock extends NodeMaterialBlock {
  54935. /**
  54936. * Create a new FresnelBlock
  54937. * @param name defines the block name
  54938. */
  54939. constructor(name: string);
  54940. /**
  54941. * Gets the current class name
  54942. * @returns the class name
  54943. */
  54944. getClassName(): string;
  54945. /**
  54946. * Gets the world normal input component
  54947. */
  54948. readonly worldNormal: NodeMaterialConnectionPoint;
  54949. /**
  54950. * Gets the view direction input component
  54951. */
  54952. readonly viewDirection: NodeMaterialConnectionPoint;
  54953. /**
  54954. * Gets the bias input component
  54955. */
  54956. readonly bias: NodeMaterialConnectionPoint;
  54957. /**
  54958. * Gets the camera (or eye) position component
  54959. */
  54960. readonly power: NodeMaterialConnectionPoint;
  54961. /**
  54962. * Gets the fresnel output component
  54963. */
  54964. readonly fresnel: NodeMaterialConnectionPoint;
  54965. autoConfigure(material: NodeMaterial): void;
  54966. protected _buildBlock(state: NodeMaterialBuildState): this;
  54967. }
  54968. }
  54969. declare module BABYLON {
  54970. /**
  54971. * Block used to get the max of 2 values
  54972. */
  54973. export class MaxBlock extends NodeMaterialBlock {
  54974. /**
  54975. * Creates a new MaxBlock
  54976. * @param name defines the block name
  54977. */
  54978. constructor(name: string);
  54979. /**
  54980. * Gets the current class name
  54981. * @returns the class name
  54982. */
  54983. getClassName(): string;
  54984. /**
  54985. * Gets the left operand input component
  54986. */
  54987. readonly left: NodeMaterialConnectionPoint;
  54988. /**
  54989. * Gets the right operand input component
  54990. */
  54991. readonly right: NodeMaterialConnectionPoint;
  54992. /**
  54993. * Gets the output component
  54994. */
  54995. readonly output: NodeMaterialConnectionPoint;
  54996. protected _buildBlock(state: NodeMaterialBuildState): this;
  54997. }
  54998. }
  54999. declare module BABYLON {
  55000. /**
  55001. * Block used to get the min of 2 values
  55002. */
  55003. export class MinBlock extends NodeMaterialBlock {
  55004. /**
  55005. * Creates a new MinBlock
  55006. * @param name defines the block name
  55007. */
  55008. constructor(name: string);
  55009. /**
  55010. * Gets the current class name
  55011. * @returns the class name
  55012. */
  55013. getClassName(): string;
  55014. /**
  55015. * Gets the left operand input component
  55016. */
  55017. readonly left: NodeMaterialConnectionPoint;
  55018. /**
  55019. * Gets the right operand input component
  55020. */
  55021. readonly right: NodeMaterialConnectionPoint;
  55022. /**
  55023. * Gets the output component
  55024. */
  55025. readonly output: NodeMaterialConnectionPoint;
  55026. protected _buildBlock(state: NodeMaterialBuildState): this;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * Block used to get the distance between 2 values
  55032. */
  55033. export class DistanceBlock extends NodeMaterialBlock {
  55034. /**
  55035. * Creates a new DistanceBlock
  55036. * @param name defines the block name
  55037. */
  55038. constructor(name: string);
  55039. /**
  55040. * Gets the current class name
  55041. * @returns the class name
  55042. */
  55043. getClassName(): string;
  55044. /**
  55045. * Gets the left operand input component
  55046. */
  55047. readonly left: NodeMaterialConnectionPoint;
  55048. /**
  55049. * Gets the right operand input component
  55050. */
  55051. readonly right: NodeMaterialConnectionPoint;
  55052. /**
  55053. * Gets the output component
  55054. */
  55055. readonly output: NodeMaterialConnectionPoint;
  55056. protected _buildBlock(state: NodeMaterialBuildState): this;
  55057. }
  55058. }
  55059. declare module BABYLON {
  55060. /**
  55061. * Block used to get the length of a vector
  55062. */
  55063. export class LengthBlock extends NodeMaterialBlock {
  55064. /**
  55065. * Creates a new LengthBlock
  55066. * @param name defines the block name
  55067. */
  55068. constructor(name: string);
  55069. /**
  55070. * Gets the current class name
  55071. * @returns the class name
  55072. */
  55073. getClassName(): string;
  55074. /**
  55075. * Gets the value input component
  55076. */
  55077. readonly value: NodeMaterialConnectionPoint;
  55078. /**
  55079. * Gets the output component
  55080. */
  55081. readonly output: NodeMaterialConnectionPoint;
  55082. protected _buildBlock(state: NodeMaterialBuildState): this;
  55083. }
  55084. }
  55085. declare module BABYLON {
  55086. /**
  55087. * Block used to get negative version of a value (i.e. x * -1)
  55088. */
  55089. export class NegateBlock extends NodeMaterialBlock {
  55090. /**
  55091. * Creates a new NegateBlock
  55092. * @param name defines the block name
  55093. */
  55094. constructor(name: string);
  55095. /**
  55096. * Gets the current class name
  55097. * @returns the class name
  55098. */
  55099. getClassName(): string;
  55100. /**
  55101. * Gets the value input component
  55102. */
  55103. readonly value: NodeMaterialConnectionPoint;
  55104. /**
  55105. * Gets the output component
  55106. */
  55107. readonly output: NodeMaterialConnectionPoint;
  55108. protected _buildBlock(state: NodeMaterialBuildState): this;
  55109. }
  55110. }
  55111. declare module BABYLON {
  55112. /**
  55113. * Block used to get the value of the first parameter raised to the power of the second
  55114. */
  55115. export class PowBlock extends NodeMaterialBlock {
  55116. /**
  55117. * Creates a new PowBlock
  55118. * @param name defines the block name
  55119. */
  55120. constructor(name: string);
  55121. /**
  55122. * Gets the current class name
  55123. * @returns the class name
  55124. */
  55125. getClassName(): string;
  55126. /**
  55127. * Gets the value operand input component
  55128. */
  55129. readonly value: NodeMaterialConnectionPoint;
  55130. /**
  55131. * Gets the power operand input component
  55132. */
  55133. readonly power: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the output component
  55136. */
  55137. readonly output: NodeMaterialConnectionPoint;
  55138. protected _buildBlock(state: NodeMaterialBuildState): this;
  55139. }
  55140. }
  55141. declare module BABYLON {
  55142. /**
  55143. * Block used to get a random number
  55144. */
  55145. export class RandomNumberBlock extends NodeMaterialBlock {
  55146. /**
  55147. * Creates a new RandomNumberBlock
  55148. * @param name defines the block name
  55149. */
  55150. constructor(name: string);
  55151. /**
  55152. * Gets the current class name
  55153. * @returns the class name
  55154. */
  55155. getClassName(): string;
  55156. /**
  55157. * Gets the seed input component
  55158. */
  55159. readonly seed: NodeMaterialConnectionPoint;
  55160. /**
  55161. * Gets the output component
  55162. */
  55163. readonly output: NodeMaterialConnectionPoint;
  55164. protected _buildBlock(state: NodeMaterialBuildState): this;
  55165. }
  55166. }
  55167. declare module BABYLON {
  55168. /**
  55169. * Block used to compute arc tangent of 2 values
  55170. */
  55171. export class ArcTan2Block extends NodeMaterialBlock {
  55172. /**
  55173. * Creates a new ArcTan2Block
  55174. * @param name defines the block name
  55175. */
  55176. constructor(name: string);
  55177. /**
  55178. * Gets the current class name
  55179. * @returns the class name
  55180. */
  55181. getClassName(): string;
  55182. /**
  55183. * Gets the x operand input component
  55184. */
  55185. readonly x: NodeMaterialConnectionPoint;
  55186. /**
  55187. * Gets the y operand input component
  55188. */
  55189. readonly y: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the output component
  55192. */
  55193. readonly output: NodeMaterialConnectionPoint;
  55194. protected _buildBlock(state: NodeMaterialBuildState): this;
  55195. }
  55196. }
  55197. declare module BABYLON {
  55198. /**
  55199. * Block used to smooth step a value
  55200. */
  55201. export class SmoothStepBlock extends NodeMaterialBlock {
  55202. /**
  55203. * Creates a new SmoothStepBlock
  55204. * @param name defines the block name
  55205. */
  55206. constructor(name: string);
  55207. /**
  55208. * Gets the current class name
  55209. * @returns the class name
  55210. */
  55211. getClassName(): string;
  55212. /**
  55213. * Gets the value operand input component
  55214. */
  55215. readonly value: NodeMaterialConnectionPoint;
  55216. /**
  55217. * Gets the first edge operand input component
  55218. */
  55219. readonly edge0: NodeMaterialConnectionPoint;
  55220. /**
  55221. * Gets the second edge operand input component
  55222. */
  55223. readonly edge1: NodeMaterialConnectionPoint;
  55224. /**
  55225. * Gets the output component
  55226. */
  55227. readonly output: NodeMaterialConnectionPoint;
  55228. protected _buildBlock(state: NodeMaterialBuildState): this;
  55229. }
  55230. }
  55231. declare module BABYLON {
  55232. /**
  55233. * Block used to get the reciprocal (1 / x) of a value
  55234. */
  55235. export class ReciprocalBlock extends NodeMaterialBlock {
  55236. /**
  55237. * Creates a new ReciprocalBlock
  55238. * @param name defines the block name
  55239. */
  55240. constructor(name: string);
  55241. /**
  55242. * Gets the current class name
  55243. * @returns the class name
  55244. */
  55245. getClassName(): string;
  55246. /**
  55247. * Gets the input component
  55248. */
  55249. readonly input: NodeMaterialConnectionPoint;
  55250. /**
  55251. * Gets the output component
  55252. */
  55253. readonly output: NodeMaterialConnectionPoint;
  55254. protected _buildBlock(state: NodeMaterialBuildState): this;
  55255. }
  55256. }
  55257. declare module BABYLON {
  55258. /**
  55259. * Block used to replace a color by another one
  55260. */
  55261. export class ReplaceColorBlock extends NodeMaterialBlock {
  55262. /**
  55263. * Creates a new ReplaceColorBlock
  55264. * @param name defines the block name
  55265. */
  55266. constructor(name: string);
  55267. /**
  55268. * Gets the current class name
  55269. * @returns the class name
  55270. */
  55271. getClassName(): string;
  55272. /**
  55273. * Gets the value input component
  55274. */
  55275. readonly value: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the reference input component
  55278. */
  55279. readonly reference: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the distance input component
  55282. */
  55283. readonly distance: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the replacement input component
  55286. */
  55287. readonly replacement: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the output component
  55290. */
  55291. readonly output: NodeMaterialConnectionPoint;
  55292. protected _buildBlock(state: NodeMaterialBuildState): this;
  55293. }
  55294. }
  55295. declare module BABYLON {
  55296. /**
  55297. * Block used to posterize a value
  55298. * @see https://en.wikipedia.org/wiki/Posterization
  55299. */
  55300. export class PosterizeBlock extends NodeMaterialBlock {
  55301. /**
  55302. * Creates a new PosterizeBlock
  55303. * @param name defines the block name
  55304. */
  55305. constructor(name: string);
  55306. /**
  55307. * Gets the current class name
  55308. * @returns the class name
  55309. */
  55310. getClassName(): string;
  55311. /**
  55312. * Gets the value input component
  55313. */
  55314. readonly value: NodeMaterialConnectionPoint;
  55315. /**
  55316. * Gets the steps input component
  55317. */
  55318. readonly steps: NodeMaterialConnectionPoint;
  55319. /**
  55320. * Gets the output component
  55321. */
  55322. readonly output: NodeMaterialConnectionPoint;
  55323. protected _buildBlock(state: NodeMaterialBuildState): this;
  55324. }
  55325. }
  55326. declare module BABYLON {
  55327. /**
  55328. * Operations supported by the Wave block
  55329. */
  55330. export enum WaveBlockKind {
  55331. /** SawTooth */
  55332. SawTooth = 0,
  55333. /** Square */
  55334. Square = 1,
  55335. /** Triangle */
  55336. Triangle = 2
  55337. }
  55338. /**
  55339. * Block used to apply wave operation to floats
  55340. */
  55341. export class WaveBlock extends NodeMaterialBlock {
  55342. /**
  55343. * Gets or sets the kibnd of wave to be applied by the block
  55344. */
  55345. kind: WaveBlockKind;
  55346. /**
  55347. * Creates a new WaveBlock
  55348. * @param name defines the block name
  55349. */
  55350. constructor(name: string);
  55351. /**
  55352. * Gets the current class name
  55353. * @returns the class name
  55354. */
  55355. getClassName(): string;
  55356. /**
  55357. * Gets the input component
  55358. */
  55359. readonly input: NodeMaterialConnectionPoint;
  55360. /**
  55361. * Gets the output component
  55362. */
  55363. readonly output: NodeMaterialConnectionPoint;
  55364. protected _buildBlock(state: NodeMaterialBuildState): this;
  55365. serialize(): any;
  55366. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55367. }
  55368. }
  55369. declare module BABYLON {
  55370. /**
  55371. * Class used to store a color step for the GradientBlock
  55372. */
  55373. export class GradientBlockColorStep {
  55374. /**
  55375. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55376. */
  55377. step: number;
  55378. /**
  55379. * Gets or sets the color associated with this step
  55380. */
  55381. color: Color3;
  55382. /**
  55383. * Creates a new GradientBlockColorStep
  55384. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55385. * @param color defines the color associated with this step
  55386. */
  55387. constructor(
  55388. /**
  55389. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55390. */
  55391. step: number,
  55392. /**
  55393. * Gets or sets the color associated with this step
  55394. */
  55395. color: Color3);
  55396. }
  55397. /**
  55398. * Block used to return a color from a gradient based on an input value between 0 and 1
  55399. */
  55400. export class GradientBlock extends NodeMaterialBlock {
  55401. /**
  55402. * Gets or sets the list of color steps
  55403. */
  55404. colorSteps: GradientBlockColorStep[];
  55405. /**
  55406. * Creates a new GradientBlock
  55407. * @param name defines the block name
  55408. */
  55409. constructor(name: string);
  55410. /**
  55411. * Gets the current class name
  55412. * @returns the class name
  55413. */
  55414. getClassName(): string;
  55415. /**
  55416. * Gets the gradient input component
  55417. */
  55418. readonly gradient: NodeMaterialConnectionPoint;
  55419. /**
  55420. * Gets the output component
  55421. */
  55422. readonly output: NodeMaterialConnectionPoint;
  55423. private _writeColorConstant;
  55424. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55425. serialize(): any;
  55426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55427. protected _dumpPropertiesCode(): string;
  55428. }
  55429. }
  55430. declare module BABYLON {
  55431. /**
  55432. * Effect Render Options
  55433. */
  55434. export interface IEffectRendererOptions {
  55435. /**
  55436. * Defines the vertices positions.
  55437. */
  55438. positions?: number[];
  55439. /**
  55440. * Defines the indices.
  55441. */
  55442. indices?: number[];
  55443. }
  55444. /**
  55445. * Helper class to render one or more effects
  55446. */
  55447. export class EffectRenderer {
  55448. private engine;
  55449. private static _DefaultOptions;
  55450. private _vertexBuffers;
  55451. private _indexBuffer;
  55452. private _ringBufferIndex;
  55453. private _ringScreenBuffer;
  55454. private _fullscreenViewport;
  55455. private _getNextFrameBuffer;
  55456. /**
  55457. * Creates an effect renderer
  55458. * @param engine the engine to use for rendering
  55459. * @param options defines the options of the effect renderer
  55460. */
  55461. constructor(engine: Engine, options?: IEffectRendererOptions);
  55462. /**
  55463. * Sets the current viewport in normalized coordinates 0-1
  55464. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55465. */
  55466. setViewport(viewport?: Viewport): void;
  55467. /**
  55468. * Binds the embedded attributes buffer to the effect.
  55469. * @param effect Defines the effect to bind the attributes for
  55470. */
  55471. bindBuffers(effect: Effect): void;
  55472. /**
  55473. * Sets the current effect wrapper to use during draw.
  55474. * The effect needs to be ready before calling this api.
  55475. * This also sets the default full screen position attribute.
  55476. * @param effectWrapper Defines the effect to draw with
  55477. */
  55478. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55479. /**
  55480. * Draws a full screen quad.
  55481. */
  55482. draw(): void;
  55483. /**
  55484. * renders one or more effects to a specified texture
  55485. * @param effectWrappers list of effects to renderer
  55486. * @param outputTexture texture to draw to, if null it will render to the screen
  55487. */
  55488. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55489. /**
  55490. * Disposes of the effect renderer
  55491. */
  55492. dispose(): void;
  55493. }
  55494. /**
  55495. * Options to create an EffectWrapper
  55496. */
  55497. interface EffectWrapperCreationOptions {
  55498. /**
  55499. * Engine to use to create the effect
  55500. */
  55501. engine: Engine;
  55502. /**
  55503. * Fragment shader for the effect
  55504. */
  55505. fragmentShader: string;
  55506. /**
  55507. * Vertex shader for the effect
  55508. */
  55509. vertexShader?: string;
  55510. /**
  55511. * Attributes to use in the shader
  55512. */
  55513. attributeNames?: Array<string>;
  55514. /**
  55515. * Uniforms to use in the shader
  55516. */
  55517. uniformNames?: Array<string>;
  55518. /**
  55519. * Texture sampler names to use in the shader
  55520. */
  55521. samplerNames?: Array<string>;
  55522. /**
  55523. * The friendly name of the effect displayed in Spector.
  55524. */
  55525. name?: string;
  55526. }
  55527. /**
  55528. * Wraps an effect to be used for rendering
  55529. */
  55530. export class EffectWrapper {
  55531. /**
  55532. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55533. */
  55534. onApplyObservable: Observable<{}>;
  55535. /**
  55536. * The underlying effect
  55537. */
  55538. effect: Effect;
  55539. /**
  55540. * Creates an effect to be renderer
  55541. * @param creationOptions options to create the effect
  55542. */
  55543. constructor(creationOptions: EffectWrapperCreationOptions);
  55544. /**
  55545. * Disposes of the effect wrapper
  55546. */
  55547. dispose(): void;
  55548. }
  55549. }
  55550. declare module BABYLON {
  55551. /**
  55552. * Helper class to push actions to a pool of workers.
  55553. */
  55554. export class WorkerPool implements IDisposable {
  55555. private _workerInfos;
  55556. private _pendingActions;
  55557. /**
  55558. * Constructor
  55559. * @param workers Array of workers to use for actions
  55560. */
  55561. constructor(workers: Array<Worker>);
  55562. /**
  55563. * Terminates all workers and clears any pending actions.
  55564. */
  55565. dispose(): void;
  55566. /**
  55567. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55568. * pended until a worker has completed its action.
  55569. * @param action The action to perform. Call onComplete when the action is complete.
  55570. */
  55571. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55572. private _execute;
  55573. }
  55574. }
  55575. declare module BABYLON {
  55576. /**
  55577. * Configuration for Draco compression
  55578. */
  55579. export interface IDracoCompressionConfiguration {
  55580. /**
  55581. * Configuration for the decoder.
  55582. */
  55583. decoder: {
  55584. /**
  55585. * The url to the WebAssembly module.
  55586. */
  55587. wasmUrl?: string;
  55588. /**
  55589. * The url to the WebAssembly binary.
  55590. */
  55591. wasmBinaryUrl?: string;
  55592. /**
  55593. * The url to the fallback JavaScript module.
  55594. */
  55595. fallbackUrl?: string;
  55596. };
  55597. }
  55598. /**
  55599. * Draco compression (https://google.github.io/draco/)
  55600. *
  55601. * This class wraps the Draco module.
  55602. *
  55603. * **Encoder**
  55604. *
  55605. * The encoder is not currently implemented.
  55606. *
  55607. * **Decoder**
  55608. *
  55609. * 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.
  55610. *
  55611. * To update the configuration, use the following code:
  55612. * ```javascript
  55613. * DracoCompression.Configuration = {
  55614. * decoder: {
  55615. * wasmUrl: "<url to the WebAssembly library>",
  55616. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55617. * fallbackUrl: "<url to the fallback JavaScript library>",
  55618. * }
  55619. * };
  55620. * ```
  55621. *
  55622. * 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.
  55623. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55624. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55625. *
  55626. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55627. * ```javascript
  55628. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55629. * ```
  55630. *
  55631. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55632. */
  55633. export class DracoCompression implements IDisposable {
  55634. private _workerPoolPromise?;
  55635. private _decoderModulePromise?;
  55636. /**
  55637. * The configuration. Defaults to the following urls:
  55638. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55639. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55640. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55641. */
  55642. static Configuration: IDracoCompressionConfiguration;
  55643. /**
  55644. * Returns true if the decoder configuration is available.
  55645. */
  55646. static readonly DecoderAvailable: boolean;
  55647. /**
  55648. * Default number of workers to create when creating the draco compression object.
  55649. */
  55650. static DefaultNumWorkers: number;
  55651. private static GetDefaultNumWorkers;
  55652. private static _Default;
  55653. /**
  55654. * Default instance for the draco compression object.
  55655. */
  55656. static readonly Default: DracoCompression;
  55657. /**
  55658. * Constructor
  55659. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55660. */
  55661. constructor(numWorkers?: number);
  55662. /**
  55663. * Stop all async operations and release resources.
  55664. */
  55665. dispose(): void;
  55666. /**
  55667. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55668. * @returns a promise that resolves when ready
  55669. */
  55670. whenReadyAsync(): Promise<void>;
  55671. /**
  55672. * Decode Draco compressed mesh data to vertex data.
  55673. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55674. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55675. * @returns A promise that resolves with the decoded vertex data
  55676. */
  55677. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55678. [kind: string]: number;
  55679. }): Promise<VertexData>;
  55680. }
  55681. }
  55682. declare module BABYLON {
  55683. /**
  55684. * Class for building Constructive Solid Geometry
  55685. */
  55686. export class CSG {
  55687. private polygons;
  55688. /**
  55689. * The world matrix
  55690. */
  55691. matrix: Matrix;
  55692. /**
  55693. * Stores the position
  55694. */
  55695. position: Vector3;
  55696. /**
  55697. * Stores the rotation
  55698. */
  55699. rotation: Vector3;
  55700. /**
  55701. * Stores the rotation quaternion
  55702. */
  55703. rotationQuaternion: Nullable<Quaternion>;
  55704. /**
  55705. * Stores the scaling vector
  55706. */
  55707. scaling: Vector3;
  55708. /**
  55709. * Convert the Mesh to CSG
  55710. * @param mesh The Mesh to convert to CSG
  55711. * @returns A new CSG from the Mesh
  55712. */
  55713. static FromMesh(mesh: Mesh): CSG;
  55714. /**
  55715. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55716. * @param polygons Polygons used to construct a CSG solid
  55717. */
  55718. private static FromPolygons;
  55719. /**
  55720. * Clones, or makes a deep copy, of the CSG
  55721. * @returns A new CSG
  55722. */
  55723. clone(): CSG;
  55724. /**
  55725. * Unions this CSG with another CSG
  55726. * @param csg The CSG to union against this CSG
  55727. * @returns The unioned CSG
  55728. */
  55729. union(csg: CSG): CSG;
  55730. /**
  55731. * Unions this CSG with another CSG in place
  55732. * @param csg The CSG to union against this CSG
  55733. */
  55734. unionInPlace(csg: CSG): void;
  55735. /**
  55736. * Subtracts this CSG with another CSG
  55737. * @param csg The CSG to subtract against this CSG
  55738. * @returns A new CSG
  55739. */
  55740. subtract(csg: CSG): CSG;
  55741. /**
  55742. * Subtracts this CSG with another CSG in place
  55743. * @param csg The CSG to subtact against this CSG
  55744. */
  55745. subtractInPlace(csg: CSG): void;
  55746. /**
  55747. * Intersect this CSG with another CSG
  55748. * @param csg The CSG to intersect against this CSG
  55749. * @returns A new CSG
  55750. */
  55751. intersect(csg: CSG): CSG;
  55752. /**
  55753. * Intersects this CSG with another CSG in place
  55754. * @param csg The CSG to intersect against this CSG
  55755. */
  55756. intersectInPlace(csg: CSG): void;
  55757. /**
  55758. * Return a new CSG solid with solid and empty space switched. This solid is
  55759. * not modified.
  55760. * @returns A new CSG solid with solid and empty space switched
  55761. */
  55762. inverse(): CSG;
  55763. /**
  55764. * Inverses the CSG in place
  55765. */
  55766. inverseInPlace(): void;
  55767. /**
  55768. * This is used to keep meshes transformations so they can be restored
  55769. * when we build back a Babylon Mesh
  55770. * NB : All CSG operations are performed in world coordinates
  55771. * @param csg The CSG to copy the transform attributes from
  55772. * @returns This CSG
  55773. */
  55774. copyTransformAttributes(csg: CSG): CSG;
  55775. /**
  55776. * Build Raw mesh from CSG
  55777. * Coordinates here are in world space
  55778. * @param name The name of the mesh geometry
  55779. * @param scene The Scene
  55780. * @param keepSubMeshes Specifies if the submeshes should be kept
  55781. * @returns A new Mesh
  55782. */
  55783. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55784. /**
  55785. * Build Mesh from CSG taking material and transforms into account
  55786. * @param name The name of the Mesh
  55787. * @param material The material of the Mesh
  55788. * @param scene The Scene
  55789. * @param keepSubMeshes Specifies if submeshes should be kept
  55790. * @returns The new Mesh
  55791. */
  55792. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55793. }
  55794. }
  55795. declare module BABYLON {
  55796. /**
  55797. * Class used to create a trail following a mesh
  55798. */
  55799. export class TrailMesh extends Mesh {
  55800. private _generator;
  55801. private _autoStart;
  55802. private _running;
  55803. private _diameter;
  55804. private _length;
  55805. private _sectionPolygonPointsCount;
  55806. private _sectionVectors;
  55807. private _sectionNormalVectors;
  55808. private _beforeRenderObserver;
  55809. /**
  55810. * @constructor
  55811. * @param name The value used by scene.getMeshByName() to do a lookup.
  55812. * @param generator The mesh to generate a trail.
  55813. * @param scene The scene to add this mesh to.
  55814. * @param diameter Diameter of trailing mesh. Default is 1.
  55815. * @param length Length of trailing mesh. Default is 60.
  55816. * @param autoStart Automatically start trailing mesh. Default true.
  55817. */
  55818. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55819. /**
  55820. * "TrailMesh"
  55821. * @returns "TrailMesh"
  55822. */
  55823. getClassName(): string;
  55824. private _createMesh;
  55825. /**
  55826. * Start trailing mesh.
  55827. */
  55828. start(): void;
  55829. /**
  55830. * Stop trailing mesh.
  55831. */
  55832. stop(): void;
  55833. /**
  55834. * Update trailing mesh geometry.
  55835. */
  55836. update(): void;
  55837. /**
  55838. * Returns a new TrailMesh object.
  55839. * @param name is a string, the name given to the new mesh
  55840. * @param newGenerator use new generator object for cloned trail mesh
  55841. * @returns a new mesh
  55842. */
  55843. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55844. /**
  55845. * Serializes this trail mesh
  55846. * @param serializationObject object to write serialization to
  55847. */
  55848. serialize(serializationObject: any): void;
  55849. /**
  55850. * Parses a serialized trail mesh
  55851. * @param parsedMesh the serialized mesh
  55852. * @param scene the scene to create the trail mesh in
  55853. * @returns the created trail mesh
  55854. */
  55855. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55856. }
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * Class containing static functions to help procedurally build meshes
  55861. */
  55862. export class TiledBoxBuilder {
  55863. /**
  55864. * Creates a box mesh
  55865. * 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)
  55866. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55868. * * 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
  55869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55870. * @param name defines the name of the mesh
  55871. * @param options defines the options used to create the mesh
  55872. * @param scene defines the hosting scene
  55873. * @returns the box mesh
  55874. */
  55875. static CreateTiledBox(name: string, options: {
  55876. pattern?: number;
  55877. width?: number;
  55878. height?: number;
  55879. depth?: number;
  55880. tileSize?: number;
  55881. tileWidth?: number;
  55882. tileHeight?: number;
  55883. alignHorizontal?: number;
  55884. alignVertical?: number;
  55885. faceUV?: Vector4[];
  55886. faceColors?: Color4[];
  55887. sideOrientation?: number;
  55888. updatable?: boolean;
  55889. }, scene?: Nullable<Scene>): Mesh;
  55890. }
  55891. }
  55892. declare module BABYLON {
  55893. /**
  55894. * Class containing static functions to help procedurally build meshes
  55895. */
  55896. export class TorusKnotBuilder {
  55897. /**
  55898. * Creates a torus knot mesh
  55899. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55900. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55901. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55902. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55904. * * 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
  55905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55906. * @param name defines the name of the mesh
  55907. * @param options defines the options used to create the mesh
  55908. * @param scene defines the hosting scene
  55909. * @returns the torus knot mesh
  55910. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55911. */
  55912. static CreateTorusKnot(name: string, options: {
  55913. radius?: number;
  55914. tube?: number;
  55915. radialSegments?: number;
  55916. tubularSegments?: number;
  55917. p?: number;
  55918. q?: number;
  55919. updatable?: boolean;
  55920. sideOrientation?: number;
  55921. frontUVs?: Vector4;
  55922. backUVs?: Vector4;
  55923. }, scene: any): Mesh;
  55924. }
  55925. }
  55926. declare module BABYLON {
  55927. /**
  55928. * Polygon
  55929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55930. */
  55931. export class Polygon {
  55932. /**
  55933. * Creates a rectangle
  55934. * @param xmin bottom X coord
  55935. * @param ymin bottom Y coord
  55936. * @param xmax top X coord
  55937. * @param ymax top Y coord
  55938. * @returns points that make the resulting rectation
  55939. */
  55940. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55941. /**
  55942. * Creates a circle
  55943. * @param radius radius of circle
  55944. * @param cx scale in x
  55945. * @param cy scale in y
  55946. * @param numberOfSides number of sides that make up the circle
  55947. * @returns points that make the resulting circle
  55948. */
  55949. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55950. /**
  55951. * Creates a polygon from input string
  55952. * @param input Input polygon data
  55953. * @returns the parsed points
  55954. */
  55955. static Parse(input: string): Vector2[];
  55956. /**
  55957. * Starts building a polygon from x and y coordinates
  55958. * @param x x coordinate
  55959. * @param y y coordinate
  55960. * @returns the started path2
  55961. */
  55962. static StartingAt(x: number, y: number): Path2;
  55963. }
  55964. /**
  55965. * Builds a polygon
  55966. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55967. */
  55968. export class PolygonMeshBuilder {
  55969. private _points;
  55970. private _outlinepoints;
  55971. private _holes;
  55972. private _name;
  55973. private _scene;
  55974. private _epoints;
  55975. private _eholes;
  55976. private _addToepoint;
  55977. /**
  55978. * Babylon reference to the earcut plugin.
  55979. */
  55980. bjsEarcut: any;
  55981. /**
  55982. * Creates a PolygonMeshBuilder
  55983. * @param name name of the builder
  55984. * @param contours Path of the polygon
  55985. * @param scene scene to add to when creating the mesh
  55986. * @param earcutInjection can be used to inject your own earcut reference
  55987. */
  55988. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55989. /**
  55990. * Adds a whole within the polygon
  55991. * @param hole Array of points defining the hole
  55992. * @returns this
  55993. */
  55994. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55995. /**
  55996. * Creates the polygon
  55997. * @param updatable If the mesh should be updatable
  55998. * @param depth The depth of the mesh created
  55999. * @returns the created mesh
  56000. */
  56001. build(updatable?: boolean, depth?: number): Mesh;
  56002. /**
  56003. * Creates the polygon
  56004. * @param depth The depth of the mesh created
  56005. * @returns the created VertexData
  56006. */
  56007. buildVertexData(depth?: number): VertexData;
  56008. /**
  56009. * Adds a side to the polygon
  56010. * @param positions points that make the polygon
  56011. * @param normals normals of the polygon
  56012. * @param uvs uvs of the polygon
  56013. * @param indices indices of the polygon
  56014. * @param bounds bounds of the polygon
  56015. * @param points points of the polygon
  56016. * @param depth depth of the polygon
  56017. * @param flip flip of the polygon
  56018. */
  56019. private addSide;
  56020. }
  56021. }
  56022. declare module BABYLON {
  56023. /**
  56024. * Class containing static functions to help procedurally build meshes
  56025. */
  56026. export class PolygonBuilder {
  56027. /**
  56028. * Creates a polygon mesh
  56029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56030. * * 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
  56031. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56033. * * 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)
  56034. * * Remember you can only change the shape positions, not their number when updating a polygon
  56035. * @param name defines the name of the mesh
  56036. * @param options defines the options used to create the mesh
  56037. * @param scene defines the hosting scene
  56038. * @param earcutInjection can be used to inject your own earcut reference
  56039. * @returns the polygon mesh
  56040. */
  56041. static CreatePolygon(name: string, options: {
  56042. shape: Vector3[];
  56043. holes?: Vector3[][];
  56044. depth?: number;
  56045. faceUV?: Vector4[];
  56046. faceColors?: Color4[];
  56047. updatable?: boolean;
  56048. sideOrientation?: number;
  56049. frontUVs?: Vector4;
  56050. backUVs?: Vector4;
  56051. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56052. /**
  56053. * Creates an extruded polygon mesh, with depth in the Y direction.
  56054. * * 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)
  56055. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56056. * @param name defines the name of the mesh
  56057. * @param options defines the options used to create the mesh
  56058. * @param scene defines the hosting scene
  56059. * @param earcutInjection can be used to inject your own earcut reference
  56060. * @returns the polygon mesh
  56061. */
  56062. static ExtrudePolygon(name: string, options: {
  56063. shape: Vector3[];
  56064. holes?: Vector3[][];
  56065. depth?: number;
  56066. faceUV?: Vector4[];
  56067. faceColors?: Color4[];
  56068. updatable?: boolean;
  56069. sideOrientation?: number;
  56070. frontUVs?: Vector4;
  56071. backUVs?: Vector4;
  56072. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56073. }
  56074. }
  56075. declare module BABYLON {
  56076. /**
  56077. * Class containing static functions to help procedurally build meshes
  56078. */
  56079. export class LatheBuilder {
  56080. /**
  56081. * Creates lathe mesh.
  56082. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56083. * * 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
  56084. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56085. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56086. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56087. * * 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
  56088. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56089. * * 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
  56090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56091. * * 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
  56092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56094. * @param name defines the name of the mesh
  56095. * @param options defines the options used to create the mesh
  56096. * @param scene defines the hosting scene
  56097. * @returns the lathe mesh
  56098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56099. */
  56100. static CreateLathe(name: string, options: {
  56101. shape: Vector3[];
  56102. radius?: number;
  56103. tessellation?: number;
  56104. clip?: number;
  56105. arc?: number;
  56106. closed?: boolean;
  56107. updatable?: boolean;
  56108. sideOrientation?: number;
  56109. frontUVs?: Vector4;
  56110. backUVs?: Vector4;
  56111. cap?: number;
  56112. invertUV?: boolean;
  56113. }, scene?: Nullable<Scene>): Mesh;
  56114. }
  56115. }
  56116. declare module BABYLON {
  56117. /**
  56118. * Class containing static functions to help procedurally build meshes
  56119. */
  56120. export class TiledPlaneBuilder {
  56121. /**
  56122. * Creates a tiled plane mesh
  56123. * * The parameter `pattern` will, depending on value, do nothing or
  56124. * * * flip (reflect about central vertical) alternate tiles across and up
  56125. * * * flip every tile on alternate rows
  56126. * * * rotate (180 degs) alternate tiles across and up
  56127. * * * rotate every tile on alternate rows
  56128. * * * flip and rotate alternate tiles across and up
  56129. * * * flip and rotate every tile on alternate rows
  56130. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56131. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56132. * * 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
  56133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56134. * * 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)
  56135. * * 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)
  56136. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56137. * @param name defines the name of the mesh
  56138. * @param options defines the options used to create the mesh
  56139. * @param scene defines the hosting scene
  56140. * @returns the box mesh
  56141. */
  56142. static CreateTiledPlane(name: string, options: {
  56143. pattern?: number;
  56144. tileSize?: number;
  56145. tileWidth?: number;
  56146. tileHeight?: number;
  56147. size?: number;
  56148. width?: number;
  56149. height?: number;
  56150. alignHorizontal?: number;
  56151. alignVertical?: number;
  56152. sideOrientation?: number;
  56153. frontUVs?: Vector4;
  56154. backUVs?: Vector4;
  56155. updatable?: boolean;
  56156. }, scene?: Nullable<Scene>): Mesh;
  56157. }
  56158. }
  56159. declare module BABYLON {
  56160. /**
  56161. * Class containing static functions to help procedurally build meshes
  56162. */
  56163. export class TubeBuilder {
  56164. /**
  56165. * Creates a tube mesh.
  56166. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56167. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56168. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56169. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56170. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56171. * * 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)
  56172. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56173. * * 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
  56174. * * 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
  56175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56176. * * 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
  56177. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56179. * @param name defines the name of the mesh
  56180. * @param options defines the options used to create the mesh
  56181. * @param scene defines the hosting scene
  56182. * @returns the tube mesh
  56183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56184. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56185. */
  56186. static CreateTube(name: string, options: {
  56187. path: Vector3[];
  56188. radius?: number;
  56189. tessellation?: number;
  56190. radiusFunction?: {
  56191. (i: number, distance: number): number;
  56192. };
  56193. cap?: number;
  56194. arc?: number;
  56195. updatable?: boolean;
  56196. sideOrientation?: number;
  56197. frontUVs?: Vector4;
  56198. backUVs?: Vector4;
  56199. instance?: Mesh;
  56200. invertUV?: boolean;
  56201. }, scene?: Nullable<Scene>): Mesh;
  56202. }
  56203. }
  56204. declare module BABYLON {
  56205. /**
  56206. * Class containing static functions to help procedurally build meshes
  56207. */
  56208. export class IcoSphereBuilder {
  56209. /**
  56210. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56211. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56212. * * 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`)
  56213. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56214. * * 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
  56215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56216. * * 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
  56217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56218. * @param name defines the name of the mesh
  56219. * @param options defines the options used to create the mesh
  56220. * @param scene defines the hosting scene
  56221. * @returns the icosahedron mesh
  56222. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56223. */
  56224. static CreateIcoSphere(name: string, options: {
  56225. radius?: number;
  56226. radiusX?: number;
  56227. radiusY?: number;
  56228. radiusZ?: number;
  56229. flat?: boolean;
  56230. subdivisions?: number;
  56231. sideOrientation?: number;
  56232. frontUVs?: Vector4;
  56233. backUVs?: Vector4;
  56234. updatable?: boolean;
  56235. }, scene?: Nullable<Scene>): Mesh;
  56236. }
  56237. }
  56238. declare module BABYLON {
  56239. /**
  56240. * Class containing static functions to help procedurally build meshes
  56241. */
  56242. export class DecalBuilder {
  56243. /**
  56244. * Creates a decal mesh.
  56245. * 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
  56246. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56247. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56248. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56249. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56250. * @param name defines the name of the mesh
  56251. * @param sourceMesh defines the mesh where the decal must be applied
  56252. * @param options defines the options used to create the mesh
  56253. * @param scene defines the hosting scene
  56254. * @returns the decal mesh
  56255. * @see https://doc.babylonjs.com/how_to/decals
  56256. */
  56257. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56258. position?: Vector3;
  56259. normal?: Vector3;
  56260. size?: Vector3;
  56261. angle?: number;
  56262. }): Mesh;
  56263. }
  56264. }
  56265. declare module BABYLON {
  56266. /**
  56267. * Class containing static functions to help procedurally build meshes
  56268. */
  56269. export class MeshBuilder {
  56270. /**
  56271. * Creates a box mesh
  56272. * * The parameter `size` sets the size (float) of each box side (default 1)
  56273. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56274. * * 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)
  56275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56277. * * 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
  56278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56279. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56280. * @param name defines the name of the mesh
  56281. * @param options defines the options used to create the mesh
  56282. * @param scene defines the hosting scene
  56283. * @returns the box mesh
  56284. */
  56285. static CreateBox(name: string, options: {
  56286. size?: number;
  56287. width?: number;
  56288. height?: number;
  56289. depth?: number;
  56290. faceUV?: Vector4[];
  56291. faceColors?: Color4[];
  56292. sideOrientation?: number;
  56293. frontUVs?: Vector4;
  56294. backUVs?: Vector4;
  56295. updatable?: boolean;
  56296. }, scene?: Nullable<Scene>): Mesh;
  56297. /**
  56298. * Creates a tiled box mesh
  56299. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56301. * @param name defines the name of the mesh
  56302. * @param options defines the options used to create the mesh
  56303. * @param scene defines the hosting scene
  56304. * @returns the tiled box mesh
  56305. */
  56306. static CreateTiledBox(name: string, options: {
  56307. pattern?: number;
  56308. size?: number;
  56309. width?: number;
  56310. height?: number;
  56311. depth: number;
  56312. tileSize?: number;
  56313. tileWidth?: number;
  56314. tileHeight?: number;
  56315. faceUV?: Vector4[];
  56316. faceColors?: Color4[];
  56317. alignHorizontal?: number;
  56318. alignVertical?: number;
  56319. sideOrientation?: number;
  56320. updatable?: boolean;
  56321. }, scene?: Nullable<Scene>): Mesh;
  56322. /**
  56323. * Creates a sphere mesh
  56324. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56325. * * 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`)
  56326. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56327. * * 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
  56328. * * 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)
  56329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56330. * * 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
  56331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56332. * @param name defines the name of the mesh
  56333. * @param options defines the options used to create the mesh
  56334. * @param scene defines the hosting scene
  56335. * @returns the sphere mesh
  56336. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56337. */
  56338. static CreateSphere(name: string, options: {
  56339. segments?: number;
  56340. diameter?: number;
  56341. diameterX?: number;
  56342. diameterY?: number;
  56343. diameterZ?: number;
  56344. arc?: number;
  56345. slice?: number;
  56346. sideOrientation?: number;
  56347. frontUVs?: Vector4;
  56348. backUVs?: Vector4;
  56349. updatable?: boolean;
  56350. }, scene?: Nullable<Scene>): Mesh;
  56351. /**
  56352. * Creates a plane polygonal mesh. By default, this is a disc
  56353. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56354. * * 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
  56355. * * 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
  56356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56357. * * 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
  56358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56359. * @param name defines the name of the mesh
  56360. * @param options defines the options used to create the mesh
  56361. * @param scene defines the hosting scene
  56362. * @returns the plane polygonal mesh
  56363. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56364. */
  56365. static CreateDisc(name: string, options: {
  56366. radius?: number;
  56367. tessellation?: number;
  56368. arc?: number;
  56369. updatable?: boolean;
  56370. sideOrientation?: number;
  56371. frontUVs?: Vector4;
  56372. backUVs?: Vector4;
  56373. }, scene?: Nullable<Scene>): Mesh;
  56374. /**
  56375. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56376. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56377. * * 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`)
  56378. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56379. * * 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
  56380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56381. * * 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
  56382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56383. * @param name defines the name of the mesh
  56384. * @param options defines the options used to create the mesh
  56385. * @param scene defines the hosting scene
  56386. * @returns the icosahedron mesh
  56387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56388. */
  56389. static CreateIcoSphere(name: string, options: {
  56390. radius?: number;
  56391. radiusX?: number;
  56392. radiusY?: number;
  56393. radiusZ?: number;
  56394. flat?: boolean;
  56395. subdivisions?: number;
  56396. sideOrientation?: number;
  56397. frontUVs?: Vector4;
  56398. backUVs?: Vector4;
  56399. updatable?: boolean;
  56400. }, scene?: Nullable<Scene>): Mesh;
  56401. /**
  56402. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56403. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56404. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56405. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56406. * * 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
  56407. * * 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
  56408. * * 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
  56409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56410. * * 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
  56411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56412. * * 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
  56413. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56414. * * 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
  56415. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56417. * @param name defines the name of the mesh
  56418. * @param options defines the options used to create the mesh
  56419. * @param scene defines the hosting scene
  56420. * @returns the ribbon mesh
  56421. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56423. */
  56424. static CreateRibbon(name: string, options: {
  56425. pathArray: Vector3[][];
  56426. closeArray?: boolean;
  56427. closePath?: boolean;
  56428. offset?: number;
  56429. updatable?: boolean;
  56430. sideOrientation?: number;
  56431. frontUVs?: Vector4;
  56432. backUVs?: Vector4;
  56433. instance?: Mesh;
  56434. invertUV?: boolean;
  56435. uvs?: Vector2[];
  56436. colors?: Color4[];
  56437. }, scene?: Nullable<Scene>): Mesh;
  56438. /**
  56439. * Creates a cylinder or a cone mesh
  56440. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56441. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56442. * * 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.
  56443. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56444. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56445. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56446. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56447. * * 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).
  56448. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56449. * * 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).
  56450. * * 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
  56451. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56452. * * 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
  56453. * * 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.
  56454. * * If `enclose` is false, a ring surface is one element.
  56455. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56456. * * 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
  56457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56458. * * 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
  56459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56460. * @param name defines the name of the mesh
  56461. * @param options defines the options used to create the mesh
  56462. * @param scene defines the hosting scene
  56463. * @returns the cylinder mesh
  56464. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56465. */
  56466. static CreateCylinder(name: string, options: {
  56467. height?: number;
  56468. diameterTop?: number;
  56469. diameterBottom?: number;
  56470. diameter?: number;
  56471. tessellation?: number;
  56472. subdivisions?: number;
  56473. arc?: number;
  56474. faceColors?: Color4[];
  56475. faceUV?: Vector4[];
  56476. updatable?: boolean;
  56477. hasRings?: boolean;
  56478. enclose?: boolean;
  56479. cap?: number;
  56480. sideOrientation?: number;
  56481. frontUVs?: Vector4;
  56482. backUVs?: Vector4;
  56483. }, scene?: Nullable<Scene>): Mesh;
  56484. /**
  56485. * Creates a torus mesh
  56486. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56487. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56488. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56490. * * 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
  56491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56492. * @param name defines the name of the mesh
  56493. * @param options defines the options used to create the mesh
  56494. * @param scene defines the hosting scene
  56495. * @returns the torus mesh
  56496. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56497. */
  56498. static CreateTorus(name: string, options: {
  56499. diameter?: number;
  56500. thickness?: number;
  56501. tessellation?: number;
  56502. updatable?: boolean;
  56503. sideOrientation?: number;
  56504. frontUVs?: Vector4;
  56505. backUVs?: Vector4;
  56506. }, scene?: Nullable<Scene>): Mesh;
  56507. /**
  56508. * Creates a torus knot mesh
  56509. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56510. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56511. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56512. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56514. * * 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
  56515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56516. * @param name defines the name of the mesh
  56517. * @param options defines the options used to create the mesh
  56518. * @param scene defines the hosting scene
  56519. * @returns the torus knot mesh
  56520. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56521. */
  56522. static CreateTorusKnot(name: string, options: {
  56523. radius?: number;
  56524. tube?: number;
  56525. radialSegments?: number;
  56526. tubularSegments?: number;
  56527. p?: number;
  56528. q?: number;
  56529. updatable?: boolean;
  56530. sideOrientation?: number;
  56531. frontUVs?: Vector4;
  56532. backUVs?: Vector4;
  56533. }, scene?: Nullable<Scene>): Mesh;
  56534. /**
  56535. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56536. * * 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
  56537. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56538. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56539. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56540. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56541. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56542. * * 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
  56543. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56546. * @param name defines the name of the new line system
  56547. * @param options defines the options used to create the line system
  56548. * @param scene defines the hosting scene
  56549. * @returns a new line system mesh
  56550. */
  56551. static CreateLineSystem(name: string, options: {
  56552. lines: Vector3[][];
  56553. updatable?: boolean;
  56554. instance?: Nullable<LinesMesh>;
  56555. colors?: Nullable<Color4[][]>;
  56556. useVertexAlpha?: boolean;
  56557. }, scene: Nullable<Scene>): LinesMesh;
  56558. /**
  56559. * Creates a line mesh
  56560. * 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
  56561. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56562. * * The parameter `points` is an array successive Vector3
  56563. * * 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
  56564. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56565. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56566. * * When updating an instance, remember that only point positions can change, not the number of points
  56567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56569. * @param name defines the name of the new line system
  56570. * @param options defines the options used to create the line system
  56571. * @param scene defines the hosting scene
  56572. * @returns a new line mesh
  56573. */
  56574. static CreateLines(name: string, options: {
  56575. points: Vector3[];
  56576. updatable?: boolean;
  56577. instance?: Nullable<LinesMesh>;
  56578. colors?: Color4[];
  56579. useVertexAlpha?: boolean;
  56580. }, scene?: Nullable<Scene>): LinesMesh;
  56581. /**
  56582. * Creates a dashed line mesh
  56583. * * 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
  56584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56585. * * The parameter `points` is an array successive Vector3
  56586. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56587. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56588. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56589. * * 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
  56590. * * When updating an instance, remember that only point positions can change, not the number of points
  56591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56592. * @param name defines the name of the mesh
  56593. * @param options defines the options used to create the mesh
  56594. * @param scene defines the hosting scene
  56595. * @returns the dashed line mesh
  56596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56597. */
  56598. static CreateDashedLines(name: string, options: {
  56599. points: Vector3[];
  56600. dashSize?: number;
  56601. gapSize?: number;
  56602. dashNb?: number;
  56603. updatable?: boolean;
  56604. instance?: LinesMesh;
  56605. }, scene?: Nullable<Scene>): LinesMesh;
  56606. /**
  56607. * 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.
  56608. * * 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.
  56609. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56610. * * 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.
  56611. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56612. * * 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
  56613. * * 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
  56614. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56616. * * 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
  56617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56619. * @param name defines the name of the mesh
  56620. * @param options defines the options used to create the mesh
  56621. * @param scene defines the hosting scene
  56622. * @returns the extruded shape mesh
  56623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56625. */
  56626. static ExtrudeShape(name: string, options: {
  56627. shape: Vector3[];
  56628. path: Vector3[];
  56629. scale?: number;
  56630. rotation?: number;
  56631. cap?: number;
  56632. updatable?: boolean;
  56633. sideOrientation?: number;
  56634. frontUVs?: Vector4;
  56635. backUVs?: Vector4;
  56636. instance?: Mesh;
  56637. invertUV?: boolean;
  56638. }, scene?: Nullable<Scene>): Mesh;
  56639. /**
  56640. * Creates an custom extruded shape mesh.
  56641. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56642. * * 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.
  56643. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56644. * * 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
  56645. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56646. * * 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
  56647. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56648. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56649. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56650. * * 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
  56651. * * 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
  56652. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56654. * * 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
  56655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56657. * @param name defines the name of the mesh
  56658. * @param options defines the options used to create the mesh
  56659. * @param scene defines the hosting scene
  56660. * @returns the custom extruded shape mesh
  56661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56664. */
  56665. static ExtrudeShapeCustom(name: string, options: {
  56666. shape: Vector3[];
  56667. path: Vector3[];
  56668. scaleFunction?: any;
  56669. rotationFunction?: any;
  56670. ribbonCloseArray?: boolean;
  56671. ribbonClosePath?: boolean;
  56672. cap?: number;
  56673. updatable?: boolean;
  56674. sideOrientation?: number;
  56675. frontUVs?: Vector4;
  56676. backUVs?: Vector4;
  56677. instance?: Mesh;
  56678. invertUV?: boolean;
  56679. }, scene?: Nullable<Scene>): Mesh;
  56680. /**
  56681. * Creates lathe mesh.
  56682. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56683. * * 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
  56684. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56685. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56686. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56687. * * 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
  56688. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56689. * * 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
  56690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56691. * * 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
  56692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56694. * @param name defines the name of the mesh
  56695. * @param options defines the options used to create the mesh
  56696. * @param scene defines the hosting scene
  56697. * @returns the lathe mesh
  56698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56699. */
  56700. static CreateLathe(name: string, options: {
  56701. shape: Vector3[];
  56702. radius?: number;
  56703. tessellation?: number;
  56704. clip?: number;
  56705. arc?: number;
  56706. closed?: boolean;
  56707. updatable?: boolean;
  56708. sideOrientation?: number;
  56709. frontUVs?: Vector4;
  56710. backUVs?: Vector4;
  56711. cap?: number;
  56712. invertUV?: boolean;
  56713. }, scene?: Nullable<Scene>): Mesh;
  56714. /**
  56715. * Creates a tiled plane mesh
  56716. * * You can set a limited pattern arrangement with the tiles
  56717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56718. * * 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
  56719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56720. * @param name defines the name of the mesh
  56721. * @param options defines the options used to create the mesh
  56722. * @param scene defines the hosting scene
  56723. * @returns the plane mesh
  56724. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56725. */
  56726. static CreateTiledPlane(name: string, options: {
  56727. pattern?: number;
  56728. tileSize?: number;
  56729. tileWidth?: number;
  56730. tileHeight?: number;
  56731. size?: number;
  56732. width?: number;
  56733. height?: number;
  56734. alignHorizontal?: number;
  56735. alignVertical?: number;
  56736. sideOrientation?: number;
  56737. frontUVs?: Vector4;
  56738. backUVs?: Vector4;
  56739. updatable?: boolean;
  56740. }, scene?: Nullable<Scene>): Mesh;
  56741. /**
  56742. * Creates a plane mesh
  56743. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56744. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56745. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56747. * * 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
  56748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56749. * @param name defines the name of the mesh
  56750. * @param options defines the options used to create the mesh
  56751. * @param scene defines the hosting scene
  56752. * @returns the plane mesh
  56753. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56754. */
  56755. static CreatePlane(name: string, options: {
  56756. size?: number;
  56757. width?: number;
  56758. height?: number;
  56759. sideOrientation?: number;
  56760. frontUVs?: Vector4;
  56761. backUVs?: Vector4;
  56762. updatable?: boolean;
  56763. sourcePlane?: Plane;
  56764. }, scene?: Nullable<Scene>): Mesh;
  56765. /**
  56766. * Creates a ground mesh
  56767. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56768. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56770. * @param name defines the name of the mesh
  56771. * @param options defines the options used to create the mesh
  56772. * @param scene defines the hosting scene
  56773. * @returns the ground mesh
  56774. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56775. */
  56776. static CreateGround(name: string, options: {
  56777. width?: number;
  56778. height?: number;
  56779. subdivisions?: number;
  56780. subdivisionsX?: number;
  56781. subdivisionsY?: number;
  56782. updatable?: boolean;
  56783. }, scene?: Nullable<Scene>): Mesh;
  56784. /**
  56785. * Creates a tiled ground mesh
  56786. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56787. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56788. * * 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
  56789. * * 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
  56790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56791. * @param name defines the name of the mesh
  56792. * @param options defines the options used to create the mesh
  56793. * @param scene defines the hosting scene
  56794. * @returns the tiled ground mesh
  56795. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56796. */
  56797. static CreateTiledGround(name: string, options: {
  56798. xmin: number;
  56799. zmin: number;
  56800. xmax: number;
  56801. zmax: number;
  56802. subdivisions?: {
  56803. w: number;
  56804. h: number;
  56805. };
  56806. precision?: {
  56807. w: number;
  56808. h: number;
  56809. };
  56810. updatable?: boolean;
  56811. }, scene?: Nullable<Scene>): Mesh;
  56812. /**
  56813. * Creates a ground mesh from a height map
  56814. * * The parameter `url` sets the URL of the height map image resource.
  56815. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56816. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56817. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56818. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56819. * * 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.
  56820. * * 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).
  56821. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56823. * @param name defines the name of the mesh
  56824. * @param url defines the url to the height map
  56825. * @param options defines the options used to create the mesh
  56826. * @param scene defines the hosting scene
  56827. * @returns the ground mesh
  56828. * @see https://doc.babylonjs.com/babylon101/height_map
  56829. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56830. */
  56831. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56832. width?: number;
  56833. height?: number;
  56834. subdivisions?: number;
  56835. minHeight?: number;
  56836. maxHeight?: number;
  56837. colorFilter?: Color3;
  56838. alphaFilter?: number;
  56839. updatable?: boolean;
  56840. onReady?: (mesh: GroundMesh) => void;
  56841. }, scene?: Nullable<Scene>): GroundMesh;
  56842. /**
  56843. * Creates a polygon mesh
  56844. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56845. * * 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
  56846. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56848. * * 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)
  56849. * * Remember you can only change the shape positions, not their number when updating a polygon
  56850. * @param name defines the name of the mesh
  56851. * @param options defines the options used to create the mesh
  56852. * @param scene defines the hosting scene
  56853. * @param earcutInjection can be used to inject your own earcut reference
  56854. * @returns the polygon mesh
  56855. */
  56856. static CreatePolygon(name: string, options: {
  56857. shape: Vector3[];
  56858. holes?: Vector3[][];
  56859. depth?: number;
  56860. faceUV?: Vector4[];
  56861. faceColors?: Color4[];
  56862. updatable?: boolean;
  56863. sideOrientation?: number;
  56864. frontUVs?: Vector4;
  56865. backUVs?: Vector4;
  56866. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56867. /**
  56868. * Creates an extruded polygon mesh, with depth in the Y direction.
  56869. * * 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)
  56870. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56871. * @param name defines the name of the mesh
  56872. * @param options defines the options used to create the mesh
  56873. * @param scene defines the hosting scene
  56874. * @param earcutInjection can be used to inject your own earcut reference
  56875. * @returns the polygon mesh
  56876. */
  56877. static ExtrudePolygon(name: string, options: {
  56878. shape: Vector3[];
  56879. holes?: Vector3[][];
  56880. depth?: number;
  56881. faceUV?: Vector4[];
  56882. faceColors?: Color4[];
  56883. updatable?: boolean;
  56884. sideOrientation?: number;
  56885. frontUVs?: Vector4;
  56886. backUVs?: Vector4;
  56887. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56888. /**
  56889. * Creates a tube mesh.
  56890. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56891. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56892. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56893. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56894. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56895. * * 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)
  56896. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56897. * * 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
  56898. * * 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
  56899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56900. * * 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
  56901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56903. * @param name defines the name of the mesh
  56904. * @param options defines the options used to create the mesh
  56905. * @param scene defines the hosting scene
  56906. * @returns the tube mesh
  56907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56908. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56909. */
  56910. static CreateTube(name: string, options: {
  56911. path: Vector3[];
  56912. radius?: number;
  56913. tessellation?: number;
  56914. radiusFunction?: {
  56915. (i: number, distance: number): number;
  56916. };
  56917. cap?: number;
  56918. arc?: number;
  56919. updatable?: boolean;
  56920. sideOrientation?: number;
  56921. frontUVs?: Vector4;
  56922. backUVs?: Vector4;
  56923. instance?: Mesh;
  56924. invertUV?: boolean;
  56925. }, scene?: Nullable<Scene>): Mesh;
  56926. /**
  56927. * Creates a polyhedron mesh
  56928. * * 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
  56929. * * The parameter `size` (positive float, default 1) sets the polygon size
  56930. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56931. * * 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`
  56932. * * 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
  56933. * * 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)`)
  56934. * * 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
  56935. * * 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
  56936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56937. * * 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
  56938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56939. * @param name defines the name of the mesh
  56940. * @param options defines the options used to create the mesh
  56941. * @param scene defines the hosting scene
  56942. * @returns the polyhedron mesh
  56943. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56944. */
  56945. static CreatePolyhedron(name: string, options: {
  56946. type?: number;
  56947. size?: number;
  56948. sizeX?: number;
  56949. sizeY?: number;
  56950. sizeZ?: number;
  56951. custom?: any;
  56952. faceUV?: Vector4[];
  56953. faceColors?: Color4[];
  56954. flat?: boolean;
  56955. updatable?: boolean;
  56956. sideOrientation?: number;
  56957. frontUVs?: Vector4;
  56958. backUVs?: Vector4;
  56959. }, scene?: Nullable<Scene>): Mesh;
  56960. /**
  56961. * Creates a decal mesh.
  56962. * 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
  56963. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56964. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56965. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56966. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56967. * @param name defines the name of the mesh
  56968. * @param sourceMesh defines the mesh where the decal must be applied
  56969. * @param options defines the options used to create the mesh
  56970. * @param scene defines the hosting scene
  56971. * @returns the decal mesh
  56972. * @see https://doc.babylonjs.com/how_to/decals
  56973. */
  56974. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56975. position?: Vector3;
  56976. normal?: Vector3;
  56977. size?: Vector3;
  56978. angle?: number;
  56979. }): Mesh;
  56980. }
  56981. }
  56982. declare module BABYLON {
  56983. /**
  56984. * A simplifier interface for future simplification implementations
  56985. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56986. */
  56987. export interface ISimplifier {
  56988. /**
  56989. * Simplification of a given mesh according to the given settings.
  56990. * Since this requires computation, it is assumed that the function runs async.
  56991. * @param settings The settings of the simplification, including quality and distance
  56992. * @param successCallback A callback that will be called after the mesh was simplified.
  56993. * @param errorCallback in case of an error, this callback will be called. optional.
  56994. */
  56995. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56996. }
  56997. /**
  56998. * Expected simplification settings.
  56999. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57001. */
  57002. export interface ISimplificationSettings {
  57003. /**
  57004. * Gets or sets the expected quality
  57005. */
  57006. quality: number;
  57007. /**
  57008. * Gets or sets the distance when this optimized version should be used
  57009. */
  57010. distance: number;
  57011. /**
  57012. * Gets an already optimized mesh
  57013. */
  57014. optimizeMesh?: boolean;
  57015. }
  57016. /**
  57017. * Class used to specify simplification options
  57018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57019. */
  57020. export class SimplificationSettings implements ISimplificationSettings {
  57021. /** expected quality */
  57022. quality: number;
  57023. /** distance when this optimized version should be used */
  57024. distance: number;
  57025. /** already optimized mesh */
  57026. optimizeMesh?: boolean | undefined;
  57027. /**
  57028. * Creates a SimplificationSettings
  57029. * @param quality expected quality
  57030. * @param distance distance when this optimized version should be used
  57031. * @param optimizeMesh already optimized mesh
  57032. */
  57033. constructor(
  57034. /** expected quality */
  57035. quality: number,
  57036. /** distance when this optimized version should be used */
  57037. distance: number,
  57038. /** already optimized mesh */
  57039. optimizeMesh?: boolean | undefined);
  57040. }
  57041. /**
  57042. * Interface used to define a simplification task
  57043. */
  57044. export interface ISimplificationTask {
  57045. /**
  57046. * Array of settings
  57047. */
  57048. settings: Array<ISimplificationSettings>;
  57049. /**
  57050. * Simplification type
  57051. */
  57052. simplificationType: SimplificationType;
  57053. /**
  57054. * Mesh to simplify
  57055. */
  57056. mesh: Mesh;
  57057. /**
  57058. * Callback called on success
  57059. */
  57060. successCallback?: () => void;
  57061. /**
  57062. * Defines if parallel processing can be used
  57063. */
  57064. parallelProcessing: boolean;
  57065. }
  57066. /**
  57067. * Queue used to order the simplification tasks
  57068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57069. */
  57070. export class SimplificationQueue {
  57071. private _simplificationArray;
  57072. /**
  57073. * Gets a boolean indicating that the process is still running
  57074. */
  57075. running: boolean;
  57076. /**
  57077. * Creates a new queue
  57078. */
  57079. constructor();
  57080. /**
  57081. * Adds a new simplification task
  57082. * @param task defines a task to add
  57083. */
  57084. addTask(task: ISimplificationTask): void;
  57085. /**
  57086. * Execute next task
  57087. */
  57088. executeNext(): void;
  57089. /**
  57090. * Execute a simplification task
  57091. * @param task defines the task to run
  57092. */
  57093. runSimplification(task: ISimplificationTask): void;
  57094. private getSimplifier;
  57095. }
  57096. /**
  57097. * The implemented types of simplification
  57098. * At the moment only Quadratic Error Decimation is implemented
  57099. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57100. */
  57101. export enum SimplificationType {
  57102. /** Quadratic error decimation */
  57103. QUADRATIC = 0
  57104. }
  57105. }
  57106. declare module BABYLON {
  57107. interface Scene {
  57108. /** @hidden (Backing field) */
  57109. _simplificationQueue: SimplificationQueue;
  57110. /**
  57111. * Gets or sets the simplification queue attached to the scene
  57112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57113. */
  57114. simplificationQueue: SimplificationQueue;
  57115. }
  57116. interface Mesh {
  57117. /**
  57118. * Simplify the mesh according to the given array of settings.
  57119. * Function will return immediately and will simplify async
  57120. * @param settings a collection of simplification settings
  57121. * @param parallelProcessing should all levels calculate parallel or one after the other
  57122. * @param simplificationType the type of simplification to run
  57123. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57124. * @returns the current mesh
  57125. */
  57126. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57127. }
  57128. /**
  57129. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57130. * created in a scene
  57131. */
  57132. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57133. /**
  57134. * The component name helpfull to identify the component in the list of scene components.
  57135. */
  57136. readonly name: string;
  57137. /**
  57138. * The scene the component belongs to.
  57139. */
  57140. scene: Scene;
  57141. /**
  57142. * Creates a new instance of the component for the given scene
  57143. * @param scene Defines the scene to register the component in
  57144. */
  57145. constructor(scene: Scene);
  57146. /**
  57147. * Registers the component in a given scene
  57148. */
  57149. register(): void;
  57150. /**
  57151. * Rebuilds the elements related to this component in case of
  57152. * context lost for instance.
  57153. */
  57154. rebuild(): void;
  57155. /**
  57156. * Disposes the component and the associated ressources
  57157. */
  57158. dispose(): void;
  57159. private _beforeCameraUpdate;
  57160. }
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57165. */
  57166. export interface INavigationEnginePlugin {
  57167. /**
  57168. * plugin name
  57169. */
  57170. name: string;
  57171. /**
  57172. * Creates a navigation mesh
  57173. * @param meshes array of all the geometry used to compute the navigatio mesh
  57174. * @param parameters bunch of parameters used to filter geometry
  57175. */
  57176. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57177. /**
  57178. * Create a navigation mesh debug mesh
  57179. * @param scene is where the mesh will be added
  57180. * @returns debug display mesh
  57181. */
  57182. createDebugNavMesh(scene: Scene): Mesh;
  57183. /**
  57184. * Get a navigation mesh constrained position, closest to the parameter position
  57185. * @param position world position
  57186. * @returns the closest point to position constrained by the navigation mesh
  57187. */
  57188. getClosestPoint(position: Vector3): Vector3;
  57189. /**
  57190. * Get a navigation mesh constrained position, within a particular radius
  57191. * @param position world position
  57192. * @param maxRadius the maximum distance to the constrained world position
  57193. * @returns the closest point to position constrained by the navigation mesh
  57194. */
  57195. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57196. /**
  57197. * Compute the final position from a segment made of destination-position
  57198. * @param position world position
  57199. * @param destination world position
  57200. * @returns the resulting point along the navmesh
  57201. */
  57202. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57203. /**
  57204. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57205. * @param start world position
  57206. * @param end world position
  57207. * @returns array containing world position composing the path
  57208. */
  57209. computePath(start: Vector3, end: Vector3): Vector3[];
  57210. /**
  57211. * If this plugin is supported
  57212. * @returns true if plugin is supported
  57213. */
  57214. isSupported(): boolean;
  57215. /**
  57216. * Create a new Crowd so you can add agents
  57217. * @param maxAgents the maximum agent count in the crowd
  57218. * @param maxAgentRadius the maximum radius an agent can have
  57219. * @param scene to attach the crowd to
  57220. * @returns the crowd you can add agents to
  57221. */
  57222. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57223. /**
  57224. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57225. * The queries will try to find a solution within those bounds
  57226. * default is (1,1,1)
  57227. * @param extent x,y,z value that define the extent around the queries point of reference
  57228. */
  57229. setDefaultQueryExtent(extent: Vector3): void;
  57230. /**
  57231. * Get the Bounding box extent specified by setDefaultQueryExtent
  57232. * @returns the box extent values
  57233. */
  57234. getDefaultQueryExtent(): Vector3;
  57235. /**
  57236. * Release all resources
  57237. */
  57238. dispose(): void;
  57239. }
  57240. /**
  57241. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57242. */
  57243. export interface ICrowd {
  57244. /**
  57245. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57246. * You can attach anything to that node. The node position is updated in the scene update tick.
  57247. * @param pos world position that will be constrained by the navigation mesh
  57248. * @param parameters agent parameters
  57249. * @param transform hooked to the agent that will be update by the scene
  57250. * @returns agent index
  57251. */
  57252. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57253. /**
  57254. * Returns the agent position in world space
  57255. * @param index agent index returned by addAgent
  57256. * @returns world space position
  57257. */
  57258. getAgentPosition(index: number): Vector3;
  57259. /**
  57260. * Gets the agent velocity in world space
  57261. * @param index agent index returned by addAgent
  57262. * @returns world space velocity
  57263. */
  57264. getAgentVelocity(index: number): Vector3;
  57265. /**
  57266. * remove a particular agent previously created
  57267. * @param index agent index returned by addAgent
  57268. */
  57269. removeAgent(index: number): void;
  57270. /**
  57271. * get the list of all agents attached to this crowd
  57272. * @returns list of agent indices
  57273. */
  57274. getAgents(): number[];
  57275. /**
  57276. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57277. * @param deltaTime in seconds
  57278. */
  57279. update(deltaTime: number): void;
  57280. /**
  57281. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57282. * @param index agent index returned by addAgent
  57283. * @param destination targeted world position
  57284. */
  57285. agentGoto(index: number, destination: Vector3): void;
  57286. /**
  57287. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57288. * The queries will try to find a solution within those bounds
  57289. * default is (1,1,1)
  57290. * @param extent x,y,z value that define the extent around the queries point of reference
  57291. */
  57292. setDefaultQueryExtent(extent: Vector3): void;
  57293. /**
  57294. * Get the Bounding box extent specified by setDefaultQueryExtent
  57295. * @returns the box extent values
  57296. */
  57297. getDefaultQueryExtent(): Vector3;
  57298. /**
  57299. * Release all resources
  57300. */
  57301. dispose(): void;
  57302. }
  57303. /**
  57304. * Configures an agent
  57305. */
  57306. export interface IAgentParameters {
  57307. /**
  57308. * Agent radius. [Limit: >= 0]
  57309. */
  57310. radius: number;
  57311. /**
  57312. * Agent height. [Limit: > 0]
  57313. */
  57314. height: number;
  57315. /**
  57316. * Maximum allowed acceleration. [Limit: >= 0]
  57317. */
  57318. maxAcceleration: number;
  57319. /**
  57320. * Maximum allowed speed. [Limit: >= 0]
  57321. */
  57322. maxSpeed: number;
  57323. /**
  57324. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57325. */
  57326. collisionQueryRange: number;
  57327. /**
  57328. * The path visibility optimization range. [Limit: > 0]
  57329. */
  57330. pathOptimizationRange: number;
  57331. /**
  57332. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57333. */
  57334. separationWeight: number;
  57335. }
  57336. /**
  57337. * Configures the navigation mesh creation
  57338. */
  57339. export interface INavMeshParameters {
  57340. /**
  57341. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57342. */
  57343. cs: number;
  57344. /**
  57345. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57346. */
  57347. ch: number;
  57348. /**
  57349. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57350. */
  57351. walkableSlopeAngle: number;
  57352. /**
  57353. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57354. * be considered walkable. [Limit: >= 3] [Units: vx]
  57355. */
  57356. walkableHeight: number;
  57357. /**
  57358. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57359. */
  57360. walkableClimb: number;
  57361. /**
  57362. * The distance to erode/shrink the walkable area of the heightfield away from
  57363. * obstructions. [Limit: >=0] [Units: vx]
  57364. */
  57365. walkableRadius: number;
  57366. /**
  57367. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57368. */
  57369. maxEdgeLen: number;
  57370. /**
  57371. * The maximum distance a simplfied contour's border edges should deviate
  57372. * the original raw contour. [Limit: >=0] [Units: vx]
  57373. */
  57374. maxSimplificationError: number;
  57375. /**
  57376. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57377. */
  57378. minRegionArea: number;
  57379. /**
  57380. * Any regions with a span count smaller than this value will, if possible,
  57381. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57382. */
  57383. mergeRegionArea: number;
  57384. /**
  57385. * The maximum number of vertices allowed for polygons generated during the
  57386. * contour to polygon conversion process. [Limit: >= 3]
  57387. */
  57388. maxVertsPerPoly: number;
  57389. /**
  57390. * Sets the sampling distance to use when generating the detail mesh.
  57391. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57392. */
  57393. detailSampleDist: number;
  57394. /**
  57395. * The maximum distance the detail mesh surface should deviate from heightfield
  57396. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57397. */
  57398. detailSampleMaxError: number;
  57399. }
  57400. }
  57401. declare module BABYLON {
  57402. /**
  57403. * RecastJS navigation plugin
  57404. */
  57405. export class RecastJSPlugin implements INavigationEnginePlugin {
  57406. /**
  57407. * Reference to the Recast library
  57408. */
  57409. bjsRECAST: any;
  57410. /**
  57411. * plugin name
  57412. */
  57413. name: string;
  57414. /**
  57415. * the first navmesh created. We might extend this to support multiple navmeshes
  57416. */
  57417. navMesh: any;
  57418. /**
  57419. * Initializes the recastJS plugin
  57420. * @param recastInjection can be used to inject your own recast reference
  57421. */
  57422. constructor(recastInjection?: any);
  57423. /**
  57424. * Creates a navigation mesh
  57425. * @param meshes array of all the geometry used to compute the navigatio mesh
  57426. * @param parameters bunch of parameters used to filter geometry
  57427. */
  57428. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57429. /**
  57430. * Create a navigation mesh debug mesh
  57431. * @param scene is where the mesh will be added
  57432. * @returns debug display mesh
  57433. */
  57434. createDebugNavMesh(scene: Scene): Mesh;
  57435. /**
  57436. * Get a navigation mesh constrained position, closest to the parameter position
  57437. * @param position world position
  57438. * @returns the closest point to position constrained by the navigation mesh
  57439. */
  57440. getClosestPoint(position: Vector3): Vector3;
  57441. /**
  57442. * Get a navigation mesh constrained position, within a particular radius
  57443. * @param position world position
  57444. * @param maxRadius the maximum distance to the constrained world position
  57445. * @returns the closest point to position constrained by the navigation mesh
  57446. */
  57447. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57448. /**
  57449. * Compute the final position from a segment made of destination-position
  57450. * @param position world position
  57451. * @param destination world position
  57452. * @returns the resulting point along the navmesh
  57453. */
  57454. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57455. /**
  57456. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57457. * @param start world position
  57458. * @param end world position
  57459. * @returns array containing world position composing the path
  57460. */
  57461. computePath(start: Vector3, end: Vector3): Vector3[];
  57462. /**
  57463. * Create a new Crowd so you can add agents
  57464. * @param maxAgents the maximum agent count in the crowd
  57465. * @param maxAgentRadius the maximum radius an agent can have
  57466. * @param scene to attach the crowd to
  57467. * @returns the crowd you can add agents to
  57468. */
  57469. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57470. /**
  57471. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57472. * The queries will try to find a solution within those bounds
  57473. * default is (1,1,1)
  57474. * @param extent x,y,z value that define the extent around the queries point of reference
  57475. */
  57476. setDefaultQueryExtent(extent: Vector3): void;
  57477. /**
  57478. * Get the Bounding box extent specified by setDefaultQueryExtent
  57479. * @returns the box extent values
  57480. */
  57481. getDefaultQueryExtent(): Vector3;
  57482. /**
  57483. * Disposes
  57484. */
  57485. dispose(): void;
  57486. /**
  57487. * If this plugin is supported
  57488. * @returns true if plugin is supported
  57489. */
  57490. isSupported(): boolean;
  57491. }
  57492. /**
  57493. * Recast detour crowd implementation
  57494. */
  57495. export class RecastJSCrowd implements ICrowd {
  57496. /**
  57497. * Recast/detour plugin
  57498. */
  57499. bjsRECASTPlugin: RecastJSPlugin;
  57500. /**
  57501. * Link to the detour crowd
  57502. */
  57503. recastCrowd: any;
  57504. /**
  57505. * One transform per agent
  57506. */
  57507. transforms: TransformNode[];
  57508. /**
  57509. * All agents created
  57510. */
  57511. agents: number[];
  57512. /**
  57513. * Link to the scene is kept to unregister the crowd from the scene
  57514. */
  57515. private _scene;
  57516. /**
  57517. * Observer for crowd updates
  57518. */
  57519. private _onBeforeAnimationsObserver;
  57520. /**
  57521. * Constructor
  57522. * @param plugin recastJS plugin
  57523. * @param maxAgents the maximum agent count in the crowd
  57524. * @param maxAgentRadius the maximum radius an agent can have
  57525. * @param scene to attach the crowd to
  57526. * @returns the crowd you can add agents to
  57527. */
  57528. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57529. /**
  57530. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57531. * You can attach anything to that node. The node position is updated in the scene update tick.
  57532. * @param pos world position that will be constrained by the navigation mesh
  57533. * @param parameters agent parameters
  57534. * @param transform hooked to the agent that will be update by the scene
  57535. * @returns agent index
  57536. */
  57537. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57538. /**
  57539. * Returns the agent position in world space
  57540. * @param index agent index returned by addAgent
  57541. * @returns world space position
  57542. */
  57543. getAgentPosition(index: number): Vector3;
  57544. /**
  57545. * Returns the agent velocity in world space
  57546. * @param index agent index returned by addAgent
  57547. * @returns world space velocity
  57548. */
  57549. getAgentVelocity(index: number): Vector3;
  57550. /**
  57551. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57552. * @param index agent index returned by addAgent
  57553. * @param destination targeted world position
  57554. */
  57555. agentGoto(index: number, destination: Vector3): void;
  57556. /**
  57557. * remove a particular agent previously created
  57558. * @param index agent index returned by addAgent
  57559. */
  57560. removeAgent(index: number): void;
  57561. /**
  57562. * get the list of all agents attached to this crowd
  57563. * @returns list of agent indices
  57564. */
  57565. getAgents(): number[];
  57566. /**
  57567. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57568. * @param deltaTime in seconds
  57569. */
  57570. update(deltaTime: number): void;
  57571. /**
  57572. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57573. * The queries will try to find a solution within those bounds
  57574. * default is (1,1,1)
  57575. * @param extent x,y,z value that define the extent around the queries point of reference
  57576. */
  57577. setDefaultQueryExtent(extent: Vector3): void;
  57578. /**
  57579. * Get the Bounding box extent specified by setDefaultQueryExtent
  57580. * @returns the box extent values
  57581. */
  57582. getDefaultQueryExtent(): Vector3;
  57583. /**
  57584. * Release all resources
  57585. */
  57586. dispose(): void;
  57587. }
  57588. }
  57589. declare module BABYLON {
  57590. /**
  57591. * Class used to enable access to IndexedDB
  57592. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57593. */
  57594. export class Database implements IOfflineProvider {
  57595. private _callbackManifestChecked;
  57596. private _currentSceneUrl;
  57597. private _db;
  57598. private _enableSceneOffline;
  57599. private _enableTexturesOffline;
  57600. private _manifestVersionFound;
  57601. private _mustUpdateRessources;
  57602. private _hasReachedQuota;
  57603. private _isSupported;
  57604. private _idbFactory;
  57605. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57606. private static IsUASupportingBlobStorage;
  57607. /**
  57608. * Gets a boolean indicating if Database storate is enabled (off by default)
  57609. */
  57610. static IDBStorageEnabled: boolean;
  57611. /**
  57612. * Gets a boolean indicating if scene must be saved in the database
  57613. */
  57614. readonly enableSceneOffline: boolean;
  57615. /**
  57616. * Gets a boolean indicating if textures must be saved in the database
  57617. */
  57618. readonly enableTexturesOffline: boolean;
  57619. /**
  57620. * Creates a new Database
  57621. * @param urlToScene defines the url to load the scene
  57622. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57623. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57624. */
  57625. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57626. private static _ParseURL;
  57627. private static _ReturnFullUrlLocation;
  57628. private _checkManifestFile;
  57629. /**
  57630. * Open the database and make it available
  57631. * @param successCallback defines the callback to call on success
  57632. * @param errorCallback defines the callback to call on error
  57633. */
  57634. open(successCallback: () => void, errorCallback: () => void): void;
  57635. /**
  57636. * Loads an image from the database
  57637. * @param url defines the url to load from
  57638. * @param image defines the target DOM image
  57639. */
  57640. loadImage(url: string, image: HTMLImageElement): void;
  57641. private _loadImageFromDBAsync;
  57642. private _saveImageIntoDBAsync;
  57643. private _checkVersionFromDB;
  57644. private _loadVersionFromDBAsync;
  57645. private _saveVersionIntoDBAsync;
  57646. /**
  57647. * Loads a file from database
  57648. * @param url defines the URL to load from
  57649. * @param sceneLoaded defines a callback to call on success
  57650. * @param progressCallBack defines a callback to call when progress changed
  57651. * @param errorCallback defines a callback to call on error
  57652. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57653. */
  57654. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57655. private _loadFileAsync;
  57656. private _saveFileAsync;
  57657. /**
  57658. * Validates if xhr data is correct
  57659. * @param xhr defines the request to validate
  57660. * @param dataType defines the expected data type
  57661. * @returns true if data is correct
  57662. */
  57663. private static _ValidateXHRData;
  57664. }
  57665. }
  57666. declare module BABYLON {
  57667. /** @hidden */
  57668. export var gpuUpdateParticlesPixelShader: {
  57669. name: string;
  57670. shader: string;
  57671. };
  57672. }
  57673. declare module BABYLON {
  57674. /** @hidden */
  57675. export var gpuUpdateParticlesVertexShader: {
  57676. name: string;
  57677. shader: string;
  57678. };
  57679. }
  57680. declare module BABYLON {
  57681. /** @hidden */
  57682. export var clipPlaneFragmentDeclaration2: {
  57683. name: string;
  57684. shader: string;
  57685. };
  57686. }
  57687. declare module BABYLON {
  57688. /** @hidden */
  57689. export var gpuRenderParticlesPixelShader: {
  57690. name: string;
  57691. shader: string;
  57692. };
  57693. }
  57694. declare module BABYLON {
  57695. /** @hidden */
  57696. export var clipPlaneVertexDeclaration2: {
  57697. name: string;
  57698. shader: string;
  57699. };
  57700. }
  57701. declare module BABYLON {
  57702. /** @hidden */
  57703. export var gpuRenderParticlesVertexShader: {
  57704. name: string;
  57705. shader: string;
  57706. };
  57707. }
  57708. declare module BABYLON {
  57709. /**
  57710. * This represents a GPU particle system in Babylon
  57711. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57712. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57713. */
  57714. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57715. /**
  57716. * The layer mask we are rendering the particles through.
  57717. */
  57718. layerMask: number;
  57719. private _capacity;
  57720. private _activeCount;
  57721. private _currentActiveCount;
  57722. private _accumulatedCount;
  57723. private _renderEffect;
  57724. private _updateEffect;
  57725. private _buffer0;
  57726. private _buffer1;
  57727. private _spriteBuffer;
  57728. private _updateVAO;
  57729. private _renderVAO;
  57730. private _targetIndex;
  57731. private _sourceBuffer;
  57732. private _targetBuffer;
  57733. private _engine;
  57734. private _currentRenderId;
  57735. private _started;
  57736. private _stopped;
  57737. private _timeDelta;
  57738. private _randomTexture;
  57739. private _randomTexture2;
  57740. private _attributesStrideSize;
  57741. private _updateEffectOptions;
  57742. private _randomTextureSize;
  57743. private _actualFrame;
  57744. private readonly _rawTextureWidth;
  57745. /**
  57746. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57747. */
  57748. static readonly IsSupported: boolean;
  57749. /**
  57750. * An event triggered when the system is disposed.
  57751. */
  57752. onDisposeObservable: Observable<GPUParticleSystem>;
  57753. /**
  57754. * Gets the maximum number of particles active at the same time.
  57755. * @returns The max number of active particles.
  57756. */
  57757. getCapacity(): number;
  57758. /**
  57759. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57760. * to override the particles.
  57761. */
  57762. forceDepthWrite: boolean;
  57763. /**
  57764. * Gets or set the number of active particles
  57765. */
  57766. activeParticleCount: number;
  57767. private _preWarmDone;
  57768. /**
  57769. * Is this system ready to be used/rendered
  57770. * @return true if the system is ready
  57771. */
  57772. isReady(): boolean;
  57773. /**
  57774. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57775. * @returns True if it has been started, otherwise false.
  57776. */
  57777. isStarted(): boolean;
  57778. /**
  57779. * Starts the particle system and begins to emit
  57780. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57781. */
  57782. start(delay?: number): void;
  57783. /**
  57784. * Stops the particle system.
  57785. */
  57786. stop(): void;
  57787. /**
  57788. * Remove all active particles
  57789. */
  57790. reset(): void;
  57791. /**
  57792. * Returns the string "GPUParticleSystem"
  57793. * @returns a string containing the class name
  57794. */
  57795. getClassName(): string;
  57796. private _colorGradientsTexture;
  57797. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57798. /**
  57799. * Adds a new color gradient
  57800. * @param gradient defines the gradient to use (between 0 and 1)
  57801. * @param color1 defines the color to affect to the specified gradient
  57802. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57803. * @returns the current particle system
  57804. */
  57805. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57806. /**
  57807. * Remove a specific color gradient
  57808. * @param gradient defines the gradient to remove
  57809. * @returns the current particle system
  57810. */
  57811. removeColorGradient(gradient: number): GPUParticleSystem;
  57812. private _angularSpeedGradientsTexture;
  57813. private _sizeGradientsTexture;
  57814. private _velocityGradientsTexture;
  57815. private _limitVelocityGradientsTexture;
  57816. private _dragGradientsTexture;
  57817. private _addFactorGradient;
  57818. /**
  57819. * Adds a new size gradient
  57820. * @param gradient defines the gradient to use (between 0 and 1)
  57821. * @param factor defines the size factor to affect to the specified gradient
  57822. * @returns the current particle system
  57823. */
  57824. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57825. /**
  57826. * Remove a specific size gradient
  57827. * @param gradient defines the gradient to remove
  57828. * @returns the current particle system
  57829. */
  57830. removeSizeGradient(gradient: number): GPUParticleSystem;
  57831. /**
  57832. * Adds a new angular speed gradient
  57833. * @param gradient defines the gradient to use (between 0 and 1)
  57834. * @param factor defines the angular speed to affect to the specified gradient
  57835. * @returns the current particle system
  57836. */
  57837. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57838. /**
  57839. * Remove a specific angular speed gradient
  57840. * @param gradient defines the gradient to remove
  57841. * @returns the current particle system
  57842. */
  57843. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57844. /**
  57845. * Adds a new velocity gradient
  57846. * @param gradient defines the gradient to use (between 0 and 1)
  57847. * @param factor defines the velocity to affect to the specified gradient
  57848. * @returns the current particle system
  57849. */
  57850. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57851. /**
  57852. * Remove a specific velocity gradient
  57853. * @param gradient defines the gradient to remove
  57854. * @returns the current particle system
  57855. */
  57856. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57857. /**
  57858. * Adds a new limit velocity gradient
  57859. * @param gradient defines the gradient to use (between 0 and 1)
  57860. * @param factor defines the limit velocity value to affect to the specified gradient
  57861. * @returns the current particle system
  57862. */
  57863. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57864. /**
  57865. * Remove a specific limit velocity gradient
  57866. * @param gradient defines the gradient to remove
  57867. * @returns the current particle system
  57868. */
  57869. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57870. /**
  57871. * Adds a new drag gradient
  57872. * @param gradient defines the gradient to use (between 0 and 1)
  57873. * @param factor defines the drag value to affect to the specified gradient
  57874. * @returns the current particle system
  57875. */
  57876. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57877. /**
  57878. * Remove a specific drag gradient
  57879. * @param gradient defines the gradient to remove
  57880. * @returns the current particle system
  57881. */
  57882. removeDragGradient(gradient: number): GPUParticleSystem;
  57883. /**
  57884. * Not supported by GPUParticleSystem
  57885. * @param gradient defines the gradient to use (between 0 and 1)
  57886. * @param factor defines the emit rate value to affect to the specified gradient
  57887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57888. * @returns the current particle system
  57889. */
  57890. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57891. /**
  57892. * Not supported by GPUParticleSystem
  57893. * @param gradient defines the gradient to remove
  57894. * @returns the current particle system
  57895. */
  57896. removeEmitRateGradient(gradient: number): IParticleSystem;
  57897. /**
  57898. * Not supported by GPUParticleSystem
  57899. * @param gradient defines the gradient to use (between 0 and 1)
  57900. * @param factor defines the start size value to affect to the specified gradient
  57901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57902. * @returns the current particle system
  57903. */
  57904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57905. /**
  57906. * Not supported by GPUParticleSystem
  57907. * @param gradient defines the gradient to remove
  57908. * @returns the current particle system
  57909. */
  57910. removeStartSizeGradient(gradient: number): IParticleSystem;
  57911. /**
  57912. * Not supported by GPUParticleSystem
  57913. * @param gradient defines the gradient to use (between 0 and 1)
  57914. * @param min defines the color remap minimal range
  57915. * @param max defines the color remap maximal range
  57916. * @returns the current particle system
  57917. */
  57918. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57919. /**
  57920. * Not supported by GPUParticleSystem
  57921. * @param gradient defines the gradient to remove
  57922. * @returns the current particle system
  57923. */
  57924. removeColorRemapGradient(): IParticleSystem;
  57925. /**
  57926. * Not supported by GPUParticleSystem
  57927. * @param gradient defines the gradient to use (between 0 and 1)
  57928. * @param min defines the alpha remap minimal range
  57929. * @param max defines the alpha remap maximal range
  57930. * @returns the current particle system
  57931. */
  57932. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57933. /**
  57934. * Not supported by GPUParticleSystem
  57935. * @param gradient defines the gradient to remove
  57936. * @returns the current particle system
  57937. */
  57938. removeAlphaRemapGradient(): IParticleSystem;
  57939. /**
  57940. * Not supported by GPUParticleSystem
  57941. * @param gradient defines the gradient to use (between 0 and 1)
  57942. * @param color defines the color to affect to the specified gradient
  57943. * @returns the current particle system
  57944. */
  57945. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57946. /**
  57947. * Not supported by GPUParticleSystem
  57948. * @param gradient defines the gradient to remove
  57949. * @returns the current particle system
  57950. */
  57951. removeRampGradient(): IParticleSystem;
  57952. /**
  57953. * Not supported by GPUParticleSystem
  57954. * @returns the list of ramp gradients
  57955. */
  57956. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57957. /**
  57958. * Not supported by GPUParticleSystem
  57959. * Gets or sets a boolean indicating that ramp gradients must be used
  57960. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57961. */
  57962. useRampGradients: boolean;
  57963. /**
  57964. * Not supported by GPUParticleSystem
  57965. * @param gradient defines the gradient to use (between 0 and 1)
  57966. * @param factor defines the life time factor to affect to the specified gradient
  57967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57968. * @returns the current particle system
  57969. */
  57970. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57971. /**
  57972. * Not supported by GPUParticleSystem
  57973. * @param gradient defines the gradient to remove
  57974. * @returns the current particle system
  57975. */
  57976. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57977. /**
  57978. * Instantiates a GPU particle system.
  57979. * 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.
  57980. * @param name The name of the particle system
  57981. * @param options The options used to create the system
  57982. * @param scene The scene the particle system belongs to
  57983. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57984. */
  57985. constructor(name: string, options: Partial<{
  57986. capacity: number;
  57987. randomTextureSize: number;
  57988. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57989. protected _reset(): void;
  57990. private _createUpdateVAO;
  57991. private _createRenderVAO;
  57992. private _initialize;
  57993. /** @hidden */
  57994. _recreateUpdateEffect(): void;
  57995. /** @hidden */
  57996. _recreateRenderEffect(): void;
  57997. /**
  57998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57999. * @param preWarm defines if we are in the pre-warmimg phase
  58000. */
  58001. animate(preWarm?: boolean): void;
  58002. private _createFactorGradientTexture;
  58003. private _createSizeGradientTexture;
  58004. private _createAngularSpeedGradientTexture;
  58005. private _createVelocityGradientTexture;
  58006. private _createLimitVelocityGradientTexture;
  58007. private _createDragGradientTexture;
  58008. private _createColorGradientTexture;
  58009. /**
  58010. * Renders the particle system in its current state
  58011. * @param preWarm defines if the system should only update the particles but not render them
  58012. * @returns the current number of particles
  58013. */
  58014. render(preWarm?: boolean): number;
  58015. /**
  58016. * Rebuilds the particle system
  58017. */
  58018. rebuild(): void;
  58019. private _releaseBuffers;
  58020. private _releaseVAOs;
  58021. /**
  58022. * Disposes the particle system and free the associated resources
  58023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58024. */
  58025. dispose(disposeTexture?: boolean): void;
  58026. /**
  58027. * Clones the particle system.
  58028. * @param name The name of the cloned object
  58029. * @param newEmitter The new emitter to use
  58030. * @returns the cloned particle system
  58031. */
  58032. clone(name: string, newEmitter: any): GPUParticleSystem;
  58033. /**
  58034. * Serializes the particle system to a JSON object.
  58035. * @returns the JSON object
  58036. */
  58037. serialize(): any;
  58038. /**
  58039. * Parses a JSON object to create a GPU particle system.
  58040. * @param parsedParticleSystem The JSON object to parse
  58041. * @param scene The scene to create the particle system in
  58042. * @param rootUrl The root url to use to load external dependencies like texture
  58043. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58044. * @returns the parsed GPU particle system
  58045. */
  58046. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58047. }
  58048. }
  58049. declare module BABYLON {
  58050. /**
  58051. * Represents a set of particle systems working together to create a specific effect
  58052. */
  58053. export class ParticleSystemSet implements IDisposable {
  58054. private _emitterCreationOptions;
  58055. private _emitterNode;
  58056. /**
  58057. * Gets the particle system list
  58058. */
  58059. systems: IParticleSystem[];
  58060. /**
  58061. * Gets the emitter node used with this set
  58062. */
  58063. readonly emitterNode: Nullable<TransformNode>;
  58064. /**
  58065. * Creates a new emitter mesh as a sphere
  58066. * @param options defines the options used to create the sphere
  58067. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58068. * @param scene defines the hosting scene
  58069. */
  58070. setEmitterAsSphere(options: {
  58071. diameter: number;
  58072. segments: number;
  58073. color: Color3;
  58074. }, renderingGroupId: number, scene: Scene): void;
  58075. /**
  58076. * Starts all particle systems of the set
  58077. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58078. */
  58079. start(emitter?: AbstractMesh): void;
  58080. /**
  58081. * Release all associated resources
  58082. */
  58083. dispose(): void;
  58084. /**
  58085. * Serialize the set into a JSON compatible object
  58086. * @returns a JSON compatible representation of the set
  58087. */
  58088. serialize(): any;
  58089. /**
  58090. * Parse a new ParticleSystemSet from a serialized source
  58091. * @param data defines a JSON compatible representation of the set
  58092. * @param scene defines the hosting scene
  58093. * @param gpu defines if we want GPU particles or CPU particles
  58094. * @returns a new ParticleSystemSet
  58095. */
  58096. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58097. }
  58098. }
  58099. declare module BABYLON {
  58100. /**
  58101. * This class is made for on one-liner static method to help creating particle system set.
  58102. */
  58103. export class ParticleHelper {
  58104. /**
  58105. * Gets or sets base Assets URL
  58106. */
  58107. static BaseAssetsUrl: string;
  58108. /**
  58109. * Create a default particle system that you can tweak
  58110. * @param emitter defines the emitter to use
  58111. * @param capacity defines the system capacity (default is 500 particles)
  58112. * @param scene defines the hosting scene
  58113. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58114. * @returns the new Particle system
  58115. */
  58116. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58117. /**
  58118. * This is the main static method (one-liner) of this helper to create different particle systems
  58119. * @param type This string represents the type to the particle system to create
  58120. * @param scene The scene where the particle system should live
  58121. * @param gpu If the system will use gpu
  58122. * @returns the ParticleSystemSet created
  58123. */
  58124. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58125. /**
  58126. * Static function used to export a particle system to a ParticleSystemSet variable.
  58127. * Please note that the emitter shape is not exported
  58128. * @param systems defines the particle systems to export
  58129. * @returns the created particle system set
  58130. */
  58131. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58132. }
  58133. }
  58134. declare module BABYLON {
  58135. interface Engine {
  58136. /**
  58137. * Create an effect to use with particle systems.
  58138. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58139. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58140. * @param uniformsNames defines a list of attribute names
  58141. * @param samplers defines an array of string used to represent textures
  58142. * @param defines defines the string containing the defines to use to compile the shaders
  58143. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58144. * @param onCompiled defines a function to call when the effect creation is successful
  58145. * @param onError defines a function to call when the effect creation has failed
  58146. * @returns the new Effect
  58147. */
  58148. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58149. }
  58150. interface Mesh {
  58151. /**
  58152. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58153. * @returns an array of IParticleSystem
  58154. */
  58155. getEmittedParticleSystems(): IParticleSystem[];
  58156. /**
  58157. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58158. * @returns an array of IParticleSystem
  58159. */
  58160. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58161. }
  58162. /**
  58163. * @hidden
  58164. */
  58165. export var _IDoNeedToBeInTheBuild: number;
  58166. }
  58167. declare module BABYLON {
  58168. interface Scene {
  58169. /** @hidden (Backing field) */
  58170. _physicsEngine: Nullable<IPhysicsEngine>;
  58171. /**
  58172. * Gets the current physics engine
  58173. * @returns a IPhysicsEngine or null if none attached
  58174. */
  58175. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58176. /**
  58177. * Enables physics to the current scene
  58178. * @param gravity defines the scene's gravity for the physics engine
  58179. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58180. * @return a boolean indicating if the physics engine was initialized
  58181. */
  58182. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58183. /**
  58184. * Disables and disposes the physics engine associated with the scene
  58185. */
  58186. disablePhysicsEngine(): void;
  58187. /**
  58188. * Gets a boolean indicating if there is an active physics engine
  58189. * @returns a boolean indicating if there is an active physics engine
  58190. */
  58191. isPhysicsEnabled(): boolean;
  58192. /**
  58193. * Deletes a physics compound impostor
  58194. * @param compound defines the compound to delete
  58195. */
  58196. deleteCompoundImpostor(compound: any): void;
  58197. /**
  58198. * An event triggered when physic simulation is about to be run
  58199. */
  58200. onBeforePhysicsObservable: Observable<Scene>;
  58201. /**
  58202. * An event triggered when physic simulation has been done
  58203. */
  58204. onAfterPhysicsObservable: Observable<Scene>;
  58205. }
  58206. interface AbstractMesh {
  58207. /** @hidden */
  58208. _physicsImpostor: Nullable<PhysicsImpostor>;
  58209. /**
  58210. * Gets or sets impostor used for physic simulation
  58211. * @see http://doc.babylonjs.com/features/physics_engine
  58212. */
  58213. physicsImpostor: Nullable<PhysicsImpostor>;
  58214. /**
  58215. * Gets the current physics impostor
  58216. * @see http://doc.babylonjs.com/features/physics_engine
  58217. * @returns a physics impostor or null
  58218. */
  58219. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58220. /** Apply a physic impulse to the mesh
  58221. * @param force defines the force to apply
  58222. * @param contactPoint defines where to apply the force
  58223. * @returns the current mesh
  58224. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58225. */
  58226. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58227. /**
  58228. * Creates a physic joint between two meshes
  58229. * @param otherMesh defines the other mesh to use
  58230. * @param pivot1 defines the pivot to use on this mesh
  58231. * @param pivot2 defines the pivot to use on the other mesh
  58232. * @param options defines additional options (can be plugin dependent)
  58233. * @returns the current mesh
  58234. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58235. */
  58236. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58237. /** @hidden */
  58238. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58239. }
  58240. /**
  58241. * Defines the physics engine scene component responsible to manage a physics engine
  58242. */
  58243. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58244. /**
  58245. * The component name helpful to identify the component in the list of scene components.
  58246. */
  58247. readonly name: string;
  58248. /**
  58249. * The scene the component belongs to.
  58250. */
  58251. scene: Scene;
  58252. /**
  58253. * Creates a new instance of the component for the given scene
  58254. * @param scene Defines the scene to register the component in
  58255. */
  58256. constructor(scene: Scene);
  58257. /**
  58258. * Registers the component in a given scene
  58259. */
  58260. register(): void;
  58261. /**
  58262. * Rebuilds the elements related to this component in case of
  58263. * context lost for instance.
  58264. */
  58265. rebuild(): void;
  58266. /**
  58267. * Disposes the component and the associated ressources
  58268. */
  58269. dispose(): void;
  58270. }
  58271. }
  58272. declare module BABYLON {
  58273. /**
  58274. * A helper for physics simulations
  58275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58276. */
  58277. export class PhysicsHelper {
  58278. private _scene;
  58279. private _physicsEngine;
  58280. /**
  58281. * Initializes the Physics helper
  58282. * @param scene Babylon.js scene
  58283. */
  58284. constructor(scene: Scene);
  58285. /**
  58286. * Applies a radial explosion impulse
  58287. * @param origin the origin of the explosion
  58288. * @param radiusOrEventOptions the radius or the options of radial explosion
  58289. * @param strength the explosion strength
  58290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58291. * @returns A physics radial explosion event, or null
  58292. */
  58293. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58294. /**
  58295. * Applies a radial explosion force
  58296. * @param origin the origin of the explosion
  58297. * @param radiusOrEventOptions the radius or the options of radial explosion
  58298. * @param strength the explosion strength
  58299. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58300. * @returns A physics radial explosion event, or null
  58301. */
  58302. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58303. /**
  58304. * Creates a gravitational field
  58305. * @param origin the origin of the explosion
  58306. * @param radiusOrEventOptions the radius or the options of radial explosion
  58307. * @param strength the explosion strength
  58308. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58309. * @returns A physics gravitational field event, or null
  58310. */
  58311. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58312. /**
  58313. * Creates a physics updraft event
  58314. * @param origin the origin of the updraft
  58315. * @param radiusOrEventOptions the radius or the options of the updraft
  58316. * @param strength the strength of the updraft
  58317. * @param height the height of the updraft
  58318. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58319. * @returns A physics updraft event, or null
  58320. */
  58321. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58322. /**
  58323. * Creates a physics vortex event
  58324. * @param origin the of the vortex
  58325. * @param radiusOrEventOptions the radius or the options of the vortex
  58326. * @param strength the strength of the vortex
  58327. * @param height the height of the vortex
  58328. * @returns a Physics vortex event, or null
  58329. * A physics vortex event or null
  58330. */
  58331. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58332. }
  58333. /**
  58334. * Represents a physics radial explosion event
  58335. */
  58336. class PhysicsRadialExplosionEvent {
  58337. private _scene;
  58338. private _options;
  58339. private _sphere;
  58340. private _dataFetched;
  58341. /**
  58342. * Initializes a radial explosioin event
  58343. * @param _scene BabylonJS scene
  58344. * @param _options The options for the vortex event
  58345. */
  58346. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58347. /**
  58348. * Returns the data related to the radial explosion event (sphere).
  58349. * @returns The radial explosion event data
  58350. */
  58351. getData(): PhysicsRadialExplosionEventData;
  58352. /**
  58353. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58354. * @param impostor A physics imposter
  58355. * @param origin the origin of the explosion
  58356. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58357. */
  58358. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58359. /**
  58360. * Triggers affecterd impostors callbacks
  58361. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58362. */
  58363. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58364. /**
  58365. * Disposes the sphere.
  58366. * @param force Specifies if the sphere should be disposed by force
  58367. */
  58368. dispose(force?: boolean): void;
  58369. /*** Helpers ***/
  58370. private _prepareSphere;
  58371. private _intersectsWithSphere;
  58372. }
  58373. /**
  58374. * Represents a gravitational field event
  58375. */
  58376. class PhysicsGravitationalFieldEvent {
  58377. private _physicsHelper;
  58378. private _scene;
  58379. private _origin;
  58380. private _options;
  58381. private _tickCallback;
  58382. private _sphere;
  58383. private _dataFetched;
  58384. /**
  58385. * Initializes the physics gravitational field event
  58386. * @param _physicsHelper A physics helper
  58387. * @param _scene BabylonJS scene
  58388. * @param _origin The origin position of the gravitational field event
  58389. * @param _options The options for the vortex event
  58390. */
  58391. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58392. /**
  58393. * Returns the data related to the gravitational field event (sphere).
  58394. * @returns A gravitational field event
  58395. */
  58396. getData(): PhysicsGravitationalFieldEventData;
  58397. /**
  58398. * Enables the gravitational field.
  58399. */
  58400. enable(): void;
  58401. /**
  58402. * Disables the gravitational field.
  58403. */
  58404. disable(): void;
  58405. /**
  58406. * Disposes the sphere.
  58407. * @param force The force to dispose from the gravitational field event
  58408. */
  58409. dispose(force?: boolean): void;
  58410. private _tick;
  58411. }
  58412. /**
  58413. * Represents a physics updraft event
  58414. */
  58415. class PhysicsUpdraftEvent {
  58416. private _scene;
  58417. private _origin;
  58418. private _options;
  58419. private _physicsEngine;
  58420. private _originTop;
  58421. private _originDirection;
  58422. private _tickCallback;
  58423. private _cylinder;
  58424. private _cylinderPosition;
  58425. private _dataFetched;
  58426. /**
  58427. * Initializes the physics updraft event
  58428. * @param _scene BabylonJS scene
  58429. * @param _origin The origin position of the updraft
  58430. * @param _options The options for the updraft event
  58431. */
  58432. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58433. /**
  58434. * Returns the data related to the updraft event (cylinder).
  58435. * @returns A physics updraft event
  58436. */
  58437. getData(): PhysicsUpdraftEventData;
  58438. /**
  58439. * Enables the updraft.
  58440. */
  58441. enable(): void;
  58442. /**
  58443. * Disables the updraft.
  58444. */
  58445. disable(): void;
  58446. /**
  58447. * Disposes the cylinder.
  58448. * @param force Specifies if the updraft should be disposed by force
  58449. */
  58450. dispose(force?: boolean): void;
  58451. private getImpostorHitData;
  58452. private _tick;
  58453. /*** Helpers ***/
  58454. private _prepareCylinder;
  58455. private _intersectsWithCylinder;
  58456. }
  58457. /**
  58458. * Represents a physics vortex event
  58459. */
  58460. class PhysicsVortexEvent {
  58461. private _scene;
  58462. private _origin;
  58463. private _options;
  58464. private _physicsEngine;
  58465. private _originTop;
  58466. private _tickCallback;
  58467. private _cylinder;
  58468. private _cylinderPosition;
  58469. private _dataFetched;
  58470. /**
  58471. * Initializes the physics vortex event
  58472. * @param _scene The BabylonJS scene
  58473. * @param _origin The origin position of the vortex
  58474. * @param _options The options for the vortex event
  58475. */
  58476. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58477. /**
  58478. * Returns the data related to the vortex event (cylinder).
  58479. * @returns The physics vortex event data
  58480. */
  58481. getData(): PhysicsVortexEventData;
  58482. /**
  58483. * Enables the vortex.
  58484. */
  58485. enable(): void;
  58486. /**
  58487. * Disables the cortex.
  58488. */
  58489. disable(): void;
  58490. /**
  58491. * Disposes the sphere.
  58492. * @param force
  58493. */
  58494. dispose(force?: boolean): void;
  58495. private getImpostorHitData;
  58496. private _tick;
  58497. /*** Helpers ***/
  58498. private _prepareCylinder;
  58499. private _intersectsWithCylinder;
  58500. }
  58501. /**
  58502. * Options fot the radial explosion event
  58503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58504. */
  58505. export class PhysicsRadialExplosionEventOptions {
  58506. /**
  58507. * The radius of the sphere for the radial explosion.
  58508. */
  58509. radius: number;
  58510. /**
  58511. * The strenth of the explosion.
  58512. */
  58513. strength: number;
  58514. /**
  58515. * The strenght of the force in correspondence to the distance of the affected object
  58516. */
  58517. falloff: PhysicsRadialImpulseFalloff;
  58518. /**
  58519. * Sphere options for the radial explosion.
  58520. */
  58521. sphere: {
  58522. segments: number;
  58523. diameter: number;
  58524. };
  58525. /**
  58526. * Sphere options for the radial explosion.
  58527. */
  58528. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58529. }
  58530. /**
  58531. * Options fot the updraft event
  58532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58533. */
  58534. export class PhysicsUpdraftEventOptions {
  58535. /**
  58536. * The radius of the cylinder for the vortex
  58537. */
  58538. radius: number;
  58539. /**
  58540. * The strenth of the updraft.
  58541. */
  58542. strength: number;
  58543. /**
  58544. * The height of the cylinder for the updraft.
  58545. */
  58546. height: number;
  58547. /**
  58548. * The mode for the the updraft.
  58549. */
  58550. updraftMode: PhysicsUpdraftMode;
  58551. }
  58552. /**
  58553. * Options fot the vortex event
  58554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58555. */
  58556. export class PhysicsVortexEventOptions {
  58557. /**
  58558. * The radius of the cylinder for the vortex
  58559. */
  58560. radius: number;
  58561. /**
  58562. * The strenth of the vortex.
  58563. */
  58564. strength: number;
  58565. /**
  58566. * The height of the cylinder for the vortex.
  58567. */
  58568. height: number;
  58569. /**
  58570. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58571. */
  58572. centripetalForceThreshold: number;
  58573. /**
  58574. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58575. */
  58576. centripetalForceMultiplier: number;
  58577. /**
  58578. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58579. */
  58580. centrifugalForceMultiplier: number;
  58581. /**
  58582. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58583. */
  58584. updraftForceMultiplier: number;
  58585. }
  58586. /**
  58587. * The strenght of the force in correspondence to the distance of the affected object
  58588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58589. */
  58590. export enum PhysicsRadialImpulseFalloff {
  58591. /** Defines that impulse is constant in strength across it's whole radius */
  58592. Constant = 0,
  58593. /** Defines that impulse gets weaker if it's further from the origin */
  58594. Linear = 1
  58595. }
  58596. /**
  58597. * The strength of the force in correspondence to the distance of the affected object
  58598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58599. */
  58600. export enum PhysicsUpdraftMode {
  58601. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58602. Center = 0,
  58603. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58604. Perpendicular = 1
  58605. }
  58606. /**
  58607. * Interface for a physics hit data
  58608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58609. */
  58610. export interface PhysicsHitData {
  58611. /**
  58612. * The force applied at the contact point
  58613. */
  58614. force: Vector3;
  58615. /**
  58616. * The contact point
  58617. */
  58618. contactPoint: Vector3;
  58619. /**
  58620. * The distance from the origin to the contact point
  58621. */
  58622. distanceFromOrigin: number;
  58623. }
  58624. /**
  58625. * Interface for radial explosion event data
  58626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58627. */
  58628. export interface PhysicsRadialExplosionEventData {
  58629. /**
  58630. * A sphere used for the radial explosion event
  58631. */
  58632. sphere: Mesh;
  58633. }
  58634. /**
  58635. * Interface for gravitational field event data
  58636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58637. */
  58638. export interface PhysicsGravitationalFieldEventData {
  58639. /**
  58640. * A sphere mesh used for the gravitational field event
  58641. */
  58642. sphere: Mesh;
  58643. }
  58644. /**
  58645. * Interface for updraft event data
  58646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58647. */
  58648. export interface PhysicsUpdraftEventData {
  58649. /**
  58650. * A cylinder used for the updraft event
  58651. */
  58652. cylinder: Mesh;
  58653. }
  58654. /**
  58655. * Interface for vortex event data
  58656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58657. */
  58658. export interface PhysicsVortexEventData {
  58659. /**
  58660. * A cylinder used for the vortex event
  58661. */
  58662. cylinder: Mesh;
  58663. }
  58664. /**
  58665. * Interface for an affected physics impostor
  58666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58667. */
  58668. export interface PhysicsAffectedImpostorWithData {
  58669. /**
  58670. * The impostor affected by the effect
  58671. */
  58672. impostor: PhysicsImpostor;
  58673. /**
  58674. * The data about the hit/horce from the explosion
  58675. */
  58676. hitData: PhysicsHitData;
  58677. }
  58678. }
  58679. declare module BABYLON {
  58680. /** @hidden */
  58681. export var blackAndWhitePixelShader: {
  58682. name: string;
  58683. shader: string;
  58684. };
  58685. }
  58686. declare module BABYLON {
  58687. /**
  58688. * Post process used to render in black and white
  58689. */
  58690. export class BlackAndWhitePostProcess extends PostProcess {
  58691. /**
  58692. * Linear about to convert he result to black and white (default: 1)
  58693. */
  58694. degree: number;
  58695. /**
  58696. * Creates a black and white post process
  58697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58698. * @param name The name of the effect.
  58699. * @param options The required width/height ratio to downsize to before computing the render pass.
  58700. * @param camera The camera to apply the render pass to.
  58701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58702. * @param engine The engine which the post process will be applied. (default: current engine)
  58703. * @param reusable If the post process can be reused on the same frame. (default: false)
  58704. */
  58705. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58706. }
  58707. }
  58708. declare module BABYLON {
  58709. /**
  58710. * This represents a set of one or more post processes in Babylon.
  58711. * A post process can be used to apply a shader to a texture after it is rendered.
  58712. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58713. */
  58714. export class PostProcessRenderEffect {
  58715. private _postProcesses;
  58716. private _getPostProcesses;
  58717. private _singleInstance;
  58718. private _cameras;
  58719. private _indicesForCamera;
  58720. /**
  58721. * Name of the effect
  58722. * @hidden
  58723. */
  58724. _name: string;
  58725. /**
  58726. * Instantiates a post process render effect.
  58727. * A post process can be used to apply a shader to a texture after it is rendered.
  58728. * @param engine The engine the effect is tied to
  58729. * @param name The name of the effect
  58730. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58731. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58732. */
  58733. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58734. /**
  58735. * Checks if all the post processes in the effect are supported.
  58736. */
  58737. readonly isSupported: boolean;
  58738. /**
  58739. * Updates the current state of the effect
  58740. * @hidden
  58741. */
  58742. _update(): void;
  58743. /**
  58744. * Attaches the effect on cameras
  58745. * @param cameras The camera to attach to.
  58746. * @hidden
  58747. */
  58748. _attachCameras(cameras: Camera): void;
  58749. /**
  58750. * Attaches the effect on cameras
  58751. * @param cameras The camera to attach to.
  58752. * @hidden
  58753. */
  58754. _attachCameras(cameras: Camera[]): void;
  58755. /**
  58756. * Detaches the effect on cameras
  58757. * @param cameras The camera to detatch from.
  58758. * @hidden
  58759. */
  58760. _detachCameras(cameras: Camera): void;
  58761. /**
  58762. * Detatches the effect on cameras
  58763. * @param cameras The camera to detatch from.
  58764. * @hidden
  58765. */
  58766. _detachCameras(cameras: Camera[]): void;
  58767. /**
  58768. * Enables the effect on given cameras
  58769. * @param cameras The camera to enable.
  58770. * @hidden
  58771. */
  58772. _enable(cameras: Camera): void;
  58773. /**
  58774. * Enables the effect on given cameras
  58775. * @param cameras The camera to enable.
  58776. * @hidden
  58777. */
  58778. _enable(cameras: Nullable<Camera[]>): void;
  58779. /**
  58780. * Disables the effect on the given cameras
  58781. * @param cameras The camera to disable.
  58782. * @hidden
  58783. */
  58784. _disable(cameras: Camera): void;
  58785. /**
  58786. * Disables the effect on the given cameras
  58787. * @param cameras The camera to disable.
  58788. * @hidden
  58789. */
  58790. _disable(cameras: Nullable<Camera[]>): void;
  58791. /**
  58792. * Gets a list of the post processes contained in the effect.
  58793. * @param camera The camera to get the post processes on.
  58794. * @returns The list of the post processes in the effect.
  58795. */
  58796. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58797. }
  58798. }
  58799. declare module BABYLON {
  58800. /** @hidden */
  58801. export var extractHighlightsPixelShader: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module BABYLON {
  58807. /**
  58808. * 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.
  58809. */
  58810. export class ExtractHighlightsPostProcess extends PostProcess {
  58811. /**
  58812. * The luminance threshold, pixels below this value will be set to black.
  58813. */
  58814. threshold: number;
  58815. /** @hidden */
  58816. _exposure: number;
  58817. /**
  58818. * Post process which has the input texture to be used when performing highlight extraction
  58819. * @hidden
  58820. */
  58821. _inputPostProcess: Nullable<PostProcess>;
  58822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58823. }
  58824. }
  58825. declare module BABYLON {
  58826. /** @hidden */
  58827. export var bloomMergePixelShader: {
  58828. name: string;
  58829. shader: string;
  58830. };
  58831. }
  58832. declare module BABYLON {
  58833. /**
  58834. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58835. */
  58836. export class BloomMergePostProcess extends PostProcess {
  58837. /** Weight of the bloom to be added to the original input. */
  58838. weight: number;
  58839. /**
  58840. * Creates a new instance of @see BloomMergePostProcess
  58841. * @param name The name of the effect.
  58842. * @param originalFromInput Post process which's input will be used for the merge.
  58843. * @param blurred Blurred highlights post process which's output will be used.
  58844. * @param weight Weight of the bloom to be added to the original input.
  58845. * @param options The required width/height ratio to downsize to before computing the render pass.
  58846. * @param camera The camera to apply the render pass to.
  58847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58848. * @param engine The engine which the post process will be applied. (default: current engine)
  58849. * @param reusable If the post process can be reused on the same frame. (default: false)
  58850. * @param textureType Type of textures used when performing the post process. (default: 0)
  58851. * @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)
  58852. */
  58853. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58854. /** Weight of the bloom to be added to the original input. */
  58855. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /**
  58860. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58861. */
  58862. export class BloomEffect extends PostProcessRenderEffect {
  58863. private bloomScale;
  58864. /**
  58865. * @hidden Internal
  58866. */
  58867. _effects: Array<PostProcess>;
  58868. /**
  58869. * @hidden Internal
  58870. */
  58871. _downscale: ExtractHighlightsPostProcess;
  58872. private _blurX;
  58873. private _blurY;
  58874. private _merge;
  58875. /**
  58876. * The luminance threshold to find bright areas of the image to bloom.
  58877. */
  58878. threshold: number;
  58879. /**
  58880. * The strength of the bloom.
  58881. */
  58882. weight: number;
  58883. /**
  58884. * Specifies the size of the bloom blur kernel, relative to the final output size
  58885. */
  58886. kernel: number;
  58887. /**
  58888. * Creates a new instance of @see BloomEffect
  58889. * @param scene The scene the effect belongs to.
  58890. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58891. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58892. * @param bloomWeight The the strength of bloom.
  58893. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58894. * @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)
  58895. */
  58896. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58897. /**
  58898. * Disposes each of the internal effects for a given camera.
  58899. * @param camera The camera to dispose the effect on.
  58900. */
  58901. disposeEffects(camera: Camera): void;
  58902. /**
  58903. * @hidden Internal
  58904. */
  58905. _updateEffects(): void;
  58906. /**
  58907. * Internal
  58908. * @returns if all the contained post processes are ready.
  58909. * @hidden
  58910. */
  58911. _isReady(): boolean;
  58912. }
  58913. }
  58914. declare module BABYLON {
  58915. /** @hidden */
  58916. export var chromaticAberrationPixelShader: {
  58917. name: string;
  58918. shader: string;
  58919. };
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58924. */
  58925. export class ChromaticAberrationPostProcess extends PostProcess {
  58926. /**
  58927. * The amount of seperation of rgb channels (default: 30)
  58928. */
  58929. aberrationAmount: number;
  58930. /**
  58931. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58932. */
  58933. radialIntensity: number;
  58934. /**
  58935. * 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))
  58936. */
  58937. direction: Vector2;
  58938. /**
  58939. * 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))
  58940. */
  58941. centerPosition: Vector2;
  58942. /**
  58943. * Creates a new instance ChromaticAberrationPostProcess
  58944. * @param name The name of the effect.
  58945. * @param screenWidth The width of the screen to apply the effect on.
  58946. * @param screenHeight The height of the screen to apply the effect on.
  58947. * @param options The required width/height ratio to downsize to before computing the render pass.
  58948. * @param camera The camera to apply the render pass to.
  58949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58950. * @param engine The engine which the post process will be applied. (default: current engine)
  58951. * @param reusable If the post process can be reused on the same frame. (default: false)
  58952. * @param textureType Type of textures used when performing the post process. (default: 0)
  58953. * @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)
  58954. */
  58955. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58956. }
  58957. }
  58958. declare module BABYLON {
  58959. /** @hidden */
  58960. export var circleOfConfusionPixelShader: {
  58961. name: string;
  58962. shader: string;
  58963. };
  58964. }
  58965. declare module BABYLON {
  58966. /**
  58967. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58968. */
  58969. export class CircleOfConfusionPostProcess extends PostProcess {
  58970. /**
  58971. * 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.
  58972. */
  58973. lensSize: number;
  58974. /**
  58975. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58976. */
  58977. fStop: number;
  58978. /**
  58979. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58980. */
  58981. focusDistance: number;
  58982. /**
  58983. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58984. */
  58985. focalLength: number;
  58986. private _depthTexture;
  58987. /**
  58988. * Creates a new instance CircleOfConfusionPostProcess
  58989. * @param name The name of the effect.
  58990. * @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.
  58991. * @param options The required width/height ratio to downsize to before computing the render pass.
  58992. * @param camera The camera to apply the render pass to.
  58993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58994. * @param engine The engine which the post process will be applied. (default: current engine)
  58995. * @param reusable If the post process can be reused on the same frame. (default: false)
  58996. * @param textureType Type of textures used when performing the post process. (default: 0)
  58997. * @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)
  58998. */
  58999. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59000. /**
  59001. * 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.
  59002. */
  59003. depthTexture: RenderTargetTexture;
  59004. }
  59005. }
  59006. declare module BABYLON {
  59007. /** @hidden */
  59008. export var colorCorrectionPixelShader: {
  59009. name: string;
  59010. shader: string;
  59011. };
  59012. }
  59013. declare module BABYLON {
  59014. /**
  59015. *
  59016. * This post-process allows the modification of rendered colors by using
  59017. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59018. *
  59019. * The object needs to be provided an url to a texture containing the color
  59020. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59021. * Use an image editing software to tweak the LUT to match your needs.
  59022. *
  59023. * For an example of a color LUT, see here:
  59024. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59025. * For explanations on color grading, see here:
  59026. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59027. *
  59028. */
  59029. export class ColorCorrectionPostProcess extends PostProcess {
  59030. private _colorTableTexture;
  59031. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59032. }
  59033. }
  59034. declare module BABYLON {
  59035. /** @hidden */
  59036. export var convolutionPixelShader: {
  59037. name: string;
  59038. shader: string;
  59039. };
  59040. }
  59041. declare module BABYLON {
  59042. /**
  59043. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59044. * input texture to perform effects such as edge detection or sharpening
  59045. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59046. */
  59047. export class ConvolutionPostProcess extends PostProcess {
  59048. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59049. kernel: number[];
  59050. /**
  59051. * Creates a new instance ConvolutionPostProcess
  59052. * @param name The name of the effect.
  59053. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59054. * @param options The required width/height ratio to downsize to before computing the render pass.
  59055. * @param camera The camera to apply the render pass to.
  59056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59057. * @param engine The engine which the post process will be applied. (default: current engine)
  59058. * @param reusable If the post process can be reused on the same frame. (default: false)
  59059. * @param textureType Type of textures used when performing the post process. (default: 0)
  59060. */
  59061. constructor(name: string,
  59062. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59063. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59064. /**
  59065. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59066. */
  59067. static EdgeDetect0Kernel: number[];
  59068. /**
  59069. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59070. */
  59071. static EdgeDetect1Kernel: number[];
  59072. /**
  59073. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59074. */
  59075. static EdgeDetect2Kernel: number[];
  59076. /**
  59077. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59078. */
  59079. static SharpenKernel: number[];
  59080. /**
  59081. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59082. */
  59083. static EmbossKernel: number[];
  59084. /**
  59085. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59086. */
  59087. static GaussianKernel: number[];
  59088. }
  59089. }
  59090. declare module BABYLON {
  59091. /**
  59092. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59093. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59094. * based on samples that have a large difference in distance than the center pixel.
  59095. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59096. */
  59097. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59098. direction: Vector2;
  59099. /**
  59100. * Creates a new instance CircleOfConfusionPostProcess
  59101. * @param name The name of the effect.
  59102. * @param scene The scene the effect belongs to.
  59103. * @param direction The direction the blur should be applied.
  59104. * @param kernel The size of the kernel used to blur.
  59105. * @param options The required width/height ratio to downsize to before computing the render pass.
  59106. * @param camera The camera to apply the render pass to.
  59107. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59108. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59110. * @param engine The engine which the post process will be applied. (default: current engine)
  59111. * @param reusable If the post process can be reused on the same frame. (default: false)
  59112. * @param textureType Type of textures used when performing the post process. (default: 0)
  59113. * @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)
  59114. */
  59115. 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);
  59116. }
  59117. }
  59118. declare module BABYLON {
  59119. /** @hidden */
  59120. export var depthOfFieldMergePixelShader: {
  59121. name: string;
  59122. shader: string;
  59123. };
  59124. }
  59125. declare module BABYLON {
  59126. /**
  59127. * Options to be set when merging outputs from the default pipeline.
  59128. */
  59129. export class DepthOfFieldMergePostProcessOptions {
  59130. /**
  59131. * The original image to merge on top of
  59132. */
  59133. originalFromInput: PostProcess;
  59134. /**
  59135. * Parameters to perform the merge of the depth of field effect
  59136. */
  59137. depthOfField?: {
  59138. circleOfConfusion: PostProcess;
  59139. blurSteps: Array<PostProcess>;
  59140. };
  59141. /**
  59142. * Parameters to perform the merge of bloom effect
  59143. */
  59144. bloom?: {
  59145. blurred: PostProcess;
  59146. weight: number;
  59147. };
  59148. }
  59149. /**
  59150. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59151. */
  59152. export class DepthOfFieldMergePostProcess extends PostProcess {
  59153. private blurSteps;
  59154. /**
  59155. * Creates a new instance of DepthOfFieldMergePostProcess
  59156. * @param name The name of the effect.
  59157. * @param originalFromInput Post process which's input will be used for the merge.
  59158. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59159. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59160. * @param options The required width/height ratio to downsize to before computing the render pass.
  59161. * @param camera The camera to apply the render pass to.
  59162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59163. * @param engine The engine which the post process will be applied. (default: current engine)
  59164. * @param reusable If the post process can be reused on the same frame. (default: false)
  59165. * @param textureType Type of textures used when performing the post process. (default: 0)
  59166. * @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)
  59167. */
  59168. 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);
  59169. /**
  59170. * Updates the effect with the current post process compile time values and recompiles the shader.
  59171. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59172. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59173. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59174. * @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
  59175. * @param onCompiled Called when the shader has been compiled.
  59176. * @param onError Called if there is an error when compiling a shader.
  59177. */
  59178. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59179. }
  59180. }
  59181. declare module BABYLON {
  59182. /**
  59183. * Specifies the level of max blur that should be applied when using the depth of field effect
  59184. */
  59185. export enum DepthOfFieldEffectBlurLevel {
  59186. /**
  59187. * Subtle blur
  59188. */
  59189. Low = 0,
  59190. /**
  59191. * Medium blur
  59192. */
  59193. Medium = 1,
  59194. /**
  59195. * Large blur
  59196. */
  59197. High = 2
  59198. }
  59199. /**
  59200. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59201. */
  59202. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59203. private _circleOfConfusion;
  59204. /**
  59205. * @hidden Internal, blurs from high to low
  59206. */
  59207. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59208. private _depthOfFieldBlurY;
  59209. private _dofMerge;
  59210. /**
  59211. * @hidden Internal post processes in depth of field effect
  59212. */
  59213. _effects: Array<PostProcess>;
  59214. /**
  59215. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59216. */
  59217. focalLength: number;
  59218. /**
  59219. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59220. */
  59221. fStop: number;
  59222. /**
  59223. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59224. */
  59225. focusDistance: number;
  59226. /**
  59227. * 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.
  59228. */
  59229. lensSize: number;
  59230. /**
  59231. * Creates a new instance DepthOfFieldEffect
  59232. * @param scene The scene the effect belongs to.
  59233. * @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.
  59234. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59235. * @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)
  59236. */
  59237. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59238. /**
  59239. * Get the current class name of the current effet
  59240. * @returns "DepthOfFieldEffect"
  59241. */
  59242. getClassName(): string;
  59243. /**
  59244. * 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.
  59245. */
  59246. depthTexture: RenderTargetTexture;
  59247. /**
  59248. * Disposes each of the internal effects for a given camera.
  59249. * @param camera The camera to dispose the effect on.
  59250. */
  59251. disposeEffects(camera: Camera): void;
  59252. /**
  59253. * @hidden Internal
  59254. */
  59255. _updateEffects(): void;
  59256. /**
  59257. * Internal
  59258. * @returns if all the contained post processes are ready.
  59259. * @hidden
  59260. */
  59261. _isReady(): boolean;
  59262. }
  59263. }
  59264. declare module BABYLON {
  59265. /** @hidden */
  59266. export var displayPassPixelShader: {
  59267. name: string;
  59268. shader: string;
  59269. };
  59270. }
  59271. declare module BABYLON {
  59272. /**
  59273. * DisplayPassPostProcess which produces an output the same as it's input
  59274. */
  59275. export class DisplayPassPostProcess extends PostProcess {
  59276. /**
  59277. * Creates the DisplayPassPostProcess
  59278. * @param name The name of the effect.
  59279. * @param options The required width/height ratio to downsize to before computing the render pass.
  59280. * @param camera The camera to apply the render pass to.
  59281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59282. * @param engine The engine which the post process will be applied. (default: current engine)
  59283. * @param reusable If the post process can be reused on the same frame. (default: false)
  59284. */
  59285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /** @hidden */
  59290. export var filterPixelShader: {
  59291. name: string;
  59292. shader: string;
  59293. };
  59294. }
  59295. declare module BABYLON {
  59296. /**
  59297. * Applies a kernel filter to the image
  59298. */
  59299. export class FilterPostProcess extends PostProcess {
  59300. /** The matrix to be applied to the image */
  59301. kernelMatrix: Matrix;
  59302. /**
  59303. *
  59304. * @param name The name of the effect.
  59305. * @param kernelMatrix The matrix to be applied to the image
  59306. * @param options The required width/height ratio to downsize to before computing the render pass.
  59307. * @param camera The camera to apply the render pass to.
  59308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59309. * @param engine The engine which the post process will be applied. (default: current engine)
  59310. * @param reusable If the post process can be reused on the same frame. (default: false)
  59311. */
  59312. constructor(name: string,
  59313. /** The matrix to be applied to the image */
  59314. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59315. }
  59316. }
  59317. declare module BABYLON {
  59318. /** @hidden */
  59319. export var fxaaPixelShader: {
  59320. name: string;
  59321. shader: string;
  59322. };
  59323. }
  59324. declare module BABYLON {
  59325. /** @hidden */
  59326. export var fxaaVertexShader: {
  59327. name: string;
  59328. shader: string;
  59329. };
  59330. }
  59331. declare module BABYLON {
  59332. /**
  59333. * Fxaa post process
  59334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59335. */
  59336. export class FxaaPostProcess extends PostProcess {
  59337. /** @hidden */
  59338. texelWidth: number;
  59339. /** @hidden */
  59340. texelHeight: number;
  59341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59342. private _getDefines;
  59343. }
  59344. }
  59345. declare module BABYLON {
  59346. /** @hidden */
  59347. export var grainPixelShader: {
  59348. name: string;
  59349. shader: string;
  59350. };
  59351. }
  59352. declare module BABYLON {
  59353. /**
  59354. * The GrainPostProcess adds noise to the image at mid luminance levels
  59355. */
  59356. export class GrainPostProcess extends PostProcess {
  59357. /**
  59358. * The intensity of the grain added (default: 30)
  59359. */
  59360. intensity: number;
  59361. /**
  59362. * If the grain should be randomized on every frame
  59363. */
  59364. animated: boolean;
  59365. /**
  59366. * Creates a new instance of @see GrainPostProcess
  59367. * @param name The name of the effect.
  59368. * @param options The required width/height ratio to downsize to before computing the render pass.
  59369. * @param camera The camera to apply the render pass to.
  59370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59371. * @param engine The engine which the post process will be applied. (default: current engine)
  59372. * @param reusable If the post process can be reused on the same frame. (default: false)
  59373. * @param textureType Type of textures used when performing the post process. (default: 0)
  59374. * @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)
  59375. */
  59376. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /** @hidden */
  59381. export var highlightsPixelShader: {
  59382. name: string;
  59383. shader: string;
  59384. };
  59385. }
  59386. declare module BABYLON {
  59387. /**
  59388. * Extracts highlights from the image
  59389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59390. */
  59391. export class HighlightsPostProcess extends PostProcess {
  59392. /**
  59393. * Extracts highlights from the image
  59394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59395. * @param name The name of the effect.
  59396. * @param options The required width/height ratio to downsize to before computing the render pass.
  59397. * @param camera The camera to apply the render pass to.
  59398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59399. * @param engine The engine which the post process will be applied. (default: current engine)
  59400. * @param reusable If the post process can be reused on the same frame. (default: false)
  59401. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59402. */
  59403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /** @hidden */
  59408. export var mrtFragmentDeclaration: {
  59409. name: string;
  59410. shader: string;
  59411. };
  59412. }
  59413. declare module BABYLON {
  59414. /** @hidden */
  59415. export var geometryPixelShader: {
  59416. name: string;
  59417. shader: string;
  59418. };
  59419. }
  59420. declare module BABYLON {
  59421. /** @hidden */
  59422. export var geometryVertexShader: {
  59423. name: string;
  59424. shader: string;
  59425. };
  59426. }
  59427. declare module BABYLON {
  59428. /** @hidden */
  59429. interface ISavedTransformationMatrix {
  59430. world: Matrix;
  59431. viewProjection: Matrix;
  59432. }
  59433. /**
  59434. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59435. */
  59436. export class GeometryBufferRenderer {
  59437. /**
  59438. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59439. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59440. */
  59441. static readonly POSITION_TEXTURE_TYPE: number;
  59442. /**
  59443. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59444. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59445. */
  59446. static readonly VELOCITY_TEXTURE_TYPE: number;
  59447. /**
  59448. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59449. * in order to compute objects velocities when enableVelocity is set to "true"
  59450. * @hidden
  59451. */
  59452. _previousTransformationMatrices: {
  59453. [index: number]: ISavedTransformationMatrix;
  59454. };
  59455. /**
  59456. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59457. * in order to compute objects velocities when enableVelocity is set to "true"
  59458. * @hidden
  59459. */
  59460. _previousBonesTransformationMatrices: {
  59461. [index: number]: Float32Array;
  59462. };
  59463. /**
  59464. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59465. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59466. */
  59467. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59468. private _scene;
  59469. private _multiRenderTarget;
  59470. private _ratio;
  59471. private _enablePosition;
  59472. private _enableVelocity;
  59473. private _positionIndex;
  59474. private _velocityIndex;
  59475. protected _effect: Effect;
  59476. protected _cachedDefines: string;
  59477. /**
  59478. * Set the render list (meshes to be rendered) used in the G buffer.
  59479. */
  59480. renderList: Mesh[];
  59481. /**
  59482. * Gets wether or not G buffer are supported by the running hardware.
  59483. * This requires draw buffer supports
  59484. */
  59485. readonly isSupported: boolean;
  59486. /**
  59487. * Returns the index of the given texture type in the G-Buffer textures array
  59488. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59489. * @returns the index of the given texture type in the G-Buffer textures array
  59490. */
  59491. getTextureIndex(textureType: number): number;
  59492. /**
  59493. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59494. */
  59495. /**
  59496. * Sets whether or not objects positions are enabled for the G buffer.
  59497. */
  59498. enablePosition: boolean;
  59499. /**
  59500. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59501. */
  59502. /**
  59503. * Sets wether or not objects velocities are enabled for the G buffer.
  59504. */
  59505. enableVelocity: boolean;
  59506. /**
  59507. * Gets the scene associated with the buffer.
  59508. */
  59509. readonly scene: Scene;
  59510. /**
  59511. * Gets the ratio used by the buffer during its creation.
  59512. * How big is the buffer related to the main canvas.
  59513. */
  59514. readonly ratio: number;
  59515. /** @hidden */
  59516. static _SceneComponentInitialization: (scene: Scene) => void;
  59517. /**
  59518. * Creates a new G Buffer for the scene
  59519. * @param scene The scene the buffer belongs to
  59520. * @param ratio How big is the buffer related to the main canvas.
  59521. */
  59522. constructor(scene: Scene, ratio?: number);
  59523. /**
  59524. * Checks wether everything is ready to render a submesh to the G buffer.
  59525. * @param subMesh the submesh to check readiness for
  59526. * @param useInstances is the mesh drawn using instance or not
  59527. * @returns true if ready otherwise false
  59528. */
  59529. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59530. /**
  59531. * Gets the current underlying G Buffer.
  59532. * @returns the buffer
  59533. */
  59534. getGBuffer(): MultiRenderTarget;
  59535. /**
  59536. * Gets the number of samples used to render the buffer (anti aliasing).
  59537. */
  59538. /**
  59539. * Sets the number of samples used to render the buffer (anti aliasing).
  59540. */
  59541. samples: number;
  59542. /**
  59543. * Disposes the renderer and frees up associated resources.
  59544. */
  59545. dispose(): void;
  59546. protected _createRenderTargets(): void;
  59547. private _copyBonesTransformationMatrices;
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. interface Scene {
  59552. /** @hidden (Backing field) */
  59553. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59554. /**
  59555. * Gets or Sets the current geometry buffer associated to the scene.
  59556. */
  59557. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59558. /**
  59559. * Enables a GeometryBufferRender and associates it with the scene
  59560. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59561. * @returns the GeometryBufferRenderer
  59562. */
  59563. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59564. /**
  59565. * Disables the GeometryBufferRender associated with the scene
  59566. */
  59567. disableGeometryBufferRenderer(): void;
  59568. }
  59569. /**
  59570. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59571. * in several rendering techniques.
  59572. */
  59573. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59574. /**
  59575. * The component name helpful to identify the component in the list of scene components.
  59576. */
  59577. readonly name: string;
  59578. /**
  59579. * The scene the component belongs to.
  59580. */
  59581. scene: Scene;
  59582. /**
  59583. * Creates a new instance of the component for the given scene
  59584. * @param scene Defines the scene to register the component in
  59585. */
  59586. constructor(scene: Scene);
  59587. /**
  59588. * Registers the component in a given scene
  59589. */
  59590. register(): void;
  59591. /**
  59592. * Rebuilds the elements related to this component in case of
  59593. * context lost for instance.
  59594. */
  59595. rebuild(): void;
  59596. /**
  59597. * Disposes the component and the associated ressources
  59598. */
  59599. dispose(): void;
  59600. private _gatherRenderTargets;
  59601. }
  59602. }
  59603. declare module BABYLON {
  59604. /** @hidden */
  59605. export var motionBlurPixelShader: {
  59606. name: string;
  59607. shader: string;
  59608. };
  59609. }
  59610. declare module BABYLON {
  59611. /**
  59612. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59613. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59614. * As an example, all you have to do is to create the post-process:
  59615. * var mb = new BABYLON.MotionBlurPostProcess(
  59616. * 'mb', // The name of the effect.
  59617. * scene, // The scene containing the objects to blur according to their velocity.
  59618. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59619. * camera // The camera to apply the render pass to.
  59620. * );
  59621. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59622. */
  59623. export class MotionBlurPostProcess extends PostProcess {
  59624. /**
  59625. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59626. */
  59627. motionStrength: number;
  59628. /**
  59629. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59630. */
  59631. /**
  59632. * Sets the number of iterations to be used for motion blur quality
  59633. */
  59634. motionBlurSamples: number;
  59635. private _motionBlurSamples;
  59636. private _geometryBufferRenderer;
  59637. /**
  59638. * Creates a new instance MotionBlurPostProcess
  59639. * @param name The name of the effect.
  59640. * @param scene The scene containing the objects to blur according to their velocity.
  59641. * @param options The required width/height ratio to downsize to before computing the render pass.
  59642. * @param camera The camera to apply the render pass to.
  59643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59644. * @param engine The engine which the post process will be applied. (default: current engine)
  59645. * @param reusable If the post process can be reused on the same frame. (default: false)
  59646. * @param textureType Type of textures used when performing the post process. (default: 0)
  59647. * @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)
  59648. */
  59649. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59650. /**
  59651. * Excludes the given skinned mesh from computing bones velocities.
  59652. * 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.
  59653. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59654. */
  59655. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59656. /**
  59657. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59658. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59659. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59660. */
  59661. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59662. /**
  59663. * Disposes the post process.
  59664. * @param camera The camera to dispose the post process on.
  59665. */
  59666. dispose(camera?: Camera): void;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /** @hidden */
  59671. export var refractionPixelShader: {
  59672. name: string;
  59673. shader: string;
  59674. };
  59675. }
  59676. declare module BABYLON {
  59677. /**
  59678. * Post process which applies a refractin texture
  59679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59680. */
  59681. export class RefractionPostProcess extends PostProcess {
  59682. /** the base color of the refraction (used to taint the rendering) */
  59683. color: Color3;
  59684. /** simulated refraction depth */
  59685. depth: number;
  59686. /** the coefficient of the base color (0 to remove base color tainting) */
  59687. colorLevel: number;
  59688. private _refTexture;
  59689. private _ownRefractionTexture;
  59690. /**
  59691. * Gets or sets the refraction texture
  59692. * Please note that you are responsible for disposing the texture if you set it manually
  59693. */
  59694. refractionTexture: Texture;
  59695. /**
  59696. * Initializes the RefractionPostProcess
  59697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59698. * @param name The name of the effect.
  59699. * @param refractionTextureUrl Url of the refraction texture to use
  59700. * @param color the base color of the refraction (used to taint the rendering)
  59701. * @param depth simulated refraction depth
  59702. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59703. * @param camera The camera to apply the render pass to.
  59704. * @param options The required width/height ratio to downsize to before computing the render pass.
  59705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59706. * @param engine The engine which the post process will be applied. (default: current engine)
  59707. * @param reusable If the post process can be reused on the same frame. (default: false)
  59708. */
  59709. constructor(name: string, refractionTextureUrl: string,
  59710. /** the base color of the refraction (used to taint the rendering) */
  59711. color: Color3,
  59712. /** simulated refraction depth */
  59713. depth: number,
  59714. /** the coefficient of the base color (0 to remove base color tainting) */
  59715. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59716. /**
  59717. * Disposes of the post process
  59718. * @param camera Camera to dispose post process on
  59719. */
  59720. dispose(camera: Camera): void;
  59721. }
  59722. }
  59723. declare module BABYLON {
  59724. /** @hidden */
  59725. export var sharpenPixelShader: {
  59726. name: string;
  59727. shader: string;
  59728. };
  59729. }
  59730. declare module BABYLON {
  59731. /**
  59732. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59733. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59734. */
  59735. export class SharpenPostProcess extends PostProcess {
  59736. /**
  59737. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59738. */
  59739. colorAmount: number;
  59740. /**
  59741. * How much sharpness should be applied (default: 0.3)
  59742. */
  59743. edgeAmount: number;
  59744. /**
  59745. * Creates a new instance ConvolutionPostProcess
  59746. * @param name The name of the effect.
  59747. * @param options The required width/height ratio to downsize to before computing the render pass.
  59748. * @param camera The camera to apply the render pass to.
  59749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59750. * @param engine The engine which the post process will be applied. (default: current engine)
  59751. * @param reusable If the post process can be reused on the same frame. (default: false)
  59752. * @param textureType Type of textures used when performing the post process. (default: 0)
  59753. * @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)
  59754. */
  59755. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59756. }
  59757. }
  59758. declare module BABYLON {
  59759. /**
  59760. * PostProcessRenderPipeline
  59761. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59762. */
  59763. export class PostProcessRenderPipeline {
  59764. private engine;
  59765. private _renderEffects;
  59766. private _renderEffectsForIsolatedPass;
  59767. /**
  59768. * List of inspectable custom properties (used by the Inspector)
  59769. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59770. */
  59771. inspectableCustomProperties: IInspectable[];
  59772. /**
  59773. * @hidden
  59774. */
  59775. protected _cameras: Camera[];
  59776. /** @hidden */
  59777. _name: string;
  59778. /**
  59779. * Gets pipeline name
  59780. */
  59781. readonly name: string;
  59782. /**
  59783. * Initializes a PostProcessRenderPipeline
  59784. * @param engine engine to add the pipeline to
  59785. * @param name name of the pipeline
  59786. */
  59787. constructor(engine: Engine, name: string);
  59788. /**
  59789. * Gets the class name
  59790. * @returns "PostProcessRenderPipeline"
  59791. */
  59792. getClassName(): string;
  59793. /**
  59794. * If all the render effects in the pipeline are supported
  59795. */
  59796. readonly isSupported: boolean;
  59797. /**
  59798. * Adds an effect to the pipeline
  59799. * @param renderEffect the effect to add
  59800. */
  59801. addEffect(renderEffect: PostProcessRenderEffect): void;
  59802. /** @hidden */
  59803. _rebuild(): void;
  59804. /** @hidden */
  59805. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59806. /** @hidden */
  59807. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59808. /** @hidden */
  59809. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59810. /** @hidden */
  59811. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59812. /** @hidden */
  59813. _attachCameras(cameras: Camera, unique: boolean): void;
  59814. /** @hidden */
  59815. _attachCameras(cameras: Camera[], unique: boolean): void;
  59816. /** @hidden */
  59817. _detachCameras(cameras: Camera): void;
  59818. /** @hidden */
  59819. _detachCameras(cameras: Nullable<Camera[]>): void;
  59820. /** @hidden */
  59821. _update(): void;
  59822. /** @hidden */
  59823. _reset(): void;
  59824. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59825. /**
  59826. * Disposes of the pipeline
  59827. */
  59828. dispose(): void;
  59829. }
  59830. }
  59831. declare module BABYLON {
  59832. /**
  59833. * PostProcessRenderPipelineManager class
  59834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59835. */
  59836. export class PostProcessRenderPipelineManager {
  59837. private _renderPipelines;
  59838. /**
  59839. * Initializes a PostProcessRenderPipelineManager
  59840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59841. */
  59842. constructor();
  59843. /**
  59844. * Gets the list of supported render pipelines
  59845. */
  59846. readonly supportedPipelines: PostProcessRenderPipeline[];
  59847. /**
  59848. * Adds a pipeline to the manager
  59849. * @param renderPipeline The pipeline to add
  59850. */
  59851. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59852. /**
  59853. * Attaches a camera to the pipeline
  59854. * @param renderPipelineName The name of the pipeline to attach to
  59855. * @param cameras the camera to attach
  59856. * @param unique if the camera can be attached multiple times to the pipeline
  59857. */
  59858. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59859. /**
  59860. * Detaches a camera from the pipeline
  59861. * @param renderPipelineName The name of the pipeline to detach from
  59862. * @param cameras the camera to detach
  59863. */
  59864. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59865. /**
  59866. * Enables an effect by name on a pipeline
  59867. * @param renderPipelineName the name of the pipeline to enable the effect in
  59868. * @param renderEffectName the name of the effect to enable
  59869. * @param cameras the cameras that the effect should be enabled on
  59870. */
  59871. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59872. /**
  59873. * Disables an effect by name on a pipeline
  59874. * @param renderPipelineName the name of the pipeline to disable the effect in
  59875. * @param renderEffectName the name of the effect to disable
  59876. * @param cameras the cameras that the effect should be disabled on
  59877. */
  59878. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59879. /**
  59880. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59881. */
  59882. update(): void;
  59883. /** @hidden */
  59884. _rebuild(): void;
  59885. /**
  59886. * Disposes of the manager and pipelines
  59887. */
  59888. dispose(): void;
  59889. }
  59890. }
  59891. declare module BABYLON {
  59892. interface Scene {
  59893. /** @hidden (Backing field) */
  59894. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59895. /**
  59896. * Gets the postprocess render pipeline manager
  59897. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59898. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59899. */
  59900. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59901. }
  59902. /**
  59903. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59904. */
  59905. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59906. /**
  59907. * The component name helpfull to identify the component in the list of scene components.
  59908. */
  59909. readonly name: string;
  59910. /**
  59911. * The scene the component belongs to.
  59912. */
  59913. scene: Scene;
  59914. /**
  59915. * Creates a new instance of the component for the given scene
  59916. * @param scene Defines the scene to register the component in
  59917. */
  59918. constructor(scene: Scene);
  59919. /**
  59920. * Registers the component in a given scene
  59921. */
  59922. register(): void;
  59923. /**
  59924. * Rebuilds the elements related to this component in case of
  59925. * context lost for instance.
  59926. */
  59927. rebuild(): void;
  59928. /**
  59929. * Disposes the component and the associated ressources
  59930. */
  59931. dispose(): void;
  59932. private _gatherRenderTargets;
  59933. }
  59934. }
  59935. declare module BABYLON {
  59936. /**
  59937. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59938. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59939. */
  59940. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59941. private _scene;
  59942. private _camerasToBeAttached;
  59943. /**
  59944. * ID of the sharpen post process,
  59945. */
  59946. private readonly SharpenPostProcessId;
  59947. /**
  59948. * @ignore
  59949. * ID of the image processing post process;
  59950. */
  59951. readonly ImageProcessingPostProcessId: string;
  59952. /**
  59953. * @ignore
  59954. * ID of the Fast Approximate Anti-Aliasing post process;
  59955. */
  59956. readonly FxaaPostProcessId: string;
  59957. /**
  59958. * ID of the chromatic aberration post process,
  59959. */
  59960. private readonly ChromaticAberrationPostProcessId;
  59961. /**
  59962. * ID of the grain post process
  59963. */
  59964. private readonly GrainPostProcessId;
  59965. /**
  59966. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59967. */
  59968. sharpen: SharpenPostProcess;
  59969. private _sharpenEffect;
  59970. private bloom;
  59971. /**
  59972. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59973. */
  59974. depthOfField: DepthOfFieldEffect;
  59975. /**
  59976. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59977. */
  59978. fxaa: FxaaPostProcess;
  59979. /**
  59980. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59981. */
  59982. imageProcessing: ImageProcessingPostProcess;
  59983. /**
  59984. * Chromatic aberration post process which will shift rgb colors in the image
  59985. */
  59986. chromaticAberration: ChromaticAberrationPostProcess;
  59987. private _chromaticAberrationEffect;
  59988. /**
  59989. * Grain post process which add noise to the image
  59990. */
  59991. grain: GrainPostProcess;
  59992. private _grainEffect;
  59993. /**
  59994. * Glow post process which adds a glow to emissive areas of the image
  59995. */
  59996. private _glowLayer;
  59997. /**
  59998. * Animations which can be used to tweak settings over a period of time
  59999. */
  60000. animations: Animation[];
  60001. private _imageProcessingConfigurationObserver;
  60002. private _sharpenEnabled;
  60003. private _bloomEnabled;
  60004. private _depthOfFieldEnabled;
  60005. private _depthOfFieldBlurLevel;
  60006. private _fxaaEnabled;
  60007. private _imageProcessingEnabled;
  60008. private _defaultPipelineTextureType;
  60009. private _bloomScale;
  60010. private _chromaticAberrationEnabled;
  60011. private _grainEnabled;
  60012. private _buildAllowed;
  60013. /**
  60014. * Gets active scene
  60015. */
  60016. readonly scene: Scene;
  60017. /**
  60018. * Enable or disable the sharpen process from the pipeline
  60019. */
  60020. sharpenEnabled: boolean;
  60021. private _resizeObserver;
  60022. private _hardwareScaleLevel;
  60023. private _bloomKernel;
  60024. /**
  60025. * Specifies the size of the bloom blur kernel, relative to the final output size
  60026. */
  60027. bloomKernel: number;
  60028. /**
  60029. * Specifies the weight of the bloom in the final rendering
  60030. */
  60031. private _bloomWeight;
  60032. /**
  60033. * Specifies the luma threshold for the area that will be blurred by the bloom
  60034. */
  60035. private _bloomThreshold;
  60036. private _hdr;
  60037. /**
  60038. * The strength of the bloom.
  60039. */
  60040. bloomWeight: number;
  60041. /**
  60042. * The strength of the bloom.
  60043. */
  60044. bloomThreshold: number;
  60045. /**
  60046. * The scale of the bloom, lower value will provide better performance.
  60047. */
  60048. bloomScale: number;
  60049. /**
  60050. * Enable or disable the bloom from the pipeline
  60051. */
  60052. bloomEnabled: boolean;
  60053. private _rebuildBloom;
  60054. /**
  60055. * If the depth of field is enabled.
  60056. */
  60057. depthOfFieldEnabled: boolean;
  60058. /**
  60059. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60060. */
  60061. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60062. /**
  60063. * If the anti aliasing is enabled.
  60064. */
  60065. fxaaEnabled: boolean;
  60066. private _samples;
  60067. /**
  60068. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60069. */
  60070. samples: number;
  60071. /**
  60072. * If image processing is enabled.
  60073. */
  60074. imageProcessingEnabled: boolean;
  60075. /**
  60076. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60077. */
  60078. glowLayerEnabled: boolean;
  60079. /**
  60080. * Gets the glow layer (or null if not defined)
  60081. */
  60082. readonly glowLayer: Nullable<GlowLayer>;
  60083. /**
  60084. * Enable or disable the chromaticAberration process from the pipeline
  60085. */
  60086. chromaticAberrationEnabled: boolean;
  60087. /**
  60088. * Enable or disable the grain process from the pipeline
  60089. */
  60090. grainEnabled: boolean;
  60091. /**
  60092. * @constructor
  60093. * @param name - The rendering pipeline name (default: "")
  60094. * @param hdr - If high dynamic range textures should be used (default: true)
  60095. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60096. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60097. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60098. */
  60099. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60100. /**
  60101. * Get the class name
  60102. * @returns "DefaultRenderingPipeline"
  60103. */
  60104. getClassName(): string;
  60105. /**
  60106. * Force the compilation of the entire pipeline.
  60107. */
  60108. prepare(): void;
  60109. private _hasCleared;
  60110. private _prevPostProcess;
  60111. private _prevPrevPostProcess;
  60112. private _setAutoClearAndTextureSharing;
  60113. private _depthOfFieldSceneObserver;
  60114. private _buildPipeline;
  60115. private _disposePostProcesses;
  60116. /**
  60117. * Adds a camera to the pipeline
  60118. * @param camera the camera to be added
  60119. */
  60120. addCamera(camera: Camera): void;
  60121. /**
  60122. * Removes a camera from the pipeline
  60123. * @param camera the camera to remove
  60124. */
  60125. removeCamera(camera: Camera): void;
  60126. /**
  60127. * Dispose of the pipeline and stop all post processes
  60128. */
  60129. dispose(): void;
  60130. /**
  60131. * Serialize the rendering pipeline (Used when exporting)
  60132. * @returns the serialized object
  60133. */
  60134. serialize(): any;
  60135. /**
  60136. * Parse the serialized pipeline
  60137. * @param source Source pipeline.
  60138. * @param scene The scene to load the pipeline to.
  60139. * @param rootUrl The URL of the serialized pipeline.
  60140. * @returns An instantiated pipeline from the serialized object.
  60141. */
  60142. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60143. }
  60144. }
  60145. declare module BABYLON {
  60146. /** @hidden */
  60147. export var lensHighlightsPixelShader: {
  60148. name: string;
  60149. shader: string;
  60150. };
  60151. }
  60152. declare module BABYLON {
  60153. /** @hidden */
  60154. export var depthOfFieldPixelShader: {
  60155. name: string;
  60156. shader: string;
  60157. };
  60158. }
  60159. declare module BABYLON {
  60160. /**
  60161. * BABYLON.JS Chromatic Aberration GLSL Shader
  60162. * Author: Olivier Guyot
  60163. * Separates very slightly R, G and B colors on the edges of the screen
  60164. * Inspired by Francois Tarlier & Martins Upitis
  60165. */
  60166. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60167. /**
  60168. * @ignore
  60169. * The chromatic aberration PostProcess id in the pipeline
  60170. */
  60171. LensChromaticAberrationEffect: string;
  60172. /**
  60173. * @ignore
  60174. * The highlights enhancing PostProcess id in the pipeline
  60175. */
  60176. HighlightsEnhancingEffect: string;
  60177. /**
  60178. * @ignore
  60179. * The depth-of-field PostProcess id in the pipeline
  60180. */
  60181. LensDepthOfFieldEffect: string;
  60182. private _scene;
  60183. private _depthTexture;
  60184. private _grainTexture;
  60185. private _chromaticAberrationPostProcess;
  60186. private _highlightsPostProcess;
  60187. private _depthOfFieldPostProcess;
  60188. private _edgeBlur;
  60189. private _grainAmount;
  60190. private _chromaticAberration;
  60191. private _distortion;
  60192. private _highlightsGain;
  60193. private _highlightsThreshold;
  60194. private _dofDistance;
  60195. private _dofAperture;
  60196. private _dofDarken;
  60197. private _dofPentagon;
  60198. private _blurNoise;
  60199. /**
  60200. * @constructor
  60201. *
  60202. * Effect parameters are as follow:
  60203. * {
  60204. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60205. * edge_blur: number; // from 0 to x (1 for realism)
  60206. * distortion: number; // from 0 to x (1 for realism)
  60207. * grain_amount: number; // from 0 to 1
  60208. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60209. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60210. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60211. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60212. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60213. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60214. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60215. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60216. * }
  60217. * Note: if an effect parameter is unset, effect is disabled
  60218. *
  60219. * @param name The rendering pipeline name
  60220. * @param parameters - An object containing all parameters (see above)
  60221. * @param scene The scene linked to this pipeline
  60222. * @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)
  60223. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60224. */
  60225. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60226. /**
  60227. * Get the class name
  60228. * @returns "LensRenderingPipeline"
  60229. */
  60230. getClassName(): string;
  60231. /**
  60232. * Gets associated scene
  60233. */
  60234. readonly scene: Scene;
  60235. /**
  60236. * Gets or sets the edge blur
  60237. */
  60238. edgeBlur: number;
  60239. /**
  60240. * Gets or sets the grain amount
  60241. */
  60242. grainAmount: number;
  60243. /**
  60244. * Gets or sets the chromatic aberration amount
  60245. */
  60246. chromaticAberration: number;
  60247. /**
  60248. * Gets or sets the depth of field aperture
  60249. */
  60250. dofAperture: number;
  60251. /**
  60252. * Gets or sets the edge distortion
  60253. */
  60254. edgeDistortion: number;
  60255. /**
  60256. * Gets or sets the depth of field distortion
  60257. */
  60258. dofDistortion: number;
  60259. /**
  60260. * Gets or sets the darken out of focus amount
  60261. */
  60262. darkenOutOfFocus: number;
  60263. /**
  60264. * Gets or sets a boolean indicating if blur noise is enabled
  60265. */
  60266. blurNoise: boolean;
  60267. /**
  60268. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60269. */
  60270. pentagonBokeh: boolean;
  60271. /**
  60272. * Gets or sets the highlight grain amount
  60273. */
  60274. highlightsGain: number;
  60275. /**
  60276. * Gets or sets the highlight threshold
  60277. */
  60278. highlightsThreshold: number;
  60279. /**
  60280. * Sets the amount of blur at the edges
  60281. * @param amount blur amount
  60282. */
  60283. setEdgeBlur(amount: number): void;
  60284. /**
  60285. * Sets edge blur to 0
  60286. */
  60287. disableEdgeBlur(): void;
  60288. /**
  60289. * Sets the amout of grain
  60290. * @param amount Amount of grain
  60291. */
  60292. setGrainAmount(amount: number): void;
  60293. /**
  60294. * Set grain amount to 0
  60295. */
  60296. disableGrain(): void;
  60297. /**
  60298. * Sets the chromatic aberration amount
  60299. * @param amount amount of chromatic aberration
  60300. */
  60301. setChromaticAberration(amount: number): void;
  60302. /**
  60303. * Sets chromatic aberration amount to 0
  60304. */
  60305. disableChromaticAberration(): void;
  60306. /**
  60307. * Sets the EdgeDistortion amount
  60308. * @param amount amount of EdgeDistortion
  60309. */
  60310. setEdgeDistortion(amount: number): void;
  60311. /**
  60312. * Sets edge distortion to 0
  60313. */
  60314. disableEdgeDistortion(): void;
  60315. /**
  60316. * Sets the FocusDistance amount
  60317. * @param amount amount of FocusDistance
  60318. */
  60319. setFocusDistance(amount: number): void;
  60320. /**
  60321. * Disables depth of field
  60322. */
  60323. disableDepthOfField(): void;
  60324. /**
  60325. * Sets the Aperture amount
  60326. * @param amount amount of Aperture
  60327. */
  60328. setAperture(amount: number): void;
  60329. /**
  60330. * Sets the DarkenOutOfFocus amount
  60331. * @param amount amount of DarkenOutOfFocus
  60332. */
  60333. setDarkenOutOfFocus(amount: number): void;
  60334. private _pentagonBokehIsEnabled;
  60335. /**
  60336. * Creates a pentagon bokeh effect
  60337. */
  60338. enablePentagonBokeh(): void;
  60339. /**
  60340. * Disables the pentagon bokeh effect
  60341. */
  60342. disablePentagonBokeh(): void;
  60343. /**
  60344. * Enables noise blur
  60345. */
  60346. enableNoiseBlur(): void;
  60347. /**
  60348. * Disables noise blur
  60349. */
  60350. disableNoiseBlur(): void;
  60351. /**
  60352. * Sets the HighlightsGain amount
  60353. * @param amount amount of HighlightsGain
  60354. */
  60355. setHighlightsGain(amount: number): void;
  60356. /**
  60357. * Sets the HighlightsThreshold amount
  60358. * @param amount amount of HighlightsThreshold
  60359. */
  60360. setHighlightsThreshold(amount: number): void;
  60361. /**
  60362. * Disables highlights
  60363. */
  60364. disableHighlights(): void;
  60365. /**
  60366. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60367. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60368. */
  60369. dispose(disableDepthRender?: boolean): void;
  60370. private _createChromaticAberrationPostProcess;
  60371. private _createHighlightsPostProcess;
  60372. private _createDepthOfFieldPostProcess;
  60373. private _createGrainTexture;
  60374. }
  60375. }
  60376. declare module BABYLON {
  60377. /** @hidden */
  60378. export var ssao2PixelShader: {
  60379. name: string;
  60380. shader: string;
  60381. };
  60382. }
  60383. declare module BABYLON {
  60384. /** @hidden */
  60385. export var ssaoCombinePixelShader: {
  60386. name: string;
  60387. shader: string;
  60388. };
  60389. }
  60390. declare module BABYLON {
  60391. /**
  60392. * Render pipeline to produce ssao effect
  60393. */
  60394. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60395. /**
  60396. * @ignore
  60397. * The PassPostProcess id in the pipeline that contains the original scene color
  60398. */
  60399. SSAOOriginalSceneColorEffect: string;
  60400. /**
  60401. * @ignore
  60402. * The SSAO PostProcess id in the pipeline
  60403. */
  60404. SSAORenderEffect: string;
  60405. /**
  60406. * @ignore
  60407. * The horizontal blur PostProcess id in the pipeline
  60408. */
  60409. SSAOBlurHRenderEffect: string;
  60410. /**
  60411. * @ignore
  60412. * The vertical blur PostProcess id in the pipeline
  60413. */
  60414. SSAOBlurVRenderEffect: string;
  60415. /**
  60416. * @ignore
  60417. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60418. */
  60419. SSAOCombineRenderEffect: string;
  60420. /**
  60421. * The output strength of the SSAO post-process. Default value is 1.0.
  60422. */
  60423. totalStrength: number;
  60424. /**
  60425. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60426. */
  60427. maxZ: number;
  60428. /**
  60429. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60430. */
  60431. minZAspect: number;
  60432. private _samples;
  60433. /**
  60434. * Number of samples used for the SSAO calculations. Default value is 8
  60435. */
  60436. samples: number;
  60437. private _textureSamples;
  60438. /**
  60439. * Number of samples to use for antialiasing
  60440. */
  60441. textureSamples: number;
  60442. /**
  60443. * Ratio object used for SSAO ratio and blur ratio
  60444. */
  60445. private _ratio;
  60446. /**
  60447. * Dynamically generated sphere sampler.
  60448. */
  60449. private _sampleSphere;
  60450. /**
  60451. * Blur filter offsets
  60452. */
  60453. private _samplerOffsets;
  60454. private _expensiveBlur;
  60455. /**
  60456. * If bilateral blur should be used
  60457. */
  60458. expensiveBlur: boolean;
  60459. /**
  60460. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60461. */
  60462. radius: number;
  60463. /**
  60464. * The base color of the SSAO post-process
  60465. * The final result is "base + ssao" between [0, 1]
  60466. */
  60467. base: number;
  60468. /**
  60469. * Support test.
  60470. */
  60471. static readonly IsSupported: boolean;
  60472. private _scene;
  60473. private _depthTexture;
  60474. private _normalTexture;
  60475. private _randomTexture;
  60476. private _originalColorPostProcess;
  60477. private _ssaoPostProcess;
  60478. private _blurHPostProcess;
  60479. private _blurVPostProcess;
  60480. private _ssaoCombinePostProcess;
  60481. private _firstUpdate;
  60482. /**
  60483. * Gets active scene
  60484. */
  60485. readonly scene: Scene;
  60486. /**
  60487. * @constructor
  60488. * @param name The rendering pipeline name
  60489. * @param scene The scene linked to this pipeline
  60490. * @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 }
  60491. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60492. */
  60493. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60494. /**
  60495. * Get the class name
  60496. * @returns "SSAO2RenderingPipeline"
  60497. */
  60498. getClassName(): string;
  60499. /**
  60500. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60501. */
  60502. dispose(disableGeometryBufferRenderer?: boolean): void;
  60503. private _createBlurPostProcess;
  60504. /** @hidden */
  60505. _rebuild(): void;
  60506. private _bits;
  60507. private _radicalInverse_VdC;
  60508. private _hammersley;
  60509. private _hemisphereSample_uniform;
  60510. private _generateHemisphere;
  60511. private _createSSAOPostProcess;
  60512. private _createSSAOCombinePostProcess;
  60513. private _createRandomTexture;
  60514. /**
  60515. * Serialize the rendering pipeline (Used when exporting)
  60516. * @returns the serialized object
  60517. */
  60518. serialize(): any;
  60519. /**
  60520. * Parse the serialized pipeline
  60521. * @param source Source pipeline.
  60522. * @param scene The scene to load the pipeline to.
  60523. * @param rootUrl The URL of the serialized pipeline.
  60524. * @returns An instantiated pipeline from the serialized object.
  60525. */
  60526. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60527. }
  60528. }
  60529. declare module BABYLON {
  60530. /** @hidden */
  60531. export var ssaoPixelShader: {
  60532. name: string;
  60533. shader: string;
  60534. };
  60535. }
  60536. declare module BABYLON {
  60537. /**
  60538. * Render pipeline to produce ssao effect
  60539. */
  60540. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60541. /**
  60542. * @ignore
  60543. * The PassPostProcess id in the pipeline that contains the original scene color
  60544. */
  60545. SSAOOriginalSceneColorEffect: string;
  60546. /**
  60547. * @ignore
  60548. * The SSAO PostProcess id in the pipeline
  60549. */
  60550. SSAORenderEffect: string;
  60551. /**
  60552. * @ignore
  60553. * The horizontal blur PostProcess id in the pipeline
  60554. */
  60555. SSAOBlurHRenderEffect: string;
  60556. /**
  60557. * @ignore
  60558. * The vertical blur PostProcess id in the pipeline
  60559. */
  60560. SSAOBlurVRenderEffect: string;
  60561. /**
  60562. * @ignore
  60563. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60564. */
  60565. SSAOCombineRenderEffect: string;
  60566. /**
  60567. * The output strength of the SSAO post-process. Default value is 1.0.
  60568. */
  60569. totalStrength: number;
  60570. /**
  60571. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60572. */
  60573. radius: number;
  60574. /**
  60575. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60576. * Must not be equal to fallOff and superior to fallOff.
  60577. * Default value is 0.0075
  60578. */
  60579. area: number;
  60580. /**
  60581. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60582. * Must not be equal to area and inferior to area.
  60583. * Default value is 0.000001
  60584. */
  60585. fallOff: number;
  60586. /**
  60587. * The base color of the SSAO post-process
  60588. * The final result is "base + ssao" between [0, 1]
  60589. */
  60590. base: number;
  60591. private _scene;
  60592. private _depthTexture;
  60593. private _randomTexture;
  60594. private _originalColorPostProcess;
  60595. private _ssaoPostProcess;
  60596. private _blurHPostProcess;
  60597. private _blurVPostProcess;
  60598. private _ssaoCombinePostProcess;
  60599. private _firstUpdate;
  60600. /**
  60601. * Gets active scene
  60602. */
  60603. readonly scene: Scene;
  60604. /**
  60605. * @constructor
  60606. * @param name - The rendering pipeline name
  60607. * @param scene - The scene linked to this pipeline
  60608. * @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 }
  60609. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60610. */
  60611. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60612. /**
  60613. * Get the class name
  60614. * @returns "SSAORenderingPipeline"
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60619. */
  60620. dispose(disableDepthRender?: boolean): void;
  60621. private _createBlurPostProcess;
  60622. /** @hidden */
  60623. _rebuild(): void;
  60624. private _createSSAOPostProcess;
  60625. private _createSSAOCombinePostProcess;
  60626. private _createRandomTexture;
  60627. }
  60628. }
  60629. declare module BABYLON {
  60630. /** @hidden */
  60631. export var standardPixelShader: {
  60632. name: string;
  60633. shader: string;
  60634. };
  60635. }
  60636. declare module BABYLON {
  60637. /**
  60638. * Standard rendering pipeline
  60639. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60640. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60641. */
  60642. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60643. /**
  60644. * Public members
  60645. */
  60646. /**
  60647. * Post-process which contains the original scene color before the pipeline applies all the effects
  60648. */
  60649. originalPostProcess: Nullable<PostProcess>;
  60650. /**
  60651. * Post-process used to down scale an image x4
  60652. */
  60653. downSampleX4PostProcess: Nullable<PostProcess>;
  60654. /**
  60655. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60656. */
  60657. brightPassPostProcess: Nullable<PostProcess>;
  60658. /**
  60659. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60660. */
  60661. blurHPostProcesses: PostProcess[];
  60662. /**
  60663. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60664. */
  60665. blurVPostProcesses: PostProcess[];
  60666. /**
  60667. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60668. */
  60669. textureAdderPostProcess: Nullable<PostProcess>;
  60670. /**
  60671. * Post-process used to create volumetric lighting effect
  60672. */
  60673. volumetricLightPostProcess: Nullable<PostProcess>;
  60674. /**
  60675. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60676. */
  60677. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60678. /**
  60679. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60680. */
  60681. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60682. /**
  60683. * Post-process used to merge the volumetric light effect and the real scene color
  60684. */
  60685. volumetricLightMergePostProces: Nullable<PostProcess>;
  60686. /**
  60687. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60688. */
  60689. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60690. /**
  60691. * Base post-process used to calculate the average luminance of the final image for HDR
  60692. */
  60693. luminancePostProcess: Nullable<PostProcess>;
  60694. /**
  60695. * Post-processes used to create down sample post-processes in order to get
  60696. * the average luminance of the final image for HDR
  60697. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60698. */
  60699. luminanceDownSamplePostProcesses: PostProcess[];
  60700. /**
  60701. * Post-process used to create a HDR effect (light adaptation)
  60702. */
  60703. hdrPostProcess: Nullable<PostProcess>;
  60704. /**
  60705. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60706. */
  60707. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60708. /**
  60709. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60710. */
  60711. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60712. /**
  60713. * Post-process used to merge the final HDR post-process and the real scene color
  60714. */
  60715. hdrFinalPostProcess: Nullable<PostProcess>;
  60716. /**
  60717. * Post-process used to create a lens flare effect
  60718. */
  60719. lensFlarePostProcess: Nullable<PostProcess>;
  60720. /**
  60721. * Post-process that merges the result of the lens flare post-process and the real scene color
  60722. */
  60723. lensFlareComposePostProcess: Nullable<PostProcess>;
  60724. /**
  60725. * Post-process used to create a motion blur effect
  60726. */
  60727. motionBlurPostProcess: Nullable<PostProcess>;
  60728. /**
  60729. * Post-process used to create a depth of field effect
  60730. */
  60731. depthOfFieldPostProcess: Nullable<PostProcess>;
  60732. /**
  60733. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60734. */
  60735. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60736. /**
  60737. * Represents the brightness threshold in order to configure the illuminated surfaces
  60738. */
  60739. brightThreshold: number;
  60740. /**
  60741. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60742. */
  60743. blurWidth: number;
  60744. /**
  60745. * Sets if the blur for highlighted surfaces must be only horizontal
  60746. */
  60747. horizontalBlur: boolean;
  60748. /**
  60749. * Gets the overall exposure used by the pipeline
  60750. */
  60751. /**
  60752. * Sets the overall exposure used by the pipeline
  60753. */
  60754. exposure: number;
  60755. /**
  60756. * Texture used typically to simulate "dirty" on camera lens
  60757. */
  60758. lensTexture: Nullable<Texture>;
  60759. /**
  60760. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60761. */
  60762. volumetricLightCoefficient: number;
  60763. /**
  60764. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60765. */
  60766. volumetricLightPower: number;
  60767. /**
  60768. * Used the set the blur intensity to smooth the volumetric lights
  60769. */
  60770. volumetricLightBlurScale: number;
  60771. /**
  60772. * Light (spot or directional) used to generate the volumetric lights rays
  60773. * The source light must have a shadow generate so the pipeline can get its
  60774. * depth map
  60775. */
  60776. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60777. /**
  60778. * For eye adaptation, represents the minimum luminance the eye can see
  60779. */
  60780. hdrMinimumLuminance: number;
  60781. /**
  60782. * For eye adaptation, represents the decrease luminance speed
  60783. */
  60784. hdrDecreaseRate: number;
  60785. /**
  60786. * For eye adaptation, represents the increase luminance speed
  60787. */
  60788. hdrIncreaseRate: number;
  60789. /**
  60790. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60791. */
  60792. /**
  60793. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60794. */
  60795. hdrAutoExposure: boolean;
  60796. /**
  60797. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60798. */
  60799. lensColorTexture: Nullable<Texture>;
  60800. /**
  60801. * The overall strengh for the lens flare effect
  60802. */
  60803. lensFlareStrength: number;
  60804. /**
  60805. * Dispersion coefficient for lens flare ghosts
  60806. */
  60807. lensFlareGhostDispersal: number;
  60808. /**
  60809. * Main lens flare halo width
  60810. */
  60811. lensFlareHaloWidth: number;
  60812. /**
  60813. * Based on the lens distortion effect, defines how much the lens flare result
  60814. * is distorted
  60815. */
  60816. lensFlareDistortionStrength: number;
  60817. /**
  60818. * Configures the blur intensity used for for lens flare (halo)
  60819. */
  60820. lensFlareBlurWidth: number;
  60821. /**
  60822. * Lens star texture must be used to simulate rays on the flares and is available
  60823. * in the documentation
  60824. */
  60825. lensStarTexture: Nullable<Texture>;
  60826. /**
  60827. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60828. * flare effect by taking account of the dirt texture
  60829. */
  60830. lensFlareDirtTexture: Nullable<Texture>;
  60831. /**
  60832. * Represents the focal length for the depth of field effect
  60833. */
  60834. depthOfFieldDistance: number;
  60835. /**
  60836. * Represents the blur intensity for the blurred part of the depth of field effect
  60837. */
  60838. depthOfFieldBlurWidth: number;
  60839. /**
  60840. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60841. */
  60842. /**
  60843. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60844. */
  60845. motionStrength: number;
  60846. /**
  60847. * Gets wether or not the motion blur post-process is object based or screen based.
  60848. */
  60849. /**
  60850. * Sets wether or not the motion blur post-process should be object based or screen based
  60851. */
  60852. objectBasedMotionBlur: boolean;
  60853. /**
  60854. * List of animations for the pipeline (IAnimatable implementation)
  60855. */
  60856. animations: Animation[];
  60857. /**
  60858. * Private members
  60859. */
  60860. private _scene;
  60861. private _currentDepthOfFieldSource;
  60862. private _basePostProcess;
  60863. private _fixedExposure;
  60864. private _currentExposure;
  60865. private _hdrAutoExposure;
  60866. private _hdrCurrentLuminance;
  60867. private _motionStrength;
  60868. private _isObjectBasedMotionBlur;
  60869. private _floatTextureType;
  60870. private _camerasToBeAttached;
  60871. private _ratio;
  60872. private _bloomEnabled;
  60873. private _depthOfFieldEnabled;
  60874. private _vlsEnabled;
  60875. private _lensFlareEnabled;
  60876. private _hdrEnabled;
  60877. private _motionBlurEnabled;
  60878. private _fxaaEnabled;
  60879. private _motionBlurSamples;
  60880. private _volumetricLightStepsCount;
  60881. private _samples;
  60882. /**
  60883. * @ignore
  60884. * Specifies if the bloom pipeline is enabled
  60885. */
  60886. BloomEnabled: boolean;
  60887. /**
  60888. * @ignore
  60889. * Specifies if the depth of field pipeline is enabed
  60890. */
  60891. DepthOfFieldEnabled: boolean;
  60892. /**
  60893. * @ignore
  60894. * Specifies if the lens flare pipeline is enabed
  60895. */
  60896. LensFlareEnabled: boolean;
  60897. /**
  60898. * @ignore
  60899. * Specifies if the HDR pipeline is enabled
  60900. */
  60901. HDREnabled: boolean;
  60902. /**
  60903. * @ignore
  60904. * Specifies if the volumetric lights scattering effect is enabled
  60905. */
  60906. VLSEnabled: boolean;
  60907. /**
  60908. * @ignore
  60909. * Specifies if the motion blur effect is enabled
  60910. */
  60911. MotionBlurEnabled: boolean;
  60912. /**
  60913. * Specifies if anti-aliasing is enabled
  60914. */
  60915. fxaaEnabled: boolean;
  60916. /**
  60917. * Specifies the number of steps used to calculate the volumetric lights
  60918. * Typically in interval [50, 200]
  60919. */
  60920. volumetricLightStepsCount: number;
  60921. /**
  60922. * Specifies the number of samples used for the motion blur effect
  60923. * Typically in interval [16, 64]
  60924. */
  60925. motionBlurSamples: number;
  60926. /**
  60927. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60928. */
  60929. samples: number;
  60930. /**
  60931. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60932. * @constructor
  60933. * @param name The rendering pipeline name
  60934. * @param scene The scene linked to this pipeline
  60935. * @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)
  60936. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60937. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60938. */
  60939. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60940. private _buildPipeline;
  60941. private _createDownSampleX4PostProcess;
  60942. private _createBrightPassPostProcess;
  60943. private _createBlurPostProcesses;
  60944. private _createTextureAdderPostProcess;
  60945. private _createVolumetricLightPostProcess;
  60946. private _createLuminancePostProcesses;
  60947. private _createHdrPostProcess;
  60948. private _createLensFlarePostProcess;
  60949. private _createDepthOfFieldPostProcess;
  60950. private _createMotionBlurPostProcess;
  60951. private _getDepthTexture;
  60952. private _disposePostProcesses;
  60953. /**
  60954. * Dispose of the pipeline and stop all post processes
  60955. */
  60956. dispose(): void;
  60957. /**
  60958. * Serialize the rendering pipeline (Used when exporting)
  60959. * @returns the serialized object
  60960. */
  60961. serialize(): any;
  60962. /**
  60963. * Parse the serialized pipeline
  60964. * @param source Source pipeline.
  60965. * @param scene The scene to load the pipeline to.
  60966. * @param rootUrl The URL of the serialized pipeline.
  60967. * @returns An instantiated pipeline from the serialized object.
  60968. */
  60969. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60970. /**
  60971. * Luminance steps
  60972. */
  60973. static LuminanceSteps: number;
  60974. }
  60975. }
  60976. declare module BABYLON {
  60977. /** @hidden */
  60978. export var tonemapPixelShader: {
  60979. name: string;
  60980. shader: string;
  60981. };
  60982. }
  60983. declare module BABYLON {
  60984. /** Defines operator used for tonemapping */
  60985. export enum TonemappingOperator {
  60986. /** Hable */
  60987. Hable = 0,
  60988. /** Reinhard */
  60989. Reinhard = 1,
  60990. /** HejiDawson */
  60991. HejiDawson = 2,
  60992. /** Photographic */
  60993. Photographic = 3
  60994. }
  60995. /**
  60996. * Defines a post process to apply tone mapping
  60997. */
  60998. export class TonemapPostProcess extends PostProcess {
  60999. private _operator;
  61000. /** Defines the required exposure adjustement */
  61001. exposureAdjustment: number;
  61002. /**
  61003. * Creates a new TonemapPostProcess
  61004. * @param name defines the name of the postprocess
  61005. * @param _operator defines the operator to use
  61006. * @param exposureAdjustment defines the required exposure adjustement
  61007. * @param camera defines the camera to use (can be null)
  61008. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61009. * @param engine defines the hosting engine (can be ignore if camera is set)
  61010. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61011. */
  61012. constructor(name: string, _operator: TonemappingOperator,
  61013. /** Defines the required exposure adjustement */
  61014. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61015. }
  61016. }
  61017. declare module BABYLON {
  61018. /** @hidden */
  61019. export var depthVertexShader: {
  61020. name: string;
  61021. shader: string;
  61022. };
  61023. }
  61024. declare module BABYLON {
  61025. /** @hidden */
  61026. export var volumetricLightScatteringPixelShader: {
  61027. name: string;
  61028. shader: string;
  61029. };
  61030. }
  61031. declare module BABYLON {
  61032. /** @hidden */
  61033. export var volumetricLightScatteringPassVertexShader: {
  61034. name: string;
  61035. shader: string;
  61036. };
  61037. }
  61038. declare module BABYLON {
  61039. /** @hidden */
  61040. export var volumetricLightScatteringPassPixelShader: {
  61041. name: string;
  61042. shader: string;
  61043. };
  61044. }
  61045. declare module BABYLON {
  61046. /**
  61047. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61048. */
  61049. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61050. private _volumetricLightScatteringPass;
  61051. private _volumetricLightScatteringRTT;
  61052. private _viewPort;
  61053. private _screenCoordinates;
  61054. private _cachedDefines;
  61055. /**
  61056. * If not undefined, the mesh position is computed from the attached node position
  61057. */
  61058. attachedNode: {
  61059. position: Vector3;
  61060. };
  61061. /**
  61062. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61063. */
  61064. customMeshPosition: Vector3;
  61065. /**
  61066. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61067. */
  61068. useCustomMeshPosition: boolean;
  61069. /**
  61070. * If the post-process should inverse the light scattering direction
  61071. */
  61072. invert: boolean;
  61073. /**
  61074. * The internal mesh used by the post-process
  61075. */
  61076. mesh: Mesh;
  61077. /**
  61078. * @hidden
  61079. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61080. */
  61081. useDiffuseColor: boolean;
  61082. /**
  61083. * Array containing the excluded meshes not rendered in the internal pass
  61084. */
  61085. excludedMeshes: AbstractMesh[];
  61086. /**
  61087. * Controls the overall intensity of the post-process
  61088. */
  61089. exposure: number;
  61090. /**
  61091. * Dissipates each sample's contribution in range [0, 1]
  61092. */
  61093. decay: number;
  61094. /**
  61095. * Controls the overall intensity of each sample
  61096. */
  61097. weight: number;
  61098. /**
  61099. * Controls the density of each sample
  61100. */
  61101. density: number;
  61102. /**
  61103. * @constructor
  61104. * @param name The post-process name
  61105. * @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)
  61106. * @param camera The camera that the post-process will be attached to
  61107. * @param mesh The mesh used to create the light scattering
  61108. * @param samples The post-process quality, default 100
  61109. * @param samplingModeThe post-process filtering mode
  61110. * @param engine The babylon engine
  61111. * @param reusable If the post-process is reusable
  61112. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61113. */
  61114. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61115. /**
  61116. * Returns the string "VolumetricLightScatteringPostProcess"
  61117. * @returns "VolumetricLightScatteringPostProcess"
  61118. */
  61119. getClassName(): string;
  61120. private _isReady;
  61121. /**
  61122. * Sets the new light position for light scattering effect
  61123. * @param position The new custom light position
  61124. */
  61125. setCustomMeshPosition(position: Vector3): void;
  61126. /**
  61127. * Returns the light position for light scattering effect
  61128. * @return Vector3 The custom light position
  61129. */
  61130. getCustomMeshPosition(): Vector3;
  61131. /**
  61132. * Disposes the internal assets and detaches the post-process from the camera
  61133. */
  61134. dispose(camera: Camera): void;
  61135. /**
  61136. * Returns the render target texture used by the post-process
  61137. * @return the render target texture used by the post-process
  61138. */
  61139. getPass(): RenderTargetTexture;
  61140. private _meshExcluded;
  61141. private _createPass;
  61142. private _updateMeshScreenCoordinates;
  61143. /**
  61144. * Creates a default mesh for the Volumeric Light Scattering post-process
  61145. * @param name The mesh name
  61146. * @param scene The scene where to create the mesh
  61147. * @return the default mesh
  61148. */
  61149. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61150. }
  61151. }
  61152. declare module BABYLON {
  61153. interface Scene {
  61154. /** @hidden (Backing field) */
  61155. _boundingBoxRenderer: BoundingBoxRenderer;
  61156. /** @hidden (Backing field) */
  61157. _forceShowBoundingBoxes: boolean;
  61158. /**
  61159. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61160. */
  61161. forceShowBoundingBoxes: boolean;
  61162. /**
  61163. * Gets the bounding box renderer associated with the scene
  61164. * @returns a BoundingBoxRenderer
  61165. */
  61166. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61167. }
  61168. interface AbstractMesh {
  61169. /** @hidden (Backing field) */
  61170. _showBoundingBox: boolean;
  61171. /**
  61172. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61173. */
  61174. showBoundingBox: boolean;
  61175. }
  61176. /**
  61177. * Component responsible of rendering the bounding box of the meshes in a scene.
  61178. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61179. */
  61180. export class BoundingBoxRenderer implements ISceneComponent {
  61181. /**
  61182. * The component name helpfull to identify the component in the list of scene components.
  61183. */
  61184. readonly name: string;
  61185. /**
  61186. * The scene the component belongs to.
  61187. */
  61188. scene: Scene;
  61189. /**
  61190. * Color of the bounding box lines placed in front of an object
  61191. */
  61192. frontColor: Color3;
  61193. /**
  61194. * Color of the bounding box lines placed behind an object
  61195. */
  61196. backColor: Color3;
  61197. /**
  61198. * Defines if the renderer should show the back lines or not
  61199. */
  61200. showBackLines: boolean;
  61201. /**
  61202. * @hidden
  61203. */
  61204. renderList: SmartArray<BoundingBox>;
  61205. private _colorShader;
  61206. private _vertexBuffers;
  61207. private _indexBuffer;
  61208. private _fillIndexBuffer;
  61209. private _fillIndexData;
  61210. /**
  61211. * Instantiates a new bounding box renderer in a scene.
  61212. * @param scene the scene the renderer renders in
  61213. */
  61214. constructor(scene: Scene);
  61215. /**
  61216. * Registers the component in a given scene
  61217. */
  61218. register(): void;
  61219. private _evaluateSubMesh;
  61220. private _activeMesh;
  61221. private _prepareRessources;
  61222. private _createIndexBuffer;
  61223. /**
  61224. * Rebuilds the elements related to this component in case of
  61225. * context lost for instance.
  61226. */
  61227. rebuild(): void;
  61228. /**
  61229. * @hidden
  61230. */
  61231. reset(): void;
  61232. /**
  61233. * Render the bounding boxes of a specific rendering group
  61234. * @param renderingGroupId defines the rendering group to render
  61235. */
  61236. render(renderingGroupId: number): void;
  61237. /**
  61238. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61239. * @param mesh Define the mesh to render the occlusion bounding box for
  61240. */
  61241. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61242. /**
  61243. * Dispose and release the resources attached to this renderer.
  61244. */
  61245. dispose(): void;
  61246. }
  61247. }
  61248. declare module BABYLON {
  61249. /** @hidden */
  61250. export var depthPixelShader: {
  61251. name: string;
  61252. shader: string;
  61253. };
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * This represents a depth renderer in Babylon.
  61258. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61259. */
  61260. export class DepthRenderer {
  61261. private _scene;
  61262. private _depthMap;
  61263. private _effect;
  61264. private readonly _storeNonLinearDepth;
  61265. private readonly _clearColor;
  61266. /** Get if the depth renderer is using packed depth or not */
  61267. readonly isPacked: boolean;
  61268. private _cachedDefines;
  61269. private _camera;
  61270. /**
  61271. * Specifiess that the depth renderer will only be used within
  61272. * the camera it is created for.
  61273. * This can help forcing its rendering during the camera processing.
  61274. */
  61275. useOnlyInActiveCamera: boolean;
  61276. /** @hidden */
  61277. static _SceneComponentInitialization: (scene: Scene) => void;
  61278. /**
  61279. * Instantiates a depth renderer
  61280. * @param scene The scene the renderer belongs to
  61281. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61282. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61283. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61284. */
  61285. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61286. /**
  61287. * Creates the depth rendering effect and checks if the effect is ready.
  61288. * @param subMesh The submesh to be used to render the depth map of
  61289. * @param useInstances If multiple world instances should be used
  61290. * @returns if the depth renderer is ready to render the depth map
  61291. */
  61292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61293. /**
  61294. * Gets the texture which the depth map will be written to.
  61295. * @returns The depth map texture
  61296. */
  61297. getDepthMap(): RenderTargetTexture;
  61298. /**
  61299. * Disposes of the depth renderer.
  61300. */
  61301. dispose(): void;
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. interface Scene {
  61306. /** @hidden (Backing field) */
  61307. _depthRenderer: {
  61308. [id: string]: DepthRenderer;
  61309. };
  61310. /**
  61311. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61312. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61313. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61314. * @returns the created depth renderer
  61315. */
  61316. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61317. /**
  61318. * Disables a depth renderer for a given camera
  61319. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61320. */
  61321. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61322. }
  61323. /**
  61324. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61325. * in several rendering techniques.
  61326. */
  61327. export class DepthRendererSceneComponent implements ISceneComponent {
  61328. /**
  61329. * The component name helpfull to identify the component in the list of scene components.
  61330. */
  61331. readonly name: string;
  61332. /**
  61333. * The scene the component belongs to.
  61334. */
  61335. scene: Scene;
  61336. /**
  61337. * Creates a new instance of the component for the given scene
  61338. * @param scene Defines the scene to register the component in
  61339. */
  61340. constructor(scene: Scene);
  61341. /**
  61342. * Registers the component in a given scene
  61343. */
  61344. register(): void;
  61345. /**
  61346. * Rebuilds the elements related to this component in case of
  61347. * context lost for instance.
  61348. */
  61349. rebuild(): void;
  61350. /**
  61351. * Disposes the component and the associated ressources
  61352. */
  61353. dispose(): void;
  61354. private _gatherRenderTargets;
  61355. private _gatherActiveCameraRenderTargets;
  61356. }
  61357. }
  61358. declare module BABYLON {
  61359. /** @hidden */
  61360. export var outlinePixelShader: {
  61361. name: string;
  61362. shader: string;
  61363. };
  61364. }
  61365. declare module BABYLON {
  61366. /** @hidden */
  61367. export var outlineVertexShader: {
  61368. name: string;
  61369. shader: string;
  61370. };
  61371. }
  61372. declare module BABYLON {
  61373. interface Scene {
  61374. /** @hidden */
  61375. _outlineRenderer: OutlineRenderer;
  61376. /**
  61377. * Gets the outline renderer associated with the scene
  61378. * @returns a OutlineRenderer
  61379. */
  61380. getOutlineRenderer(): OutlineRenderer;
  61381. }
  61382. interface AbstractMesh {
  61383. /** @hidden (Backing field) */
  61384. _renderOutline: boolean;
  61385. /**
  61386. * Gets or sets a boolean indicating if the outline must be rendered as well
  61387. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61388. */
  61389. renderOutline: boolean;
  61390. /** @hidden (Backing field) */
  61391. _renderOverlay: boolean;
  61392. /**
  61393. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61394. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61395. */
  61396. renderOverlay: boolean;
  61397. }
  61398. /**
  61399. * This class is responsible to draw bothe outline/overlay of meshes.
  61400. * It should not be used directly but through the available method on mesh.
  61401. */
  61402. export class OutlineRenderer implements ISceneComponent {
  61403. /**
  61404. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61405. */
  61406. private static _StencilReference;
  61407. /**
  61408. * The name of the component. Each component must have a unique name.
  61409. */
  61410. name: string;
  61411. /**
  61412. * The scene the component belongs to.
  61413. */
  61414. scene: Scene;
  61415. /**
  61416. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61417. */
  61418. zOffset: number;
  61419. private _engine;
  61420. private _effect;
  61421. private _cachedDefines;
  61422. private _savedDepthWrite;
  61423. /**
  61424. * Instantiates a new outline renderer. (There could be only one per scene).
  61425. * @param scene Defines the scene it belongs to
  61426. */
  61427. constructor(scene: Scene);
  61428. /**
  61429. * Register the component to one instance of a scene.
  61430. */
  61431. register(): void;
  61432. /**
  61433. * Rebuilds the elements related to this component in case of
  61434. * context lost for instance.
  61435. */
  61436. rebuild(): void;
  61437. /**
  61438. * Disposes the component and the associated ressources.
  61439. */
  61440. dispose(): void;
  61441. /**
  61442. * Renders the outline in the canvas.
  61443. * @param subMesh Defines the sumesh to render
  61444. * @param batch Defines the batch of meshes in case of instances
  61445. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61446. */
  61447. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61448. /**
  61449. * Returns whether or not the outline renderer is ready for a given submesh.
  61450. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61451. * @param subMesh Defines the submesh to check readyness for
  61452. * @param useInstances Defines wheter wee are trying to render instances or not
  61453. * @returns true if ready otherwise false
  61454. */
  61455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61456. private _beforeRenderingMesh;
  61457. private _afterRenderingMesh;
  61458. }
  61459. }
  61460. declare module BABYLON {
  61461. /**
  61462. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61463. * @see http://doc.babylonjs.com/babylon101/sprites
  61464. */
  61465. export class SpritePackedManager extends SpriteManager {
  61466. /** defines the packed manager's name */
  61467. name: string;
  61468. /**
  61469. * Creates a new sprite manager from a packed sprite sheet
  61470. * @param name defines the manager's name
  61471. * @param imgUrl defines the sprite sheet url
  61472. * @param capacity defines the maximum allowed number of sprites
  61473. * @param scene defines the hosting scene
  61474. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61475. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61476. * @param samplingMode defines the smapling mode to use with spritesheet
  61477. * @param fromPacked set to true; do not alter
  61478. */
  61479. constructor(
  61480. /** defines the packed manager's name */
  61481. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61482. }
  61483. }
  61484. declare module BABYLON {
  61485. /**
  61486. * Defines the list of states available for a task inside a AssetsManager
  61487. */
  61488. export enum AssetTaskState {
  61489. /**
  61490. * Initialization
  61491. */
  61492. INIT = 0,
  61493. /**
  61494. * Running
  61495. */
  61496. RUNNING = 1,
  61497. /**
  61498. * Done
  61499. */
  61500. DONE = 2,
  61501. /**
  61502. * Error
  61503. */
  61504. ERROR = 3
  61505. }
  61506. /**
  61507. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61508. */
  61509. export abstract class AbstractAssetTask {
  61510. /**
  61511. * Task name
  61512. */ name: string;
  61513. /**
  61514. * Callback called when the task is successful
  61515. */
  61516. onSuccess: (task: any) => void;
  61517. /**
  61518. * Callback called when the task is not successful
  61519. */
  61520. onError: (task: any, message?: string, exception?: any) => void;
  61521. /**
  61522. * Creates a new AssetsManager
  61523. * @param name defines the name of the task
  61524. */
  61525. constructor(
  61526. /**
  61527. * Task name
  61528. */ name: string);
  61529. private _isCompleted;
  61530. private _taskState;
  61531. private _errorObject;
  61532. /**
  61533. * Get if the task is completed
  61534. */
  61535. readonly isCompleted: boolean;
  61536. /**
  61537. * Gets the current state of the task
  61538. */
  61539. readonly taskState: AssetTaskState;
  61540. /**
  61541. * Gets the current error object (if task is in error)
  61542. */
  61543. readonly errorObject: {
  61544. message?: string;
  61545. exception?: any;
  61546. };
  61547. /**
  61548. * Internal only
  61549. * @hidden
  61550. */
  61551. _setErrorObject(message?: string, exception?: any): void;
  61552. /**
  61553. * Execute the current task
  61554. * @param scene defines the scene where you want your assets to be loaded
  61555. * @param onSuccess is a callback called when the task is successfully executed
  61556. * @param onError is a callback called if an error occurs
  61557. */
  61558. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61559. /**
  61560. * Execute the current task
  61561. * @param scene defines the scene where you want your assets to be loaded
  61562. * @param onSuccess is a callback called when the task is successfully executed
  61563. * @param onError is a callback called if an error occurs
  61564. */
  61565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61566. /**
  61567. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61568. * This can be used with failed tasks that have the reason for failure fixed.
  61569. */
  61570. reset(): void;
  61571. private onErrorCallback;
  61572. private onDoneCallback;
  61573. }
  61574. /**
  61575. * Define the interface used by progress events raised during assets loading
  61576. */
  61577. export interface IAssetsProgressEvent {
  61578. /**
  61579. * Defines the number of remaining tasks to process
  61580. */
  61581. remainingCount: number;
  61582. /**
  61583. * Defines the total number of tasks
  61584. */
  61585. totalCount: number;
  61586. /**
  61587. * Defines the task that was just processed
  61588. */
  61589. task: AbstractAssetTask;
  61590. }
  61591. /**
  61592. * Class used to share progress information about assets loading
  61593. */
  61594. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61595. /**
  61596. * Defines the number of remaining tasks to process
  61597. */
  61598. remainingCount: number;
  61599. /**
  61600. * Defines the total number of tasks
  61601. */
  61602. totalCount: number;
  61603. /**
  61604. * Defines the task that was just processed
  61605. */
  61606. task: AbstractAssetTask;
  61607. /**
  61608. * Creates a AssetsProgressEvent
  61609. * @param remainingCount defines the number of remaining tasks to process
  61610. * @param totalCount defines the total number of tasks
  61611. * @param task defines the task that was just processed
  61612. */
  61613. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61614. }
  61615. /**
  61616. * Define a task used by AssetsManager to load meshes
  61617. */
  61618. export class MeshAssetTask extends AbstractAssetTask {
  61619. /**
  61620. * Defines the name of the task
  61621. */
  61622. name: string;
  61623. /**
  61624. * Defines the list of mesh's names you want to load
  61625. */
  61626. meshesNames: any;
  61627. /**
  61628. * Defines the root url to use as a base to load your meshes and associated resources
  61629. */
  61630. rootUrl: string;
  61631. /**
  61632. * Defines the filename of the scene to load from
  61633. */
  61634. sceneFilename: string;
  61635. /**
  61636. * Gets the list of loaded meshes
  61637. */
  61638. loadedMeshes: Array<AbstractMesh>;
  61639. /**
  61640. * Gets the list of loaded particle systems
  61641. */
  61642. loadedParticleSystems: Array<IParticleSystem>;
  61643. /**
  61644. * Gets the list of loaded skeletons
  61645. */
  61646. loadedSkeletons: Array<Skeleton>;
  61647. /**
  61648. * Gets the list of loaded animation groups
  61649. */
  61650. loadedAnimationGroups: Array<AnimationGroup>;
  61651. /**
  61652. * Callback called when the task is successful
  61653. */
  61654. onSuccess: (task: MeshAssetTask) => void;
  61655. /**
  61656. * Callback called when the task is successful
  61657. */
  61658. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61659. /**
  61660. * Creates a new MeshAssetTask
  61661. * @param name defines the name of the task
  61662. * @param meshesNames defines the list of mesh's names you want to load
  61663. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61664. * @param sceneFilename defines the filename of the scene to load from
  61665. */
  61666. constructor(
  61667. /**
  61668. * Defines the name of the task
  61669. */
  61670. name: string,
  61671. /**
  61672. * Defines the list of mesh's names you want to load
  61673. */
  61674. meshesNames: any,
  61675. /**
  61676. * Defines the root url to use as a base to load your meshes and associated resources
  61677. */
  61678. rootUrl: string,
  61679. /**
  61680. * Defines the filename of the scene to load from
  61681. */
  61682. sceneFilename: string);
  61683. /**
  61684. * Execute the current task
  61685. * @param scene defines the scene where you want your assets to be loaded
  61686. * @param onSuccess is a callback called when the task is successfully executed
  61687. * @param onError is a callback called if an error occurs
  61688. */
  61689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61690. }
  61691. /**
  61692. * Define a task used by AssetsManager to load text content
  61693. */
  61694. export class TextFileAssetTask extends AbstractAssetTask {
  61695. /**
  61696. * Defines the name of the task
  61697. */
  61698. name: string;
  61699. /**
  61700. * Defines the location of the file to load
  61701. */
  61702. url: string;
  61703. /**
  61704. * Gets the loaded text string
  61705. */
  61706. text: string;
  61707. /**
  61708. * Callback called when the task is successful
  61709. */
  61710. onSuccess: (task: TextFileAssetTask) => void;
  61711. /**
  61712. * Callback called when the task is successful
  61713. */
  61714. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61715. /**
  61716. * Creates a new TextFileAssetTask object
  61717. * @param name defines the name of the task
  61718. * @param url defines the location of the file to load
  61719. */
  61720. constructor(
  61721. /**
  61722. * Defines the name of the task
  61723. */
  61724. name: string,
  61725. /**
  61726. * Defines the location of the file to load
  61727. */
  61728. url: string);
  61729. /**
  61730. * Execute the current task
  61731. * @param scene defines the scene where you want your assets to be loaded
  61732. * @param onSuccess is a callback called when the task is successfully executed
  61733. * @param onError is a callback called if an error occurs
  61734. */
  61735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61736. }
  61737. /**
  61738. * Define a task used by AssetsManager to load binary data
  61739. */
  61740. export class BinaryFileAssetTask extends AbstractAssetTask {
  61741. /**
  61742. * Defines the name of the task
  61743. */
  61744. name: string;
  61745. /**
  61746. * Defines the location of the file to load
  61747. */
  61748. url: string;
  61749. /**
  61750. * Gets the lodaded data (as an array buffer)
  61751. */
  61752. data: ArrayBuffer;
  61753. /**
  61754. * Callback called when the task is successful
  61755. */
  61756. onSuccess: (task: BinaryFileAssetTask) => void;
  61757. /**
  61758. * Callback called when the task is successful
  61759. */
  61760. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61761. /**
  61762. * Creates a new BinaryFileAssetTask object
  61763. * @param name defines the name of the new task
  61764. * @param url defines the location of the file to load
  61765. */
  61766. constructor(
  61767. /**
  61768. * Defines the name of the task
  61769. */
  61770. name: string,
  61771. /**
  61772. * Defines the location of the file to load
  61773. */
  61774. url: string);
  61775. /**
  61776. * Execute the current task
  61777. * @param scene defines the scene where you want your assets to be loaded
  61778. * @param onSuccess is a callback called when the task is successfully executed
  61779. * @param onError is a callback called if an error occurs
  61780. */
  61781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61782. }
  61783. /**
  61784. * Define a task used by AssetsManager to load images
  61785. */
  61786. export class ImageAssetTask extends AbstractAssetTask {
  61787. /**
  61788. * Defines the name of the task
  61789. */
  61790. name: string;
  61791. /**
  61792. * Defines the location of the image to load
  61793. */
  61794. url: string;
  61795. /**
  61796. * Gets the loaded images
  61797. */
  61798. image: HTMLImageElement;
  61799. /**
  61800. * Callback called when the task is successful
  61801. */
  61802. onSuccess: (task: ImageAssetTask) => void;
  61803. /**
  61804. * Callback called when the task is successful
  61805. */
  61806. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61807. /**
  61808. * Creates a new ImageAssetTask
  61809. * @param name defines the name of the task
  61810. * @param url defines the location of the image to load
  61811. */
  61812. constructor(
  61813. /**
  61814. * Defines the name of the task
  61815. */
  61816. name: string,
  61817. /**
  61818. * Defines the location of the image to load
  61819. */
  61820. url: string);
  61821. /**
  61822. * Execute the current task
  61823. * @param scene defines the scene where you want your assets to be loaded
  61824. * @param onSuccess is a callback called when the task is successfully executed
  61825. * @param onError is a callback called if an error occurs
  61826. */
  61827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61828. }
  61829. /**
  61830. * Defines the interface used by texture loading tasks
  61831. */
  61832. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61833. /**
  61834. * Gets the loaded texture
  61835. */
  61836. texture: TEX;
  61837. }
  61838. /**
  61839. * Define a task used by AssetsManager to load 2D textures
  61840. */
  61841. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61842. /**
  61843. * Defines the name of the task
  61844. */
  61845. name: string;
  61846. /**
  61847. * Defines the location of the file to load
  61848. */
  61849. url: string;
  61850. /**
  61851. * Defines if mipmap should not be generated (default is false)
  61852. */
  61853. noMipmap?: boolean | undefined;
  61854. /**
  61855. * Defines if texture must be inverted on Y axis (default is false)
  61856. */
  61857. invertY?: boolean | undefined;
  61858. /**
  61859. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61860. */
  61861. samplingMode: number;
  61862. /**
  61863. * Gets the loaded texture
  61864. */
  61865. texture: Texture;
  61866. /**
  61867. * Callback called when the task is successful
  61868. */
  61869. onSuccess: (task: TextureAssetTask) => void;
  61870. /**
  61871. * Callback called when the task is successful
  61872. */
  61873. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61874. /**
  61875. * Creates a new TextureAssetTask object
  61876. * @param name defines the name of the task
  61877. * @param url defines the location of the file to load
  61878. * @param noMipmap defines if mipmap should not be generated (default is false)
  61879. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61880. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61881. */
  61882. constructor(
  61883. /**
  61884. * Defines the name of the task
  61885. */
  61886. name: string,
  61887. /**
  61888. * Defines the location of the file to load
  61889. */
  61890. url: string,
  61891. /**
  61892. * Defines if mipmap should not be generated (default is false)
  61893. */
  61894. noMipmap?: boolean | undefined,
  61895. /**
  61896. * Defines if texture must be inverted on Y axis (default is false)
  61897. */
  61898. invertY?: boolean | undefined,
  61899. /**
  61900. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61901. */
  61902. samplingMode?: number);
  61903. /**
  61904. * Execute the current task
  61905. * @param scene defines the scene where you want your assets to be loaded
  61906. * @param onSuccess is a callback called when the task is successfully executed
  61907. * @param onError is a callback called if an error occurs
  61908. */
  61909. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61910. }
  61911. /**
  61912. * Define a task used by AssetsManager to load cube textures
  61913. */
  61914. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61915. /**
  61916. * Defines the name of the task
  61917. */
  61918. name: string;
  61919. /**
  61920. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61921. */
  61922. url: string;
  61923. /**
  61924. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61925. */
  61926. extensions?: string[] | undefined;
  61927. /**
  61928. * Defines if mipmaps should not be generated (default is false)
  61929. */
  61930. noMipmap?: boolean | undefined;
  61931. /**
  61932. * Defines the explicit list of files (undefined by default)
  61933. */
  61934. files?: string[] | undefined;
  61935. /**
  61936. * Gets the loaded texture
  61937. */
  61938. texture: CubeTexture;
  61939. /**
  61940. * Callback called when the task is successful
  61941. */
  61942. onSuccess: (task: CubeTextureAssetTask) => void;
  61943. /**
  61944. * Callback called when the task is successful
  61945. */
  61946. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61947. /**
  61948. * Creates a new CubeTextureAssetTask
  61949. * @param name defines the name of the task
  61950. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61951. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61952. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61953. * @param files defines the explicit list of files (undefined by default)
  61954. */
  61955. constructor(
  61956. /**
  61957. * Defines the name of the task
  61958. */
  61959. name: string,
  61960. /**
  61961. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61962. */
  61963. url: string,
  61964. /**
  61965. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61966. */
  61967. extensions?: string[] | undefined,
  61968. /**
  61969. * Defines if mipmaps should not be generated (default is false)
  61970. */
  61971. noMipmap?: boolean | undefined,
  61972. /**
  61973. * Defines the explicit list of files (undefined by default)
  61974. */
  61975. files?: string[] | undefined);
  61976. /**
  61977. * Execute the current task
  61978. * @param scene defines the scene where you want your assets to be loaded
  61979. * @param onSuccess is a callback called when the task is successfully executed
  61980. * @param onError is a callback called if an error occurs
  61981. */
  61982. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61983. }
  61984. /**
  61985. * Define a task used by AssetsManager to load HDR cube textures
  61986. */
  61987. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61988. /**
  61989. * Defines the name of the task
  61990. */
  61991. name: string;
  61992. /**
  61993. * Defines the location of the file to load
  61994. */
  61995. url: string;
  61996. /**
  61997. * Defines the desired size (the more it increases the longer the generation will be)
  61998. */
  61999. size: number;
  62000. /**
  62001. * Defines if mipmaps should not be generated (default is false)
  62002. */
  62003. noMipmap: boolean;
  62004. /**
  62005. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62006. */
  62007. generateHarmonics: boolean;
  62008. /**
  62009. * 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)
  62010. */
  62011. gammaSpace: boolean;
  62012. /**
  62013. * Internal Use Only
  62014. */
  62015. reserved: boolean;
  62016. /**
  62017. * Gets the loaded texture
  62018. */
  62019. texture: HDRCubeTexture;
  62020. /**
  62021. * Callback called when the task is successful
  62022. */
  62023. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62024. /**
  62025. * Callback called when the task is successful
  62026. */
  62027. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62028. /**
  62029. * Creates a new HDRCubeTextureAssetTask object
  62030. * @param name defines the name of the task
  62031. * @param url defines the location of the file to load
  62032. * @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.
  62033. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62034. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62035. * @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)
  62036. * @param reserved Internal use only
  62037. */
  62038. constructor(
  62039. /**
  62040. * Defines the name of the task
  62041. */
  62042. name: string,
  62043. /**
  62044. * Defines the location of the file to load
  62045. */
  62046. url: string,
  62047. /**
  62048. * Defines the desired size (the more it increases the longer the generation will be)
  62049. */
  62050. size: number,
  62051. /**
  62052. * Defines if mipmaps should not be generated (default is false)
  62053. */
  62054. noMipmap?: boolean,
  62055. /**
  62056. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62057. */
  62058. generateHarmonics?: boolean,
  62059. /**
  62060. * 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)
  62061. */
  62062. gammaSpace?: boolean,
  62063. /**
  62064. * Internal Use Only
  62065. */
  62066. reserved?: boolean);
  62067. /**
  62068. * Execute the current task
  62069. * @param scene defines the scene where you want your assets to be loaded
  62070. * @param onSuccess is a callback called when the task is successfully executed
  62071. * @param onError is a callback called if an error occurs
  62072. */
  62073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62074. }
  62075. /**
  62076. * Define a task used by AssetsManager to load Equirectangular cube textures
  62077. */
  62078. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62079. /**
  62080. * Defines the name of the task
  62081. */
  62082. name: string;
  62083. /**
  62084. * Defines the location of the file to load
  62085. */
  62086. url: string;
  62087. /**
  62088. * Defines the desired size (the more it increases the longer the generation will be)
  62089. */
  62090. size: number;
  62091. /**
  62092. * Defines if mipmaps should not be generated (default is false)
  62093. */
  62094. noMipmap: boolean;
  62095. /**
  62096. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62097. * but the standard material would require them in Gamma space) (default is true)
  62098. */
  62099. gammaSpace: boolean;
  62100. /**
  62101. * Gets the loaded texture
  62102. */
  62103. texture: EquiRectangularCubeTexture;
  62104. /**
  62105. * Callback called when the task is successful
  62106. */
  62107. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62108. /**
  62109. * Callback called when the task is successful
  62110. */
  62111. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62112. /**
  62113. * Creates a new EquiRectangularCubeTextureAssetTask object
  62114. * @param name defines the name of the task
  62115. * @param url defines the location of the file to load
  62116. * @param size defines the desired size (the more it increases the longer the generation will be)
  62117. * If the size is omitted this implies you are using a preprocessed cubemap.
  62118. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62119. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62120. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62121. * (default is true)
  62122. */
  62123. constructor(
  62124. /**
  62125. * Defines the name of the task
  62126. */
  62127. name: string,
  62128. /**
  62129. * Defines the location of the file to load
  62130. */
  62131. url: string,
  62132. /**
  62133. * Defines the desired size (the more it increases the longer the generation will be)
  62134. */
  62135. size: number,
  62136. /**
  62137. * Defines if mipmaps should not be generated (default is false)
  62138. */
  62139. noMipmap?: boolean,
  62140. /**
  62141. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62142. * but the standard material would require them in Gamma space) (default is true)
  62143. */
  62144. gammaSpace?: boolean);
  62145. /**
  62146. * Execute the current task
  62147. * @param scene defines the scene where you want your assets to be loaded
  62148. * @param onSuccess is a callback called when the task is successfully executed
  62149. * @param onError is a callback called if an error occurs
  62150. */
  62151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62152. }
  62153. /**
  62154. * This class can be used to easily import assets into a scene
  62155. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62156. */
  62157. export class AssetsManager {
  62158. private _scene;
  62159. private _isLoading;
  62160. protected _tasks: AbstractAssetTask[];
  62161. protected _waitingTasksCount: number;
  62162. protected _totalTasksCount: number;
  62163. /**
  62164. * Callback called when all tasks are processed
  62165. */
  62166. onFinish: (tasks: AbstractAssetTask[]) => void;
  62167. /**
  62168. * Callback called when a task is successful
  62169. */
  62170. onTaskSuccess: (task: AbstractAssetTask) => void;
  62171. /**
  62172. * Callback called when a task had an error
  62173. */
  62174. onTaskError: (task: AbstractAssetTask) => void;
  62175. /**
  62176. * Callback called when a task is done (whatever the result is)
  62177. */
  62178. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62179. /**
  62180. * Observable called when all tasks are processed
  62181. */
  62182. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62183. /**
  62184. * Observable called when a task had an error
  62185. */
  62186. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62187. /**
  62188. * Observable called when all tasks were executed
  62189. */
  62190. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62191. /**
  62192. * Observable called when a task is done (whatever the result is)
  62193. */
  62194. onProgressObservable: Observable<IAssetsProgressEvent>;
  62195. /**
  62196. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62198. */
  62199. useDefaultLoadingScreen: boolean;
  62200. /**
  62201. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62202. * when all assets have been downloaded.
  62203. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62204. */
  62205. autoHideLoadingUI: boolean;
  62206. /**
  62207. * Creates a new AssetsManager
  62208. * @param scene defines the scene to work on
  62209. */
  62210. constructor(scene: Scene);
  62211. /**
  62212. * Add a MeshAssetTask to the list of active tasks
  62213. * @param taskName defines the name of the new task
  62214. * @param meshesNames defines the name of meshes to load
  62215. * @param rootUrl defines the root url to use to locate files
  62216. * @param sceneFilename defines the filename of the scene file
  62217. * @returns a new MeshAssetTask object
  62218. */
  62219. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62220. /**
  62221. * Add a TextFileAssetTask to the list of active tasks
  62222. * @param taskName defines the name of the new task
  62223. * @param url defines the url of the file to load
  62224. * @returns a new TextFileAssetTask object
  62225. */
  62226. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62227. /**
  62228. * Add a BinaryFileAssetTask to the list of active tasks
  62229. * @param taskName defines the name of the new task
  62230. * @param url defines the url of the file to load
  62231. * @returns a new BinaryFileAssetTask object
  62232. */
  62233. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62234. /**
  62235. * Add a ImageAssetTask to the list of active tasks
  62236. * @param taskName defines the name of the new task
  62237. * @param url defines the url of the file to load
  62238. * @returns a new ImageAssetTask object
  62239. */
  62240. addImageTask(taskName: string, url: string): ImageAssetTask;
  62241. /**
  62242. * Add a TextureAssetTask to the list of active tasks
  62243. * @param taskName defines the name of the new task
  62244. * @param url defines the url of the file to load
  62245. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62246. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62247. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62248. * @returns a new TextureAssetTask object
  62249. */
  62250. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62251. /**
  62252. * Add a CubeTextureAssetTask to the list of active tasks
  62253. * @param taskName defines the name of the new task
  62254. * @param url defines the url of the file to load
  62255. * @param extensions defines the extension to use to load the cube map (can be null)
  62256. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62257. * @param files defines the list of files to load (can be null)
  62258. * @returns a new CubeTextureAssetTask object
  62259. */
  62260. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62261. /**
  62262. *
  62263. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62264. * @param taskName defines the name of the new task
  62265. * @param url defines the url of the file to load
  62266. * @param size defines the size you want for the cubemap (can be null)
  62267. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62268. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62269. * @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)
  62270. * @param reserved Internal use only
  62271. * @returns a new HDRCubeTextureAssetTask object
  62272. */
  62273. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62274. /**
  62275. *
  62276. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62277. * @param taskName defines the name of the new task
  62278. * @param url defines the url of the file to load
  62279. * @param size defines the size you want for the cubemap (can be null)
  62280. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62281. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62282. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62283. * @returns a new EquiRectangularCubeTextureAssetTask object
  62284. */
  62285. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62286. /**
  62287. * Remove a task from the assets manager.
  62288. * @param task the task to remove
  62289. */
  62290. removeTask(task: AbstractAssetTask): void;
  62291. private _decreaseWaitingTasksCount;
  62292. private _runTask;
  62293. /**
  62294. * Reset the AssetsManager and remove all tasks
  62295. * @return the current instance of the AssetsManager
  62296. */
  62297. reset(): AssetsManager;
  62298. /**
  62299. * Start the loading process
  62300. * @return the current instance of the AssetsManager
  62301. */
  62302. load(): AssetsManager;
  62303. /**
  62304. * Start the loading process as an async operation
  62305. * @return a promise returning the list of failed tasks
  62306. */
  62307. loadAsync(): Promise<void>;
  62308. }
  62309. }
  62310. declare module BABYLON {
  62311. /**
  62312. * Wrapper class for promise with external resolve and reject.
  62313. */
  62314. export class Deferred<T> {
  62315. /**
  62316. * The promise associated with this deferred object.
  62317. */
  62318. readonly promise: Promise<T>;
  62319. private _resolve;
  62320. private _reject;
  62321. /**
  62322. * The resolve method of the promise associated with this deferred object.
  62323. */
  62324. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62325. /**
  62326. * The reject method of the promise associated with this deferred object.
  62327. */
  62328. readonly reject: (reason?: any) => void;
  62329. /**
  62330. * Constructor for this deferred object.
  62331. */
  62332. constructor();
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62338. */
  62339. export class MeshExploder {
  62340. private _centerMesh;
  62341. private _meshes;
  62342. private _meshesOrigins;
  62343. private _toCenterVectors;
  62344. private _scaledDirection;
  62345. private _newPosition;
  62346. private _centerPosition;
  62347. /**
  62348. * Explodes meshes from a center mesh.
  62349. * @param meshes The meshes to explode.
  62350. * @param centerMesh The mesh to be center of explosion.
  62351. */
  62352. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62353. private _setCenterMesh;
  62354. /**
  62355. * Get class name
  62356. * @returns "MeshExploder"
  62357. */
  62358. getClassName(): string;
  62359. /**
  62360. * "Exploded meshes"
  62361. * @returns Array of meshes with the centerMesh at index 0.
  62362. */
  62363. getMeshes(): Array<Mesh>;
  62364. /**
  62365. * Explodes meshes giving a specific direction
  62366. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62367. */
  62368. explode(direction?: number): void;
  62369. }
  62370. }
  62371. declare module BABYLON {
  62372. /**
  62373. * Class used to help managing file picking and drag'n'drop
  62374. */
  62375. export class FilesInput {
  62376. /**
  62377. * List of files ready to be loaded
  62378. */
  62379. static readonly FilesToLoad: {
  62380. [key: string]: File;
  62381. };
  62382. /**
  62383. * Callback called when a file is processed
  62384. */
  62385. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62386. private _engine;
  62387. private _currentScene;
  62388. private _sceneLoadedCallback;
  62389. private _progressCallback;
  62390. private _additionalRenderLoopLogicCallback;
  62391. private _textureLoadingCallback;
  62392. private _startingProcessingFilesCallback;
  62393. private _onReloadCallback;
  62394. private _errorCallback;
  62395. private _elementToMonitor;
  62396. private _sceneFileToLoad;
  62397. private _filesToLoad;
  62398. /**
  62399. * Creates a new FilesInput
  62400. * @param engine defines the rendering engine
  62401. * @param scene defines the hosting scene
  62402. * @param sceneLoadedCallback callback called when scene is loaded
  62403. * @param progressCallback callback called to track progress
  62404. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62405. * @param textureLoadingCallback callback called when a texture is loading
  62406. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62407. * @param onReloadCallback callback called when a reload is requested
  62408. * @param errorCallback callback call if an error occurs
  62409. */
  62410. 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);
  62411. private _dragEnterHandler;
  62412. private _dragOverHandler;
  62413. private _dropHandler;
  62414. /**
  62415. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62416. * @param elementToMonitor defines the DOM element to track
  62417. */
  62418. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62419. /**
  62420. * Release all associated resources
  62421. */
  62422. dispose(): void;
  62423. private renderFunction;
  62424. private drag;
  62425. private drop;
  62426. private _traverseFolder;
  62427. private _processFiles;
  62428. /**
  62429. * Load files from a drop event
  62430. * @param event defines the drop event to use as source
  62431. */
  62432. loadFiles(event: any): void;
  62433. private _processReload;
  62434. /**
  62435. * Reload the current scene from the loaded files
  62436. */
  62437. reload(): void;
  62438. }
  62439. }
  62440. declare module BABYLON {
  62441. /**
  62442. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62444. */
  62445. export class SceneOptimization {
  62446. /**
  62447. * Defines the priority of this optimization (0 by default which means first in the list)
  62448. */
  62449. priority: number;
  62450. /**
  62451. * Gets a string describing the action executed by the current optimization
  62452. * @returns description string
  62453. */
  62454. getDescription(): string;
  62455. /**
  62456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62457. * @param scene defines the current scene where to apply this optimization
  62458. * @param optimizer defines the current optimizer
  62459. * @returns true if everything that can be done was applied
  62460. */
  62461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62462. /**
  62463. * Creates the SceneOptimization object
  62464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62465. * @param desc defines the description associated with the optimization
  62466. */
  62467. constructor(
  62468. /**
  62469. * Defines the priority of this optimization (0 by default which means first in the list)
  62470. */
  62471. priority?: number);
  62472. }
  62473. /**
  62474. * Defines an optimization used to reduce the size of render target textures
  62475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62476. */
  62477. export class TextureOptimization extends SceneOptimization {
  62478. /**
  62479. * Defines the priority of this optimization (0 by default which means first in the list)
  62480. */
  62481. priority: number;
  62482. /**
  62483. * 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
  62484. */
  62485. maximumSize: number;
  62486. /**
  62487. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62488. */
  62489. step: number;
  62490. /**
  62491. * Gets a string describing the action executed by the current optimization
  62492. * @returns description string
  62493. */
  62494. getDescription(): string;
  62495. /**
  62496. * Creates the TextureOptimization object
  62497. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62498. * @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
  62499. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62500. */
  62501. constructor(
  62502. /**
  62503. * Defines the priority of this optimization (0 by default which means first in the list)
  62504. */
  62505. priority?: number,
  62506. /**
  62507. * 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
  62508. */
  62509. maximumSize?: number,
  62510. /**
  62511. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62512. */
  62513. step?: number);
  62514. /**
  62515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62516. * @param scene defines the current scene where to apply this optimization
  62517. * @param optimizer defines the current optimizer
  62518. * @returns true if everything that can be done was applied
  62519. */
  62520. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62521. }
  62522. /**
  62523. * Defines an optimization used to increase or decrease the rendering resolution
  62524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62525. */
  62526. export class HardwareScalingOptimization extends SceneOptimization {
  62527. /**
  62528. * Defines the priority of this optimization (0 by default which means first in the list)
  62529. */
  62530. priority: number;
  62531. /**
  62532. * Defines the maximum scale to use (2 by default)
  62533. */
  62534. maximumScale: number;
  62535. /**
  62536. * Defines the step to use between two passes (0.5 by default)
  62537. */
  62538. step: number;
  62539. private _currentScale;
  62540. private _directionOffset;
  62541. /**
  62542. * Gets a string describing the action executed by the current optimization
  62543. * @return description string
  62544. */
  62545. getDescription(): string;
  62546. /**
  62547. * Creates the HardwareScalingOptimization object
  62548. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62549. * @param maximumScale defines the maximum scale to use (2 by default)
  62550. * @param step defines the step to use between two passes (0.5 by default)
  62551. */
  62552. constructor(
  62553. /**
  62554. * Defines the priority of this optimization (0 by default which means first in the list)
  62555. */
  62556. priority?: number,
  62557. /**
  62558. * Defines the maximum scale to use (2 by default)
  62559. */
  62560. maximumScale?: number,
  62561. /**
  62562. * Defines the step to use between two passes (0.5 by default)
  62563. */
  62564. step?: number);
  62565. /**
  62566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62567. * @param scene defines the current scene where to apply this optimization
  62568. * @param optimizer defines the current optimizer
  62569. * @returns true if everything that can be done was applied
  62570. */
  62571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62572. }
  62573. /**
  62574. * Defines an optimization used to remove shadows
  62575. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62576. */
  62577. export class ShadowsOptimization extends SceneOptimization {
  62578. /**
  62579. * Gets a string describing the action executed by the current optimization
  62580. * @return description string
  62581. */
  62582. getDescription(): string;
  62583. /**
  62584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62585. * @param scene defines the current scene where to apply this optimization
  62586. * @param optimizer defines the current optimizer
  62587. * @returns true if everything that can be done was applied
  62588. */
  62589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62590. }
  62591. /**
  62592. * Defines an optimization used to turn post-processes off
  62593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62594. */
  62595. export class PostProcessesOptimization extends SceneOptimization {
  62596. /**
  62597. * Gets a string describing the action executed by the current optimization
  62598. * @return description string
  62599. */
  62600. getDescription(): string;
  62601. /**
  62602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62603. * @param scene defines the current scene where to apply this optimization
  62604. * @param optimizer defines the current optimizer
  62605. * @returns true if everything that can be done was applied
  62606. */
  62607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62608. }
  62609. /**
  62610. * Defines an optimization used to turn lens flares off
  62611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62612. */
  62613. export class LensFlaresOptimization extends SceneOptimization {
  62614. /**
  62615. * Gets a string describing the action executed by the current optimization
  62616. * @return description string
  62617. */
  62618. getDescription(): string;
  62619. /**
  62620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62621. * @param scene defines the current scene where to apply this optimization
  62622. * @param optimizer defines the current optimizer
  62623. * @returns true if everything that can be done was applied
  62624. */
  62625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62626. }
  62627. /**
  62628. * Defines an optimization based on user defined callback.
  62629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62630. */
  62631. export class CustomOptimization extends SceneOptimization {
  62632. /**
  62633. * Callback called to apply the custom optimization.
  62634. */
  62635. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62636. /**
  62637. * Callback called to get custom description
  62638. */
  62639. onGetDescription: () => string;
  62640. /**
  62641. * Gets a string describing the action executed by the current optimization
  62642. * @returns description string
  62643. */
  62644. getDescription(): string;
  62645. /**
  62646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62647. * @param scene defines the current scene where to apply this optimization
  62648. * @param optimizer defines the current optimizer
  62649. * @returns true if everything that can be done was applied
  62650. */
  62651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62652. }
  62653. /**
  62654. * Defines an optimization used to turn particles off
  62655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62656. */
  62657. export class ParticlesOptimization extends SceneOptimization {
  62658. /**
  62659. * Gets a string describing the action executed by the current optimization
  62660. * @return description string
  62661. */
  62662. getDescription(): string;
  62663. /**
  62664. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62665. * @param scene defines the current scene where to apply this optimization
  62666. * @param optimizer defines the current optimizer
  62667. * @returns true if everything that can be done was applied
  62668. */
  62669. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62670. }
  62671. /**
  62672. * Defines an optimization used to turn render targets off
  62673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62674. */
  62675. export class RenderTargetsOptimization extends SceneOptimization {
  62676. /**
  62677. * Gets a string describing the action executed by the current optimization
  62678. * @return description string
  62679. */
  62680. getDescription(): string;
  62681. /**
  62682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62683. * @param scene defines the current scene where to apply this optimization
  62684. * @param optimizer defines the current optimizer
  62685. * @returns true if everything that can be done was applied
  62686. */
  62687. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62688. }
  62689. /**
  62690. * Defines an optimization used to merge meshes with compatible materials
  62691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62692. */
  62693. export class MergeMeshesOptimization extends SceneOptimization {
  62694. private static _UpdateSelectionTree;
  62695. /**
  62696. * Gets or sets a boolean which defines if optimization octree has to be updated
  62697. */
  62698. /**
  62699. * Gets or sets a boolean which defines if optimization octree has to be updated
  62700. */
  62701. static UpdateSelectionTree: boolean;
  62702. /**
  62703. * Gets a string describing the action executed by the current optimization
  62704. * @return description string
  62705. */
  62706. getDescription(): string;
  62707. private _canBeMerged;
  62708. /**
  62709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62710. * @param scene defines the current scene where to apply this optimization
  62711. * @param optimizer defines the current optimizer
  62712. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62713. * @returns true if everything that can be done was applied
  62714. */
  62715. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62716. }
  62717. /**
  62718. * Defines a list of options used by SceneOptimizer
  62719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62720. */
  62721. export class SceneOptimizerOptions {
  62722. /**
  62723. * Defines the target frame rate to reach (60 by default)
  62724. */
  62725. targetFrameRate: number;
  62726. /**
  62727. * Defines the interval between two checkes (2000ms by default)
  62728. */
  62729. trackerDuration: number;
  62730. /**
  62731. * Gets the list of optimizations to apply
  62732. */
  62733. optimizations: SceneOptimization[];
  62734. /**
  62735. * Creates a new list of options used by SceneOptimizer
  62736. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62737. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62738. */
  62739. constructor(
  62740. /**
  62741. * Defines the target frame rate to reach (60 by default)
  62742. */
  62743. targetFrameRate?: number,
  62744. /**
  62745. * Defines the interval between two checkes (2000ms by default)
  62746. */
  62747. trackerDuration?: number);
  62748. /**
  62749. * Add a new optimization
  62750. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62751. * @returns the current SceneOptimizerOptions
  62752. */
  62753. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62754. /**
  62755. * Add a new custom optimization
  62756. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62757. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62758. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62759. * @returns the current SceneOptimizerOptions
  62760. */
  62761. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62762. /**
  62763. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62764. * @param targetFrameRate defines the target frame rate (60 by default)
  62765. * @returns a SceneOptimizerOptions object
  62766. */
  62767. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62768. /**
  62769. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62770. * @param targetFrameRate defines the target frame rate (60 by default)
  62771. * @returns a SceneOptimizerOptions object
  62772. */
  62773. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62774. /**
  62775. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62776. * @param targetFrameRate defines the target frame rate (60 by default)
  62777. * @returns a SceneOptimizerOptions object
  62778. */
  62779. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62780. }
  62781. /**
  62782. * Class used to run optimizations in order to reach a target frame rate
  62783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62784. */
  62785. export class SceneOptimizer implements IDisposable {
  62786. private _isRunning;
  62787. private _options;
  62788. private _scene;
  62789. private _currentPriorityLevel;
  62790. private _targetFrameRate;
  62791. private _trackerDuration;
  62792. private _currentFrameRate;
  62793. private _sceneDisposeObserver;
  62794. private _improvementMode;
  62795. /**
  62796. * Defines an observable called when the optimizer reaches the target frame rate
  62797. */
  62798. onSuccessObservable: Observable<SceneOptimizer>;
  62799. /**
  62800. * Defines an observable called when the optimizer enables an optimization
  62801. */
  62802. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62803. /**
  62804. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62805. */
  62806. onFailureObservable: Observable<SceneOptimizer>;
  62807. /**
  62808. * Gets a boolean indicating if the optimizer is in improvement mode
  62809. */
  62810. readonly isInImprovementMode: boolean;
  62811. /**
  62812. * Gets the current priority level (0 at start)
  62813. */
  62814. readonly currentPriorityLevel: number;
  62815. /**
  62816. * Gets the current frame rate checked by the SceneOptimizer
  62817. */
  62818. readonly currentFrameRate: number;
  62819. /**
  62820. * Gets or sets the current target frame rate (60 by default)
  62821. */
  62822. /**
  62823. * Gets or sets the current target frame rate (60 by default)
  62824. */
  62825. targetFrameRate: number;
  62826. /**
  62827. * Gets or sets the current interval between two checks (every 2000ms by default)
  62828. */
  62829. /**
  62830. * Gets or sets the current interval between two checks (every 2000ms by default)
  62831. */
  62832. trackerDuration: number;
  62833. /**
  62834. * Gets the list of active optimizations
  62835. */
  62836. readonly optimizations: SceneOptimization[];
  62837. /**
  62838. * Creates a new SceneOptimizer
  62839. * @param scene defines the scene to work on
  62840. * @param options defines the options to use with the SceneOptimizer
  62841. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62842. * @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)
  62843. */
  62844. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62845. /**
  62846. * Stops the current optimizer
  62847. */
  62848. stop(): void;
  62849. /**
  62850. * Reset the optimizer to initial step (current priority level = 0)
  62851. */
  62852. reset(): void;
  62853. /**
  62854. * Start the optimizer. By default it will try to reach a specific framerate
  62855. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62856. */
  62857. start(): void;
  62858. private _checkCurrentState;
  62859. /**
  62860. * Release all resources
  62861. */
  62862. dispose(): void;
  62863. /**
  62864. * Helper function to create a SceneOptimizer with one single line of code
  62865. * @param scene defines the scene to work on
  62866. * @param options defines the options to use with the SceneOptimizer
  62867. * @param onSuccess defines a callback to call on success
  62868. * @param onFailure defines a callback to call on failure
  62869. * @returns the new SceneOptimizer object
  62870. */
  62871. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62872. }
  62873. }
  62874. declare module BABYLON {
  62875. /**
  62876. * Class used to serialize a scene into a string
  62877. */
  62878. export class SceneSerializer {
  62879. /**
  62880. * Clear cache used by a previous serialization
  62881. */
  62882. static ClearCache(): void;
  62883. /**
  62884. * Serialize a scene into a JSON compatible object
  62885. * @param scene defines the scene to serialize
  62886. * @returns a JSON compatible object
  62887. */
  62888. static Serialize(scene: Scene): any;
  62889. /**
  62890. * Serialize a mesh into a JSON compatible object
  62891. * @param toSerialize defines the mesh to serialize
  62892. * @param withParents defines if parents must be serialized as well
  62893. * @param withChildren defines if children must be serialized as well
  62894. * @returns a JSON compatible object
  62895. */
  62896. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Class used to host texture specific utilities
  62902. */
  62903. export class TextureTools {
  62904. /**
  62905. * Uses the GPU to create a copy texture rescaled at a given size
  62906. * @param texture Texture to copy from
  62907. * @param width defines the desired width
  62908. * @param height defines the desired height
  62909. * @param useBilinearMode defines if bilinear mode has to be used
  62910. * @return the generated texture
  62911. */
  62912. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62913. }
  62914. }
  62915. declare module BABYLON {
  62916. /**
  62917. * This represents the different options available for the video capture.
  62918. */
  62919. export interface VideoRecorderOptions {
  62920. /** Defines the mime type of the video. */
  62921. mimeType: string;
  62922. /** Defines the FPS the video should be recorded at. */
  62923. fps: number;
  62924. /** Defines the chunk size for the recording data. */
  62925. recordChunckSize: number;
  62926. /** The audio tracks to attach to the recording. */
  62927. audioTracks?: MediaStreamTrack[];
  62928. }
  62929. /**
  62930. * This can help with recording videos from BabylonJS.
  62931. * This is based on the available WebRTC functionalities of the browser.
  62932. *
  62933. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62934. */
  62935. export class VideoRecorder {
  62936. private static readonly _defaultOptions;
  62937. /**
  62938. * Returns whether or not the VideoRecorder is available in your browser.
  62939. * @param engine Defines the Babylon Engine.
  62940. * @returns true if supported otherwise false.
  62941. */
  62942. static IsSupported(engine: Engine): boolean;
  62943. private readonly _options;
  62944. private _canvas;
  62945. private _mediaRecorder;
  62946. private _recordedChunks;
  62947. private _fileName;
  62948. private _resolve;
  62949. private _reject;
  62950. /**
  62951. * True when a recording is already in progress.
  62952. */
  62953. readonly isRecording: boolean;
  62954. /**
  62955. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62956. * @param engine Defines the BabylonJS Engine you wish to record.
  62957. * @param options Defines options that can be used to customize the capture.
  62958. */
  62959. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62960. /**
  62961. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62962. */
  62963. stopRecording(): void;
  62964. /**
  62965. * Starts recording the canvas for a max duration specified in parameters.
  62966. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62967. * If null no automatic download will start and you can rely on the promise to get the data back.
  62968. * @param maxDuration Defines the maximum recording time in seconds.
  62969. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62970. * @return A promise callback at the end of the recording with the video data in Blob.
  62971. */
  62972. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62973. /**
  62974. * Releases internal resources used during the recording.
  62975. */
  62976. dispose(): void;
  62977. private _handleDataAvailable;
  62978. private _handleError;
  62979. private _handleStop;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Class containing a set of static utilities functions for screenshots
  62985. */
  62986. export class ScreenshotTools {
  62987. /**
  62988. * Captures a screenshot of the current rendering
  62989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62990. * @param engine defines the rendering engine
  62991. * @param camera defines the source camera
  62992. * @param size This parameter can be set to a single number or to an object with the
  62993. * following (optional) properties: precision, width, height. If a single number is passed,
  62994. * it will be used for both width and height. If an object is passed, the screenshot size
  62995. * will be derived from the parameters. The precision property is a multiplier allowing
  62996. * rendering at a higher or lower resolution
  62997. * @param successCallback defines the callback receives a single parameter which contains the
  62998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62999. * src parameter of an <img> to display it
  63000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63001. * Check your browser for supported MIME types
  63002. */
  63003. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63004. /**
  63005. * Captures a screenshot of the current rendering
  63006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63007. * @param engine defines the rendering engine
  63008. * @param camera defines the source camera
  63009. * @param size This parameter can be set to a single number or to an object with the
  63010. * following (optional) properties: precision, width, height. If a single number is passed,
  63011. * it will be used for both width and height. If an object is passed, the screenshot size
  63012. * will be derived from the parameters. The precision property is a multiplier allowing
  63013. * rendering at a higher or lower resolution
  63014. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63015. * Check your browser for supported MIME types
  63016. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63017. * to the src parameter of an <img> to display it
  63018. */
  63019. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63020. /**
  63021. * Generates an image screenshot from the specified camera.
  63022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63023. * @param engine The engine to use for rendering
  63024. * @param camera The camera to use for rendering
  63025. * @param size This parameter can be set to a single number or to an object with the
  63026. * following (optional) properties: precision, width, height. If a single number is passed,
  63027. * it will be used for both width and height. If an object is passed, the screenshot size
  63028. * will be derived from the parameters. The precision property is a multiplier allowing
  63029. * rendering at a higher or lower resolution
  63030. * @param successCallback The callback receives a single parameter which contains the
  63031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63032. * src parameter of an <img> to display it
  63033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63034. * Check your browser for supported MIME types
  63035. * @param samples Texture samples (default: 1)
  63036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63037. * @param fileName A name for for the downloaded file.
  63038. */
  63039. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63040. /**
  63041. * Generates an image screenshot from the specified camera.
  63042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63043. * @param engine The engine to use for rendering
  63044. * @param camera The camera to use for rendering
  63045. * @param size This parameter can be set to a single number or to an object with the
  63046. * following (optional) properties: precision, width, height. If a single number is passed,
  63047. * it will be used for both width and height. If an object is passed, the screenshot size
  63048. * will be derived from the parameters. The precision property is a multiplier allowing
  63049. * rendering at a higher or lower resolution
  63050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63051. * Check your browser for supported MIME types
  63052. * @param samples Texture samples (default: 1)
  63053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63054. * @param fileName A name for for the downloaded file.
  63055. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63056. * to the src parameter of an <img> to display it
  63057. */
  63058. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63059. /**
  63060. * Gets height and width for screenshot size
  63061. * @private
  63062. */
  63063. private static _getScreenshotSize;
  63064. }
  63065. }
  63066. declare module BABYLON {
  63067. /**
  63068. * A cursor which tracks a point on a path
  63069. */
  63070. export class PathCursor {
  63071. private path;
  63072. /**
  63073. * Stores path cursor callbacks for when an onchange event is triggered
  63074. */
  63075. private _onchange;
  63076. /**
  63077. * The value of the path cursor
  63078. */
  63079. value: number;
  63080. /**
  63081. * The animation array of the path cursor
  63082. */
  63083. animations: Animation[];
  63084. /**
  63085. * Initializes the path cursor
  63086. * @param path The path to track
  63087. */
  63088. constructor(path: Path2);
  63089. /**
  63090. * Gets the cursor point on the path
  63091. * @returns A point on the path cursor at the cursor location
  63092. */
  63093. getPoint(): Vector3;
  63094. /**
  63095. * Moves the cursor ahead by the step amount
  63096. * @param step The amount to move the cursor forward
  63097. * @returns This path cursor
  63098. */
  63099. moveAhead(step?: number): PathCursor;
  63100. /**
  63101. * Moves the cursor behind by the step amount
  63102. * @param step The amount to move the cursor back
  63103. * @returns This path cursor
  63104. */
  63105. moveBack(step?: number): PathCursor;
  63106. /**
  63107. * Moves the cursor by the step amount
  63108. * If the step amount is greater than one, an exception is thrown
  63109. * @param step The amount to move the cursor
  63110. * @returns This path cursor
  63111. */
  63112. move(step: number): PathCursor;
  63113. /**
  63114. * Ensures that the value is limited between zero and one
  63115. * @returns This path cursor
  63116. */
  63117. private ensureLimits;
  63118. /**
  63119. * Runs onchange callbacks on change (used by the animation engine)
  63120. * @returns This path cursor
  63121. */
  63122. private raiseOnChange;
  63123. /**
  63124. * Executes a function on change
  63125. * @param f A path cursor onchange callback
  63126. * @returns This path cursor
  63127. */
  63128. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63129. }
  63130. }
  63131. declare module BABYLON {
  63132. /** @hidden */
  63133. export var blurPixelShader: {
  63134. name: string;
  63135. shader: string;
  63136. };
  63137. }
  63138. declare module BABYLON {
  63139. /** @hidden */
  63140. export var pointCloudVertexDeclaration: {
  63141. name: string;
  63142. shader: string;
  63143. };
  63144. }
  63145. // Mixins
  63146. interface Window {
  63147. mozIndexedDB: IDBFactory;
  63148. webkitIndexedDB: IDBFactory;
  63149. msIndexedDB: IDBFactory;
  63150. webkitURL: typeof URL;
  63151. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63152. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63153. WebGLRenderingContext: WebGLRenderingContext;
  63154. MSGesture: MSGesture;
  63155. CANNON: any;
  63156. AudioContext: AudioContext;
  63157. webkitAudioContext: AudioContext;
  63158. PointerEvent: any;
  63159. Math: Math;
  63160. Uint8Array: Uint8ArrayConstructor;
  63161. Float32Array: Float32ArrayConstructor;
  63162. mozURL: typeof URL;
  63163. msURL: typeof URL;
  63164. VRFrameData: any; // WebVR, from specs 1.1
  63165. DracoDecoderModule: any;
  63166. setImmediate(handler: (...args: any[]) => void): number;
  63167. }
  63168. interface HTMLCanvasElement {
  63169. requestPointerLock(): void;
  63170. msRequestPointerLock?(): void;
  63171. mozRequestPointerLock?(): void;
  63172. webkitRequestPointerLock?(): void;
  63173. /** Track wether a record is in progress */
  63174. isRecording: boolean;
  63175. /** Capture Stream method defined by some browsers */
  63176. captureStream(fps?: number): MediaStream;
  63177. }
  63178. interface CanvasRenderingContext2D {
  63179. msImageSmoothingEnabled: boolean;
  63180. }
  63181. interface MouseEvent {
  63182. mozMovementX: number;
  63183. mozMovementY: number;
  63184. webkitMovementX: number;
  63185. webkitMovementY: number;
  63186. msMovementX: number;
  63187. msMovementY: number;
  63188. }
  63189. interface Navigator {
  63190. mozGetVRDevices: (any: any) => any;
  63191. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63192. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63193. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63194. webkitGetGamepads(): Gamepad[];
  63195. msGetGamepads(): Gamepad[];
  63196. webkitGamepads(): Gamepad[];
  63197. }
  63198. interface HTMLVideoElement {
  63199. mozSrcObject: any;
  63200. }
  63201. interface Math {
  63202. fround(x: number): number;
  63203. imul(a: number, b: number): number;
  63204. }
  63205. interface WebGLRenderingContext {
  63206. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63207. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63208. vertexAttribDivisor(index: number, divisor: number): void;
  63209. createVertexArray(): any;
  63210. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63211. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63212. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63213. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63214. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63215. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63216. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63217. // Queries
  63218. createQuery(): WebGLQuery;
  63219. deleteQuery(query: WebGLQuery): void;
  63220. beginQuery(target: number, query: WebGLQuery): void;
  63221. endQuery(target: number): void;
  63222. getQueryParameter(query: WebGLQuery, pname: number): any;
  63223. getQuery(target: number, pname: number): any;
  63224. MAX_SAMPLES: number;
  63225. RGBA8: number;
  63226. READ_FRAMEBUFFER: number;
  63227. DRAW_FRAMEBUFFER: number;
  63228. UNIFORM_BUFFER: number;
  63229. HALF_FLOAT_OES: number;
  63230. RGBA16F: number;
  63231. RGBA32F: number;
  63232. R32F: number;
  63233. RG32F: number;
  63234. RGB32F: number;
  63235. R16F: number;
  63236. RG16F: number;
  63237. RGB16F: number;
  63238. RED: number;
  63239. RG: number;
  63240. R8: number;
  63241. RG8: number;
  63242. UNSIGNED_INT_24_8: number;
  63243. DEPTH24_STENCIL8: number;
  63244. MIN: number;
  63245. MAX: number;
  63246. /* Multiple Render Targets */
  63247. drawBuffers(buffers: number[]): void;
  63248. readBuffer(src: number): void;
  63249. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63250. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63251. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63252. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63253. // Occlusion Query
  63254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63255. ANY_SAMPLES_PASSED: number;
  63256. QUERY_RESULT_AVAILABLE: number;
  63257. QUERY_RESULT: number;
  63258. }
  63259. interface WebGLProgram {
  63260. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63261. }
  63262. interface EXT_disjoint_timer_query {
  63263. QUERY_COUNTER_BITS_EXT: number;
  63264. TIME_ELAPSED_EXT: number;
  63265. TIMESTAMP_EXT: number;
  63266. GPU_DISJOINT_EXT: number;
  63267. QUERY_RESULT_EXT: number;
  63268. QUERY_RESULT_AVAILABLE_EXT: number;
  63269. queryCounterEXT(query: WebGLQuery, target: number): void;
  63270. createQueryEXT(): WebGLQuery;
  63271. beginQueryEXT(target: number, query: WebGLQuery): void;
  63272. endQueryEXT(target: number): void;
  63273. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63274. deleteQueryEXT(query: WebGLQuery): void;
  63275. }
  63276. interface WebGLUniformLocation {
  63277. _currentState: any;
  63278. }
  63279. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63280. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63281. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63282. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63283. interface WebGLRenderingContext {
  63284. readonly RASTERIZER_DISCARD: number;
  63285. readonly DEPTH_COMPONENT24: number;
  63286. readonly TEXTURE_3D: number;
  63287. readonly TEXTURE_2D_ARRAY: number;
  63288. readonly TEXTURE_COMPARE_FUNC: number;
  63289. readonly TEXTURE_COMPARE_MODE: number;
  63290. readonly COMPARE_REF_TO_TEXTURE: number;
  63291. readonly TEXTURE_WRAP_R: number;
  63292. readonly HALF_FLOAT: number;
  63293. readonly RGB8: number;
  63294. readonly RED_INTEGER: number;
  63295. readonly RG_INTEGER: number;
  63296. readonly RGB_INTEGER: number;
  63297. readonly RGBA_INTEGER: number;
  63298. readonly R8_SNORM: number;
  63299. readonly RG8_SNORM: number;
  63300. readonly RGB8_SNORM: number;
  63301. readonly RGBA8_SNORM: number;
  63302. readonly R8I: number;
  63303. readonly RG8I: number;
  63304. readonly RGB8I: number;
  63305. readonly RGBA8I: number;
  63306. readonly R8UI: number;
  63307. readonly RG8UI: number;
  63308. readonly RGB8UI: number;
  63309. readonly RGBA8UI: number;
  63310. readonly R16I: number;
  63311. readonly RG16I: number;
  63312. readonly RGB16I: number;
  63313. readonly RGBA16I: number;
  63314. readonly R16UI: number;
  63315. readonly RG16UI: number;
  63316. readonly RGB16UI: number;
  63317. readonly RGBA16UI: number;
  63318. readonly R32I: number;
  63319. readonly RG32I: number;
  63320. readonly RGB32I: number;
  63321. readonly RGBA32I: number;
  63322. readonly R32UI: number;
  63323. readonly RG32UI: number;
  63324. readonly RGB32UI: number;
  63325. readonly RGBA32UI: number;
  63326. readonly RGB10_A2UI: number;
  63327. readonly R11F_G11F_B10F: number;
  63328. readonly RGB9_E5: number;
  63329. readonly RGB10_A2: number;
  63330. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63331. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63332. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63333. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63334. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63335. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63336. 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;
  63337. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63338. readonly TRANSFORM_FEEDBACK: number;
  63339. readonly INTERLEAVED_ATTRIBS: number;
  63340. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63341. createTransformFeedback(): WebGLTransformFeedback;
  63342. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63343. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63344. beginTransformFeedback(primitiveMode: number): void;
  63345. endTransformFeedback(): void;
  63346. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63347. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63348. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63349. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63350. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63351. }
  63352. interface ImageBitmap {
  63353. readonly width: number;
  63354. readonly height: number;
  63355. close(): void;
  63356. }
  63357. interface WebGLQuery extends WebGLObject {
  63358. }
  63359. declare var WebGLQuery: {
  63360. prototype: WebGLQuery;
  63361. new(): WebGLQuery;
  63362. };
  63363. interface WebGLSampler extends WebGLObject {
  63364. }
  63365. declare var WebGLSampler: {
  63366. prototype: WebGLSampler;
  63367. new(): WebGLSampler;
  63368. };
  63369. interface WebGLSync extends WebGLObject {
  63370. }
  63371. declare var WebGLSync: {
  63372. prototype: WebGLSync;
  63373. new(): WebGLSync;
  63374. };
  63375. interface WebGLTransformFeedback extends WebGLObject {
  63376. }
  63377. declare var WebGLTransformFeedback: {
  63378. prototype: WebGLTransformFeedback;
  63379. new(): WebGLTransformFeedback;
  63380. };
  63381. interface WebGLVertexArrayObject extends WebGLObject {
  63382. }
  63383. declare var WebGLVertexArrayObject: {
  63384. prototype: WebGLVertexArrayObject;
  63385. new(): WebGLVertexArrayObject;
  63386. };
  63387. // Type definitions for WebVR API
  63388. // Project: https://w3c.github.io/webvr/
  63389. // Definitions by: six a <https://github.com/lostfictions>
  63390. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63391. interface VRDisplay extends EventTarget {
  63392. /**
  63393. * Dictionary of capabilities describing the VRDisplay.
  63394. */
  63395. readonly capabilities: VRDisplayCapabilities;
  63396. /**
  63397. * z-depth defining the far plane of the eye view frustum
  63398. * enables mapping of values in the render target depth
  63399. * attachment to scene coordinates. Initially set to 10000.0.
  63400. */
  63401. depthFar: number;
  63402. /**
  63403. * z-depth defining the near plane of the eye view frustum
  63404. * enables mapping of values in the render target depth
  63405. * attachment to scene coordinates. Initially set to 0.01.
  63406. */
  63407. depthNear: number;
  63408. /**
  63409. * An identifier for this distinct VRDisplay. Used as an
  63410. * association point in the Gamepad API.
  63411. */
  63412. readonly displayId: number;
  63413. /**
  63414. * A display name, a user-readable name identifying it.
  63415. */
  63416. readonly displayName: string;
  63417. readonly isConnected: boolean;
  63418. readonly isPresenting: boolean;
  63419. /**
  63420. * If this VRDisplay supports room-scale experiences, the optional
  63421. * stage attribute contains details on the room-scale parameters.
  63422. */
  63423. readonly stageParameters: VRStageParameters | null;
  63424. /**
  63425. * Passing the value returned by `requestAnimationFrame` to
  63426. * `cancelAnimationFrame` will unregister the callback.
  63427. * @param handle Define the hanle of the request to cancel
  63428. */
  63429. cancelAnimationFrame(handle: number): void;
  63430. /**
  63431. * Stops presenting to the VRDisplay.
  63432. * @returns a promise to know when it stopped
  63433. */
  63434. exitPresent(): Promise<void>;
  63435. /**
  63436. * Return the current VREyeParameters for the given eye.
  63437. * @param whichEye Define the eye we want the parameter for
  63438. * @returns the eye parameters
  63439. */
  63440. getEyeParameters(whichEye: string): VREyeParameters;
  63441. /**
  63442. * Populates the passed VRFrameData with the information required to render
  63443. * the current frame.
  63444. * @param frameData Define the data structure to populate
  63445. * @returns true if ok otherwise false
  63446. */
  63447. getFrameData(frameData: VRFrameData): boolean;
  63448. /**
  63449. * Get the layers currently being presented.
  63450. * @returns the list of VR layers
  63451. */
  63452. getLayers(): VRLayer[];
  63453. /**
  63454. * Return a VRPose containing the future predicted pose of the VRDisplay
  63455. * when the current frame will be presented. The value returned will not
  63456. * change until JavaScript has returned control to the browser.
  63457. *
  63458. * The VRPose will contain the position, orientation, velocity,
  63459. * and acceleration of each of these properties.
  63460. * @returns the pose object
  63461. */
  63462. getPose(): VRPose;
  63463. /**
  63464. * Return the current instantaneous pose of the VRDisplay, with no
  63465. * prediction applied.
  63466. * @returns the current instantaneous pose
  63467. */
  63468. getImmediatePose(): VRPose;
  63469. /**
  63470. * The callback passed to `requestAnimationFrame` will be called
  63471. * any time a new frame should be rendered. When the VRDisplay is
  63472. * presenting the callback will be called at the native refresh
  63473. * rate of the HMD. When not presenting this function acts
  63474. * identically to how window.requestAnimationFrame acts. Content should
  63475. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63476. * asynchronously from other displays and at differing refresh rates.
  63477. * @param callback Define the eaction to run next frame
  63478. * @returns the request handle it
  63479. */
  63480. requestAnimationFrame(callback: FrameRequestCallback): number;
  63481. /**
  63482. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63483. * Repeat calls while already presenting will update the VRLayers being displayed.
  63484. * @param layers Define the list of layer to present
  63485. * @returns a promise to know when the request has been fulfilled
  63486. */
  63487. requestPresent(layers: VRLayer[]): Promise<void>;
  63488. /**
  63489. * Reset the pose for this display, treating its current position and
  63490. * orientation as the "origin/zero" values. VRPose.position,
  63491. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63492. * updated when calling resetPose(). This should be called in only
  63493. * sitting-space experiences.
  63494. */
  63495. resetPose(): void;
  63496. /**
  63497. * The VRLayer provided to the VRDisplay will be captured and presented
  63498. * in the HMD. Calling this function has the same effect on the source
  63499. * canvas as any other operation that uses its source image, and canvases
  63500. * created without preserveDrawingBuffer set to true will be cleared.
  63501. * @param pose Define the pose to submit
  63502. */
  63503. submitFrame(pose?: VRPose): void;
  63504. }
  63505. declare var VRDisplay: {
  63506. prototype: VRDisplay;
  63507. new(): VRDisplay;
  63508. };
  63509. interface VRLayer {
  63510. leftBounds?: number[] | Float32Array | null;
  63511. rightBounds?: number[] | Float32Array | null;
  63512. source?: HTMLCanvasElement | null;
  63513. }
  63514. interface VRDisplayCapabilities {
  63515. readonly canPresent: boolean;
  63516. readonly hasExternalDisplay: boolean;
  63517. readonly hasOrientation: boolean;
  63518. readonly hasPosition: boolean;
  63519. readonly maxLayers: number;
  63520. }
  63521. interface VREyeParameters {
  63522. /** @deprecated */
  63523. readonly fieldOfView: VRFieldOfView;
  63524. readonly offset: Float32Array;
  63525. readonly renderHeight: number;
  63526. readonly renderWidth: number;
  63527. }
  63528. interface VRFieldOfView {
  63529. readonly downDegrees: number;
  63530. readonly leftDegrees: number;
  63531. readonly rightDegrees: number;
  63532. readonly upDegrees: number;
  63533. }
  63534. interface VRFrameData {
  63535. readonly leftProjectionMatrix: Float32Array;
  63536. readonly leftViewMatrix: Float32Array;
  63537. readonly pose: VRPose;
  63538. readonly rightProjectionMatrix: Float32Array;
  63539. readonly rightViewMatrix: Float32Array;
  63540. readonly timestamp: number;
  63541. }
  63542. interface VRPose {
  63543. readonly angularAcceleration: Float32Array | null;
  63544. readonly angularVelocity: Float32Array | null;
  63545. readonly linearAcceleration: Float32Array | null;
  63546. readonly linearVelocity: Float32Array | null;
  63547. readonly orientation: Float32Array | null;
  63548. readonly position: Float32Array | null;
  63549. readonly timestamp: number;
  63550. }
  63551. interface VRStageParameters {
  63552. sittingToStandingTransform?: Float32Array;
  63553. sizeX?: number;
  63554. sizeY?: number;
  63555. }
  63556. interface Navigator {
  63557. getVRDisplays(): Promise<VRDisplay[]>;
  63558. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63559. }
  63560. interface Window {
  63561. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63562. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63563. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63564. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63565. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63566. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63567. }
  63568. interface Gamepad {
  63569. readonly displayId: number;
  63570. }
  63571. type XRSessionMode =
  63572. | "inline"
  63573. | "immersive-vr"
  63574. | "immersive-ar";
  63575. type XRReferenceSpaceType =
  63576. | "viewer"
  63577. | "local"
  63578. | "local-floor"
  63579. | "bounded-floor"
  63580. | "unbounded";
  63581. type XREnvironmentBlendMode =
  63582. | "opaque"
  63583. | "additive"
  63584. | "alpha-blend";
  63585. type XRVisibilityState =
  63586. | "visible"
  63587. | "visible-blurred"
  63588. | "hidden";
  63589. type XRHandedness =
  63590. | "none"
  63591. | "left"
  63592. | "right";
  63593. type XRTargetRayMode =
  63594. | "gaze"
  63595. | "tracked-pointer"
  63596. | "screen";
  63597. type XREye =
  63598. | "none"
  63599. | "left"
  63600. | "right";
  63601. interface XRSpace extends EventTarget {
  63602. }
  63603. interface XRRenderState {
  63604. depthNear?: number;
  63605. depthFar?: number;
  63606. inlineVerticalFieldOfView?: number;
  63607. baseLayer?: XRWebGLLayer;
  63608. }
  63609. interface XRInputSource {
  63610. handedness: XRHandedness;
  63611. targetRayMode: XRTargetRayMode;
  63612. targetRaySpace: XRSpace;
  63613. gripSpace: XRSpace | undefined;
  63614. gamepad: Gamepad | undefined;
  63615. profiles: Array<string>;
  63616. }
  63617. interface XRSession {
  63618. addEventListener: Function;
  63619. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63620. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63621. requestAnimationFrame: Function;
  63622. end(): Promise<void>;
  63623. renderState: XRRenderState;
  63624. inputSources: Array<XRInputSource>;
  63625. }
  63626. interface XRReferenceSpace extends XRSpace {
  63627. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63628. onreset: any;
  63629. }
  63630. interface XRFrame {
  63631. session: XRSession;
  63632. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63633. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63634. }
  63635. interface XRViewerPose extends XRPose {
  63636. views: Array<XRView>;
  63637. }
  63638. interface XRPose {
  63639. transform: XRRigidTransform;
  63640. emulatedPosition: boolean;
  63641. }
  63642. declare var XRWebGLLayer: {
  63643. prototype: XRWebGLLayer;
  63644. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63645. };
  63646. interface XRWebGLLayer {
  63647. framebuffer: WebGLFramebuffer;
  63648. framebufferWidth: number;
  63649. framebufferHeight: number;
  63650. getViewport: Function;
  63651. }
  63652. interface XRRigidTransform {
  63653. position: DOMPointReadOnly;
  63654. orientation: DOMPointReadOnly;
  63655. matrix: Float32Array;
  63656. inverse: XRRigidTransform;
  63657. }
  63658. interface XRView {
  63659. eye: XREye;
  63660. projectionMatrix: Float32Array;
  63661. transform: XRRigidTransform;
  63662. }
  63663. interface XRInputSourceChangeEvent {
  63664. session: XRSession;
  63665. removed: Array<XRInputSource>;
  63666. added: Array<XRInputSource>;
  63667. }
  63668. /**
  63669. * @ignore
  63670. */
  63671. declare module BABYLON.GLTF2.Exporter {
  63672. }
  63673. /**
  63674. * @ignore
  63675. */
  63676. declare module BABYLON.GLTF1 {
  63677. }
  63678. declare module BABYLON.GUI {
  63679. /**
  63680. * Class used to specific a value and its associated unit
  63681. */
  63682. export class ValueAndUnit {
  63683. /** defines the unit to store */
  63684. unit: number;
  63685. /** defines a boolean indicating if the value can be negative */
  63686. negativeValueAllowed: boolean;
  63687. private _value;
  63688. private _originalUnit;
  63689. /**
  63690. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63691. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63692. */
  63693. ignoreAdaptiveScaling: boolean;
  63694. /**
  63695. * Creates a new ValueAndUnit
  63696. * @param value defines the value to store
  63697. * @param unit defines the unit to store
  63698. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63699. */
  63700. constructor(value: number,
  63701. /** defines the unit to store */
  63702. unit?: number,
  63703. /** defines a boolean indicating if the value can be negative */
  63704. negativeValueAllowed?: boolean);
  63705. /** Gets a boolean indicating if the value is a percentage */
  63706. readonly isPercentage: boolean;
  63707. /** Gets a boolean indicating if the value is store as pixel */
  63708. readonly isPixel: boolean;
  63709. /** Gets direct internal value */
  63710. readonly internalValue: number;
  63711. /**
  63712. * Gets value as pixel
  63713. * @param host defines the root host
  63714. * @param refValue defines the reference value for percentages
  63715. * @returns the value as pixel
  63716. */
  63717. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63718. /**
  63719. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63720. * @param value defines the value to store
  63721. * @param unit defines the unit to store
  63722. * @returns the current ValueAndUnit
  63723. */
  63724. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63725. /**
  63726. * Gets the value accordingly to its unit
  63727. * @param host defines the root host
  63728. * @returns the value
  63729. */
  63730. getValue(host: AdvancedDynamicTexture): number;
  63731. /**
  63732. * Gets a string representation of the value
  63733. * @param host defines the root host
  63734. * @param decimals defines an optional number of decimals to display
  63735. * @returns a string
  63736. */
  63737. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63738. /**
  63739. * Store a value parsed from a string
  63740. * @param source defines the source string
  63741. * @returns true if the value was successfully parsed
  63742. */
  63743. fromString(source: string | number): boolean;
  63744. private static _Regex;
  63745. private static _UNITMODE_PERCENTAGE;
  63746. private static _UNITMODE_PIXEL;
  63747. /** UNITMODE_PERCENTAGE */
  63748. static readonly UNITMODE_PERCENTAGE: number;
  63749. /** UNITMODE_PIXEL */
  63750. static readonly UNITMODE_PIXEL: number;
  63751. }
  63752. }
  63753. declare module BABYLON.GUI {
  63754. /**
  63755. * Define a style used by control to automatically setup properties based on a template.
  63756. * Only support font related properties so far
  63757. */
  63758. export class Style implements BABYLON.IDisposable {
  63759. private _fontFamily;
  63760. private _fontStyle;
  63761. private _fontWeight;
  63762. /** @hidden */
  63763. _host: AdvancedDynamicTexture;
  63764. /** @hidden */
  63765. _fontSize: ValueAndUnit;
  63766. /**
  63767. * BABYLON.Observable raised when the style values are changed
  63768. */
  63769. onChangedObservable: BABYLON.Observable<Style>;
  63770. /**
  63771. * Creates a new style object
  63772. * @param host defines the AdvancedDynamicTexture which hosts this style
  63773. */
  63774. constructor(host: AdvancedDynamicTexture);
  63775. /**
  63776. * Gets or sets the font size
  63777. */
  63778. fontSize: string | number;
  63779. /**
  63780. * Gets or sets the font family
  63781. */
  63782. fontFamily: string;
  63783. /**
  63784. * Gets or sets the font style
  63785. */
  63786. fontStyle: string;
  63787. /** Gets or sets font weight */
  63788. fontWeight: string;
  63789. /** Dispose all associated resources */
  63790. dispose(): void;
  63791. }
  63792. }
  63793. declare module BABYLON.GUI {
  63794. /**
  63795. * Class used to transport BABYLON.Vector2 information for pointer events
  63796. */
  63797. export class Vector2WithInfo extends BABYLON.Vector2 {
  63798. /** defines the current mouse button index */
  63799. buttonIndex: number;
  63800. /**
  63801. * Creates a new Vector2WithInfo
  63802. * @param source defines the vector2 data to transport
  63803. * @param buttonIndex defines the current mouse button index
  63804. */
  63805. constructor(source: BABYLON.Vector2,
  63806. /** defines the current mouse button index */
  63807. buttonIndex?: number);
  63808. }
  63809. /** Class used to provide 2D matrix features */
  63810. export class Matrix2D {
  63811. /** Gets the internal array of 6 floats used to store matrix data */
  63812. m: Float32Array;
  63813. /**
  63814. * Creates a new matrix
  63815. * @param m00 defines value for (0, 0)
  63816. * @param m01 defines value for (0, 1)
  63817. * @param m10 defines value for (1, 0)
  63818. * @param m11 defines value for (1, 1)
  63819. * @param m20 defines value for (2, 0)
  63820. * @param m21 defines value for (2, 1)
  63821. */
  63822. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63823. /**
  63824. * Fills the matrix from direct values
  63825. * @param m00 defines value for (0, 0)
  63826. * @param m01 defines value for (0, 1)
  63827. * @param m10 defines value for (1, 0)
  63828. * @param m11 defines value for (1, 1)
  63829. * @param m20 defines value for (2, 0)
  63830. * @param m21 defines value for (2, 1)
  63831. * @returns the current modified matrix
  63832. */
  63833. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63834. /**
  63835. * Gets matrix determinant
  63836. * @returns the determinant
  63837. */
  63838. determinant(): number;
  63839. /**
  63840. * Inverses the matrix and stores it in a target matrix
  63841. * @param result defines the target matrix
  63842. * @returns the current matrix
  63843. */
  63844. invertToRef(result: Matrix2D): Matrix2D;
  63845. /**
  63846. * Multiplies the current matrix with another one
  63847. * @param other defines the second operand
  63848. * @param result defines the target matrix
  63849. * @returns the current matrix
  63850. */
  63851. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63852. /**
  63853. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63854. * @param x defines the x coordinate to transform
  63855. * @param y defines the x coordinate to transform
  63856. * @param result defines the target vector2
  63857. * @returns the current matrix
  63858. */
  63859. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63860. /**
  63861. * Creates an identity matrix
  63862. * @returns a new matrix
  63863. */
  63864. static Identity(): Matrix2D;
  63865. /**
  63866. * Creates a translation matrix and stores it in a target matrix
  63867. * @param x defines the x coordinate of the translation
  63868. * @param y defines the y coordinate of the translation
  63869. * @param result defines the target matrix
  63870. */
  63871. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63872. /**
  63873. * Creates a scaling matrix and stores it in a target matrix
  63874. * @param x defines the x coordinate of the scaling
  63875. * @param y defines the y coordinate of the scaling
  63876. * @param result defines the target matrix
  63877. */
  63878. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63879. /**
  63880. * Creates a rotation matrix and stores it in a target matrix
  63881. * @param angle defines the rotation angle
  63882. * @param result defines the target matrix
  63883. */
  63884. static RotationToRef(angle: number, result: Matrix2D): void;
  63885. private static _TempPreTranslationMatrix;
  63886. private static _TempPostTranslationMatrix;
  63887. private static _TempRotationMatrix;
  63888. private static _TempScalingMatrix;
  63889. private static _TempCompose0;
  63890. private static _TempCompose1;
  63891. private static _TempCompose2;
  63892. /**
  63893. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63894. * @param tx defines the x coordinate of the translation
  63895. * @param ty defines the y coordinate of the translation
  63896. * @param angle defines the rotation angle
  63897. * @param scaleX defines the x coordinate of the scaling
  63898. * @param scaleY defines the y coordinate of the scaling
  63899. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63900. * @param result defines the target matrix
  63901. */
  63902. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63903. }
  63904. }
  63905. declare module BABYLON.GUI {
  63906. /**
  63907. * Class used to store 2D control sizes
  63908. */
  63909. export class Measure {
  63910. /** defines left coordinate */
  63911. left: number;
  63912. /** defines top coordinate */
  63913. top: number;
  63914. /** defines width dimension */
  63915. width: number;
  63916. /** defines height dimension */
  63917. height: number;
  63918. /**
  63919. * Creates a new measure
  63920. * @param left defines left coordinate
  63921. * @param top defines top coordinate
  63922. * @param width defines width dimension
  63923. * @param height defines height dimension
  63924. */
  63925. constructor(
  63926. /** defines left coordinate */
  63927. left: number,
  63928. /** defines top coordinate */
  63929. top: number,
  63930. /** defines width dimension */
  63931. width: number,
  63932. /** defines height dimension */
  63933. height: number);
  63934. /**
  63935. * Copy from another measure
  63936. * @param other defines the other measure to copy from
  63937. */
  63938. copyFrom(other: Measure): void;
  63939. /**
  63940. * Copy from a group of 4 floats
  63941. * @param left defines left coordinate
  63942. * @param top defines top coordinate
  63943. * @param width defines width dimension
  63944. * @param height defines height dimension
  63945. */
  63946. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63947. /**
  63948. * Computes the axis aligned bounding box measure for two given measures
  63949. * @param a Input measure
  63950. * @param b Input measure
  63951. * @param result the resulting bounding measure
  63952. */
  63953. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63954. /**
  63955. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63956. * @param transform the matrix to transform the measure before computing the AABB
  63957. * @param result the resulting AABB
  63958. */
  63959. transformToRef(transform: Matrix2D, result: Measure): void;
  63960. /**
  63961. * Check equality between this measure and another one
  63962. * @param other defines the other measures
  63963. * @returns true if both measures are equals
  63964. */
  63965. isEqualsTo(other: Measure): boolean;
  63966. /**
  63967. * Creates an empty measure
  63968. * @returns a new measure
  63969. */
  63970. static Empty(): Measure;
  63971. }
  63972. }
  63973. declare module BABYLON.GUI {
  63974. /**
  63975. * Interface used to define a control that can receive focus
  63976. */
  63977. export interface IFocusableControl {
  63978. /**
  63979. * Function called when the control receives the focus
  63980. */
  63981. onFocus(): void;
  63982. /**
  63983. * Function called when the control loses the focus
  63984. */
  63985. onBlur(): void;
  63986. /**
  63987. * Function called to let the control handle keyboard events
  63988. * @param evt defines the current keyboard event
  63989. */
  63990. processKeyboard(evt: KeyboardEvent): void;
  63991. /**
  63992. * Function called to get the list of controls that should not steal the focus from this control
  63993. * @returns an array of controls
  63994. */
  63995. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63996. }
  63997. /**
  63998. * Class used to create texture to support 2D GUI elements
  63999. * @see http://doc.babylonjs.com/how_to/gui
  64000. */
  64001. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64002. private _isDirty;
  64003. private _renderObserver;
  64004. private _resizeObserver;
  64005. private _preKeyboardObserver;
  64006. private _pointerMoveObserver;
  64007. private _pointerObserver;
  64008. private _canvasPointerOutObserver;
  64009. private _background;
  64010. /** @hidden */
  64011. _rootContainer: Container;
  64012. /** @hidden */
  64013. _lastPickedControl: Control;
  64014. /** @hidden */
  64015. _lastControlOver: {
  64016. [pointerId: number]: Control;
  64017. };
  64018. /** @hidden */
  64019. _lastControlDown: {
  64020. [pointerId: number]: Control;
  64021. };
  64022. /** @hidden */
  64023. _capturingControl: {
  64024. [pointerId: number]: Control;
  64025. };
  64026. /** @hidden */
  64027. _shouldBlockPointer: boolean;
  64028. /** @hidden */
  64029. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64030. /** @hidden */
  64031. _linkedControls: Control[];
  64032. private _isFullscreen;
  64033. private _fullscreenViewport;
  64034. private _idealWidth;
  64035. private _idealHeight;
  64036. private _useSmallestIdeal;
  64037. private _renderAtIdealSize;
  64038. private _focusedControl;
  64039. private _blockNextFocusCheck;
  64040. private _renderScale;
  64041. private _rootCanvas;
  64042. private _cursorChanged;
  64043. /**
  64044. * Define type to string to ensure compatibility across browsers
  64045. * Safari doesn't support DataTransfer constructor
  64046. */
  64047. private _clipboardData;
  64048. /**
  64049. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64050. */
  64051. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64052. /**
  64053. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64054. */
  64055. onControlPickedObservable: BABYLON.Observable<Control>;
  64056. /**
  64057. * BABYLON.Observable event triggered before layout is evaluated
  64058. */
  64059. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64060. /**
  64061. * BABYLON.Observable event triggered after the layout was evaluated
  64062. */
  64063. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64064. /**
  64065. * BABYLON.Observable event triggered before the texture is rendered
  64066. */
  64067. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64068. /**
  64069. * BABYLON.Observable event triggered after the texture was rendered
  64070. */
  64071. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64072. /**
  64073. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64074. */
  64075. premulAlpha: boolean;
  64076. /**
  64077. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64078. * Useful when you want more antialiasing
  64079. */
  64080. renderScale: number;
  64081. /** Gets or sets the background color */
  64082. background: string;
  64083. /**
  64084. * Gets or sets the ideal width used to design controls.
  64085. * The GUI will then rescale everything accordingly
  64086. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64087. */
  64088. idealWidth: number;
  64089. /**
  64090. * Gets or sets the ideal height used to design controls.
  64091. * The GUI will then rescale everything accordingly
  64092. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64093. */
  64094. idealHeight: number;
  64095. /**
  64096. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64097. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64098. */
  64099. useSmallestIdeal: boolean;
  64100. /**
  64101. * Gets or sets a boolean indicating if adaptive scaling must be used
  64102. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64103. */
  64104. renderAtIdealSize: boolean;
  64105. /**
  64106. * Gets the underlying layer used to render the texture when in fullscreen mode
  64107. */
  64108. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64109. /**
  64110. * Gets the root container control
  64111. */
  64112. readonly rootContainer: Container;
  64113. /**
  64114. * Returns an array containing the root container.
  64115. * This is mostly used to let the Inspector introspects the ADT
  64116. * @returns an array containing the rootContainer
  64117. */
  64118. getChildren(): Array<Container>;
  64119. /**
  64120. * Will return all controls that are inside this texture
  64121. * @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
  64122. * @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
  64123. * @return all child controls
  64124. */
  64125. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64126. /**
  64127. * Gets or sets the current focused control
  64128. */
  64129. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64130. /**
  64131. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64132. */
  64133. isForeground: boolean;
  64134. /**
  64135. * Gets or set information about clipboardData
  64136. */
  64137. clipboardData: string;
  64138. /**
  64139. * Creates a new AdvancedDynamicTexture
  64140. * @param name defines the name of the texture
  64141. * @param width defines the width of the texture
  64142. * @param height defines the height of the texture
  64143. * @param scene defines the hosting scene
  64144. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64145. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64146. */
  64147. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64148. /**
  64149. * Get the current class name of the texture useful for serialization or dynamic coding.
  64150. * @returns "AdvancedDynamicTexture"
  64151. */
  64152. getClassName(): string;
  64153. /**
  64154. * Function used to execute a function on all controls
  64155. * @param func defines the function to execute
  64156. * @param container defines the container where controls belong. If null the root container will be used
  64157. */
  64158. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64159. private _useInvalidateRectOptimization;
  64160. /**
  64161. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64162. */
  64163. useInvalidateRectOptimization: boolean;
  64164. private _invalidatedRectangle;
  64165. /**
  64166. * Invalidates a rectangle area on the gui texture
  64167. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64168. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64169. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64170. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64171. */
  64172. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64173. /**
  64174. * Marks the texture as dirty forcing a complete update
  64175. */
  64176. markAsDirty(): void;
  64177. /**
  64178. * Helper function used to create a new style
  64179. * @returns a new style
  64180. * @see http://doc.babylonjs.com/how_to/gui#styles
  64181. */
  64182. createStyle(): Style;
  64183. /**
  64184. * Adds a new control to the root container
  64185. * @param control defines the control to add
  64186. * @returns the current texture
  64187. */
  64188. addControl(control: Control): AdvancedDynamicTexture;
  64189. /**
  64190. * Removes a control from the root container
  64191. * @param control defines the control to remove
  64192. * @returns the current texture
  64193. */
  64194. removeControl(control: Control): AdvancedDynamicTexture;
  64195. /**
  64196. * Release all resources
  64197. */
  64198. dispose(): void;
  64199. private _onResize;
  64200. /** @hidden */
  64201. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64202. /**
  64203. * Get screen coordinates for a vector3
  64204. * @param position defines the position to project
  64205. * @param worldMatrix defines the world matrix to use
  64206. * @returns the projected position
  64207. */
  64208. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64209. private _checkUpdate;
  64210. private _clearMeasure;
  64211. private _render;
  64212. /** @hidden */
  64213. _changeCursor(cursor: string): void;
  64214. /** @hidden */
  64215. _registerLastControlDown(control: Control, pointerId: number): void;
  64216. private _doPicking;
  64217. /** @hidden */
  64218. _cleanControlAfterRemovalFromList(list: {
  64219. [pointerId: number]: Control;
  64220. }, control: Control): void;
  64221. /** @hidden */
  64222. _cleanControlAfterRemoval(control: Control): void;
  64223. /** Attach to all scene events required to support pointer events */
  64224. attach(): void;
  64225. /** @hidden */
  64226. private onClipboardCopy;
  64227. /** @hidden */
  64228. private onClipboardCut;
  64229. /** @hidden */
  64230. private onClipboardPaste;
  64231. /**
  64232. * Register the clipboard Events onto the canvas
  64233. */
  64234. registerClipboardEvents(): void;
  64235. /**
  64236. * Unregister the clipboard Events from the canvas
  64237. */
  64238. unRegisterClipboardEvents(): void;
  64239. /**
  64240. * Connect the texture to a hosting mesh to enable interactions
  64241. * @param mesh defines the mesh to attach to
  64242. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64243. */
  64244. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64245. /**
  64246. * Move the focus to a specific control
  64247. * @param control defines the control which will receive the focus
  64248. */
  64249. moveFocusToControl(control: IFocusableControl): void;
  64250. private _manageFocus;
  64251. private _attachToOnPointerOut;
  64252. /**
  64253. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64254. * @param mesh defines the mesh which will receive the texture
  64255. * @param width defines the texture width (1024 by default)
  64256. * @param height defines the texture height (1024 by default)
  64257. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64258. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64259. * @returns a new AdvancedDynamicTexture
  64260. */
  64261. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64262. /**
  64263. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64264. * In this mode the texture will rely on a layer for its rendering.
  64265. * This allows it to be treated like any other layer.
  64266. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64267. * LayerMask is set through advancedTexture.layer.layerMask
  64268. * @param name defines name for the texture
  64269. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64270. * @param scene defines the hsoting scene
  64271. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64272. * @returns a new AdvancedDynamicTexture
  64273. */
  64274. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64275. }
  64276. }
  64277. declare module BABYLON.GUI {
  64278. /**
  64279. * Root class used for all 2D controls
  64280. * @see http://doc.babylonjs.com/how_to/gui#controls
  64281. */
  64282. export class Control {
  64283. /** defines the name of the control */
  64284. name?: string | undefined;
  64285. /**
  64286. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64287. */
  64288. static AllowAlphaInheritance: boolean;
  64289. private _alpha;
  64290. private _alphaSet;
  64291. private _zIndex;
  64292. /** @hidden */
  64293. _host: AdvancedDynamicTexture;
  64294. /** Gets or sets the control parent */
  64295. parent: BABYLON.Nullable<Container>;
  64296. /** @hidden */
  64297. _currentMeasure: Measure;
  64298. private _fontFamily;
  64299. private _fontStyle;
  64300. private _fontWeight;
  64301. private _fontSize;
  64302. private _font;
  64303. /** @hidden */
  64304. _width: ValueAndUnit;
  64305. /** @hidden */
  64306. _height: ValueAndUnit;
  64307. /** @hidden */
  64308. protected _fontOffset: {
  64309. ascent: number;
  64310. height: number;
  64311. descent: number;
  64312. };
  64313. private _color;
  64314. private _style;
  64315. private _styleObserver;
  64316. /** @hidden */
  64317. protected _horizontalAlignment: number;
  64318. /** @hidden */
  64319. protected _verticalAlignment: number;
  64320. /** @hidden */
  64321. protected _isDirty: boolean;
  64322. /** @hidden */
  64323. protected _wasDirty: boolean;
  64324. /** @hidden */
  64325. _tempParentMeasure: Measure;
  64326. /** @hidden */
  64327. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64328. /** @hidden */
  64329. protected _cachedParentMeasure: Measure;
  64330. private _paddingLeft;
  64331. private _paddingRight;
  64332. private _paddingTop;
  64333. private _paddingBottom;
  64334. /** @hidden */
  64335. _left: ValueAndUnit;
  64336. /** @hidden */
  64337. _top: ValueAndUnit;
  64338. private _scaleX;
  64339. private _scaleY;
  64340. private _rotation;
  64341. private _transformCenterX;
  64342. private _transformCenterY;
  64343. /** @hidden */
  64344. _transformMatrix: Matrix2D;
  64345. /** @hidden */
  64346. protected _invertTransformMatrix: Matrix2D;
  64347. /** @hidden */
  64348. protected _transformedPosition: BABYLON.Vector2;
  64349. private _isMatrixDirty;
  64350. private _cachedOffsetX;
  64351. private _cachedOffsetY;
  64352. private _isVisible;
  64353. private _isHighlighted;
  64354. /** @hidden */
  64355. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64356. private _fontSet;
  64357. private _dummyVector2;
  64358. private _downCount;
  64359. private _enterCount;
  64360. private _doNotRender;
  64361. private _downPointerIds;
  64362. protected _isEnabled: boolean;
  64363. protected _disabledColor: string;
  64364. /** @hidden */
  64365. protected _rebuildLayout: boolean;
  64366. /** @hidden */
  64367. _isClipped: boolean;
  64368. /** @hidden */
  64369. _tag: any;
  64370. /**
  64371. * 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
  64372. */
  64373. uniqueId: number;
  64374. /**
  64375. * Gets or sets an object used to store user defined information for the node
  64376. */
  64377. metadata: any;
  64378. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64379. isHitTestVisible: boolean;
  64380. /** Gets or sets a boolean indicating if the control can block pointer events */
  64381. isPointerBlocker: boolean;
  64382. /** Gets or sets a boolean indicating if the control can be focusable */
  64383. isFocusInvisible: boolean;
  64384. /**
  64385. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64386. * 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
  64387. */
  64388. clipChildren: boolean;
  64389. /**
  64390. * Gets or sets a boolean indicating that control content must be clipped
  64391. * 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
  64392. */
  64393. clipContent: boolean;
  64394. /**
  64395. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64396. */
  64397. useBitmapCache: boolean;
  64398. private _cacheData;
  64399. private _shadowOffsetX;
  64400. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64401. shadowOffsetX: number;
  64402. private _shadowOffsetY;
  64403. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64404. shadowOffsetY: number;
  64405. private _shadowBlur;
  64406. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64407. shadowBlur: number;
  64408. private _shadowColor;
  64409. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64410. shadowColor: string;
  64411. /** Gets or sets the cursor to use when the control is hovered */
  64412. hoverCursor: string;
  64413. /** @hidden */
  64414. protected _linkOffsetX: ValueAndUnit;
  64415. /** @hidden */
  64416. protected _linkOffsetY: ValueAndUnit;
  64417. /** Gets the control type name */
  64418. readonly typeName: string;
  64419. /**
  64420. * Get the current class name of the control.
  64421. * @returns current class name
  64422. */
  64423. getClassName(): string;
  64424. /**
  64425. * An event triggered when the pointer move over the control.
  64426. */
  64427. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64428. /**
  64429. * An event triggered when the pointer move out of the control.
  64430. */
  64431. onPointerOutObservable: BABYLON.Observable<Control>;
  64432. /**
  64433. * An event triggered when the pointer taps the control
  64434. */
  64435. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64436. /**
  64437. * An event triggered when pointer up
  64438. */
  64439. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64440. /**
  64441. * An event triggered when a control is clicked on
  64442. */
  64443. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64444. /**
  64445. * An event triggered when pointer enters the control
  64446. */
  64447. onPointerEnterObservable: BABYLON.Observable<Control>;
  64448. /**
  64449. * An event triggered when the control is marked as dirty
  64450. */
  64451. onDirtyObservable: BABYLON.Observable<Control>;
  64452. /**
  64453. * An event triggered before drawing the control
  64454. */
  64455. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64456. /**
  64457. * An event triggered after the control was drawn
  64458. */
  64459. onAfterDrawObservable: BABYLON.Observable<Control>;
  64460. /**
  64461. * Get the hosting AdvancedDynamicTexture
  64462. */
  64463. readonly host: AdvancedDynamicTexture;
  64464. /** Gets or set information about font offsets (used to render and align text) */
  64465. fontOffset: {
  64466. ascent: number;
  64467. height: number;
  64468. descent: number;
  64469. };
  64470. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64471. alpha: number;
  64472. /**
  64473. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64474. */
  64475. isHighlighted: boolean;
  64476. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64477. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64478. */
  64479. scaleX: number;
  64480. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64481. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64482. */
  64483. scaleY: number;
  64484. /** Gets or sets the rotation angle (0 by default)
  64485. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64486. */
  64487. rotation: number;
  64488. /** Gets or sets the transformation center on Y axis (0 by default)
  64489. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64490. */
  64491. transformCenterY: number;
  64492. /** Gets or sets the transformation center on X axis (0 by default)
  64493. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64494. */
  64495. transformCenterX: number;
  64496. /**
  64497. * Gets or sets the horizontal alignment
  64498. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64499. */
  64500. horizontalAlignment: number;
  64501. /**
  64502. * Gets or sets the vertical alignment
  64503. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64504. */
  64505. verticalAlignment: number;
  64506. /**
  64507. * Gets or sets control width
  64508. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64509. */
  64510. width: string | number;
  64511. /**
  64512. * Gets or sets the control width in pixel
  64513. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64514. */
  64515. widthInPixels: number;
  64516. /**
  64517. * Gets or sets control height
  64518. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64519. */
  64520. height: string | number;
  64521. /**
  64522. * Gets or sets control height in pixel
  64523. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64524. */
  64525. heightInPixels: number;
  64526. /** Gets or set font family */
  64527. fontFamily: string;
  64528. /** Gets or sets font style */
  64529. fontStyle: string;
  64530. /** Gets or sets font weight */
  64531. fontWeight: string;
  64532. /**
  64533. * Gets or sets style
  64534. * @see http://doc.babylonjs.com/how_to/gui#styles
  64535. */
  64536. style: BABYLON.Nullable<Style>;
  64537. /** @hidden */
  64538. readonly _isFontSizeInPercentage: boolean;
  64539. /** Gets or sets font size in pixels */
  64540. fontSizeInPixels: number;
  64541. /** Gets or sets font size */
  64542. fontSize: string | number;
  64543. /** Gets or sets foreground color */
  64544. color: string;
  64545. /** Gets or sets z index which is used to reorder controls on the z axis */
  64546. zIndex: number;
  64547. /** Gets or sets a boolean indicating if the control can be rendered */
  64548. notRenderable: boolean;
  64549. /** Gets or sets a boolean indicating if the control is visible */
  64550. isVisible: boolean;
  64551. /** Gets a boolean indicating that the control needs to update its rendering */
  64552. readonly isDirty: boolean;
  64553. /**
  64554. * Gets the current linked mesh (or null if none)
  64555. */
  64556. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64557. /**
  64558. * Gets or sets a value indicating the padding to use on the left of the control
  64559. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64560. */
  64561. paddingLeft: string | number;
  64562. /**
  64563. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64564. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64565. */
  64566. paddingLeftInPixels: number;
  64567. /**
  64568. * Gets or sets a value indicating the padding to use on the right of the control
  64569. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64570. */
  64571. paddingRight: string | number;
  64572. /**
  64573. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64574. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64575. */
  64576. paddingRightInPixels: number;
  64577. /**
  64578. * Gets or sets a value indicating the padding to use on the top of the control
  64579. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64580. */
  64581. paddingTop: string | number;
  64582. /**
  64583. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64584. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64585. */
  64586. paddingTopInPixels: number;
  64587. /**
  64588. * Gets or sets a value indicating the padding to use on the bottom of the control
  64589. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64590. */
  64591. paddingBottom: string | number;
  64592. /**
  64593. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64594. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64595. */
  64596. paddingBottomInPixels: number;
  64597. /**
  64598. * Gets or sets a value indicating the left coordinate of the control
  64599. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64600. */
  64601. left: string | number;
  64602. /**
  64603. * Gets or sets a value indicating the left coordinate in pixels of the control
  64604. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64605. */
  64606. leftInPixels: number;
  64607. /**
  64608. * Gets or sets a value indicating the top coordinate of the control
  64609. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64610. */
  64611. top: string | number;
  64612. /**
  64613. * Gets or sets a value indicating the top coordinate in pixels of the control
  64614. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64615. */
  64616. topInPixels: number;
  64617. /**
  64618. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64619. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64620. */
  64621. linkOffsetX: string | number;
  64622. /**
  64623. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64624. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64625. */
  64626. linkOffsetXInPixels: number;
  64627. /**
  64628. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64629. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64630. */
  64631. linkOffsetY: string | number;
  64632. /**
  64633. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64634. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64635. */
  64636. linkOffsetYInPixels: number;
  64637. /** Gets the center coordinate on X axis */
  64638. readonly centerX: number;
  64639. /** Gets the center coordinate on Y axis */
  64640. readonly centerY: number;
  64641. /** Gets or sets if control is Enabled*/
  64642. isEnabled: boolean;
  64643. /** Gets or sets background color of control if it's disabled*/
  64644. disabledColor: string;
  64645. /**
  64646. * Creates a new control
  64647. * @param name defines the name of the control
  64648. */
  64649. constructor(
  64650. /** defines the name of the control */
  64651. name?: string | undefined);
  64652. /** @hidden */
  64653. protected _getTypeName(): string;
  64654. /**
  64655. * Gets the first ascendant in the hierarchy of the given type
  64656. * @param className defines the required type
  64657. * @returns the ascendant or null if not found
  64658. */
  64659. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64660. /** @hidden */
  64661. _resetFontCache(): void;
  64662. /**
  64663. * Determines if a container is an ascendant of the current control
  64664. * @param container defines the container to look for
  64665. * @returns true if the container is one of the ascendant of the control
  64666. */
  64667. isAscendant(container: Control): boolean;
  64668. /**
  64669. * Gets coordinates in local control space
  64670. * @param globalCoordinates defines the coordinates to transform
  64671. * @returns the new coordinates in local space
  64672. */
  64673. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64674. /**
  64675. * Gets coordinates in local control space
  64676. * @param globalCoordinates defines the coordinates to transform
  64677. * @param result defines the target vector2 where to store the result
  64678. * @returns the current control
  64679. */
  64680. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64681. /**
  64682. * Gets coordinates in parent local control space
  64683. * @param globalCoordinates defines the coordinates to transform
  64684. * @returns the new coordinates in parent local space
  64685. */
  64686. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64687. /**
  64688. * Move the current control to a vector3 position projected onto the screen.
  64689. * @param position defines the target position
  64690. * @param scene defines the hosting scene
  64691. */
  64692. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64693. /** @hidden */
  64694. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64695. /**
  64696. * Will return all controls that have this control as ascendant
  64697. * @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
  64698. * @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
  64699. * @return all child controls
  64700. */
  64701. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64702. /**
  64703. * Link current control with a target mesh
  64704. * @param mesh defines the mesh to link with
  64705. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64706. */
  64707. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64708. /** @hidden */
  64709. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64710. /** @hidden */
  64711. _offsetLeft(offset: number): void;
  64712. /** @hidden */
  64713. _offsetTop(offset: number): void;
  64714. /** @hidden */
  64715. _markMatrixAsDirty(): void;
  64716. /** @hidden */
  64717. _flagDescendantsAsMatrixDirty(): void;
  64718. /** @hidden */
  64719. _intersectsRect(rect: Measure): boolean;
  64720. /** @hidden */
  64721. protected invalidateRect(): void;
  64722. /** @hidden */
  64723. _markAsDirty(force?: boolean): void;
  64724. /** @hidden */
  64725. _markAllAsDirty(): void;
  64726. /** @hidden */
  64727. _link(host: AdvancedDynamicTexture): void;
  64728. /** @hidden */
  64729. protected _transform(context?: CanvasRenderingContext2D): void;
  64730. /** @hidden */
  64731. _renderHighlight(context: CanvasRenderingContext2D): void;
  64732. /** @hidden */
  64733. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64734. /** @hidden */
  64735. protected _applyStates(context: CanvasRenderingContext2D): void;
  64736. /** @hidden */
  64737. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64738. /** @hidden */
  64739. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64740. protected _evaluateClippingState(parentMeasure: Measure): void;
  64741. /** @hidden */
  64742. _measure(): void;
  64743. /** @hidden */
  64744. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64745. /** @hidden */
  64746. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64747. /** @hidden */
  64748. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64749. /** @hidden */
  64750. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64751. private static _ClipMeasure;
  64752. private _tmpMeasureA;
  64753. private _clip;
  64754. /** @hidden */
  64755. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64756. /** @hidden */
  64757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64758. /**
  64759. * Tests if a given coordinates belong to the current control
  64760. * @param x defines x coordinate to test
  64761. * @param y defines y coordinate to test
  64762. * @returns true if the coordinates are inside the control
  64763. */
  64764. contains(x: number, y: number): boolean;
  64765. /** @hidden */
  64766. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64767. /** @hidden */
  64768. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64769. /** @hidden */
  64770. _onPointerEnter(target: Control): boolean;
  64771. /** @hidden */
  64772. _onPointerOut(target: Control, force?: boolean): void;
  64773. /** @hidden */
  64774. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64775. /** @hidden */
  64776. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64777. /** @hidden */
  64778. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64779. /** @hidden */
  64780. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64781. private _prepareFont;
  64782. /** Releases associated resources */
  64783. dispose(): void;
  64784. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64785. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64786. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64787. private static _VERTICAL_ALIGNMENT_TOP;
  64788. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64789. private static _VERTICAL_ALIGNMENT_CENTER;
  64790. /** HORIZONTAL_ALIGNMENT_LEFT */
  64791. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64792. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64793. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64794. /** HORIZONTAL_ALIGNMENT_CENTER */
  64795. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64796. /** VERTICAL_ALIGNMENT_TOP */
  64797. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64798. /** VERTICAL_ALIGNMENT_BOTTOM */
  64799. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64800. /** VERTICAL_ALIGNMENT_CENTER */
  64801. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64802. private static _FontHeightSizes;
  64803. /** @hidden */
  64804. static _GetFontOffset(font: string): {
  64805. ascent: number;
  64806. height: number;
  64807. descent: number;
  64808. };
  64809. /**
  64810. * Creates a stack panel that can be used to render headers
  64811. * @param control defines the control to associate with the header
  64812. * @param text defines the text of the header
  64813. * @param size defines the size of the header
  64814. * @param options defines options used to configure the header
  64815. * @returns a new StackPanel
  64816. * @ignore
  64817. * @hidden
  64818. */
  64819. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64820. isHorizontal: boolean;
  64821. controlFirst: boolean;
  64822. }) => any;
  64823. /** @hidden */
  64824. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64825. }
  64826. }
  64827. declare module BABYLON.GUI {
  64828. /**
  64829. * Root class for 2D containers
  64830. * @see http://doc.babylonjs.com/how_to/gui#containers
  64831. */
  64832. export class Container extends Control {
  64833. name?: string | undefined;
  64834. /** @hidden */
  64835. protected _children: Control[];
  64836. /** @hidden */
  64837. protected _measureForChildren: Measure;
  64838. /** @hidden */
  64839. protected _background: string;
  64840. /** @hidden */
  64841. protected _adaptWidthToChildren: boolean;
  64842. /** @hidden */
  64843. protected _adaptHeightToChildren: boolean;
  64844. /**
  64845. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64846. */
  64847. logLayoutCycleErrors: boolean;
  64848. /**
  64849. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64850. */
  64851. maxLayoutCycle: number;
  64852. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64853. adaptHeightToChildren: boolean;
  64854. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64855. adaptWidthToChildren: boolean;
  64856. /** Gets or sets background color */
  64857. background: string;
  64858. /** Gets the list of children */
  64859. readonly children: Control[];
  64860. /**
  64861. * Creates a new Container
  64862. * @param name defines the name of the container
  64863. */
  64864. constructor(name?: string | undefined);
  64865. protected _getTypeName(): string;
  64866. _flagDescendantsAsMatrixDirty(): void;
  64867. /**
  64868. * Gets a child using its name
  64869. * @param name defines the child name to look for
  64870. * @returns the child control if found
  64871. */
  64872. getChildByName(name: string): BABYLON.Nullable<Control>;
  64873. /**
  64874. * Gets a child using its type and its name
  64875. * @param name defines the child name to look for
  64876. * @param type defines the child type to look for
  64877. * @returns the child control if found
  64878. */
  64879. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64880. /**
  64881. * Search for a specific control in children
  64882. * @param control defines the control to look for
  64883. * @returns true if the control is in child list
  64884. */
  64885. containsControl(control: Control): boolean;
  64886. /**
  64887. * Adds a new control to the current container
  64888. * @param control defines the control to add
  64889. * @returns the current container
  64890. */
  64891. addControl(control: BABYLON.Nullable<Control>): Container;
  64892. /**
  64893. * Removes all controls from the current container
  64894. * @returns the current container
  64895. */
  64896. clearControls(): Container;
  64897. /**
  64898. * Removes a control from the current container
  64899. * @param control defines the control to remove
  64900. * @returns the current container
  64901. */
  64902. removeControl(control: Control): Container;
  64903. /** @hidden */
  64904. _reOrderControl(control: Control): void;
  64905. /** @hidden */
  64906. _offsetLeft(offset: number): void;
  64907. /** @hidden */
  64908. _offsetTop(offset: number): void;
  64909. /** @hidden */
  64910. _markAllAsDirty(): void;
  64911. /** @hidden */
  64912. protected _localDraw(context: CanvasRenderingContext2D): void;
  64913. /** @hidden */
  64914. _link(host: AdvancedDynamicTexture): void;
  64915. /** @hidden */
  64916. protected _beforeLayout(): void;
  64917. /** @hidden */
  64918. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64919. /** @hidden */
  64920. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64921. protected _postMeasure(): void;
  64922. /** @hidden */
  64923. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64924. /** @hidden */
  64925. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64926. /** @hidden */
  64927. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64928. /** @hidden */
  64929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64930. /** Releases associated resources */
  64931. dispose(): void;
  64932. }
  64933. }
  64934. declare module BABYLON.GUI {
  64935. /** Class used to create rectangle container */
  64936. export class Rectangle extends Container {
  64937. name?: string | undefined;
  64938. private _thickness;
  64939. private _cornerRadius;
  64940. /** Gets or sets border thickness */
  64941. thickness: number;
  64942. /** Gets or sets the corner radius angle */
  64943. cornerRadius: number;
  64944. /**
  64945. * Creates a new Rectangle
  64946. * @param name defines the control name
  64947. */
  64948. constructor(name?: string | undefined);
  64949. protected _getTypeName(): string;
  64950. protected _localDraw(context: CanvasRenderingContext2D): void;
  64951. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64952. private _drawRoundedRect;
  64953. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64954. }
  64955. }
  64956. declare module BABYLON.GUI {
  64957. /**
  64958. * Enum that determines the text-wrapping mode to use.
  64959. */
  64960. export enum TextWrapping {
  64961. /**
  64962. * Clip the text when it's larger than Control.width; this is the default mode.
  64963. */
  64964. Clip = 0,
  64965. /**
  64966. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64967. */
  64968. WordWrap = 1,
  64969. /**
  64970. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64971. */
  64972. Ellipsis = 2
  64973. }
  64974. /**
  64975. * Class used to create text block control
  64976. */
  64977. export class TextBlock extends Control {
  64978. /**
  64979. * Defines the name of the control
  64980. */
  64981. name?: string | undefined;
  64982. private _text;
  64983. private _textWrapping;
  64984. private _textHorizontalAlignment;
  64985. private _textVerticalAlignment;
  64986. private _lines;
  64987. private _resizeToFit;
  64988. private _lineSpacing;
  64989. private _outlineWidth;
  64990. private _outlineColor;
  64991. /**
  64992. * An event triggered after the text is changed
  64993. */
  64994. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64995. /**
  64996. * An event triggered after the text was broken up into lines
  64997. */
  64998. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64999. /**
  65000. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65001. */
  65002. readonly lines: any[];
  65003. /**
  65004. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65005. */
  65006. /**
  65007. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65008. */
  65009. resizeToFit: boolean;
  65010. /**
  65011. * Gets or sets a boolean indicating if text must be wrapped
  65012. */
  65013. /**
  65014. * Gets or sets a boolean indicating if text must be wrapped
  65015. */
  65016. textWrapping: TextWrapping | boolean;
  65017. /**
  65018. * Gets or sets text to display
  65019. */
  65020. /**
  65021. * Gets or sets text to display
  65022. */
  65023. text: string;
  65024. /**
  65025. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65026. */
  65027. /**
  65028. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65029. */
  65030. textHorizontalAlignment: number;
  65031. /**
  65032. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65033. */
  65034. /**
  65035. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65036. */
  65037. textVerticalAlignment: number;
  65038. /**
  65039. * Gets or sets line spacing value
  65040. */
  65041. /**
  65042. * Gets or sets line spacing value
  65043. */
  65044. lineSpacing: string | number;
  65045. /**
  65046. * Gets or sets outlineWidth of the text to display
  65047. */
  65048. /**
  65049. * Gets or sets outlineWidth of the text to display
  65050. */
  65051. outlineWidth: number;
  65052. /**
  65053. * Gets or sets outlineColor of the text to display
  65054. */
  65055. /**
  65056. * Gets or sets outlineColor of the text to display
  65057. */
  65058. outlineColor: string;
  65059. /**
  65060. * Creates a new TextBlock object
  65061. * @param name defines the name of the control
  65062. * @param text defines the text to display (emptry string by default)
  65063. */
  65064. constructor(
  65065. /**
  65066. * Defines the name of the control
  65067. */
  65068. name?: string | undefined, text?: string);
  65069. protected _getTypeName(): string;
  65070. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65071. private _drawText;
  65072. /** @hidden */
  65073. _draw(context: CanvasRenderingContext2D): void;
  65074. protected _applyStates(context: CanvasRenderingContext2D): void;
  65075. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65076. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65077. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65078. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65079. protected _renderLines(context: CanvasRenderingContext2D): void;
  65080. /**
  65081. * Given a width constraint applied on the text block, find the expected height
  65082. * @returns expected height
  65083. */
  65084. computeExpectedHeight(): number;
  65085. dispose(): void;
  65086. }
  65087. }
  65088. declare module BABYLON.GUI {
  65089. /**
  65090. * Class used to create 2D images
  65091. */
  65092. export class Image extends Control {
  65093. name?: string | undefined;
  65094. private static _WorkingCanvas;
  65095. private _domImage;
  65096. private _imageWidth;
  65097. private _imageHeight;
  65098. private _loaded;
  65099. private _stretch;
  65100. private _source;
  65101. private _autoScale;
  65102. private _sourceLeft;
  65103. private _sourceTop;
  65104. private _sourceWidth;
  65105. private _sourceHeight;
  65106. private _cellWidth;
  65107. private _cellHeight;
  65108. private _cellId;
  65109. private _populateNinePatchSlicesFromImage;
  65110. private _sliceLeft;
  65111. private _sliceRight;
  65112. private _sliceTop;
  65113. private _sliceBottom;
  65114. private _detectPointerOnOpaqueOnly;
  65115. /**
  65116. * BABYLON.Observable notified when the content is loaded
  65117. */
  65118. onImageLoadedObservable: BABYLON.Observable<Image>;
  65119. /**
  65120. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65121. */
  65122. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65123. /**
  65124. * Gets a boolean indicating that the content is loaded
  65125. */
  65126. readonly isLoaded: boolean;
  65127. /**
  65128. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65129. */
  65130. populateNinePatchSlicesFromImage: boolean;
  65131. /**
  65132. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65133. * Beware using this as this will comsume more memory as the image has to be stored twice
  65134. */
  65135. detectPointerOnOpaqueOnly: boolean;
  65136. /**
  65137. * Gets or sets the left value for slicing (9-patch)
  65138. */
  65139. sliceLeft: number;
  65140. /**
  65141. * Gets or sets the right value for slicing (9-patch)
  65142. */
  65143. sliceRight: number;
  65144. /**
  65145. * Gets or sets the top value for slicing (9-patch)
  65146. */
  65147. sliceTop: number;
  65148. /**
  65149. * Gets or sets the bottom value for slicing (9-patch)
  65150. */
  65151. sliceBottom: number;
  65152. /**
  65153. * Gets or sets the left coordinate in the source image
  65154. */
  65155. sourceLeft: number;
  65156. /**
  65157. * Gets or sets the top coordinate in the source image
  65158. */
  65159. sourceTop: number;
  65160. /**
  65161. * Gets or sets the width to capture in the source image
  65162. */
  65163. sourceWidth: number;
  65164. /**
  65165. * Gets or sets the height to capture in the source image
  65166. */
  65167. sourceHeight: number;
  65168. /**
  65169. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65170. * @see http://doc.babylonjs.com/how_to/gui#image
  65171. */
  65172. autoScale: boolean;
  65173. /** Gets or sets the streching mode used by the image */
  65174. stretch: number;
  65175. /**
  65176. * Gets or sets the internal DOM image used to render the control
  65177. */
  65178. domImage: HTMLImageElement;
  65179. private _onImageLoaded;
  65180. private _extractNinePatchSliceDataFromImage;
  65181. /**
  65182. * Gets or sets image source url
  65183. */
  65184. source: BABYLON.Nullable<string>;
  65185. /**
  65186. * Checks for svg document with icon id present
  65187. */
  65188. private _svgCheck;
  65189. /**
  65190. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65191. * given external svg file and icon id
  65192. */
  65193. private _getSVGAttribs;
  65194. /**
  65195. * Gets or sets the cell width to use when animation sheet is enabled
  65196. * @see http://doc.babylonjs.com/how_to/gui#image
  65197. */
  65198. cellWidth: number;
  65199. /**
  65200. * Gets or sets the cell height to use when animation sheet is enabled
  65201. * @see http://doc.babylonjs.com/how_to/gui#image
  65202. */
  65203. cellHeight: number;
  65204. /**
  65205. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65206. * @see http://doc.babylonjs.com/how_to/gui#image
  65207. */
  65208. cellId: number;
  65209. /**
  65210. * Creates a new Image
  65211. * @param name defines the control name
  65212. * @param url defines the image url
  65213. */
  65214. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65215. /**
  65216. * Tests if a given coordinates belong to the current control
  65217. * @param x defines x coordinate to test
  65218. * @param y defines y coordinate to test
  65219. * @returns true if the coordinates are inside the control
  65220. */
  65221. contains(x: number, y: number): boolean;
  65222. protected _getTypeName(): string;
  65223. /** Force the control to synchronize with its content */
  65224. synchronizeSizeWithContent(): void;
  65225. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65226. private _prepareWorkingCanvasForOpaqueDetection;
  65227. private _drawImage;
  65228. _draw(context: CanvasRenderingContext2D): void;
  65229. private _renderCornerPatch;
  65230. private _renderNinePatch;
  65231. dispose(): void;
  65232. /** STRETCH_NONE */
  65233. static readonly STRETCH_NONE: number;
  65234. /** STRETCH_FILL */
  65235. static readonly STRETCH_FILL: number;
  65236. /** STRETCH_UNIFORM */
  65237. static readonly STRETCH_UNIFORM: number;
  65238. /** STRETCH_EXTEND */
  65239. static readonly STRETCH_EXTEND: number;
  65240. /** NINE_PATCH */
  65241. static readonly STRETCH_NINE_PATCH: number;
  65242. }
  65243. }
  65244. declare module BABYLON.GUI {
  65245. /**
  65246. * Class used to create 2D buttons
  65247. */
  65248. export class Button extends Rectangle {
  65249. name?: string | undefined;
  65250. /**
  65251. * Function called to generate a pointer enter animation
  65252. */
  65253. pointerEnterAnimation: () => void;
  65254. /**
  65255. * Function called to generate a pointer out animation
  65256. */
  65257. pointerOutAnimation: () => void;
  65258. /**
  65259. * Function called to generate a pointer down animation
  65260. */
  65261. pointerDownAnimation: () => void;
  65262. /**
  65263. * Function called to generate a pointer up animation
  65264. */
  65265. pointerUpAnimation: () => void;
  65266. /**
  65267. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65268. */
  65269. delegatePickingToChildren: boolean;
  65270. private _image;
  65271. /**
  65272. * Returns the image part of the button (if any)
  65273. */
  65274. readonly image: BABYLON.Nullable<Image>;
  65275. private _textBlock;
  65276. /**
  65277. * Returns the image part of the button (if any)
  65278. */
  65279. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65280. /**
  65281. * Creates a new Button
  65282. * @param name defines the name of the button
  65283. */
  65284. constructor(name?: string | undefined);
  65285. protected _getTypeName(): string;
  65286. /** @hidden */
  65287. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65288. /** @hidden */
  65289. _onPointerEnter(target: Control): boolean;
  65290. /** @hidden */
  65291. _onPointerOut(target: Control, force?: boolean): void;
  65292. /** @hidden */
  65293. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65294. /** @hidden */
  65295. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65296. /**
  65297. * Creates a new button made with an image and a text
  65298. * @param name defines the name of the button
  65299. * @param text defines the text of the button
  65300. * @param imageUrl defines the url of the image
  65301. * @returns a new Button
  65302. */
  65303. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65304. /**
  65305. * Creates a new button made with an image
  65306. * @param name defines the name of the button
  65307. * @param imageUrl defines the url of the image
  65308. * @returns a new Button
  65309. */
  65310. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65311. /**
  65312. * Creates a new button made with a text
  65313. * @param name defines the name of the button
  65314. * @param text defines the text of the button
  65315. * @returns a new Button
  65316. */
  65317. static CreateSimpleButton(name: string, text: string): Button;
  65318. /**
  65319. * Creates a new button made with an image and a centered text
  65320. * @param name defines the name of the button
  65321. * @param text defines the text of the button
  65322. * @param imageUrl defines the url of the image
  65323. * @returns a new Button
  65324. */
  65325. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65326. }
  65327. }
  65328. declare module BABYLON.GUI {
  65329. /**
  65330. * Class used to create a 2D stack panel container
  65331. */
  65332. export class StackPanel extends Container {
  65333. name?: string | undefined;
  65334. private _isVertical;
  65335. private _manualWidth;
  65336. private _manualHeight;
  65337. private _doNotTrackManualChanges;
  65338. /**
  65339. * Gets or sets a boolean indicating that layou warnings should be ignored
  65340. */
  65341. ignoreLayoutWarnings: boolean;
  65342. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65343. isVertical: boolean;
  65344. /**
  65345. * Gets or sets panel width.
  65346. * This value should not be set when in horizontal mode as it will be computed automatically
  65347. */
  65348. width: string | number;
  65349. /**
  65350. * Gets or sets panel height.
  65351. * This value should not be set when in vertical mode as it will be computed automatically
  65352. */
  65353. height: string | number;
  65354. /**
  65355. * Creates a new StackPanel
  65356. * @param name defines control name
  65357. */
  65358. constructor(name?: string | undefined);
  65359. protected _getTypeName(): string;
  65360. /** @hidden */
  65361. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65362. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65363. protected _postMeasure(): void;
  65364. }
  65365. }
  65366. declare module BABYLON.GUI {
  65367. /**
  65368. * Class used to represent a 2D checkbox
  65369. */
  65370. export class Checkbox extends Control {
  65371. name?: string | undefined;
  65372. private _isChecked;
  65373. private _background;
  65374. private _checkSizeRatio;
  65375. private _thickness;
  65376. /** Gets or sets border thickness */
  65377. thickness: number;
  65378. /**
  65379. * BABYLON.Observable raised when isChecked property changes
  65380. */
  65381. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65382. /** Gets or sets a value indicating the ratio between overall size and check size */
  65383. checkSizeRatio: number;
  65384. /** Gets or sets background color */
  65385. background: string;
  65386. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65387. isChecked: boolean;
  65388. /**
  65389. * Creates a new CheckBox
  65390. * @param name defines the control name
  65391. */
  65392. constructor(name?: string | undefined);
  65393. protected _getTypeName(): string;
  65394. /** @hidden */
  65395. _draw(context: CanvasRenderingContext2D): void;
  65396. /** @hidden */
  65397. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65398. /**
  65399. * Utility function to easily create a checkbox with a header
  65400. * @param title defines the label to use for the header
  65401. * @param onValueChanged defines the callback to call when value changes
  65402. * @returns a StackPanel containing the checkbox and a textBlock
  65403. */
  65404. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65405. }
  65406. }
  65407. declare module BABYLON.GUI {
  65408. /**
  65409. * Class used to store key control properties
  65410. */
  65411. export class KeyPropertySet {
  65412. /** Width */
  65413. width?: string;
  65414. /** Height */
  65415. height?: string;
  65416. /** Left padding */
  65417. paddingLeft?: string;
  65418. /** Right padding */
  65419. paddingRight?: string;
  65420. /** Top padding */
  65421. paddingTop?: string;
  65422. /** Bottom padding */
  65423. paddingBottom?: string;
  65424. /** Foreground color */
  65425. color?: string;
  65426. /** Background color */
  65427. background?: string;
  65428. }
  65429. /**
  65430. * Class used to create virtual keyboard
  65431. */
  65432. export class VirtualKeyboard extends StackPanel {
  65433. /** BABYLON.Observable raised when a key is pressed */
  65434. onKeyPressObservable: BABYLON.Observable<string>;
  65435. /** Gets or sets default key button width */
  65436. defaultButtonWidth: string;
  65437. /** Gets or sets default key button height */
  65438. defaultButtonHeight: string;
  65439. /** Gets or sets default key button left padding */
  65440. defaultButtonPaddingLeft: string;
  65441. /** Gets or sets default key button right padding */
  65442. defaultButtonPaddingRight: string;
  65443. /** Gets or sets default key button top padding */
  65444. defaultButtonPaddingTop: string;
  65445. /** Gets or sets default key button bottom padding */
  65446. defaultButtonPaddingBottom: string;
  65447. /** Gets or sets default key button foreground color */
  65448. defaultButtonColor: string;
  65449. /** Gets or sets default key button background color */
  65450. defaultButtonBackground: string;
  65451. /** Gets or sets shift button foreground color */
  65452. shiftButtonColor: string;
  65453. /** Gets or sets shift button thickness*/
  65454. selectedShiftThickness: number;
  65455. /** Gets shift key state */
  65456. shiftState: number;
  65457. protected _getTypeName(): string;
  65458. private _createKey;
  65459. /**
  65460. * Adds a new row of keys
  65461. * @param keys defines the list of keys to add
  65462. * @param propertySets defines the associated property sets
  65463. */
  65464. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65465. /**
  65466. * Set the shift key to a specific state
  65467. * @param shiftState defines the new shift state
  65468. */
  65469. applyShiftState(shiftState: number): void;
  65470. private _currentlyConnectedInputText;
  65471. private _connectedInputTexts;
  65472. private _onKeyPressObserver;
  65473. /** Gets the input text control currently attached to the keyboard */
  65474. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65475. /**
  65476. * Connects the keyboard with an input text control
  65477. *
  65478. * @param input defines the target control
  65479. */
  65480. connect(input: InputText): void;
  65481. /**
  65482. * Disconnects the keyboard from connected InputText controls
  65483. *
  65484. * @param input optionally defines a target control, otherwise all are disconnected
  65485. */
  65486. disconnect(input?: InputText): void;
  65487. private _removeConnectedInputObservables;
  65488. /**
  65489. * Release all resources
  65490. */
  65491. dispose(): void;
  65492. /**
  65493. * Creates a new keyboard using a default layout
  65494. *
  65495. * @param name defines control name
  65496. * @returns a new VirtualKeyboard
  65497. */
  65498. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65499. }
  65500. }
  65501. declare module BABYLON.GUI {
  65502. /**
  65503. * Class used to create input text control
  65504. */
  65505. export class InputText extends Control implements IFocusableControl {
  65506. name?: string | undefined;
  65507. private _text;
  65508. private _placeholderText;
  65509. private _background;
  65510. private _focusedBackground;
  65511. private _focusedColor;
  65512. private _placeholderColor;
  65513. private _thickness;
  65514. private _margin;
  65515. private _autoStretchWidth;
  65516. private _maxWidth;
  65517. private _isFocused;
  65518. private _blinkTimeout;
  65519. private _blinkIsEven;
  65520. private _cursorOffset;
  65521. private _scrollLeft;
  65522. private _textWidth;
  65523. private _clickedCoordinate;
  65524. private _deadKey;
  65525. private _addKey;
  65526. private _currentKey;
  65527. private _isTextHighlightOn;
  65528. private _textHighlightColor;
  65529. private _highligherOpacity;
  65530. private _highlightedText;
  65531. private _startHighlightIndex;
  65532. private _endHighlightIndex;
  65533. private _cursorIndex;
  65534. private _onFocusSelectAll;
  65535. private _isPointerDown;
  65536. private _onClipboardObserver;
  65537. private _onPointerDblTapObserver;
  65538. /** @hidden */
  65539. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65540. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65541. promptMessage: string;
  65542. /** Force disable prompt on mobile device */
  65543. disableMobilePrompt: boolean;
  65544. /** BABYLON.Observable raised when the text changes */
  65545. onTextChangedObservable: BABYLON.Observable<InputText>;
  65546. /** BABYLON.Observable raised just before an entered character is to be added */
  65547. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65548. /** BABYLON.Observable raised when the control gets the focus */
  65549. onFocusObservable: BABYLON.Observable<InputText>;
  65550. /** BABYLON.Observable raised when the control loses the focus */
  65551. onBlurObservable: BABYLON.Observable<InputText>;
  65552. /**Observable raised when the text is highlighted */
  65553. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65554. /**Observable raised when copy event is triggered */
  65555. onTextCopyObservable: BABYLON.Observable<InputText>;
  65556. /** BABYLON.Observable raised when cut event is triggered */
  65557. onTextCutObservable: BABYLON.Observable<InputText>;
  65558. /** BABYLON.Observable raised when paste event is triggered */
  65559. onTextPasteObservable: BABYLON.Observable<InputText>;
  65560. /** BABYLON.Observable raised when a key event was processed */
  65561. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65562. /** Gets or sets the maximum width allowed by the control */
  65563. maxWidth: string | number;
  65564. /** Gets the maximum width allowed by the control in pixels */
  65565. readonly maxWidthInPixels: number;
  65566. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65567. highligherOpacity: number;
  65568. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65569. onFocusSelectAll: boolean;
  65570. /** Gets or sets the text hightlight color */
  65571. textHighlightColor: string;
  65572. /** Gets or sets control margin */
  65573. margin: string;
  65574. /** Gets control margin in pixels */
  65575. readonly marginInPixels: number;
  65576. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65577. autoStretchWidth: boolean;
  65578. /** Gets or sets border thickness */
  65579. thickness: number;
  65580. /** Gets or sets the background color when focused */
  65581. focusedBackground: string;
  65582. /** Gets or sets the background color when focused */
  65583. focusedColor: string;
  65584. /** Gets or sets the background color */
  65585. background: string;
  65586. /** Gets or sets the placeholder color */
  65587. placeholderColor: string;
  65588. /** Gets or sets the text displayed when the control is empty */
  65589. placeholderText: string;
  65590. /** Gets or sets the dead key flag */
  65591. deadKey: boolean;
  65592. /** Gets or sets the highlight text */
  65593. highlightedText: string;
  65594. /** Gets or sets if the current key should be added */
  65595. addKey: boolean;
  65596. /** Gets or sets the value of the current key being entered */
  65597. currentKey: string;
  65598. /** Gets or sets the text displayed in the control */
  65599. text: string;
  65600. /** Gets or sets control width */
  65601. width: string | number;
  65602. /**
  65603. * Creates a new InputText
  65604. * @param name defines the control name
  65605. * @param text defines the text of the control
  65606. */
  65607. constructor(name?: string | undefined, text?: string);
  65608. /** @hidden */
  65609. onBlur(): void;
  65610. /** @hidden */
  65611. onFocus(): void;
  65612. protected _getTypeName(): string;
  65613. /**
  65614. * Function called to get the list of controls that should not steal the focus from this control
  65615. * @returns an array of controls
  65616. */
  65617. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65618. /** @hidden */
  65619. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65620. /** @hidden */
  65621. private _updateValueFromCursorIndex;
  65622. /** @hidden */
  65623. private _processDblClick;
  65624. /** @hidden */
  65625. private _selectAllText;
  65626. /**
  65627. * Handles the keyboard event
  65628. * @param evt Defines the KeyboardEvent
  65629. */
  65630. processKeyboard(evt: KeyboardEvent): void;
  65631. /** @hidden */
  65632. private _onCopyText;
  65633. /** @hidden */
  65634. private _onCutText;
  65635. /** @hidden */
  65636. private _onPasteText;
  65637. _draw(context: CanvasRenderingContext2D): void;
  65638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65639. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65640. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65641. protected _beforeRenderText(text: string): string;
  65642. dispose(): void;
  65643. }
  65644. }
  65645. declare module BABYLON.GUI {
  65646. /**
  65647. * Class used to create a 2D grid container
  65648. */
  65649. export class Grid extends Container {
  65650. name?: string | undefined;
  65651. private _rowDefinitions;
  65652. private _columnDefinitions;
  65653. private _cells;
  65654. private _childControls;
  65655. /**
  65656. * Gets the number of columns
  65657. */
  65658. readonly columnCount: number;
  65659. /**
  65660. * Gets the number of rows
  65661. */
  65662. readonly rowCount: number;
  65663. /** Gets the list of children */
  65664. readonly children: Control[];
  65665. /** Gets the list of cells (e.g. the containers) */
  65666. readonly cells: {
  65667. [key: string]: Container;
  65668. };
  65669. /**
  65670. * Gets the definition of a specific row
  65671. * @param index defines the index of the row
  65672. * @returns the row definition
  65673. */
  65674. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65675. /**
  65676. * Gets the definition of a specific column
  65677. * @param index defines the index of the column
  65678. * @returns the column definition
  65679. */
  65680. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65681. /**
  65682. * Adds a new row to the grid
  65683. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65684. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65685. * @returns the current grid
  65686. */
  65687. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65688. /**
  65689. * Adds a new column to the grid
  65690. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65691. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65692. * @returns the current grid
  65693. */
  65694. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65695. /**
  65696. * Update a row definition
  65697. * @param index defines the index of the row to update
  65698. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65699. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65700. * @returns the current grid
  65701. */
  65702. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65703. /**
  65704. * Update a column definition
  65705. * @param index defines the index of the column to update
  65706. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65707. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65708. * @returns the current grid
  65709. */
  65710. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65711. /**
  65712. * Gets the list of children stored in a specific cell
  65713. * @param row defines the row to check
  65714. * @param column defines the column to check
  65715. * @returns the list of controls
  65716. */
  65717. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65718. /**
  65719. * Gets a string representing the child cell info (row x column)
  65720. * @param child defines the control to get info from
  65721. * @returns a string containing the child cell info (row x column)
  65722. */
  65723. getChildCellInfo(child: Control): string;
  65724. private _removeCell;
  65725. private _offsetCell;
  65726. /**
  65727. * Remove a column definition at specified index
  65728. * @param index defines the index of the column to remove
  65729. * @returns the current grid
  65730. */
  65731. removeColumnDefinition(index: number): Grid;
  65732. /**
  65733. * Remove a row definition at specified index
  65734. * @param index defines the index of the row to remove
  65735. * @returns the current grid
  65736. */
  65737. removeRowDefinition(index: number): Grid;
  65738. /**
  65739. * Adds a new control to the current grid
  65740. * @param control defines the control to add
  65741. * @param row defines the row where to add the control (0 by default)
  65742. * @param column defines the column where to add the control (0 by default)
  65743. * @returns the current grid
  65744. */
  65745. addControl(control: Control, row?: number, column?: number): Grid;
  65746. /**
  65747. * Removes a control from the current container
  65748. * @param control defines the control to remove
  65749. * @returns the current container
  65750. */
  65751. removeControl(control: Control): Container;
  65752. /**
  65753. * Creates a new Grid
  65754. * @param name defines control name
  65755. */
  65756. constructor(name?: string | undefined);
  65757. protected _getTypeName(): string;
  65758. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65759. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65760. _flagDescendantsAsMatrixDirty(): void;
  65761. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65762. /** Releases associated resources */
  65763. dispose(): void;
  65764. }
  65765. }
  65766. declare module BABYLON.GUI {
  65767. /** Class used to create color pickers */
  65768. export class ColorPicker extends Control {
  65769. name?: string | undefined;
  65770. private static _Epsilon;
  65771. private _colorWheelCanvas;
  65772. private _value;
  65773. private _tmpColor;
  65774. private _pointerStartedOnSquare;
  65775. private _pointerStartedOnWheel;
  65776. private _squareLeft;
  65777. private _squareTop;
  65778. private _squareSize;
  65779. private _h;
  65780. private _s;
  65781. private _v;
  65782. private _lastPointerDownID;
  65783. /**
  65784. * BABYLON.Observable raised when the value changes
  65785. */
  65786. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65787. /** Gets or sets the color of the color picker */
  65788. value: BABYLON.Color3;
  65789. /**
  65790. * Gets or sets control width
  65791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65792. */
  65793. width: string | number;
  65794. /**
  65795. * Gets or sets control height
  65796. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65797. */
  65798. /** Gets or sets control height */
  65799. height: string | number;
  65800. /** Gets or sets control size */
  65801. size: string | number;
  65802. /**
  65803. * Creates a new ColorPicker
  65804. * @param name defines the control name
  65805. */
  65806. constructor(name?: string | undefined);
  65807. protected _getTypeName(): string;
  65808. /** @hidden */
  65809. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65810. private _updateSquareProps;
  65811. private _drawGradientSquare;
  65812. private _drawCircle;
  65813. private _createColorWheelCanvas;
  65814. /** @hidden */
  65815. _draw(context: CanvasRenderingContext2D): void;
  65816. private _pointerIsDown;
  65817. private _updateValueFromPointer;
  65818. private _isPointOnSquare;
  65819. private _isPointOnWheel;
  65820. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65821. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65822. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65823. /**
  65824. * This function expands the color picker by creating a color picker dialog with manual
  65825. * color value input and the ability to save colors into an array to be used later in
  65826. * subsequent launches of the dialogue.
  65827. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65828. * @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.
  65829. * @returns picked color as a hex string and the saved colors array as hex strings.
  65830. */
  65831. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65832. pickerWidth?: string;
  65833. pickerHeight?: string;
  65834. headerHeight?: string;
  65835. lastColor?: string;
  65836. swatchLimit?: number;
  65837. numSwatchesPerLine?: number;
  65838. savedColors?: Array<string>;
  65839. }): Promise<{
  65840. savedColors?: string[];
  65841. pickedColor: string;
  65842. }>;
  65843. }
  65844. }
  65845. declare module BABYLON.GUI {
  65846. /** Class used to create 2D ellipse containers */
  65847. export class Ellipse extends Container {
  65848. name?: string | undefined;
  65849. private _thickness;
  65850. /** Gets or sets border thickness */
  65851. thickness: number;
  65852. /**
  65853. * Creates a new Ellipse
  65854. * @param name defines the control name
  65855. */
  65856. constructor(name?: string | undefined);
  65857. protected _getTypeName(): string;
  65858. protected _localDraw(context: CanvasRenderingContext2D): void;
  65859. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65860. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65861. }
  65862. }
  65863. declare module BABYLON.GUI {
  65864. /**
  65865. * Class used to create a password control
  65866. */
  65867. export class InputPassword extends InputText {
  65868. protected _beforeRenderText(text: string): string;
  65869. }
  65870. }
  65871. declare module BABYLON.GUI {
  65872. /** Class used to render 2D lines */
  65873. export class Line extends Control {
  65874. name?: string | undefined;
  65875. private _lineWidth;
  65876. private _x1;
  65877. private _y1;
  65878. private _x2;
  65879. private _y2;
  65880. private _dash;
  65881. private _connectedControl;
  65882. private _connectedControlDirtyObserver;
  65883. /** Gets or sets the dash pattern */
  65884. dash: Array<number>;
  65885. /** Gets or sets the control connected with the line end */
  65886. connectedControl: Control;
  65887. /** Gets or sets start coordinates on X axis */
  65888. x1: string | number;
  65889. /** Gets or sets start coordinates on Y axis */
  65890. y1: string | number;
  65891. /** Gets or sets end coordinates on X axis */
  65892. x2: string | number;
  65893. /** Gets or sets end coordinates on Y axis */
  65894. y2: string | number;
  65895. /** Gets or sets line width */
  65896. lineWidth: number;
  65897. /** Gets or sets horizontal alignment */
  65898. horizontalAlignment: number;
  65899. /** Gets or sets vertical alignment */
  65900. verticalAlignment: number;
  65901. private readonly _effectiveX2;
  65902. private readonly _effectiveY2;
  65903. /**
  65904. * Creates a new Line
  65905. * @param name defines the control name
  65906. */
  65907. constructor(name?: string | undefined);
  65908. protected _getTypeName(): string;
  65909. _draw(context: CanvasRenderingContext2D): void;
  65910. _measure(): void;
  65911. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65912. /**
  65913. * Move one end of the line given 3D cartesian coordinates.
  65914. * @param position Targeted world position
  65915. * @param scene BABYLON.Scene
  65916. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65917. */
  65918. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65919. /**
  65920. * Move one end of the line to a position in screen absolute space.
  65921. * @param projectedPosition Position in screen absolute space (X, Y)
  65922. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65923. */
  65924. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65925. }
  65926. }
  65927. declare module BABYLON.GUI {
  65928. /**
  65929. * Class used to store a point for a MultiLine object.
  65930. * The point can be pure 2D coordinates, a mesh or a control
  65931. */
  65932. export class MultiLinePoint {
  65933. private _multiLine;
  65934. private _x;
  65935. private _y;
  65936. private _control;
  65937. private _mesh;
  65938. private _controlObserver;
  65939. private _meshObserver;
  65940. /** @hidden */
  65941. _point: BABYLON.Vector2;
  65942. /**
  65943. * Creates a new MultiLinePoint
  65944. * @param multiLine defines the source MultiLine object
  65945. */
  65946. constructor(multiLine: MultiLine);
  65947. /** Gets or sets x coordinate */
  65948. x: string | number;
  65949. /** Gets or sets y coordinate */
  65950. y: string | number;
  65951. /** Gets or sets the control associated with this point */
  65952. control: BABYLON.Nullable<Control>;
  65953. /** Gets or sets the mesh associated with this point */
  65954. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65955. /** Resets links */
  65956. resetLinks(): void;
  65957. /**
  65958. * Gets a translation vector
  65959. * @returns the translation vector
  65960. */
  65961. translate(): BABYLON.Vector2;
  65962. private _translatePoint;
  65963. /** Release associated resources */
  65964. dispose(): void;
  65965. }
  65966. }
  65967. declare module BABYLON.GUI {
  65968. /**
  65969. * Class used to create multi line control
  65970. */
  65971. export class MultiLine extends Control {
  65972. name?: string | undefined;
  65973. private _lineWidth;
  65974. private _dash;
  65975. private _points;
  65976. private _minX;
  65977. private _minY;
  65978. private _maxX;
  65979. private _maxY;
  65980. /**
  65981. * Creates a new MultiLine
  65982. * @param name defines the control name
  65983. */
  65984. constructor(name?: string | undefined);
  65985. /** Gets or sets dash pattern */
  65986. dash: Array<number>;
  65987. /**
  65988. * Gets point stored at specified index
  65989. * @param index defines the index to look for
  65990. * @returns the requested point if found
  65991. */
  65992. getAt(index: number): MultiLinePoint;
  65993. /** Function called when a point is updated */
  65994. onPointUpdate: () => void;
  65995. /**
  65996. * Adds new points to the point collection
  65997. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65998. * @returns the list of created MultiLinePoint
  65999. */
  66000. add(...items: (AbstractMesh | Control | {
  66001. x: string | number;
  66002. y: string | number;
  66003. })[]): MultiLinePoint[];
  66004. /**
  66005. * Adds a new point to the point collection
  66006. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66007. * @returns the created MultiLinePoint
  66008. */
  66009. push(item?: (AbstractMesh | Control | {
  66010. x: string | number;
  66011. y: string | number;
  66012. })): MultiLinePoint;
  66013. /**
  66014. * Remove a specific value or point from the active point collection
  66015. * @param value defines the value or point to remove
  66016. */
  66017. remove(value: number | MultiLinePoint): void;
  66018. /**
  66019. * Resets this object to initial state (no point)
  66020. */
  66021. reset(): void;
  66022. /**
  66023. * Resets all links
  66024. */
  66025. resetLinks(): void;
  66026. /** Gets or sets line width */
  66027. lineWidth: number;
  66028. horizontalAlignment: number;
  66029. verticalAlignment: number;
  66030. protected _getTypeName(): string;
  66031. _draw(context: CanvasRenderingContext2D): void;
  66032. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66033. _measure(): void;
  66034. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66035. dispose(): void;
  66036. }
  66037. }
  66038. declare module BABYLON.GUI {
  66039. /**
  66040. * Class used to create radio button controls
  66041. */
  66042. export class RadioButton extends Control {
  66043. name?: string | undefined;
  66044. private _isChecked;
  66045. private _background;
  66046. private _checkSizeRatio;
  66047. private _thickness;
  66048. /** Gets or sets border thickness */
  66049. thickness: number;
  66050. /** Gets or sets group name */
  66051. group: string;
  66052. /** BABYLON.Observable raised when isChecked is changed */
  66053. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66054. /** Gets or sets a value indicating the ratio between overall size and check size */
  66055. checkSizeRatio: number;
  66056. /** Gets or sets background color */
  66057. background: string;
  66058. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66059. isChecked: boolean;
  66060. /**
  66061. * Creates a new RadioButton
  66062. * @param name defines the control name
  66063. */
  66064. constructor(name?: string | undefined);
  66065. protected _getTypeName(): string;
  66066. _draw(context: CanvasRenderingContext2D): void;
  66067. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66068. /**
  66069. * Utility function to easily create a radio button with a header
  66070. * @param title defines the label to use for the header
  66071. * @param group defines the group to use for the radio button
  66072. * @param isChecked defines the initial state of the radio button
  66073. * @param onValueChanged defines the callback to call when value changes
  66074. * @returns a StackPanel containing the radio button and a textBlock
  66075. */
  66076. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66077. }
  66078. }
  66079. declare module BABYLON.GUI {
  66080. /**
  66081. * Class used to create slider controls
  66082. */
  66083. export class BaseSlider extends Control {
  66084. name?: string | undefined;
  66085. protected _thumbWidth: ValueAndUnit;
  66086. private _minimum;
  66087. private _maximum;
  66088. private _value;
  66089. private _isVertical;
  66090. protected _barOffset: ValueAndUnit;
  66091. private _isThumbClamped;
  66092. protected _displayThumb: boolean;
  66093. private _step;
  66094. private _lastPointerDownID;
  66095. protected _effectiveBarOffset: number;
  66096. protected _renderLeft: number;
  66097. protected _renderTop: number;
  66098. protected _renderWidth: number;
  66099. protected _renderHeight: number;
  66100. protected _backgroundBoxLength: number;
  66101. protected _backgroundBoxThickness: number;
  66102. protected _effectiveThumbThickness: number;
  66103. /** BABYLON.Observable raised when the sldier value changes */
  66104. onValueChangedObservable: BABYLON.Observable<number>;
  66105. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66106. displayThumb: boolean;
  66107. /** Gets or sets a step to apply to values (0 by default) */
  66108. step: number;
  66109. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66110. barOffset: string | number;
  66111. /** Gets main bar offset in pixels*/
  66112. readonly barOffsetInPixels: number;
  66113. /** Gets or sets thumb width */
  66114. thumbWidth: string | number;
  66115. /** Gets thumb width in pixels */
  66116. readonly thumbWidthInPixels: number;
  66117. /** Gets or sets minimum value */
  66118. minimum: number;
  66119. /** Gets or sets maximum value */
  66120. maximum: number;
  66121. /** Gets or sets current value */
  66122. value: number;
  66123. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66124. isVertical: boolean;
  66125. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66126. isThumbClamped: boolean;
  66127. /**
  66128. * Creates a new BaseSlider
  66129. * @param name defines the control name
  66130. */
  66131. constructor(name?: string | undefined);
  66132. protected _getTypeName(): string;
  66133. protected _getThumbPosition(): number;
  66134. protected _getThumbThickness(type: string): number;
  66135. protected _prepareRenderingData(type: string): void;
  66136. private _pointerIsDown;
  66137. /** @hidden */
  66138. protected _updateValueFromPointer(x: number, y: number): void;
  66139. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66140. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66141. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66142. }
  66143. }
  66144. declare module BABYLON.GUI {
  66145. /**
  66146. * Class used to create slider controls
  66147. */
  66148. export class Slider extends BaseSlider {
  66149. name?: string | undefined;
  66150. private _background;
  66151. private _borderColor;
  66152. private _isThumbCircle;
  66153. protected _displayValueBar: boolean;
  66154. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66155. displayValueBar: boolean;
  66156. /** Gets or sets border color */
  66157. borderColor: string;
  66158. /** Gets or sets background color */
  66159. background: string;
  66160. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66161. isThumbCircle: boolean;
  66162. /**
  66163. * Creates a new Slider
  66164. * @param name defines the control name
  66165. */
  66166. constructor(name?: string | undefined);
  66167. protected _getTypeName(): string;
  66168. _draw(context: CanvasRenderingContext2D): void;
  66169. }
  66170. }
  66171. declare module BABYLON.GUI {
  66172. /** Class used to create a RadioGroup
  66173. * which contains groups of radio buttons
  66174. */
  66175. export class SelectorGroup {
  66176. /** name of SelectorGroup */
  66177. name: string;
  66178. private _groupPanel;
  66179. private _selectors;
  66180. private _groupHeader;
  66181. /**
  66182. * Creates a new SelectorGroup
  66183. * @param name of group, used as a group heading
  66184. */
  66185. constructor(
  66186. /** name of SelectorGroup */
  66187. name: string);
  66188. /** Gets the groupPanel of the SelectorGroup */
  66189. readonly groupPanel: StackPanel;
  66190. /** Gets the selectors array */
  66191. readonly selectors: StackPanel[];
  66192. /** Gets and sets the group header */
  66193. header: string;
  66194. /** @hidden */
  66195. private _addGroupHeader;
  66196. /** @hidden*/
  66197. _getSelector(selectorNb: number): StackPanel | undefined;
  66198. /** Removes the selector at the given position
  66199. * @param selectorNb the position of the selector within the group
  66200. */
  66201. removeSelector(selectorNb: number): void;
  66202. }
  66203. /** Class used to create a CheckboxGroup
  66204. * which contains groups of checkbox buttons
  66205. */
  66206. export class CheckboxGroup extends SelectorGroup {
  66207. /** Adds a checkbox as a control
  66208. * @param text is the label for the selector
  66209. * @param func is the function called when the Selector is checked
  66210. * @param checked is true when Selector is checked
  66211. */
  66212. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66213. /** @hidden */
  66214. _setSelectorLabel(selectorNb: number, label: string): void;
  66215. /** @hidden */
  66216. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66217. /** @hidden */
  66218. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66219. /** @hidden */
  66220. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66221. }
  66222. /** Class used to create a RadioGroup
  66223. * which contains groups of radio buttons
  66224. */
  66225. export class RadioGroup extends SelectorGroup {
  66226. private _selectNb;
  66227. /** Adds a radio button as a control
  66228. * @param label is the label for the selector
  66229. * @param func is the function called when the Selector is checked
  66230. * @param checked is true when Selector is checked
  66231. */
  66232. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66233. /** @hidden */
  66234. _setSelectorLabel(selectorNb: number, label: string): void;
  66235. /** @hidden */
  66236. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66237. /** @hidden */
  66238. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66239. /** @hidden */
  66240. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66241. }
  66242. /** Class used to create a SliderGroup
  66243. * which contains groups of slider buttons
  66244. */
  66245. export class SliderGroup extends SelectorGroup {
  66246. /**
  66247. * Adds a slider to the SelectorGroup
  66248. * @param label is the label for the SliderBar
  66249. * @param func is the function called when the Slider moves
  66250. * @param unit is a string describing the units used, eg degrees or metres
  66251. * @param min is the minimum value for the Slider
  66252. * @param max is the maximum value for the Slider
  66253. * @param value is the start value for the Slider between min and max
  66254. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66255. */
  66256. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66257. /** @hidden */
  66258. _setSelectorLabel(selectorNb: number, label: string): void;
  66259. /** @hidden */
  66260. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66261. /** @hidden */
  66262. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66263. /** @hidden */
  66264. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66265. }
  66266. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66267. * @see http://doc.babylonjs.com/how_to/selector
  66268. */
  66269. export class SelectionPanel extends Rectangle {
  66270. /** name of SelectionPanel */
  66271. name: string;
  66272. /** an array of SelectionGroups */
  66273. groups: SelectorGroup[];
  66274. private _panel;
  66275. private _buttonColor;
  66276. private _buttonBackground;
  66277. private _headerColor;
  66278. private _barColor;
  66279. private _barHeight;
  66280. private _spacerHeight;
  66281. private _labelColor;
  66282. private _groups;
  66283. private _bars;
  66284. /**
  66285. * Creates a new SelectionPanel
  66286. * @param name of SelectionPanel
  66287. * @param groups is an array of SelectionGroups
  66288. */
  66289. constructor(
  66290. /** name of SelectionPanel */
  66291. name: string,
  66292. /** an array of SelectionGroups */
  66293. groups?: SelectorGroup[]);
  66294. protected _getTypeName(): string;
  66295. /** Gets or sets the headerColor */
  66296. headerColor: string;
  66297. private _setHeaderColor;
  66298. /** Gets or sets the button color */
  66299. buttonColor: string;
  66300. private _setbuttonColor;
  66301. /** Gets or sets the label color */
  66302. labelColor: string;
  66303. private _setLabelColor;
  66304. /** Gets or sets the button background */
  66305. buttonBackground: string;
  66306. private _setButtonBackground;
  66307. /** Gets or sets the color of separator bar */
  66308. barColor: string;
  66309. private _setBarColor;
  66310. /** Gets or sets the height of separator bar */
  66311. barHeight: string;
  66312. private _setBarHeight;
  66313. /** Gets or sets the height of spacers*/
  66314. spacerHeight: string;
  66315. private _setSpacerHeight;
  66316. /** Adds a bar between groups */
  66317. private _addSpacer;
  66318. /** Add a group to the selection panel
  66319. * @param group is the selector group to add
  66320. */
  66321. addGroup(group: SelectorGroup): void;
  66322. /** Remove the group from the given position
  66323. * @param groupNb is the position of the group in the list
  66324. */
  66325. removeGroup(groupNb: number): void;
  66326. /** Change a group header label
  66327. * @param label is the new group header label
  66328. * @param groupNb is the number of the group to relabel
  66329. * */
  66330. setHeaderName(label: string, groupNb: number): void;
  66331. /** Change selector label to the one given
  66332. * @param label is the new selector label
  66333. * @param groupNb is the number of the groupcontaining the selector
  66334. * @param selectorNb is the number of the selector within a group to relabel
  66335. * */
  66336. relabel(label: string, groupNb: number, selectorNb: number): void;
  66337. /** For a given group position remove the selector at the given position
  66338. * @param groupNb is the number of the group to remove the selector from
  66339. * @param selectorNb is the number of the selector within the group
  66340. */
  66341. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66342. /** For a given group position of correct type add a checkbox button
  66343. * @param groupNb is the number of the group to remove the selector from
  66344. * @param label is the label for the selector
  66345. * @param func is the function called when the Selector is checked
  66346. * @param checked is true when Selector is checked
  66347. */
  66348. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66349. /** For a given group position of correct type add a radio button
  66350. * @param groupNb is the number of the group to remove the selector from
  66351. * @param label is the label for the selector
  66352. * @param func is the function called when the Selector is checked
  66353. * @param checked is true when Selector is checked
  66354. */
  66355. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66356. /**
  66357. * For a given slider group add a slider
  66358. * @param groupNb is the number of the group to add the slider to
  66359. * @param label is the label for the Slider
  66360. * @param func is the function called when the Slider moves
  66361. * @param unit is a string describing the units used, eg degrees or metres
  66362. * @param min is the minimum value for the Slider
  66363. * @param max is the maximum value for the Slider
  66364. * @param value is the start value for the Slider between min and max
  66365. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66366. */
  66367. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66368. }
  66369. }
  66370. declare module BABYLON.GUI {
  66371. /**
  66372. * Class used to hold a the container for ScrollViewer
  66373. * @hidden
  66374. */
  66375. export class _ScrollViewerWindow extends Container {
  66376. parentClientWidth: number;
  66377. parentClientHeight: number;
  66378. /**
  66379. * Creates a new ScrollViewerWindow
  66380. * @param name of ScrollViewerWindow
  66381. */
  66382. constructor(name?: string);
  66383. protected _getTypeName(): string;
  66384. /** @hidden */
  66385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66386. protected _postMeasure(): void;
  66387. }
  66388. }
  66389. declare module BABYLON.GUI {
  66390. /**
  66391. * Class used to create slider controls
  66392. */
  66393. export class ScrollBar extends BaseSlider {
  66394. name?: string | undefined;
  66395. private _background;
  66396. private _borderColor;
  66397. private _thumbMeasure;
  66398. /** Gets or sets border color */
  66399. borderColor: string;
  66400. /** Gets or sets background color */
  66401. background: string;
  66402. /**
  66403. * Creates a new Slider
  66404. * @param name defines the control name
  66405. */
  66406. constructor(name?: string | undefined);
  66407. protected _getTypeName(): string;
  66408. protected _getThumbThickness(): number;
  66409. _draw(context: CanvasRenderingContext2D): void;
  66410. private _first;
  66411. private _originX;
  66412. private _originY;
  66413. /** @hidden */
  66414. protected _updateValueFromPointer(x: number, y: number): void;
  66415. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66416. }
  66417. }
  66418. declare module BABYLON.GUI {
  66419. /**
  66420. * Class used to hold a viewer window and sliders in a grid
  66421. */
  66422. export class ScrollViewer extends Rectangle {
  66423. private _grid;
  66424. private _horizontalBarSpace;
  66425. private _verticalBarSpace;
  66426. private _dragSpace;
  66427. private _horizontalBar;
  66428. private _verticalBar;
  66429. private _barColor;
  66430. private _barBackground;
  66431. private _barSize;
  66432. private _endLeft;
  66433. private _endTop;
  66434. private _window;
  66435. private _pointerIsOver;
  66436. private _wheelPrecision;
  66437. private _onPointerObserver;
  66438. private _clientWidth;
  66439. private _clientHeight;
  66440. /**
  66441. * Gets the horizontal scrollbar
  66442. */
  66443. readonly horizontalBar: ScrollBar;
  66444. /**
  66445. * Gets the vertical scrollbar
  66446. */
  66447. readonly verticalBar: ScrollBar;
  66448. /**
  66449. * Adds a new control to the current container
  66450. * @param control defines the control to add
  66451. * @returns the current container
  66452. */
  66453. addControl(control: BABYLON.Nullable<Control>): Container;
  66454. /**
  66455. * Removes a control from the current container
  66456. * @param control defines the control to remove
  66457. * @returns the current container
  66458. */
  66459. removeControl(control: Control): Container;
  66460. /** Gets the list of children */
  66461. readonly children: Control[];
  66462. _flagDescendantsAsMatrixDirty(): void;
  66463. /**
  66464. * Creates a new ScrollViewer
  66465. * @param name of ScrollViewer
  66466. */
  66467. constructor(name?: string);
  66468. /** Reset the scroll viewer window to initial size */
  66469. resetWindow(): void;
  66470. protected _getTypeName(): string;
  66471. private _buildClientSizes;
  66472. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66473. protected _postMeasure(): void;
  66474. /**
  66475. * Gets or sets the mouse wheel precision
  66476. * from 0 to 1 with a default value of 0.05
  66477. * */
  66478. wheelPrecision: number;
  66479. /** Gets or sets the bar color */
  66480. barColor: string;
  66481. /** Gets or sets the size of the bar */
  66482. barSize: number;
  66483. /** Gets or sets the bar background */
  66484. barBackground: string;
  66485. /** @hidden */
  66486. private _updateScroller;
  66487. _link(host: AdvancedDynamicTexture): void;
  66488. /** @hidden */
  66489. private _attachWheel;
  66490. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66491. /** Releases associated resources */
  66492. dispose(): void;
  66493. }
  66494. }
  66495. declare module BABYLON.GUI {
  66496. /** Class used to render a grid */
  66497. export class DisplayGrid extends Control {
  66498. name?: string | undefined;
  66499. private _cellWidth;
  66500. private _cellHeight;
  66501. private _minorLineTickness;
  66502. private _minorLineColor;
  66503. private _majorLineTickness;
  66504. private _majorLineColor;
  66505. private _majorLineFrequency;
  66506. private _background;
  66507. private _displayMajorLines;
  66508. private _displayMinorLines;
  66509. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66510. displayMinorLines: boolean;
  66511. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66512. displayMajorLines: boolean;
  66513. /** Gets or sets background color (Black by default) */
  66514. background: string;
  66515. /** Gets or sets the width of each cell (20 by default) */
  66516. cellWidth: number;
  66517. /** Gets or sets the height of each cell (20 by default) */
  66518. cellHeight: number;
  66519. /** Gets or sets the tickness of minor lines (1 by default) */
  66520. minorLineTickness: number;
  66521. /** Gets or sets the color of minor lines (DarkGray by default) */
  66522. minorLineColor: string;
  66523. /** Gets or sets the tickness of major lines (2 by default) */
  66524. majorLineTickness: number;
  66525. /** Gets or sets the color of major lines (White by default) */
  66526. majorLineColor: string;
  66527. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66528. majorLineFrequency: number;
  66529. /**
  66530. * Creates a new GridDisplayRectangle
  66531. * @param name defines the control name
  66532. */
  66533. constructor(name?: string | undefined);
  66534. _draw(context: CanvasRenderingContext2D): void;
  66535. protected _getTypeName(): string;
  66536. }
  66537. }
  66538. declare module BABYLON.GUI {
  66539. /**
  66540. * Class used to create slider controls based on images
  66541. */
  66542. export class ImageBasedSlider extends BaseSlider {
  66543. name?: string | undefined;
  66544. private _backgroundImage;
  66545. private _thumbImage;
  66546. private _valueBarImage;
  66547. private _tempMeasure;
  66548. displayThumb: boolean;
  66549. /**
  66550. * Gets or sets the image used to render the background
  66551. */
  66552. backgroundImage: Image;
  66553. /**
  66554. * Gets or sets the image used to render the value bar
  66555. */
  66556. valueBarImage: Image;
  66557. /**
  66558. * Gets or sets the image used to render the thumb
  66559. */
  66560. thumbImage: Image;
  66561. /**
  66562. * Creates a new ImageBasedSlider
  66563. * @param name defines the control name
  66564. */
  66565. constructor(name?: string | undefined);
  66566. protected _getTypeName(): string;
  66567. _draw(context: CanvasRenderingContext2D): void;
  66568. }
  66569. }
  66570. declare module BABYLON.GUI {
  66571. /**
  66572. * Forcing an export so that this code will execute
  66573. * @hidden
  66574. */
  66575. const name = "Statics";
  66576. }
  66577. declare module BABYLON.GUI {
  66578. /**
  66579. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66580. */
  66581. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66582. /**
  66583. * Define the instrumented AdvancedDynamicTexture.
  66584. */
  66585. texture: AdvancedDynamicTexture;
  66586. private _captureRenderTime;
  66587. private _renderTime;
  66588. private _captureLayoutTime;
  66589. private _layoutTime;
  66590. private _onBeginRenderObserver;
  66591. private _onEndRenderObserver;
  66592. private _onBeginLayoutObserver;
  66593. private _onEndLayoutObserver;
  66594. /**
  66595. * Gets the perf counter used to capture render time
  66596. */
  66597. readonly renderTimeCounter: BABYLON.PerfCounter;
  66598. /**
  66599. * Gets the perf counter used to capture layout time
  66600. */
  66601. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66602. /**
  66603. * Enable or disable the render time capture
  66604. */
  66605. captureRenderTime: boolean;
  66606. /**
  66607. * Enable or disable the layout time capture
  66608. */
  66609. captureLayoutTime: boolean;
  66610. /**
  66611. * Instantiates a new advanced dynamic texture instrumentation.
  66612. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66613. * @param texture Defines the AdvancedDynamicTexture to instrument
  66614. */
  66615. constructor(
  66616. /**
  66617. * Define the instrumented AdvancedDynamicTexture.
  66618. */
  66619. texture: AdvancedDynamicTexture);
  66620. /**
  66621. * Dispose and release associated resources.
  66622. */
  66623. dispose(): void;
  66624. }
  66625. }
  66626. declare module BABYLON.GUI {
  66627. /**
  66628. * Class used to load GUI via XML.
  66629. */
  66630. export class XmlLoader {
  66631. private _nodes;
  66632. private _nodeTypes;
  66633. private _isLoaded;
  66634. private _objectAttributes;
  66635. private _parentClass;
  66636. /**
  66637. * Create a new xml loader
  66638. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66639. */
  66640. constructor(parentClass?: null);
  66641. private _getChainElement;
  66642. private _getClassAttribute;
  66643. private _createGuiElement;
  66644. private _parseGrid;
  66645. private _parseElement;
  66646. private _prepareSourceElement;
  66647. private _parseElementsFromSource;
  66648. private _parseXml;
  66649. /**
  66650. * Gets if the loading has finished.
  66651. * @returns whether the loading has finished or not
  66652. */
  66653. isLoaded(): boolean;
  66654. /**
  66655. * Gets a loaded node / control by id.
  66656. * @param id the Controls id set in the xml
  66657. * @returns element of type Control
  66658. */
  66659. getNodeById(id: string): any;
  66660. /**
  66661. * Gets all loaded nodes / controls
  66662. * @returns Array of controls
  66663. */
  66664. getNodes(): any;
  66665. /**
  66666. * Initiates the xml layout loading
  66667. * @param xmlFile defines the xml layout to load
  66668. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66669. * @param callback defines the callback called on layout load.
  66670. */
  66671. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66672. }
  66673. }
  66674. declare module BABYLON.GUI {
  66675. /**
  66676. * Class used to create containers for controls
  66677. */
  66678. export class Container3D extends Control3D {
  66679. private _blockLayout;
  66680. /**
  66681. * Gets the list of child controls
  66682. */
  66683. protected _children: Control3D[];
  66684. /**
  66685. * Gets the list of child controls
  66686. */
  66687. readonly children: Array<Control3D>;
  66688. /**
  66689. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66690. * This is helpful to optimize layout operation when adding multiple children in a row
  66691. */
  66692. blockLayout: boolean;
  66693. /**
  66694. * Creates a new container
  66695. * @param name defines the container name
  66696. */
  66697. constructor(name?: string);
  66698. /**
  66699. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66700. * @returns the current container
  66701. */
  66702. updateLayout(): Container3D;
  66703. /**
  66704. * Gets a boolean indicating if the given control is in the children of this control
  66705. * @param control defines the control to check
  66706. * @returns true if the control is in the child list
  66707. */
  66708. containsControl(control: Control3D): boolean;
  66709. /**
  66710. * Adds a control to the children of this control
  66711. * @param control defines the control to add
  66712. * @returns the current container
  66713. */
  66714. addControl(control: Control3D): Container3D;
  66715. /**
  66716. * This function will be called everytime a new control is added
  66717. */
  66718. protected _arrangeChildren(): void;
  66719. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66720. /**
  66721. * Removes a control from the children of this control
  66722. * @param control defines the control to remove
  66723. * @returns the current container
  66724. */
  66725. removeControl(control: Control3D): Container3D;
  66726. protected _getTypeName(): string;
  66727. /**
  66728. * Releases all associated resources
  66729. */
  66730. dispose(): void;
  66731. /** Control rotation will remain unchanged */
  66732. static readonly UNSET_ORIENTATION: number;
  66733. /** Control will rotate to make it look at sphere central axis */
  66734. static readonly FACEORIGIN_ORIENTATION: number;
  66735. /** Control will rotate to make it look back at sphere central axis */
  66736. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66737. /** Control will rotate to look at z axis (0, 0, 1) */
  66738. static readonly FACEFORWARD_ORIENTATION: number;
  66739. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66740. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66741. }
  66742. }
  66743. declare module BABYLON.GUI {
  66744. /**
  66745. * Class used to manage 3D user interface
  66746. * @see http://doc.babylonjs.com/how_to/gui3d
  66747. */
  66748. export class GUI3DManager implements BABYLON.IDisposable {
  66749. private _scene;
  66750. private _sceneDisposeObserver;
  66751. private _utilityLayer;
  66752. private _rootContainer;
  66753. private _pointerObserver;
  66754. private _pointerOutObserver;
  66755. /** @hidden */
  66756. _lastPickedControl: Control3D;
  66757. /** @hidden */
  66758. _lastControlOver: {
  66759. [pointerId: number]: Control3D;
  66760. };
  66761. /** @hidden */
  66762. _lastControlDown: {
  66763. [pointerId: number]: Control3D;
  66764. };
  66765. /**
  66766. * BABYLON.Observable raised when the point picked by the pointer events changed
  66767. */
  66768. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66769. /** @hidden */
  66770. _sharedMaterials: {
  66771. [key: string]: BABYLON.Material;
  66772. };
  66773. /** Gets the hosting scene */
  66774. readonly scene: BABYLON.Scene;
  66775. /** Gets associated utility layer */
  66776. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66777. /**
  66778. * Creates a new GUI3DManager
  66779. * @param scene
  66780. */
  66781. constructor(scene?: BABYLON.Scene);
  66782. private _handlePointerOut;
  66783. private _doPicking;
  66784. /**
  66785. * Gets the root container
  66786. */
  66787. readonly rootContainer: Container3D;
  66788. /**
  66789. * Gets a boolean indicating if the given control is in the root child list
  66790. * @param control defines the control to check
  66791. * @returns true if the control is in the root child list
  66792. */
  66793. containsControl(control: Control3D): boolean;
  66794. /**
  66795. * Adds a control to the root child list
  66796. * @param control defines the control to add
  66797. * @returns the current manager
  66798. */
  66799. addControl(control: Control3D): GUI3DManager;
  66800. /**
  66801. * Removes a control from the root child list
  66802. * @param control defines the control to remove
  66803. * @returns the current container
  66804. */
  66805. removeControl(control: Control3D): GUI3DManager;
  66806. /**
  66807. * Releases all associated resources
  66808. */
  66809. dispose(): void;
  66810. }
  66811. }
  66812. declare module BABYLON.GUI {
  66813. /**
  66814. * Class used to transport BABYLON.Vector3 information for pointer events
  66815. */
  66816. export class Vector3WithInfo extends BABYLON.Vector3 {
  66817. /** defines the current mouse button index */
  66818. buttonIndex: number;
  66819. /**
  66820. * Creates a new Vector3WithInfo
  66821. * @param source defines the vector3 data to transport
  66822. * @param buttonIndex defines the current mouse button index
  66823. */
  66824. constructor(source: BABYLON.Vector3,
  66825. /** defines the current mouse button index */
  66826. buttonIndex?: number);
  66827. }
  66828. }
  66829. declare module BABYLON.GUI {
  66830. /**
  66831. * Class used as base class for controls
  66832. */
  66833. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66834. /** Defines the control name */
  66835. name?: string | undefined;
  66836. /** @hidden */
  66837. _host: GUI3DManager;
  66838. private _node;
  66839. private _downCount;
  66840. private _enterCount;
  66841. private _downPointerIds;
  66842. private _isVisible;
  66843. /** Gets or sets the control position in world space */
  66844. position: BABYLON.Vector3;
  66845. /** Gets or sets the control scaling in world space */
  66846. scaling: BABYLON.Vector3;
  66847. /** Callback used to start pointer enter animation */
  66848. pointerEnterAnimation: () => void;
  66849. /** Callback used to start pointer out animation */
  66850. pointerOutAnimation: () => void;
  66851. /** Callback used to start pointer down animation */
  66852. pointerDownAnimation: () => void;
  66853. /** Callback used to start pointer up animation */
  66854. pointerUpAnimation: () => void;
  66855. /**
  66856. * An event triggered when the pointer move over the control
  66857. */
  66858. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66859. /**
  66860. * An event triggered when the pointer move out of the control
  66861. */
  66862. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66863. /**
  66864. * An event triggered when the pointer taps the control
  66865. */
  66866. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66867. /**
  66868. * An event triggered when pointer is up
  66869. */
  66870. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66871. /**
  66872. * An event triggered when a control is clicked on (with a mouse)
  66873. */
  66874. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66875. /**
  66876. * An event triggered when pointer enters the control
  66877. */
  66878. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66879. /**
  66880. * Gets or sets the parent container
  66881. */
  66882. parent: BABYLON.Nullable<Container3D>;
  66883. private _behaviors;
  66884. /**
  66885. * Gets the list of attached behaviors
  66886. * @see http://doc.babylonjs.com/features/behaviour
  66887. */
  66888. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66889. /**
  66890. * Attach a behavior to the control
  66891. * @see http://doc.babylonjs.com/features/behaviour
  66892. * @param behavior defines the behavior to attach
  66893. * @returns the current control
  66894. */
  66895. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66896. /**
  66897. * Remove an attached behavior
  66898. * @see http://doc.babylonjs.com/features/behaviour
  66899. * @param behavior defines the behavior to attach
  66900. * @returns the current control
  66901. */
  66902. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66903. /**
  66904. * Gets an attached behavior by name
  66905. * @param name defines the name of the behavior to look for
  66906. * @see http://doc.babylonjs.com/features/behaviour
  66907. * @returns null if behavior was not found else the requested behavior
  66908. */
  66909. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66910. /** Gets or sets a boolean indicating if the control is visible */
  66911. isVisible: boolean;
  66912. /**
  66913. * Creates a new control
  66914. * @param name defines the control name
  66915. */
  66916. constructor(
  66917. /** Defines the control name */
  66918. name?: string | undefined);
  66919. /**
  66920. * Gets a string representing the class name
  66921. */
  66922. readonly typeName: string;
  66923. /**
  66924. * Get the current class name of the control.
  66925. * @returns current class name
  66926. */
  66927. getClassName(): string;
  66928. protected _getTypeName(): string;
  66929. /**
  66930. * Gets the transform node used by this control
  66931. */
  66932. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66933. /**
  66934. * Gets the mesh used to render this control
  66935. */
  66936. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66937. /**
  66938. * Link the control as child of the given node
  66939. * @param node defines the node to link to. Use null to unlink the control
  66940. * @returns the current control
  66941. */
  66942. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66943. /** @hidden **/
  66944. _prepareNode(scene: BABYLON.Scene): void;
  66945. /**
  66946. * Node creation.
  66947. * Can be overriden by children
  66948. * @param scene defines the scene where the node must be attached
  66949. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66950. */
  66951. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66952. /**
  66953. * Affect a material to the given mesh
  66954. * @param mesh defines the mesh which will represent the control
  66955. */
  66956. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66957. /** @hidden */
  66958. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66959. /** @hidden */
  66960. _onPointerEnter(target: Control3D): boolean;
  66961. /** @hidden */
  66962. _onPointerOut(target: Control3D): void;
  66963. /** @hidden */
  66964. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66965. /** @hidden */
  66966. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66967. /** @hidden */
  66968. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66969. /** @hidden */
  66970. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66971. /** @hidden */
  66972. _disposeNode(): void;
  66973. /**
  66974. * Releases all associated resources
  66975. */
  66976. dispose(): void;
  66977. }
  66978. }
  66979. declare module BABYLON.GUI {
  66980. /**
  66981. * Class used as a root to all buttons
  66982. */
  66983. export class AbstractButton3D extends Control3D {
  66984. /**
  66985. * Creates a new button
  66986. * @param name defines the control name
  66987. */
  66988. constructor(name?: string);
  66989. protected _getTypeName(): string;
  66990. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66991. }
  66992. }
  66993. declare module BABYLON.GUI {
  66994. /**
  66995. * Class used to create a button in 3D
  66996. */
  66997. export class Button3D extends AbstractButton3D {
  66998. /** @hidden */
  66999. protected _currentMaterial: BABYLON.Material;
  67000. private _facadeTexture;
  67001. private _content;
  67002. private _contentResolution;
  67003. private _contentScaleRatio;
  67004. /**
  67005. * Gets or sets the texture resolution used to render content (512 by default)
  67006. */
  67007. contentResolution: BABYLON.int;
  67008. /**
  67009. * Gets or sets the texture scale ratio used to render content (2 by default)
  67010. */
  67011. contentScaleRatio: number;
  67012. protected _disposeFacadeTexture(): void;
  67013. protected _resetContent(): void;
  67014. /**
  67015. * Creates a new button
  67016. * @param name defines the control name
  67017. */
  67018. constructor(name?: string);
  67019. /**
  67020. * Gets or sets the GUI 2D content used to display the button's facade
  67021. */
  67022. content: Control;
  67023. /**
  67024. * Apply the facade texture (created from the content property).
  67025. * This function can be overloaded by child classes
  67026. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67027. */
  67028. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67029. protected _getTypeName(): string;
  67030. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67031. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67032. /**
  67033. * Releases all associated resources
  67034. */
  67035. dispose(): void;
  67036. }
  67037. }
  67038. declare module BABYLON.GUI {
  67039. /**
  67040. * Abstract class used to create a container panel deployed on the surface of a volume
  67041. */
  67042. export abstract class VolumeBasedPanel extends Container3D {
  67043. private _columns;
  67044. private _rows;
  67045. private _rowThenColum;
  67046. private _orientation;
  67047. protected _cellWidth: number;
  67048. protected _cellHeight: number;
  67049. /**
  67050. * Gets or sets the distance between elements
  67051. */
  67052. margin: number;
  67053. /**
  67054. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67055. * | Value | Type | Description |
  67056. * | ----- | ----------------------------------- | ----------- |
  67057. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67058. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67059. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67060. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67061. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67062. */
  67063. orientation: number;
  67064. /**
  67065. * Gets or sets the number of columns requested (10 by default).
  67066. * The panel will automatically compute the number of rows based on number of child controls.
  67067. */
  67068. columns: BABYLON.int;
  67069. /**
  67070. * Gets or sets a the number of rows requested.
  67071. * The panel will automatically compute the number of columns based on number of child controls.
  67072. */
  67073. rows: BABYLON.int;
  67074. /**
  67075. * Creates new VolumeBasedPanel
  67076. */
  67077. constructor();
  67078. protected _arrangeChildren(): void;
  67079. /** Child classes must implement this function to provide correct control positioning */
  67080. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67081. /** Child classes can implement this function to provide additional processing */
  67082. protected _finalProcessing(): void;
  67083. }
  67084. }
  67085. declare module BABYLON.GUI {
  67086. /**
  67087. * Class used to create a container panel deployed on the surface of a cylinder
  67088. */
  67089. export class CylinderPanel extends VolumeBasedPanel {
  67090. private _radius;
  67091. /**
  67092. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67093. */
  67094. radius: BABYLON.float;
  67095. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67096. private _cylindricalMapping;
  67097. }
  67098. }
  67099. declare module BABYLON.GUI {
  67100. /** @hidden */
  67101. export var fluentVertexShader: {
  67102. name: string;
  67103. shader: string;
  67104. };
  67105. }
  67106. declare module BABYLON.GUI {
  67107. /** @hidden */
  67108. export var fluentPixelShader: {
  67109. name: string;
  67110. shader: string;
  67111. };
  67112. }
  67113. declare module BABYLON.GUI {
  67114. /** @hidden */
  67115. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67116. INNERGLOW: boolean;
  67117. BORDER: boolean;
  67118. HOVERLIGHT: boolean;
  67119. TEXTURE: boolean;
  67120. constructor();
  67121. }
  67122. /**
  67123. * Class used to render controls with fluent desgin
  67124. */
  67125. export class FluentMaterial extends BABYLON.PushMaterial {
  67126. /**
  67127. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67128. */
  67129. innerGlowColorIntensity: number;
  67130. /**
  67131. * Gets or sets the inner glow color (white by default)
  67132. */
  67133. innerGlowColor: BABYLON.Color3;
  67134. /**
  67135. * Gets or sets alpha value (default is 1.0)
  67136. */
  67137. alpha: number;
  67138. /**
  67139. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67140. */
  67141. albedoColor: BABYLON.Color3;
  67142. /**
  67143. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67144. */
  67145. renderBorders: boolean;
  67146. /**
  67147. * Gets or sets border width (default is 0.5)
  67148. */
  67149. borderWidth: number;
  67150. /**
  67151. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67152. */
  67153. edgeSmoothingValue: number;
  67154. /**
  67155. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67156. */
  67157. borderMinValue: number;
  67158. /**
  67159. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67160. */
  67161. renderHoverLight: boolean;
  67162. /**
  67163. * Gets or sets the radius used to render the hover light (default is 1.0)
  67164. */
  67165. hoverRadius: number;
  67166. /**
  67167. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67168. */
  67169. hoverColor: BABYLON.Color4;
  67170. /**
  67171. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67172. */
  67173. hoverPosition: BABYLON.Vector3;
  67174. private _albedoTexture;
  67175. /** Gets or sets the texture to use for albedo color */
  67176. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67177. /**
  67178. * Creates a new Fluent material
  67179. * @param name defines the name of the material
  67180. * @param scene defines the hosting scene
  67181. */
  67182. constructor(name: string, scene: BABYLON.Scene);
  67183. needAlphaBlending(): boolean;
  67184. needAlphaTesting(): boolean;
  67185. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67186. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67187. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67188. getActiveTextures(): BABYLON.BaseTexture[];
  67189. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67190. dispose(forceDisposeEffect?: boolean): void;
  67191. clone(name: string): FluentMaterial;
  67192. serialize(): any;
  67193. getClassName(): string;
  67194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67195. }
  67196. }
  67197. declare module BABYLON.GUI {
  67198. /**
  67199. * Class used to create a holographic button in 3D
  67200. */
  67201. export class HolographicButton extends Button3D {
  67202. private _backPlate;
  67203. private _textPlate;
  67204. private _frontPlate;
  67205. private _text;
  67206. private _imageUrl;
  67207. private _shareMaterials;
  67208. private _frontMaterial;
  67209. private _backMaterial;
  67210. private _plateMaterial;
  67211. private _pickedPointObserver;
  67212. private _tooltipFade;
  67213. private _tooltipTextBlock;
  67214. private _tooltipTexture;
  67215. private _tooltipMesh;
  67216. private _tooltipHoverObserver;
  67217. private _tooltipOutObserver;
  67218. private _disposeTooltip;
  67219. /**
  67220. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67221. */
  67222. tooltipText: BABYLON.Nullable<string>;
  67223. /**
  67224. * Gets or sets text for the button
  67225. */
  67226. text: string;
  67227. /**
  67228. * Gets or sets the image url for the button
  67229. */
  67230. imageUrl: string;
  67231. /**
  67232. * Gets the back material used by this button
  67233. */
  67234. readonly backMaterial: FluentMaterial;
  67235. /**
  67236. * Gets the front material used by this button
  67237. */
  67238. readonly frontMaterial: FluentMaterial;
  67239. /**
  67240. * Gets the plate material used by this button
  67241. */
  67242. readonly plateMaterial: BABYLON.StandardMaterial;
  67243. /**
  67244. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67245. */
  67246. readonly shareMaterials: boolean;
  67247. /**
  67248. * Creates a new button
  67249. * @param name defines the control name
  67250. */
  67251. constructor(name?: string, shareMaterials?: boolean);
  67252. protected _getTypeName(): string;
  67253. private _rebuildContent;
  67254. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67255. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67256. private _createBackMaterial;
  67257. private _createFrontMaterial;
  67258. private _createPlateMaterial;
  67259. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67260. /**
  67261. * Releases all associated resources
  67262. */
  67263. dispose(): void;
  67264. }
  67265. }
  67266. declare module BABYLON.GUI {
  67267. /**
  67268. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67269. */
  67270. export class MeshButton3D extends Button3D {
  67271. /** @hidden */
  67272. protected _currentMesh: BABYLON.Mesh;
  67273. /**
  67274. * Creates a new 3D button based on a mesh
  67275. * @param mesh mesh to become a 3D button
  67276. * @param name defines the control name
  67277. */
  67278. constructor(mesh: BABYLON.Mesh, name?: string);
  67279. protected _getTypeName(): string;
  67280. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67281. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67282. }
  67283. }
  67284. declare module BABYLON.GUI {
  67285. /**
  67286. * Class used to create a container panel deployed on the surface of a plane
  67287. */
  67288. export class PlanePanel extends VolumeBasedPanel {
  67289. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67290. }
  67291. }
  67292. declare module BABYLON.GUI {
  67293. /**
  67294. * Class used to create a container panel where items get randomized planar mapping
  67295. */
  67296. export class ScatterPanel extends VolumeBasedPanel {
  67297. private _iteration;
  67298. /**
  67299. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67300. */
  67301. iteration: BABYLON.float;
  67302. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67303. private _scatterMapping;
  67304. protected _finalProcessing(): void;
  67305. }
  67306. }
  67307. declare module BABYLON.GUI {
  67308. /**
  67309. * Class used to create a container panel deployed on the surface of a sphere
  67310. */
  67311. export class SpherePanel extends VolumeBasedPanel {
  67312. private _radius;
  67313. /**
  67314. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67315. */
  67316. radius: BABYLON.float;
  67317. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67318. private _sphericalMapping;
  67319. }
  67320. }
  67321. declare module BABYLON.GUI {
  67322. /**
  67323. * Class used to create a stack panel in 3D on XY plane
  67324. */
  67325. export class StackPanel3D extends Container3D {
  67326. private _isVertical;
  67327. /**
  67328. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67329. */
  67330. isVertical: boolean;
  67331. /**
  67332. * Gets or sets the distance between elements
  67333. */
  67334. margin: number;
  67335. /**
  67336. * Creates new StackPanel
  67337. * @param isVertical
  67338. */
  67339. constructor(isVertical?: boolean);
  67340. protected _arrangeChildren(): void;
  67341. }
  67342. }
  67343. declare module BABYLON {
  67344. /**
  67345. * Mode that determines the coordinate system to use.
  67346. */
  67347. export enum GLTFLoaderCoordinateSystemMode {
  67348. /**
  67349. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67350. */
  67351. AUTO = 0,
  67352. /**
  67353. * Sets the useRightHandedSystem flag on the scene.
  67354. */
  67355. FORCE_RIGHT_HANDED = 1
  67356. }
  67357. /**
  67358. * Mode that determines what animations will start.
  67359. */
  67360. export enum GLTFLoaderAnimationStartMode {
  67361. /**
  67362. * No animation will start.
  67363. */
  67364. NONE = 0,
  67365. /**
  67366. * The first animation will start.
  67367. */
  67368. FIRST = 1,
  67369. /**
  67370. * All animations will start.
  67371. */
  67372. ALL = 2
  67373. }
  67374. /**
  67375. * Interface that contains the data for the glTF asset.
  67376. */
  67377. export interface IGLTFLoaderData {
  67378. /**
  67379. * Object that represents the glTF JSON.
  67380. */
  67381. json: Object;
  67382. /**
  67383. * The BIN chunk of a binary glTF.
  67384. */
  67385. bin: Nullable<ArrayBufferView>;
  67386. }
  67387. /**
  67388. * Interface for extending the loader.
  67389. */
  67390. export interface IGLTFLoaderExtension {
  67391. /**
  67392. * The name of this extension.
  67393. */
  67394. readonly name: string;
  67395. /**
  67396. * Defines whether this extension is enabled.
  67397. */
  67398. enabled: boolean;
  67399. }
  67400. /**
  67401. * Loader state.
  67402. */
  67403. export enum GLTFLoaderState {
  67404. /**
  67405. * The asset is loading.
  67406. */
  67407. LOADING = 0,
  67408. /**
  67409. * The asset is ready for rendering.
  67410. */
  67411. READY = 1,
  67412. /**
  67413. * The asset is completely loaded.
  67414. */
  67415. COMPLETE = 2
  67416. }
  67417. /** @hidden */
  67418. export interface IGLTFLoader extends IDisposable {
  67419. readonly state: Nullable<GLTFLoaderState>;
  67420. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67421. meshes: AbstractMesh[];
  67422. particleSystems: IParticleSystem[];
  67423. skeletons: Skeleton[];
  67424. animationGroups: AnimationGroup[];
  67425. }>;
  67426. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67427. }
  67428. /**
  67429. * File loader for loading glTF files into a scene.
  67430. */
  67431. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67432. /** @hidden */
  67433. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67434. /** @hidden */
  67435. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67436. /**
  67437. * Raised when the asset has been parsed
  67438. */
  67439. onParsedObservable: Observable<IGLTFLoaderData>;
  67440. private _onParsedObserver;
  67441. /**
  67442. * Raised when the asset has been parsed
  67443. */
  67444. onParsed: (loaderData: IGLTFLoaderData) => void;
  67445. /**
  67446. * 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.
  67447. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67448. * Defaults to true.
  67449. * @hidden
  67450. */
  67451. static IncrementalLoading: boolean;
  67452. /**
  67453. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67454. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67455. * @hidden
  67456. */
  67457. static HomogeneousCoordinates: boolean;
  67458. /**
  67459. * The coordinate system mode. Defaults to AUTO.
  67460. */
  67461. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67462. /**
  67463. * The animation start mode. Defaults to FIRST.
  67464. */
  67465. animationStartMode: GLTFLoaderAnimationStartMode;
  67466. /**
  67467. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67468. */
  67469. compileMaterials: boolean;
  67470. /**
  67471. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67472. */
  67473. useClipPlane: boolean;
  67474. /**
  67475. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67476. */
  67477. compileShadowGenerators: boolean;
  67478. /**
  67479. * Defines if the Alpha blended materials are only applied as coverage.
  67480. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67481. * If true, no extra effects are applied to transparent pixels.
  67482. */
  67483. transparencyAsCoverage: boolean;
  67484. /**
  67485. * Function called before loading a url referenced by the asset.
  67486. */
  67487. preprocessUrlAsync: (url: string) => Promise<string>;
  67488. /**
  67489. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67490. */
  67491. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67492. private _onMeshLoadedObserver;
  67493. /**
  67494. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67495. */
  67496. onMeshLoaded: (mesh: AbstractMesh) => void;
  67497. /**
  67498. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67499. */
  67500. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67501. private _onTextureLoadedObserver;
  67502. /**
  67503. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67504. */
  67505. onTextureLoaded: (texture: BaseTexture) => void;
  67506. /**
  67507. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67508. */
  67509. readonly onMaterialLoadedObservable: Observable<Material>;
  67510. private _onMaterialLoadedObserver;
  67511. /**
  67512. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67513. */
  67514. onMaterialLoaded: (material: Material) => void;
  67515. /**
  67516. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67517. */
  67518. readonly onCameraLoadedObservable: Observable<Camera>;
  67519. private _onCameraLoadedObserver;
  67520. /**
  67521. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67522. */
  67523. onCameraLoaded: (camera: Camera) => void;
  67524. /**
  67525. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67526. * For assets with LODs, raised when all of the LODs are complete.
  67527. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67528. */
  67529. readonly onCompleteObservable: Observable<void>;
  67530. private _onCompleteObserver;
  67531. /**
  67532. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67533. * For assets with LODs, raised when all of the LODs are complete.
  67534. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67535. */
  67536. onComplete: () => void;
  67537. /**
  67538. * Observable raised when an error occurs.
  67539. */
  67540. readonly onErrorObservable: Observable<any>;
  67541. private _onErrorObserver;
  67542. /**
  67543. * Callback raised when an error occurs.
  67544. */
  67545. onError: (reason: any) => void;
  67546. /**
  67547. * Observable raised after the loader is disposed.
  67548. */
  67549. readonly onDisposeObservable: Observable<void>;
  67550. private _onDisposeObserver;
  67551. /**
  67552. * Callback raised after the loader is disposed.
  67553. */
  67554. onDispose: () => void;
  67555. /**
  67556. * Observable raised after a loader extension is created.
  67557. * Set additional options for a loader extension in this event.
  67558. */
  67559. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67560. private _onExtensionLoadedObserver;
  67561. /**
  67562. * Callback raised after a loader extension is created.
  67563. */
  67564. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67565. /**
  67566. * Defines if the loader logging is enabled.
  67567. */
  67568. loggingEnabled: boolean;
  67569. /**
  67570. * Defines if the loader should capture performance counters.
  67571. */
  67572. capturePerformanceCounters: boolean;
  67573. /**
  67574. * Defines if the loader should validate the asset.
  67575. */
  67576. validate: boolean;
  67577. /**
  67578. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67579. */
  67580. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67581. private _onValidatedObserver;
  67582. /**
  67583. * Callback raised after a loader extension is created.
  67584. */
  67585. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67586. private _loader;
  67587. /**
  67588. * Name of the loader ("gltf")
  67589. */
  67590. name: string;
  67591. /**
  67592. * Supported file extensions of the loader (.gltf, .glb)
  67593. */
  67594. extensions: ISceneLoaderPluginExtensions;
  67595. /**
  67596. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67597. */
  67598. dispose(): void;
  67599. /** @hidden */
  67600. _clear(): void;
  67601. /**
  67602. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67603. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67604. * @param scene the scene the meshes should be added to
  67605. * @param data the glTF data to load
  67606. * @param rootUrl root url to load from
  67607. * @param onProgress event that fires when loading progress has occured
  67608. * @param fileName Defines the name of the file to load
  67609. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67610. */
  67611. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67612. meshes: AbstractMesh[];
  67613. particleSystems: IParticleSystem[];
  67614. skeletons: Skeleton[];
  67615. animationGroups: AnimationGroup[];
  67616. }>;
  67617. /**
  67618. * Imports all objects from the loaded glTF data and adds them to the scene
  67619. * @param scene the scene the objects should be added to
  67620. * @param data the glTF data to load
  67621. * @param rootUrl root url to load from
  67622. * @param onProgress event that fires when loading progress has occured
  67623. * @param fileName Defines the name of the file to load
  67624. * @returns a promise which completes when objects have been loaded to the scene
  67625. */
  67626. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67627. /**
  67628. * Load into an asset container.
  67629. * @param scene The scene to load into
  67630. * @param data The data to import
  67631. * @param rootUrl The root url for scene and resources
  67632. * @param onProgress The callback when the load progresses
  67633. * @param fileName Defines the name of the file to load
  67634. * @returns The loaded asset container
  67635. */
  67636. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67637. /**
  67638. * If the data string can be loaded directly.
  67639. * @param data string contianing the file data
  67640. * @returns if the data can be loaded directly
  67641. */
  67642. canDirectLoad(data: string): boolean;
  67643. /**
  67644. * Rewrites a url by combining a root url and response url.
  67645. */
  67646. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67647. /**
  67648. * Instantiates a glTF file loader plugin.
  67649. * @returns the created plugin
  67650. */
  67651. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67652. /**
  67653. * The loader state or null if the loader is not active.
  67654. */
  67655. readonly loaderState: Nullable<GLTFLoaderState>;
  67656. /**
  67657. * Returns a promise that resolves when the asset is completely loaded.
  67658. * @returns a promise that resolves when the asset is completely loaded.
  67659. */
  67660. whenCompleteAsync(): Promise<void>;
  67661. private _parseAsync;
  67662. private _validateAsync;
  67663. private _getLoader;
  67664. private _unpackBinary;
  67665. private _unpackBinaryV1;
  67666. private _unpackBinaryV2;
  67667. private static _parseVersion;
  67668. private static _compareVersion;
  67669. private static _decodeBufferToText;
  67670. private static readonly _logSpaces;
  67671. private _logIndentLevel;
  67672. private _loggingEnabled;
  67673. /** @hidden */
  67674. _log: (message: string) => void;
  67675. /** @hidden */
  67676. _logOpen(message: string): void;
  67677. /** @hidden */
  67678. _logClose(): void;
  67679. private _logEnabled;
  67680. private _logDisabled;
  67681. private _capturePerformanceCounters;
  67682. /** @hidden */
  67683. _startPerformanceCounter: (counterName: string) => void;
  67684. /** @hidden */
  67685. _endPerformanceCounter: (counterName: string) => void;
  67686. private _startPerformanceCounterEnabled;
  67687. private _startPerformanceCounterDisabled;
  67688. private _endPerformanceCounterEnabled;
  67689. private _endPerformanceCounterDisabled;
  67690. }
  67691. }
  67692. declare module BABYLON.GLTF1 {
  67693. /**
  67694. * Enums
  67695. * @hidden
  67696. */
  67697. export enum EComponentType {
  67698. BYTE = 5120,
  67699. UNSIGNED_BYTE = 5121,
  67700. SHORT = 5122,
  67701. UNSIGNED_SHORT = 5123,
  67702. FLOAT = 5126
  67703. }
  67704. /** @hidden */
  67705. export enum EShaderType {
  67706. FRAGMENT = 35632,
  67707. VERTEX = 35633
  67708. }
  67709. /** @hidden */
  67710. export enum EParameterType {
  67711. BYTE = 5120,
  67712. UNSIGNED_BYTE = 5121,
  67713. SHORT = 5122,
  67714. UNSIGNED_SHORT = 5123,
  67715. INT = 5124,
  67716. UNSIGNED_INT = 5125,
  67717. FLOAT = 5126,
  67718. FLOAT_VEC2 = 35664,
  67719. FLOAT_VEC3 = 35665,
  67720. FLOAT_VEC4 = 35666,
  67721. INT_VEC2 = 35667,
  67722. INT_VEC3 = 35668,
  67723. INT_VEC4 = 35669,
  67724. BOOL = 35670,
  67725. BOOL_VEC2 = 35671,
  67726. BOOL_VEC3 = 35672,
  67727. BOOL_VEC4 = 35673,
  67728. FLOAT_MAT2 = 35674,
  67729. FLOAT_MAT3 = 35675,
  67730. FLOAT_MAT4 = 35676,
  67731. SAMPLER_2D = 35678
  67732. }
  67733. /** @hidden */
  67734. export enum ETextureWrapMode {
  67735. CLAMP_TO_EDGE = 33071,
  67736. MIRRORED_REPEAT = 33648,
  67737. REPEAT = 10497
  67738. }
  67739. /** @hidden */
  67740. export enum ETextureFilterType {
  67741. NEAREST = 9728,
  67742. LINEAR = 9728,
  67743. NEAREST_MIPMAP_NEAREST = 9984,
  67744. LINEAR_MIPMAP_NEAREST = 9985,
  67745. NEAREST_MIPMAP_LINEAR = 9986,
  67746. LINEAR_MIPMAP_LINEAR = 9987
  67747. }
  67748. /** @hidden */
  67749. export enum ETextureFormat {
  67750. ALPHA = 6406,
  67751. RGB = 6407,
  67752. RGBA = 6408,
  67753. LUMINANCE = 6409,
  67754. LUMINANCE_ALPHA = 6410
  67755. }
  67756. /** @hidden */
  67757. export enum ECullingType {
  67758. FRONT = 1028,
  67759. BACK = 1029,
  67760. FRONT_AND_BACK = 1032
  67761. }
  67762. /** @hidden */
  67763. export enum EBlendingFunction {
  67764. ZERO = 0,
  67765. ONE = 1,
  67766. SRC_COLOR = 768,
  67767. ONE_MINUS_SRC_COLOR = 769,
  67768. DST_COLOR = 774,
  67769. ONE_MINUS_DST_COLOR = 775,
  67770. SRC_ALPHA = 770,
  67771. ONE_MINUS_SRC_ALPHA = 771,
  67772. DST_ALPHA = 772,
  67773. ONE_MINUS_DST_ALPHA = 773,
  67774. CONSTANT_COLOR = 32769,
  67775. ONE_MINUS_CONSTANT_COLOR = 32770,
  67776. CONSTANT_ALPHA = 32771,
  67777. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67778. SRC_ALPHA_SATURATE = 776
  67779. }
  67780. /** @hidden */
  67781. export interface IGLTFProperty {
  67782. extensions?: {
  67783. [key: string]: any;
  67784. };
  67785. extras?: Object;
  67786. }
  67787. /** @hidden */
  67788. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67789. name?: string;
  67790. }
  67791. /** @hidden */
  67792. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67793. bufferView: string;
  67794. byteOffset: number;
  67795. byteStride: number;
  67796. count: number;
  67797. type: string;
  67798. componentType: EComponentType;
  67799. max?: number[];
  67800. min?: number[];
  67801. name?: string;
  67802. }
  67803. /** @hidden */
  67804. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67805. buffer: string;
  67806. byteOffset: number;
  67807. byteLength: number;
  67808. byteStride: number;
  67809. target?: number;
  67810. }
  67811. /** @hidden */
  67812. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67813. uri: string;
  67814. byteLength?: number;
  67815. type?: string;
  67816. }
  67817. /** @hidden */
  67818. export interface IGLTFShader extends IGLTFChildRootProperty {
  67819. uri: string;
  67820. type: EShaderType;
  67821. }
  67822. /** @hidden */
  67823. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67824. attributes: string[];
  67825. fragmentShader: string;
  67826. vertexShader: string;
  67827. }
  67828. /** @hidden */
  67829. export interface IGLTFTechniqueParameter {
  67830. type: number;
  67831. count?: number;
  67832. semantic?: string;
  67833. node?: string;
  67834. value?: number | boolean | string | Array<any>;
  67835. source?: string;
  67836. babylonValue?: any;
  67837. }
  67838. /** @hidden */
  67839. export interface IGLTFTechniqueCommonProfile {
  67840. lightingModel: string;
  67841. texcoordBindings: Object;
  67842. parameters?: Array<any>;
  67843. }
  67844. /** @hidden */
  67845. export interface IGLTFTechniqueStatesFunctions {
  67846. blendColor?: number[];
  67847. blendEquationSeparate?: number[];
  67848. blendFuncSeparate?: number[];
  67849. colorMask: boolean[];
  67850. cullFace: number[];
  67851. }
  67852. /** @hidden */
  67853. export interface IGLTFTechniqueStates {
  67854. enable: number[];
  67855. functions: IGLTFTechniqueStatesFunctions;
  67856. }
  67857. /** @hidden */
  67858. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67859. parameters: {
  67860. [key: string]: IGLTFTechniqueParameter;
  67861. };
  67862. program: string;
  67863. attributes: {
  67864. [key: string]: string;
  67865. };
  67866. uniforms: {
  67867. [key: string]: string;
  67868. };
  67869. states: IGLTFTechniqueStates;
  67870. }
  67871. /** @hidden */
  67872. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67873. technique?: string;
  67874. values: string[];
  67875. }
  67876. /** @hidden */
  67877. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67878. attributes: {
  67879. [key: string]: string;
  67880. };
  67881. indices: string;
  67882. material: string;
  67883. mode?: number;
  67884. }
  67885. /** @hidden */
  67886. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67887. primitives: IGLTFMeshPrimitive[];
  67888. }
  67889. /** @hidden */
  67890. export interface IGLTFImage extends IGLTFChildRootProperty {
  67891. uri: string;
  67892. }
  67893. /** @hidden */
  67894. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67895. magFilter?: number;
  67896. minFilter?: number;
  67897. wrapS?: number;
  67898. wrapT?: number;
  67899. }
  67900. /** @hidden */
  67901. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67902. sampler: string;
  67903. source: string;
  67904. format?: ETextureFormat;
  67905. internalFormat?: ETextureFormat;
  67906. target?: number;
  67907. type?: number;
  67908. babylonTexture?: Texture;
  67909. }
  67910. /** @hidden */
  67911. export interface IGLTFAmbienLight {
  67912. color?: number[];
  67913. }
  67914. /** @hidden */
  67915. export interface IGLTFDirectionalLight {
  67916. color?: number[];
  67917. }
  67918. /** @hidden */
  67919. export interface IGLTFPointLight {
  67920. color?: number[];
  67921. constantAttenuation?: number;
  67922. linearAttenuation?: number;
  67923. quadraticAttenuation?: number;
  67924. }
  67925. /** @hidden */
  67926. export interface IGLTFSpotLight {
  67927. color?: number[];
  67928. constantAttenuation?: number;
  67929. fallOfAngle?: number;
  67930. fallOffExponent?: number;
  67931. linearAttenuation?: number;
  67932. quadraticAttenuation?: number;
  67933. }
  67934. /** @hidden */
  67935. export interface IGLTFLight extends IGLTFChildRootProperty {
  67936. type: string;
  67937. }
  67938. /** @hidden */
  67939. export interface IGLTFCameraOrthographic {
  67940. xmag: number;
  67941. ymag: number;
  67942. zfar: number;
  67943. znear: number;
  67944. }
  67945. /** @hidden */
  67946. export interface IGLTFCameraPerspective {
  67947. aspectRatio: number;
  67948. yfov: number;
  67949. zfar: number;
  67950. znear: number;
  67951. }
  67952. /** @hidden */
  67953. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67954. type: string;
  67955. }
  67956. /** @hidden */
  67957. export interface IGLTFAnimationChannelTarget {
  67958. id: string;
  67959. path: string;
  67960. }
  67961. /** @hidden */
  67962. export interface IGLTFAnimationChannel {
  67963. sampler: string;
  67964. target: IGLTFAnimationChannelTarget;
  67965. }
  67966. /** @hidden */
  67967. export interface IGLTFAnimationSampler {
  67968. input: string;
  67969. output: string;
  67970. interpolation?: string;
  67971. }
  67972. /** @hidden */
  67973. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67974. channels?: IGLTFAnimationChannel[];
  67975. parameters?: {
  67976. [key: string]: string;
  67977. };
  67978. samplers?: {
  67979. [key: string]: IGLTFAnimationSampler;
  67980. };
  67981. }
  67982. /** @hidden */
  67983. export interface IGLTFNodeInstanceSkin {
  67984. skeletons: string[];
  67985. skin: string;
  67986. meshes: string[];
  67987. }
  67988. /** @hidden */
  67989. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67990. bindShapeMatrix: number[];
  67991. inverseBindMatrices: string;
  67992. jointNames: string[];
  67993. babylonSkeleton?: Skeleton;
  67994. }
  67995. /** @hidden */
  67996. export interface IGLTFNode extends IGLTFChildRootProperty {
  67997. camera?: string;
  67998. children: string[];
  67999. skin?: string;
  68000. jointName?: string;
  68001. light?: string;
  68002. matrix: number[];
  68003. mesh?: string;
  68004. meshes?: string[];
  68005. rotation?: number[];
  68006. scale?: number[];
  68007. translation?: number[];
  68008. babylonNode?: Node;
  68009. }
  68010. /** @hidden */
  68011. export interface IGLTFScene extends IGLTFChildRootProperty {
  68012. nodes: string[];
  68013. }
  68014. /** @hidden */
  68015. export interface IGLTFRuntime {
  68016. extensions: {
  68017. [key: string]: any;
  68018. };
  68019. accessors: {
  68020. [key: string]: IGLTFAccessor;
  68021. };
  68022. buffers: {
  68023. [key: string]: IGLTFBuffer;
  68024. };
  68025. bufferViews: {
  68026. [key: string]: IGLTFBufferView;
  68027. };
  68028. meshes: {
  68029. [key: string]: IGLTFMesh;
  68030. };
  68031. lights: {
  68032. [key: string]: IGLTFLight;
  68033. };
  68034. cameras: {
  68035. [key: string]: IGLTFCamera;
  68036. };
  68037. nodes: {
  68038. [key: string]: IGLTFNode;
  68039. };
  68040. images: {
  68041. [key: string]: IGLTFImage;
  68042. };
  68043. textures: {
  68044. [key: string]: IGLTFTexture;
  68045. };
  68046. shaders: {
  68047. [key: string]: IGLTFShader;
  68048. };
  68049. programs: {
  68050. [key: string]: IGLTFProgram;
  68051. };
  68052. samplers: {
  68053. [key: string]: IGLTFSampler;
  68054. };
  68055. techniques: {
  68056. [key: string]: IGLTFTechnique;
  68057. };
  68058. materials: {
  68059. [key: string]: IGLTFMaterial;
  68060. };
  68061. animations: {
  68062. [key: string]: IGLTFAnimation;
  68063. };
  68064. skins: {
  68065. [key: string]: IGLTFSkins;
  68066. };
  68067. currentScene?: Object;
  68068. scenes: {
  68069. [key: string]: IGLTFScene;
  68070. };
  68071. extensionsUsed: string[];
  68072. extensionsRequired?: string[];
  68073. buffersCount: number;
  68074. shaderscount: number;
  68075. scene: Scene;
  68076. rootUrl: string;
  68077. loadedBufferCount: number;
  68078. loadedBufferViews: {
  68079. [name: string]: ArrayBufferView;
  68080. };
  68081. loadedShaderCount: number;
  68082. importOnlyMeshes: boolean;
  68083. importMeshesNames?: string[];
  68084. dummyNodes: Node[];
  68085. }
  68086. /** @hidden */
  68087. export interface INodeToRoot {
  68088. bone: Bone;
  68089. node: IGLTFNode;
  68090. id: string;
  68091. }
  68092. /** @hidden */
  68093. export interface IJointNode {
  68094. node: IGLTFNode;
  68095. id: string;
  68096. }
  68097. }
  68098. declare module BABYLON.GLTF1 {
  68099. /**
  68100. * Utils functions for GLTF
  68101. * @hidden
  68102. */
  68103. export class GLTFUtils {
  68104. /**
  68105. * Sets the given "parameter" matrix
  68106. * @param scene: the Scene object
  68107. * @param source: the source node where to pick the matrix
  68108. * @param parameter: the GLTF technique parameter
  68109. * @param uniformName: the name of the shader's uniform
  68110. * @param shaderMaterial: the shader material
  68111. */
  68112. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68113. /**
  68114. * Sets the given "parameter" matrix
  68115. * @param shaderMaterial: the shader material
  68116. * @param uniform: the name of the shader's uniform
  68117. * @param value: the value of the uniform
  68118. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68119. */
  68120. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68121. /**
  68122. * Returns the wrap mode of the texture
  68123. * @param mode: the mode value
  68124. */
  68125. static GetWrapMode(mode: number): number;
  68126. /**
  68127. * Returns the byte stride giving an accessor
  68128. * @param accessor: the GLTF accessor objet
  68129. */
  68130. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68131. /**
  68132. * Returns the texture filter mode giving a mode value
  68133. * @param mode: the filter mode value
  68134. */
  68135. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68136. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68137. /**
  68138. * Returns a buffer from its accessor
  68139. * @param gltfRuntime: the GLTF runtime
  68140. * @param accessor: the GLTF accessor
  68141. */
  68142. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68143. /**
  68144. * Decodes a buffer view into a string
  68145. * @param view: the buffer view
  68146. */
  68147. static DecodeBufferToText(view: ArrayBufferView): string;
  68148. /**
  68149. * Returns the default material of gltf. Related to
  68150. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68151. * @param scene: the Babylon.js scene
  68152. */
  68153. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68154. private static _DefaultMaterial;
  68155. }
  68156. }
  68157. declare module BABYLON.GLTF1 {
  68158. /**
  68159. * Implementation of the base glTF spec
  68160. * @hidden
  68161. */
  68162. export class GLTFLoaderBase {
  68163. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68164. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68165. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68166. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68167. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68168. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68169. }
  68170. /**
  68171. * glTF V1 Loader
  68172. * @hidden
  68173. */
  68174. export class GLTFLoader implements IGLTFLoader {
  68175. static Extensions: {
  68176. [name: string]: GLTFLoaderExtension;
  68177. };
  68178. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68179. state: Nullable<GLTFLoaderState>;
  68180. dispose(): void;
  68181. private _importMeshAsync;
  68182. /**
  68183. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68184. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68185. * @param scene the scene the meshes should be added to
  68186. * @param data gltf data containing information of the meshes in a loaded file
  68187. * @param rootUrl root url to load from
  68188. * @param onProgress event that fires when loading progress has occured
  68189. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68190. */
  68191. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68192. meshes: AbstractMesh[];
  68193. particleSystems: IParticleSystem[];
  68194. skeletons: Skeleton[];
  68195. animationGroups: AnimationGroup[];
  68196. }>;
  68197. private _loadAsync;
  68198. /**
  68199. * Imports all objects from a loaded gltf file and adds them to the scene
  68200. * @param scene the scene the objects should be added to
  68201. * @param data gltf data containing information of the meshes in a loaded file
  68202. * @param rootUrl root url to load from
  68203. * @param onProgress event that fires when loading progress has occured
  68204. * @returns a promise which completes when objects have been loaded to the scene
  68205. */
  68206. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68207. private _loadShadersAsync;
  68208. private _loadBuffersAsync;
  68209. private _createNodes;
  68210. }
  68211. /** @hidden */
  68212. export abstract class GLTFLoaderExtension {
  68213. private _name;
  68214. constructor(name: string);
  68215. readonly name: string;
  68216. /**
  68217. * Defines an override for loading the runtime
  68218. * Return true to stop further extensions from loading the runtime
  68219. */
  68220. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68221. /**
  68222. * Defines an onverride for creating gltf runtime
  68223. * Return true to stop further extensions from creating the runtime
  68224. */
  68225. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68226. /**
  68227. * Defines an override for loading buffers
  68228. * Return true to stop further extensions from loading this buffer
  68229. */
  68230. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68231. /**
  68232. * Defines an override for loading texture buffers
  68233. * Return true to stop further extensions from loading this texture data
  68234. */
  68235. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68236. /**
  68237. * Defines an override for creating textures
  68238. * Return true to stop further extensions from loading this texture
  68239. */
  68240. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68241. /**
  68242. * Defines an override for loading shader strings
  68243. * Return true to stop further extensions from loading this shader data
  68244. */
  68245. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68246. /**
  68247. * Defines an override for loading materials
  68248. * Return true to stop further extensions from loading this material
  68249. */
  68250. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68251. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68252. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68253. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68254. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68255. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68256. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68257. private static LoadTextureBufferAsync;
  68258. private static CreateTextureAsync;
  68259. private static ApplyExtensions;
  68260. }
  68261. }
  68262. declare module BABYLON.GLTF1 {
  68263. /** @hidden */
  68264. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68265. private _bin;
  68266. constructor();
  68267. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68268. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68269. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68270. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68271. }
  68272. }
  68273. declare module BABYLON.GLTF1 {
  68274. /** @hidden */
  68275. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68276. constructor();
  68277. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68278. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68279. private _loadTexture;
  68280. }
  68281. }
  68282. declare module BABYLON.GLTF2.Loader {
  68283. /**
  68284. * Loader interface with an index field.
  68285. */
  68286. export interface IArrayItem {
  68287. /**
  68288. * The index of this item in the array.
  68289. */
  68290. index: number;
  68291. }
  68292. /**
  68293. * Loader interface with additional members.
  68294. */
  68295. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68296. /** @hidden */
  68297. _data?: Promise<ArrayBufferView>;
  68298. /** @hidden */
  68299. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68300. }
  68301. /**
  68302. * Loader interface with additional members.
  68303. */
  68304. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68305. }
  68306. /** @hidden */
  68307. export interface _IAnimationSamplerData {
  68308. input: Float32Array;
  68309. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68310. output: Float32Array;
  68311. }
  68312. /**
  68313. * Loader interface with additional members.
  68314. */
  68315. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68316. /** @hidden */
  68317. _data?: Promise<_IAnimationSamplerData>;
  68318. }
  68319. /**
  68320. * Loader interface with additional members.
  68321. */
  68322. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68323. channels: IAnimationChannel[];
  68324. samplers: IAnimationSampler[];
  68325. /** @hidden */
  68326. _babylonAnimationGroup?: AnimationGroup;
  68327. }
  68328. /**
  68329. * Loader interface with additional members.
  68330. */
  68331. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68332. /** @hidden */
  68333. _data?: Promise<ArrayBufferView>;
  68334. }
  68335. /**
  68336. * Loader interface with additional members.
  68337. */
  68338. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68339. /** @hidden */
  68340. _data?: Promise<ArrayBufferView>;
  68341. /** @hidden */
  68342. _babylonBuffer?: Promise<Buffer>;
  68343. }
  68344. /**
  68345. * Loader interface with additional members.
  68346. */
  68347. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68348. }
  68349. /**
  68350. * Loader interface with additional members.
  68351. */
  68352. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68353. /** @hidden */
  68354. _data?: Promise<ArrayBufferView>;
  68355. }
  68356. /**
  68357. * Loader interface with additional members.
  68358. */
  68359. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68360. }
  68361. /**
  68362. * Loader interface with additional members.
  68363. */
  68364. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68365. }
  68366. /**
  68367. * Loader interface with additional members.
  68368. */
  68369. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68370. baseColorTexture?: ITextureInfo;
  68371. metallicRoughnessTexture?: ITextureInfo;
  68372. }
  68373. /**
  68374. * Loader interface with additional members.
  68375. */
  68376. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68377. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68378. normalTexture?: IMaterialNormalTextureInfo;
  68379. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68380. emissiveTexture?: ITextureInfo;
  68381. /** @hidden */
  68382. _data?: {
  68383. [babylonDrawMode: number]: {
  68384. babylonMaterial: Material;
  68385. babylonMeshes: AbstractMesh[];
  68386. promise: Promise<void>;
  68387. };
  68388. };
  68389. }
  68390. /**
  68391. * Loader interface with additional members.
  68392. */
  68393. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68394. primitives: IMeshPrimitive[];
  68395. }
  68396. /**
  68397. * Loader interface with additional members.
  68398. */
  68399. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68400. /** @hidden */
  68401. _instanceData?: {
  68402. babylonSourceMesh: Mesh;
  68403. promise: Promise<any>;
  68404. };
  68405. }
  68406. /**
  68407. * Loader interface with additional members.
  68408. */
  68409. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68410. /**
  68411. * The parent glTF node.
  68412. */
  68413. parent?: INode;
  68414. /** @hidden */
  68415. _babylonTransformNode?: TransformNode;
  68416. /** @hidden */
  68417. _primitiveBabylonMeshes?: AbstractMesh[];
  68418. /** @hidden */
  68419. _babylonBones?: Bone[];
  68420. /** @hidden */
  68421. _numMorphTargets?: number;
  68422. }
  68423. /** @hidden */
  68424. export interface _ISamplerData {
  68425. noMipMaps: boolean;
  68426. samplingMode: number;
  68427. wrapU: number;
  68428. wrapV: number;
  68429. }
  68430. /**
  68431. * Loader interface with additional members.
  68432. */
  68433. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68434. /** @hidden */
  68435. _data?: _ISamplerData;
  68436. }
  68437. /**
  68438. * Loader interface with additional members.
  68439. */
  68440. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68441. }
  68442. /**
  68443. * Loader interface with additional members.
  68444. */
  68445. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68446. /** @hidden */
  68447. _data?: {
  68448. babylonSkeleton: Skeleton;
  68449. promise: Promise<void>;
  68450. };
  68451. }
  68452. /**
  68453. * Loader interface with additional members.
  68454. */
  68455. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68456. }
  68457. /**
  68458. * Loader interface with additional members.
  68459. */
  68460. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68461. }
  68462. /**
  68463. * Loader interface with additional members.
  68464. */
  68465. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68466. accessors?: IAccessor[];
  68467. animations?: IAnimation[];
  68468. buffers?: IBuffer[];
  68469. bufferViews?: IBufferView[];
  68470. cameras?: ICamera[];
  68471. images?: IImage[];
  68472. materials?: IMaterial[];
  68473. meshes?: IMesh[];
  68474. nodes?: INode[];
  68475. samplers?: ISampler[];
  68476. scenes?: IScene[];
  68477. skins?: ISkin[];
  68478. textures?: ITexture[];
  68479. }
  68480. }
  68481. declare module BABYLON.GLTF2 {
  68482. /**
  68483. * Interface for a glTF loader extension.
  68484. */
  68485. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68486. /**
  68487. * Called after the loader state changes to LOADING.
  68488. */
  68489. onLoading?(): void;
  68490. /**
  68491. * Called after the loader state changes to READY.
  68492. */
  68493. onReady?(): void;
  68494. /**
  68495. * Define this method to modify the default behavior when loading scenes.
  68496. * @param context The context when loading the asset
  68497. * @param scene The glTF scene property
  68498. * @returns A promise that resolves when the load is complete or null if not handled
  68499. */
  68500. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68501. /**
  68502. * Define this method to modify the default behavior when loading nodes.
  68503. * @param context The context when loading the asset
  68504. * @param node The glTF node property
  68505. * @param assign A function called synchronously after parsing the glTF properties
  68506. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68507. */
  68508. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68509. /**
  68510. * Define this method to modify the default behavior when loading cameras.
  68511. * @param context The context when loading the asset
  68512. * @param camera The glTF camera property
  68513. * @param assign A function called synchronously after parsing the glTF properties
  68514. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68515. */
  68516. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68517. /**
  68518. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68519. * @param context The context when loading the asset
  68520. * @param primitive The glTF mesh primitive property
  68521. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68522. */
  68523. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68524. /**
  68525. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68526. * @param context The context when loading the asset
  68527. * @param name The mesh name when loading the asset
  68528. * @param node The glTF node when loading the asset
  68529. * @param mesh The glTF mesh when loading the asset
  68530. * @param primitive The glTF mesh primitive property
  68531. * @param assign A function called synchronously after parsing the glTF properties
  68532. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68533. */
  68534. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68535. /**
  68536. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68537. * @param context The context when loading the asset
  68538. * @param material The glTF material property
  68539. * @param assign A function called synchronously after parsing the glTF properties
  68540. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68541. */
  68542. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68543. /**
  68544. * Define this method to modify the default behavior when creating materials.
  68545. * @param context The context when loading the asset
  68546. * @param material The glTF material property
  68547. * @param babylonDrawMode The draw mode for the Babylon material
  68548. * @returns The Babylon material or null if not handled
  68549. */
  68550. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68551. /**
  68552. * Define this method to modify the default behavior when loading material properties.
  68553. * @param context The context when loading the asset
  68554. * @param material The glTF material property
  68555. * @param babylonMaterial The Babylon material
  68556. * @returns A promise that resolves when the load is complete or null if not handled
  68557. */
  68558. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68559. /**
  68560. * Define this method to modify the default behavior when loading texture infos.
  68561. * @param context The context when loading the asset
  68562. * @param textureInfo The glTF texture info property
  68563. * @param assign A function called synchronously after parsing the glTF properties
  68564. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68565. */
  68566. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68567. /**
  68568. * Define this method to modify the default behavior when loading animations.
  68569. * @param context The context when loading the asset
  68570. * @param animation The glTF animation property
  68571. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68572. */
  68573. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68574. /**
  68575. * @hidden Define this method to modify the default behavior when loading skins.
  68576. * @param context The context when loading the asset
  68577. * @param node The glTF node property
  68578. * @param skin The glTF skin property
  68579. * @returns A promise that resolves when the load is complete or null if not handled
  68580. */
  68581. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68582. /**
  68583. * @hidden Define this method to modify the default behavior when loading uris.
  68584. * @param context The context when loading the asset
  68585. * @param property The glTF property associated with the uri
  68586. * @param uri The uri to load
  68587. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68588. */
  68589. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68590. }
  68591. }
  68592. declare module BABYLON.GLTF2 {
  68593. /**
  68594. * Helper class for working with arrays when loading the glTF asset
  68595. */
  68596. export class ArrayItem {
  68597. /**
  68598. * Gets an item from the given array.
  68599. * @param context The context when loading the asset
  68600. * @param array The array to get the item from
  68601. * @param index The index to the array
  68602. * @returns The array item
  68603. */
  68604. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68605. /**
  68606. * Assign an `index` field to each item of the given array.
  68607. * @param array The array of items
  68608. */
  68609. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68610. }
  68611. /**
  68612. * The glTF 2.0 loader
  68613. */
  68614. export class GLTFLoader implements IGLTFLoader {
  68615. /** @hidden */
  68616. _completePromises: Promise<any>[];
  68617. private _disposed;
  68618. private _parent;
  68619. private _state;
  68620. private _extensions;
  68621. private _rootUrl;
  68622. private _fileName;
  68623. private _uniqueRootUrl;
  68624. private _gltf;
  68625. private _babylonScene;
  68626. private _rootBabylonMesh;
  68627. private _defaultBabylonMaterialData;
  68628. private _progressCallback?;
  68629. private _requests;
  68630. private static readonly _DefaultSampler;
  68631. private static _ExtensionNames;
  68632. private static _ExtensionFactories;
  68633. /**
  68634. * Registers a loader extension.
  68635. * @param name The name of the loader extension.
  68636. * @param factory The factory function that creates the loader extension.
  68637. */
  68638. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68639. /**
  68640. * Unregisters a loader extension.
  68641. * @param name The name of the loader extenion.
  68642. * @returns A boolean indicating whether the extension has been unregistered
  68643. */
  68644. static UnregisterExtension(name: string): boolean;
  68645. /**
  68646. * Gets the loader state.
  68647. */
  68648. readonly state: Nullable<GLTFLoaderState>;
  68649. /**
  68650. * The glTF object parsed from the JSON.
  68651. */
  68652. readonly gltf: IGLTF;
  68653. /**
  68654. * The Babylon scene when loading the asset.
  68655. */
  68656. readonly babylonScene: Scene;
  68657. /**
  68658. * The root Babylon mesh when loading the asset.
  68659. */
  68660. readonly rootBabylonMesh: Mesh;
  68661. /** @hidden */
  68662. constructor(parent: GLTFFileLoader);
  68663. /** @hidden */
  68664. dispose(): void;
  68665. /** @hidden */
  68666. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68667. meshes: AbstractMesh[];
  68668. particleSystems: IParticleSystem[];
  68669. skeletons: Skeleton[];
  68670. animationGroups: AnimationGroup[];
  68671. }>;
  68672. /** @hidden */
  68673. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68674. private _loadAsync;
  68675. private _loadData;
  68676. private _setupData;
  68677. private _loadExtensions;
  68678. private _checkExtensions;
  68679. private _setState;
  68680. private _createRootNode;
  68681. /**
  68682. * Loads a glTF scene.
  68683. * @param context The context when loading the asset
  68684. * @param scene The glTF scene property
  68685. * @returns A promise that resolves when the load is complete
  68686. */
  68687. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68688. private _forEachPrimitive;
  68689. private _getMeshes;
  68690. private _getSkeletons;
  68691. private _getAnimationGroups;
  68692. private _startAnimations;
  68693. /**
  68694. * Loads a glTF node.
  68695. * @param context The context when loading the asset
  68696. * @param node The glTF node property
  68697. * @param assign A function called synchronously after parsing the glTF properties
  68698. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68699. */
  68700. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68701. private _loadMeshAsync;
  68702. /**
  68703. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68704. * @param context The context when loading the asset
  68705. * @param name The mesh name when loading the asset
  68706. * @param node The glTF node when loading the asset
  68707. * @param mesh The glTF mesh when loading the asset
  68708. * @param primitive The glTF mesh primitive property
  68709. * @param assign A function called synchronously after parsing the glTF properties
  68710. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68711. */
  68712. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68713. private _loadVertexDataAsync;
  68714. private _createMorphTargets;
  68715. private _loadMorphTargetsAsync;
  68716. private _loadMorphTargetVertexDataAsync;
  68717. private static _LoadTransform;
  68718. private _loadSkinAsync;
  68719. private _loadBones;
  68720. private _loadBone;
  68721. private _loadSkinInverseBindMatricesDataAsync;
  68722. private _updateBoneMatrices;
  68723. private _getNodeMatrix;
  68724. /**
  68725. * Loads a glTF camera.
  68726. * @param context The context when loading the asset
  68727. * @param camera The glTF camera property
  68728. * @param assign A function called synchronously after parsing the glTF properties
  68729. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68730. */
  68731. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68732. private _loadAnimationsAsync;
  68733. /**
  68734. * Loads a glTF animation.
  68735. * @param context The context when loading the asset
  68736. * @param animation The glTF animation property
  68737. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68738. */
  68739. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68740. /**
  68741. * @hidden Loads a glTF animation channel.
  68742. * @param context The context when loading the asset
  68743. * @param animationContext The context of the animation when loading the asset
  68744. * @param animation The glTF animation property
  68745. * @param channel The glTF animation channel property
  68746. * @param babylonAnimationGroup The babylon animation group property
  68747. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68748. * @returns A void promise when the channel load is complete
  68749. */
  68750. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68751. private _loadAnimationSamplerAsync;
  68752. private _loadBufferAsync;
  68753. /**
  68754. * Loads a glTF buffer view.
  68755. * @param context The context when loading the asset
  68756. * @param bufferView The glTF buffer view property
  68757. * @returns A promise that resolves with the loaded data when the load is complete
  68758. */
  68759. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68760. private _loadAccessorAsync;
  68761. private _loadFloatAccessorAsync;
  68762. private _loadIndicesAccessorAsync;
  68763. private _loadVertexBufferViewAsync;
  68764. private _loadVertexAccessorAsync;
  68765. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68766. /** @hidden */
  68767. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68768. private _createDefaultMaterial;
  68769. /**
  68770. * Creates a Babylon material from a glTF material.
  68771. * @param context The context when loading the asset
  68772. * @param material The glTF material property
  68773. * @param babylonDrawMode The draw mode for the Babylon material
  68774. * @returns The Babylon material
  68775. */
  68776. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68777. /**
  68778. * Loads properties from a glTF material into a Babylon material.
  68779. * @param context The context when loading the asset
  68780. * @param material The glTF material property
  68781. * @param babylonMaterial The Babylon material
  68782. * @returns A promise that resolves when the load is complete
  68783. */
  68784. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68785. /**
  68786. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68787. * @param context The context when loading the asset
  68788. * @param material The glTF material property
  68789. * @param babylonMaterial The Babylon material
  68790. * @returns A promise that resolves when the load is complete
  68791. */
  68792. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68793. /**
  68794. * Loads the alpha properties from a glTF material into a Babylon material.
  68795. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68796. * @param context The context when loading the asset
  68797. * @param material The glTF material property
  68798. * @param babylonMaterial The Babylon material
  68799. */
  68800. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68801. /**
  68802. * Loads a glTF texture info.
  68803. * @param context The context when loading the asset
  68804. * @param textureInfo The glTF texture info property
  68805. * @param assign A function called synchronously after parsing the glTF properties
  68806. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68807. */
  68808. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68809. private _loadTextureAsync;
  68810. private _loadSampler;
  68811. /**
  68812. * Loads a glTF image.
  68813. * @param context The context when loading the asset
  68814. * @param image The glTF image property
  68815. * @returns A promise that resolves with the loaded data when the load is complete
  68816. */
  68817. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68818. /**
  68819. * Loads a glTF uri.
  68820. * @param context The context when loading the asset
  68821. * @param property The glTF property associated with the uri
  68822. * @param uri The base64 or relative uri
  68823. * @returns A promise that resolves with the loaded data when the load is complete
  68824. */
  68825. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68826. private _onProgress;
  68827. /**
  68828. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68829. * @param babylonObject the Babylon object with metadata
  68830. * @param pointer the JSON pointer
  68831. */
  68832. static AddPointerMetadata(babylonObject: {
  68833. metadata: any;
  68834. }, pointer: string): void;
  68835. private static _GetTextureWrapMode;
  68836. private static _GetTextureSamplingMode;
  68837. private static _GetTypedArrayConstructor;
  68838. private static _GetTypedArray;
  68839. private static _GetNumComponents;
  68840. private static _ValidateUri;
  68841. private static _GetDrawMode;
  68842. private _compileMaterialsAsync;
  68843. private _compileShadowGeneratorsAsync;
  68844. private _forEachExtensions;
  68845. private _applyExtensions;
  68846. private _extensionsOnLoading;
  68847. private _extensionsOnReady;
  68848. private _extensionsLoadSceneAsync;
  68849. private _extensionsLoadNodeAsync;
  68850. private _extensionsLoadCameraAsync;
  68851. private _extensionsLoadVertexDataAsync;
  68852. private _extensionsLoadMeshPrimitiveAsync;
  68853. private _extensionsLoadMaterialAsync;
  68854. private _extensionsCreateMaterial;
  68855. private _extensionsLoadMaterialPropertiesAsync;
  68856. private _extensionsLoadTextureInfoAsync;
  68857. private _extensionsLoadAnimationAsync;
  68858. private _extensionsLoadSkinAsync;
  68859. private _extensionsLoadUriAsync;
  68860. /**
  68861. * Helper method called by a loader extension to load an glTF extension.
  68862. * @param context The context when loading the asset
  68863. * @param property The glTF property to load the extension from
  68864. * @param extensionName The name of the extension to load
  68865. * @param actionAsync The action to run
  68866. * @returns The promise returned by actionAsync or null if the extension does not exist
  68867. */
  68868. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68869. /**
  68870. * Helper method called by a loader extension to load a glTF extra.
  68871. * @param context The context when loading the asset
  68872. * @param property The glTF property to load the extra from
  68873. * @param extensionName The name of the extension to load
  68874. * @param actionAsync The action to run
  68875. * @returns The promise returned by actionAsync or null if the extra does not exist
  68876. */
  68877. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68878. /**
  68879. * Increments the indentation level and logs a message.
  68880. * @param message The message to log
  68881. */
  68882. logOpen(message: string): void;
  68883. /**
  68884. * Decrements the indentation level.
  68885. */
  68886. logClose(): void;
  68887. /**
  68888. * Logs a message
  68889. * @param message The message to log
  68890. */
  68891. log(message: string): void;
  68892. /**
  68893. * Starts a performance counter.
  68894. * @param counterName The name of the performance counter
  68895. */
  68896. startPerformanceCounter(counterName: string): void;
  68897. /**
  68898. * Ends a performance counter.
  68899. * @param counterName The name of the performance counter
  68900. */
  68901. endPerformanceCounter(counterName: string): void;
  68902. }
  68903. }
  68904. declare module BABYLON.GLTF2.Loader.Extensions {
  68905. /**
  68906. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68907. */
  68908. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68909. /** The name of this extension. */
  68910. readonly name: string;
  68911. /** Defines whether this extension is enabled. */
  68912. enabled: boolean;
  68913. private _loader;
  68914. private _lights?;
  68915. /** @hidden */
  68916. constructor(loader: GLTFLoader);
  68917. /** @hidden */
  68918. dispose(): void;
  68919. /** @hidden */
  68920. onLoading(): void;
  68921. /** @hidden */
  68922. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68923. private _loadLightAsync;
  68924. }
  68925. }
  68926. declare module BABYLON.GLTF2.Loader.Extensions {
  68927. /**
  68928. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68929. */
  68930. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68931. /** The name of this extension. */
  68932. readonly name: string;
  68933. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68934. dracoCompression?: DracoCompression;
  68935. /** Defines whether this extension is enabled. */
  68936. enabled: boolean;
  68937. private _loader;
  68938. /** @hidden */
  68939. constructor(loader: GLTFLoader);
  68940. /** @hidden */
  68941. dispose(): void;
  68942. /** @hidden */
  68943. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68944. }
  68945. }
  68946. declare module BABYLON.GLTF2.Loader.Extensions {
  68947. /**
  68948. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68949. */
  68950. export class KHR_lights implements IGLTFLoaderExtension {
  68951. /** The name of this extension. */
  68952. readonly name: string;
  68953. /** Defines whether this extension is enabled. */
  68954. enabled: boolean;
  68955. private _loader;
  68956. private _lights?;
  68957. /** @hidden */
  68958. constructor(loader: GLTFLoader);
  68959. /** @hidden */
  68960. dispose(): void;
  68961. /** @hidden */
  68962. onLoading(): void;
  68963. /** @hidden */
  68964. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68965. }
  68966. }
  68967. declare module BABYLON.GLTF2.Loader.Extensions {
  68968. /**
  68969. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68970. */
  68971. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68972. /** The name of this extension. */
  68973. readonly name: string;
  68974. /** Defines whether this extension is enabled. */
  68975. enabled: boolean;
  68976. private _loader;
  68977. /** @hidden */
  68978. constructor(loader: GLTFLoader);
  68979. /** @hidden */
  68980. dispose(): void;
  68981. /** @hidden */
  68982. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68983. private _loadSpecularGlossinessPropertiesAsync;
  68984. }
  68985. }
  68986. declare module BABYLON.GLTF2.Loader.Extensions {
  68987. /**
  68988. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68989. */
  68990. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68991. /** The name of this extension. */
  68992. readonly name: string;
  68993. /** Defines whether this extension is enabled. */
  68994. enabled: boolean;
  68995. private _loader;
  68996. /** @hidden */
  68997. constructor(loader: GLTFLoader);
  68998. /** @hidden */
  68999. dispose(): void;
  69000. /** @hidden */
  69001. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69002. private _loadUnlitPropertiesAsync;
  69003. }
  69004. }
  69005. declare module BABYLON.GLTF2.Loader.Extensions {
  69006. /**
  69007. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69008. */
  69009. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69010. /** The name of this extension. */
  69011. readonly name: string;
  69012. /** Defines whether this extension is enabled. */
  69013. enabled: boolean;
  69014. private _loader;
  69015. /** @hidden */
  69016. constructor(loader: GLTFLoader);
  69017. /** @hidden */
  69018. dispose(): void;
  69019. /** @hidden */
  69020. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69021. }
  69022. }
  69023. declare module BABYLON.GLTF2.Loader.Extensions {
  69024. /**
  69025. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69026. */
  69027. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69028. /** The name of this extension. */
  69029. readonly name: string;
  69030. /** Defines whether this extension is enabled. */
  69031. enabled: boolean;
  69032. private _loader;
  69033. private _clips;
  69034. private _emitters;
  69035. /** @hidden */
  69036. constructor(loader: GLTFLoader);
  69037. /** @hidden */
  69038. dispose(): void;
  69039. /** @hidden */
  69040. onLoading(): void;
  69041. /** @hidden */
  69042. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69043. /** @hidden */
  69044. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69045. /** @hidden */
  69046. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69047. private _loadClipAsync;
  69048. private _loadEmitterAsync;
  69049. private _getEventAction;
  69050. private _loadAnimationEventAsync;
  69051. }
  69052. }
  69053. declare module BABYLON.GLTF2.Loader.Extensions {
  69054. /**
  69055. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69056. */
  69057. export class MSFT_lod implements IGLTFLoaderExtension {
  69058. /** The name of this extension. */
  69059. readonly name: string;
  69060. /** Defines whether this extension is enabled. */
  69061. enabled: boolean;
  69062. /**
  69063. * Maximum number of LODs to load, starting from the lowest LOD.
  69064. */
  69065. maxLODsToLoad: number;
  69066. /**
  69067. * Observable raised when all node LODs of one level are loaded.
  69068. * The event data is the index of the loaded LOD starting from zero.
  69069. * Dispose the loader to cancel the loading of the next level of LODs.
  69070. */
  69071. onNodeLODsLoadedObservable: Observable<number>;
  69072. /**
  69073. * Observable raised when all material LODs of one level are loaded.
  69074. * The event data is the index of the loaded LOD starting from zero.
  69075. * Dispose the loader to cancel the loading of the next level of LODs.
  69076. */
  69077. onMaterialLODsLoadedObservable: Observable<number>;
  69078. private _loader;
  69079. private _nodeIndexLOD;
  69080. private _nodeSignalLODs;
  69081. private _nodePromiseLODs;
  69082. private _materialIndexLOD;
  69083. private _materialSignalLODs;
  69084. private _materialPromiseLODs;
  69085. /** @hidden */
  69086. constructor(loader: GLTFLoader);
  69087. /** @hidden */
  69088. dispose(): void;
  69089. /** @hidden */
  69090. onReady(): void;
  69091. /** @hidden */
  69092. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69093. /** @hidden */
  69094. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69095. /** @hidden */
  69096. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69097. /**
  69098. * Gets an array of LOD properties from lowest to highest.
  69099. */
  69100. private _getLODs;
  69101. private _disposeUnusedMaterials;
  69102. }
  69103. }
  69104. declare module BABYLON.GLTF2.Loader.Extensions {
  69105. /** @hidden */
  69106. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69107. readonly name: string;
  69108. enabled: boolean;
  69109. private _loader;
  69110. constructor(loader: GLTFLoader);
  69111. dispose(): void;
  69112. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69113. }
  69114. }
  69115. declare module BABYLON.GLTF2.Loader.Extensions {
  69116. /** @hidden */
  69117. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69118. readonly name: string;
  69119. enabled: boolean;
  69120. private _loader;
  69121. constructor(loader: GLTFLoader);
  69122. dispose(): void;
  69123. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69124. }
  69125. }
  69126. declare module BABYLON.GLTF2.Loader.Extensions {
  69127. /**
  69128. * Store glTF extras (if present) in BJS objects' metadata
  69129. */
  69130. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69131. /** The name of this extension. */
  69132. readonly name: string;
  69133. /** Defines whether this extension is enabled. */
  69134. enabled: boolean;
  69135. private _loader;
  69136. private _assignExtras;
  69137. /** @hidden */
  69138. constructor(loader: GLTFLoader);
  69139. /** @hidden */
  69140. dispose(): void;
  69141. /** @hidden */
  69142. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69143. /** @hidden */
  69144. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69145. /** @hidden */
  69146. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69147. }
  69148. }
  69149. declare module BABYLON {
  69150. /**
  69151. * Class reading and parsing the MTL file bundled with the obj file.
  69152. */
  69153. export class MTLFileLoader {
  69154. /**
  69155. * All material loaded from the mtl will be set here
  69156. */
  69157. materials: StandardMaterial[];
  69158. /**
  69159. * This function will read the mtl file and create each material described inside
  69160. * This function could be improve by adding :
  69161. * -some component missing (Ni, Tf...)
  69162. * -including the specific options available
  69163. *
  69164. * @param scene defines the scene the material will be created in
  69165. * @param data defines the mtl data to parse
  69166. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69167. */
  69168. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69169. /**
  69170. * Gets the texture for the material.
  69171. *
  69172. * If the material is imported from input file,
  69173. * We sanitize the url to ensure it takes the textre from aside the material.
  69174. *
  69175. * @param rootUrl The root url to load from
  69176. * @param value The value stored in the mtl
  69177. * @return The Texture
  69178. */
  69179. private static _getTexture;
  69180. }
  69181. /**
  69182. * Options for loading OBJ/MTL files
  69183. */
  69184. type MeshLoadOptions = {
  69185. /**
  69186. * Defines if UVs are optimized by default during load.
  69187. */
  69188. OptimizeWithUV: boolean;
  69189. /**
  69190. * Defines custom scaling of UV coordinates of loaded meshes.
  69191. */
  69192. UVScaling: Vector2;
  69193. /**
  69194. * Invert model on y-axis (does a model scaling inversion)
  69195. */
  69196. InvertY: boolean;
  69197. /**
  69198. * Invert Y-Axis of referenced textures on load
  69199. */
  69200. InvertTextureY: boolean;
  69201. /**
  69202. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69203. */
  69204. ImportVertexColors: boolean;
  69205. /**
  69206. * Compute the normals for the model, even if normals are present in the file.
  69207. */
  69208. ComputeNormals: boolean;
  69209. /**
  69210. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69211. */
  69212. SkipMaterials: boolean;
  69213. /**
  69214. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69215. */
  69216. MaterialLoadingFailsSilently: boolean;
  69217. };
  69218. /**
  69219. * OBJ file type loader.
  69220. * This is a babylon scene loader plugin.
  69221. */
  69222. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69223. /**
  69224. * Defines if UVs are optimized by default during load.
  69225. */
  69226. static OPTIMIZE_WITH_UV: boolean;
  69227. /**
  69228. * Invert model on y-axis (does a model scaling inversion)
  69229. */
  69230. static INVERT_Y: boolean;
  69231. /**
  69232. * Invert Y-Axis of referenced textures on load
  69233. */
  69234. static INVERT_TEXTURE_Y: boolean;
  69235. /**
  69236. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69237. */
  69238. static IMPORT_VERTEX_COLORS: boolean;
  69239. /**
  69240. * Compute the normals for the model, even if normals are present in the file.
  69241. */
  69242. static COMPUTE_NORMALS: boolean;
  69243. /**
  69244. * Defines custom scaling of UV coordinates of loaded meshes.
  69245. */
  69246. static UV_SCALING: Vector2;
  69247. /**
  69248. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69249. */
  69250. static SKIP_MATERIALS: boolean;
  69251. /**
  69252. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69253. *
  69254. * Defaults to true for backwards compatibility.
  69255. */
  69256. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69257. /**
  69258. * Defines the name of the plugin.
  69259. */
  69260. name: string;
  69261. /**
  69262. * Defines the extension the plugin is able to load.
  69263. */
  69264. extensions: string;
  69265. /** @hidden */
  69266. obj: RegExp;
  69267. /** @hidden */
  69268. group: RegExp;
  69269. /** @hidden */
  69270. mtllib: RegExp;
  69271. /** @hidden */
  69272. usemtl: RegExp;
  69273. /** @hidden */
  69274. smooth: RegExp;
  69275. /** @hidden */
  69276. vertexPattern: RegExp;
  69277. /** @hidden */
  69278. normalPattern: RegExp;
  69279. /** @hidden */
  69280. uvPattern: RegExp;
  69281. /** @hidden */
  69282. facePattern1: RegExp;
  69283. /** @hidden */
  69284. facePattern2: RegExp;
  69285. /** @hidden */
  69286. facePattern3: RegExp;
  69287. /** @hidden */
  69288. facePattern4: RegExp;
  69289. /** @hidden */
  69290. facePattern5: RegExp;
  69291. private _meshLoadOptions;
  69292. /**
  69293. * Creates loader for .OBJ files
  69294. *
  69295. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69296. */
  69297. constructor(meshLoadOptions?: MeshLoadOptions);
  69298. private static readonly currentMeshLoadOptions;
  69299. /**
  69300. * Calls synchronously the MTL file attached to this obj.
  69301. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69302. * Without this function materials are not displayed in the first frame (but displayed after).
  69303. * In consequence it is impossible to get material information in your HTML file
  69304. *
  69305. * @param url The URL of the MTL file
  69306. * @param rootUrl
  69307. * @param onSuccess Callback function to be called when the MTL file is loaded
  69308. * @private
  69309. */
  69310. private _loadMTL;
  69311. /**
  69312. * Instantiates a OBJ file loader plugin.
  69313. * @returns the created plugin
  69314. */
  69315. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69316. /**
  69317. * If the data string can be loaded directly.
  69318. *
  69319. * @param data string containing the file data
  69320. * @returns if the data can be loaded directly
  69321. */
  69322. canDirectLoad(data: string): boolean;
  69323. /**
  69324. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69325. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69326. * @param scene the scene the meshes should be added to
  69327. * @param data the OBJ data to load
  69328. * @param rootUrl root url to load from
  69329. * @param onProgress event that fires when loading progress has occured
  69330. * @param fileName Defines the name of the file to load
  69331. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69332. */
  69333. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69334. meshes: AbstractMesh[];
  69335. particleSystems: IParticleSystem[];
  69336. skeletons: Skeleton[];
  69337. animationGroups: AnimationGroup[];
  69338. }>;
  69339. /**
  69340. * Imports all objects from the loaded OBJ data and adds them to the scene
  69341. * @param scene the scene the objects should be added to
  69342. * @param data the OBJ data to load
  69343. * @param rootUrl root url to load from
  69344. * @param onProgress event that fires when loading progress has occured
  69345. * @param fileName Defines the name of the file to load
  69346. * @returns a promise which completes when objects have been loaded to the scene
  69347. */
  69348. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69349. /**
  69350. * Load into an asset container.
  69351. * @param scene The scene to load into
  69352. * @param data The data to import
  69353. * @param rootUrl The root url for scene and resources
  69354. * @param onProgress The callback when the load progresses
  69355. * @param fileName Defines the name of the file to load
  69356. * @returns The loaded asset container
  69357. */
  69358. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69359. /**
  69360. * Read the OBJ file and create an Array of meshes.
  69361. * Each mesh contains all information given by the OBJ and the MTL file.
  69362. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69363. *
  69364. * @param meshesNames
  69365. * @param scene Scene The scene where are displayed the data
  69366. * @param data String The content of the obj file
  69367. * @param rootUrl String The path to the folder
  69368. * @returns Array<AbstractMesh>
  69369. * @private
  69370. */
  69371. private _parseSolid;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /**
  69376. * STL file type loader.
  69377. * This is a babylon scene loader plugin.
  69378. */
  69379. export class STLFileLoader implements ISceneLoaderPlugin {
  69380. /** @hidden */
  69381. solidPattern: RegExp;
  69382. /** @hidden */
  69383. facetsPattern: RegExp;
  69384. /** @hidden */
  69385. normalPattern: RegExp;
  69386. /** @hidden */
  69387. vertexPattern: RegExp;
  69388. /**
  69389. * Defines the name of the plugin.
  69390. */
  69391. name: string;
  69392. /**
  69393. * Defines the extensions the stl loader is able to load.
  69394. * force data to come in as an ArrayBuffer
  69395. * we'll convert to string if it looks like it's an ASCII .stl
  69396. */
  69397. extensions: ISceneLoaderPluginExtensions;
  69398. /**
  69399. * Import meshes into a scene.
  69400. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69401. * @param scene The scene to import into
  69402. * @param data The data to import
  69403. * @param rootUrl The root url for scene and resources
  69404. * @param meshes The meshes array to import into
  69405. * @param particleSystems The particle systems array to import into
  69406. * @param skeletons The skeletons array to import into
  69407. * @param onError The callback when import fails
  69408. * @returns True if successful or false otherwise
  69409. */
  69410. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69411. /**
  69412. * Load into a scene.
  69413. * @param scene The scene to load into
  69414. * @param data The data to import
  69415. * @param rootUrl The root url for scene and resources
  69416. * @param onError The callback when import fails
  69417. * @returns true if successful or false otherwise
  69418. */
  69419. load(scene: Scene, data: any, rootUrl: string): boolean;
  69420. /**
  69421. * Load into an asset container.
  69422. * @param scene The scene to load into
  69423. * @param data The data to import
  69424. * @param rootUrl The root url for scene and resources
  69425. * @param onError The callback when import fails
  69426. * @returns The loaded asset container
  69427. */
  69428. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69429. private _isBinary;
  69430. private _parseBinary;
  69431. private _parseASCII;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * Class for generating OBJ data from a Babylon scene.
  69437. */
  69438. export class OBJExport {
  69439. /**
  69440. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69441. * @param mesh defines the list of meshes to serialize
  69442. * @param materials defines if materials should be exported
  69443. * @param matlibname defines the name of the associated mtl file
  69444. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69445. * @returns the OBJ content
  69446. */
  69447. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69448. /**
  69449. * Exports the material(s) of a mesh in .MTL file format (text)
  69450. * @param mesh defines the mesh to extract the material from
  69451. * @returns the mtl content
  69452. */
  69453. static MTL(mesh: Mesh): string;
  69454. }
  69455. }
  69456. declare module BABYLON {
  69457. /** @hidden */
  69458. export var __IGLTFExporterExtension: number;
  69459. /**
  69460. * Interface for extending the exporter
  69461. * @hidden
  69462. */
  69463. export interface IGLTFExporterExtension {
  69464. /**
  69465. * The name of this extension
  69466. */
  69467. readonly name: string;
  69468. /**
  69469. * Defines whether this extension is enabled
  69470. */
  69471. enabled: boolean;
  69472. /**
  69473. * Defines whether this extension is required
  69474. */
  69475. required: boolean;
  69476. }
  69477. }
  69478. declare module BABYLON.GLTF2.Exporter {
  69479. /** @hidden */
  69480. export var __IGLTFExporterExtensionV2: number;
  69481. /**
  69482. * Interface for a glTF exporter extension
  69483. * @hidden
  69484. */
  69485. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69486. /**
  69487. * Define this method to modify the default behavior before exporting a texture
  69488. * @param context The context when loading the asset
  69489. * @param babylonTexture The glTF texture info property
  69490. * @param mimeType The mime-type of the generated image
  69491. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69492. */
  69493. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69494. /**
  69495. * Define this method to modify the default behavior when exporting texture info
  69496. * @param context The context when loading the asset
  69497. * @param meshPrimitive glTF mesh primitive
  69498. * @param babylonSubMesh Babylon submesh
  69499. * @param binaryWriter glTF serializer binary writer instance
  69500. * @returns nullable IMeshPrimitive promise
  69501. */
  69502. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69503. /**
  69504. * Define this method to modify the default behavior when exporting a node
  69505. * @param context The context when exporting the node
  69506. * @param node glTF node
  69507. * @param babylonNode BabylonJS node
  69508. * @returns nullable INode promise
  69509. */
  69510. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69511. /**
  69512. * Called after the exporter state changes to EXPORTING
  69513. */
  69514. onExporting?(): void;
  69515. }
  69516. }
  69517. declare module BABYLON.GLTF2.Exporter {
  69518. /**
  69519. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69520. * @hidden
  69521. */
  69522. export class _GLTFMaterialExporter {
  69523. /**
  69524. * Represents the dielectric specular values for R, G and B
  69525. */
  69526. private static readonly _DielectricSpecular;
  69527. /**
  69528. * Allows the maximum specular power to be defined for material calculations
  69529. */
  69530. private static readonly _MaxSpecularPower;
  69531. /**
  69532. * Mapping to store textures
  69533. */
  69534. private _textureMap;
  69535. /**
  69536. * Numeric tolerance value
  69537. */
  69538. private static readonly _Epsilon;
  69539. /**
  69540. * Reference to the glTF Exporter
  69541. */
  69542. private _exporter;
  69543. constructor(exporter: _Exporter);
  69544. /**
  69545. * Specifies if two colors are approximately equal in value
  69546. * @param color1 first color to compare to
  69547. * @param color2 second color to compare to
  69548. * @param epsilon threshold value
  69549. */
  69550. private static FuzzyEquals;
  69551. /**
  69552. * Gets the materials from a Babylon scene and converts them to glTF materials
  69553. * @param scene babylonjs scene
  69554. * @param mimeType texture mime type
  69555. * @param images array of images
  69556. * @param textures array of textures
  69557. * @param materials array of materials
  69558. * @param imageData mapping of texture names to base64 textures
  69559. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69560. */
  69561. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69562. /**
  69563. * Makes a copy of the glTF material without the texture parameters
  69564. * @param originalMaterial original glTF material
  69565. * @returns glTF material without texture parameters
  69566. */
  69567. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69568. /**
  69569. * Specifies if the material has any texture parameters present
  69570. * @param material glTF Material
  69571. * @returns boolean specifying if texture parameters are present
  69572. */
  69573. _hasTexturesPresent(material: IMaterial): boolean;
  69574. /**
  69575. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69576. * @param babylonStandardMaterial
  69577. * @returns glTF Metallic Roughness Material representation
  69578. */
  69579. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69580. /**
  69581. * Computes the metallic factor
  69582. * @param diffuse diffused value
  69583. * @param specular specular value
  69584. * @param oneMinusSpecularStrength one minus the specular strength
  69585. * @returns metallic value
  69586. */
  69587. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69588. /**
  69589. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69590. * @param glTFMaterial glTF material
  69591. * @param babylonMaterial Babylon material
  69592. */
  69593. private static _SetAlphaMode;
  69594. /**
  69595. * Converts a Babylon Standard Material to a glTF Material
  69596. * @param babylonStandardMaterial BJS Standard Material
  69597. * @param mimeType mime type to use for the textures
  69598. * @param images array of glTF image interfaces
  69599. * @param textures array of glTF texture interfaces
  69600. * @param materials array of glTF material interfaces
  69601. * @param imageData map of image file name to data
  69602. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69603. */
  69604. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69605. /**
  69606. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69607. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69608. * @param mimeType mime type to use for the textures
  69609. * @param images array of glTF image interfaces
  69610. * @param textures array of glTF texture interfaces
  69611. * @param materials array of glTF material interfaces
  69612. * @param imageData map of image file name to data
  69613. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69614. */
  69615. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69616. /**
  69617. * Converts an image typed array buffer to a base64 image
  69618. * @param buffer typed array buffer
  69619. * @param width width of the image
  69620. * @param height height of the image
  69621. * @param mimeType mimetype of the image
  69622. * @returns base64 image string
  69623. */
  69624. private _createBase64FromCanvasAsync;
  69625. /**
  69626. * Generates a white texture based on the specified width and height
  69627. * @param width width of the texture in pixels
  69628. * @param height height of the texture in pixels
  69629. * @param scene babylonjs scene
  69630. * @returns white texture
  69631. */
  69632. private _createWhiteTexture;
  69633. /**
  69634. * 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
  69635. * @param texture1 first texture to resize
  69636. * @param texture2 second texture to resize
  69637. * @param scene babylonjs scene
  69638. * @returns resized textures or null
  69639. */
  69640. private _resizeTexturesToSameDimensions;
  69641. /**
  69642. * Converts an array of pixels to a Float32Array
  69643. * Throws an error if the pixel format is not supported
  69644. * @param pixels - array buffer containing pixel values
  69645. * @returns Float32 of pixels
  69646. */
  69647. private _convertPixelArrayToFloat32;
  69648. /**
  69649. * Convert Specular Glossiness Textures to Metallic Roughness
  69650. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69651. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69652. * @param diffuseTexture texture used to store diffuse information
  69653. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69654. * @param factors specular glossiness material factors
  69655. * @param mimeType the mime type to use for the texture
  69656. * @returns pbr metallic roughness interface or null
  69657. */
  69658. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69659. /**
  69660. * Converts specular glossiness material properties to metallic roughness
  69661. * @param specularGlossiness interface with specular glossiness material properties
  69662. * @returns interface with metallic roughness material properties
  69663. */
  69664. private _convertSpecularGlossinessToMetallicRoughness;
  69665. /**
  69666. * Calculates the surface reflectance, independent of lighting conditions
  69667. * @param color Color source to calculate brightness from
  69668. * @returns number representing the perceived brightness, or zero if color is undefined
  69669. */
  69670. private _getPerceivedBrightness;
  69671. /**
  69672. * Returns the maximum color component value
  69673. * @param color
  69674. * @returns maximum color component value, or zero if color is null or undefined
  69675. */
  69676. private _getMaxComponent;
  69677. /**
  69678. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69679. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69680. * @param mimeType mime type to use for the textures
  69681. * @param images array of glTF image interfaces
  69682. * @param textures array of glTF texture interfaces
  69683. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69684. * @param imageData map of image file name to data
  69685. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69686. * @returns glTF PBR Metallic Roughness factors
  69687. */
  69688. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69689. private _getGLTFTextureSampler;
  69690. private _getGLTFTextureWrapMode;
  69691. private _getGLTFTextureWrapModesSampler;
  69692. /**
  69693. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69694. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69695. * @param mimeType mime type to use for the textures
  69696. * @param images array of glTF image interfaces
  69697. * @param textures array of glTF texture interfaces
  69698. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69699. * @param imageData map of image file name to data
  69700. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69701. * @returns glTF PBR Metallic Roughness factors
  69702. */
  69703. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69704. /**
  69705. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69706. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69707. * @param mimeType mime type to use for the textures
  69708. * @param images array of glTF image interfaces
  69709. * @param textures array of glTF texture interfaces
  69710. * @param materials array of glTF material interfaces
  69711. * @param imageData map of image file name to data
  69712. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69713. */
  69714. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69715. private setMetallicRoughnessPbrMaterial;
  69716. private getPixelsFromTexture;
  69717. /**
  69718. * Extracts a texture from a Babylon texture into file data and glTF data
  69719. * @param babylonTexture Babylon texture to extract
  69720. * @param mimeType Mime Type of the babylonTexture
  69721. * @return glTF texture info, or null if the texture format is not supported
  69722. */
  69723. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69724. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69725. /**
  69726. * Builds a texture from base64 string
  69727. * @param base64Texture base64 texture string
  69728. * @param baseTextureName Name to use for the texture
  69729. * @param mimeType image mime type for the texture
  69730. * @param images array of images
  69731. * @param textures array of textures
  69732. * @param imageData map of image data
  69733. * @returns glTF texture info, or null if the texture format is not supported
  69734. */
  69735. private _getTextureInfoFromBase64;
  69736. }
  69737. }
  69738. declare module BABYLON {
  69739. /**
  69740. * Class for holding and downloading glTF file data
  69741. */
  69742. export class GLTFData {
  69743. /**
  69744. * Object which contains the file name as the key and its data as the value
  69745. */
  69746. glTFFiles: {
  69747. [fileName: string]: string | Blob;
  69748. };
  69749. /**
  69750. * Initializes the glTF file object
  69751. */
  69752. constructor();
  69753. /**
  69754. * Downloads the glTF data as files based on their names and data
  69755. */
  69756. downloadFiles(): void;
  69757. }
  69758. }
  69759. declare module BABYLON {
  69760. /**
  69761. * Holds a collection of exporter options and parameters
  69762. */
  69763. export interface IExportOptions {
  69764. /**
  69765. * Function which indicates whether a babylon node should be exported or not
  69766. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69767. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69768. */
  69769. shouldExportNode?(node: Node): boolean;
  69770. /**
  69771. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69772. * @param metadata source metadata to read from
  69773. * @returns the data to store to glTF node extras
  69774. */
  69775. metadataSelector?(metadata: any): any;
  69776. /**
  69777. * The sample rate to bake animation curves
  69778. */
  69779. animationSampleRate?: number;
  69780. /**
  69781. * Begin serialization without waiting for the scene to be ready
  69782. */
  69783. exportWithoutWaitingForScene?: boolean;
  69784. }
  69785. /**
  69786. * Class for generating glTF data from a Babylon scene.
  69787. */
  69788. export class GLTF2Export {
  69789. /**
  69790. * Exports the geometry of the scene to .gltf file format asynchronously
  69791. * @param scene Babylon scene with scene hierarchy information
  69792. * @param filePrefix File prefix to use when generating the glTF file
  69793. * @param options Exporter options
  69794. * @returns Returns an object with a .gltf file and associates texture names
  69795. * as keys and their data and paths as values
  69796. */
  69797. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69798. private static _PreExportAsync;
  69799. private static _PostExportAsync;
  69800. /**
  69801. * Exports the geometry of the scene to .glb file format asychronously
  69802. * @param scene Babylon scene with scene hierarchy information
  69803. * @param filePrefix File prefix to use when generating glb file
  69804. * @param options Exporter options
  69805. * @returns Returns an object with a .glb filename as key and data as value
  69806. */
  69807. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69808. }
  69809. }
  69810. declare module BABYLON.GLTF2.Exporter {
  69811. /**
  69812. * @hidden
  69813. */
  69814. export class _GLTFUtilities {
  69815. /**
  69816. * Creates a buffer view based on the supplied arguments
  69817. * @param bufferIndex index value of the specified buffer
  69818. * @param byteOffset byte offset value
  69819. * @param byteLength byte length of the bufferView
  69820. * @param byteStride byte distance between conequential elements
  69821. * @param name name of the buffer view
  69822. * @returns bufferView for glTF
  69823. */
  69824. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69825. /**
  69826. * Creates an accessor based on the supplied arguments
  69827. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69828. * @param name The name of the accessor
  69829. * @param type The type of the accessor
  69830. * @param componentType The datatype of components in the attribute
  69831. * @param count The number of attributes referenced by this accessor
  69832. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69833. * @param min Minimum value of each component in this attribute
  69834. * @param max Maximum value of each component in this attribute
  69835. * @returns accessor for glTF
  69836. */
  69837. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69838. /**
  69839. * Calculates the minimum and maximum values of an array of position floats
  69840. * @param positions Positions array of a mesh
  69841. * @param vertexStart Starting vertex offset to calculate min and max values
  69842. * @param vertexCount Number of vertices to check for min and max values
  69843. * @returns min number array and max number array
  69844. */
  69845. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69846. min: number[];
  69847. max: number[];
  69848. };
  69849. /**
  69850. * Converts a new right-handed Vector3
  69851. * @param vector vector3 array
  69852. * @returns right-handed Vector3
  69853. */
  69854. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69855. /**
  69856. * Converts a Vector3 to right-handed
  69857. * @param vector Vector3 to convert to right-handed
  69858. */
  69859. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69860. /**
  69861. * Converts a three element number array to right-handed
  69862. * @param vector number array to convert to right-handed
  69863. */
  69864. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69865. /**
  69866. * Converts a new right-handed Vector3
  69867. * @param vector vector3 array
  69868. * @returns right-handed Vector3
  69869. */
  69870. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69871. /**
  69872. * Converts a Vector3 to right-handed
  69873. * @param vector Vector3 to convert to right-handed
  69874. */
  69875. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69876. /**
  69877. * Converts a three element number array to right-handed
  69878. * @param vector number array to convert to right-handed
  69879. */
  69880. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69881. /**
  69882. * Converts a Vector4 to right-handed
  69883. * @param vector Vector4 to convert to right-handed
  69884. */
  69885. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69886. /**
  69887. * Converts a Vector4 to right-handed
  69888. * @param vector Vector4 to convert to right-handed
  69889. */
  69890. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69891. /**
  69892. * Converts a Quaternion to right-handed
  69893. * @param quaternion Source quaternion to convert to right-handed
  69894. */
  69895. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69896. /**
  69897. * Converts a Quaternion to right-handed
  69898. * @param quaternion Source quaternion to convert to right-handed
  69899. */
  69900. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69901. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69902. }
  69903. }
  69904. declare module BABYLON.GLTF2.Exporter {
  69905. /**
  69906. * Converts Babylon Scene into glTF 2.0.
  69907. * @hidden
  69908. */
  69909. export class _Exporter {
  69910. /**
  69911. * Stores the glTF to export
  69912. */
  69913. _glTF: IGLTF;
  69914. /**
  69915. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69916. */
  69917. _bufferViews: IBufferView[];
  69918. /**
  69919. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69920. */
  69921. _accessors: IAccessor[];
  69922. /**
  69923. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69924. */
  69925. private _nodes;
  69926. /**
  69927. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69928. */
  69929. private _scenes;
  69930. /**
  69931. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69932. */
  69933. private _meshes;
  69934. /**
  69935. * Stores all the generated material information, which represents the appearance of each primitive
  69936. */
  69937. _materials: IMaterial[];
  69938. _materialMap: {
  69939. [materialID: number]: number;
  69940. };
  69941. /**
  69942. * Stores all the generated texture information, which is referenced by glTF materials
  69943. */
  69944. _textures: ITexture[];
  69945. /**
  69946. * Stores all the generated image information, which is referenced by glTF textures
  69947. */
  69948. _images: IImage[];
  69949. /**
  69950. * Stores all the texture samplers
  69951. */
  69952. _samplers: ISampler[];
  69953. /**
  69954. * Stores all the generated animation samplers, which is referenced by glTF animations
  69955. */
  69956. /**
  69957. * Stores the animations for glTF models
  69958. */
  69959. private _animations;
  69960. /**
  69961. * Stores the total amount of bytes stored in the glTF buffer
  69962. */
  69963. private _totalByteLength;
  69964. /**
  69965. * Stores a reference to the Babylon scene containing the source geometry and material information
  69966. */
  69967. _babylonScene: Scene;
  69968. /**
  69969. * Stores a map of the image data, where the key is the file name and the value
  69970. * is the image data
  69971. */
  69972. _imageData: {
  69973. [fileName: string]: {
  69974. data: Uint8Array;
  69975. mimeType: ImageMimeType;
  69976. };
  69977. };
  69978. /**
  69979. * Stores a map of the unique id of a node to its index in the node array
  69980. */
  69981. private _nodeMap;
  69982. /**
  69983. * Specifies if the Babylon scene should be converted to right-handed on export
  69984. */
  69985. _convertToRightHandedSystem: boolean;
  69986. /**
  69987. * Baked animation sample rate
  69988. */
  69989. private _animationSampleRate;
  69990. private _options;
  69991. private _localEngine;
  69992. _glTFMaterialExporter: _GLTFMaterialExporter;
  69993. private _extensions;
  69994. private static _ExtensionNames;
  69995. private static _ExtensionFactories;
  69996. private _applyExtensions;
  69997. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69998. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69999. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70000. private _forEachExtensions;
  70001. private _extensionsOnExporting;
  70002. /**
  70003. * Load glTF serializer extensions
  70004. */
  70005. private _loadExtensions;
  70006. /**
  70007. * Creates a glTF Exporter instance, which can accept optional exporter options
  70008. * @param babylonScene Babylon scene object
  70009. * @param options Options to modify the behavior of the exporter
  70010. */
  70011. constructor(babylonScene: Scene, options?: IExportOptions);
  70012. /**
  70013. * Registers a glTF exporter extension
  70014. * @param name Name of the extension to export
  70015. * @param factory The factory function that creates the exporter extension
  70016. */
  70017. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70018. /**
  70019. * Un-registers an exporter extension
  70020. * @param name The name fo the exporter extension
  70021. * @returns A boolean indicating whether the extension has been un-registered
  70022. */
  70023. static UnregisterExtension(name: string): boolean;
  70024. /**
  70025. * Lazy load a local engine with premultiplied alpha set to false
  70026. */
  70027. _getLocalEngine(): Engine;
  70028. private reorderIndicesBasedOnPrimitiveMode;
  70029. /**
  70030. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70031. * clock-wise during export to glTF
  70032. * @param submesh BabylonJS submesh
  70033. * @param primitiveMode Primitive mode of the mesh
  70034. * @param sideOrientation the winding order of the submesh
  70035. * @param vertexBufferKind The type of vertex attribute
  70036. * @param meshAttributeArray The vertex attribute data
  70037. * @param byteOffset The offset to the binary data
  70038. * @param binaryWriter The binary data for the glTF file
  70039. */
  70040. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70041. /**
  70042. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70043. * clock-wise during export to glTF
  70044. * @param submesh BabylonJS submesh
  70045. * @param primitiveMode Primitive mode of the mesh
  70046. * @param sideOrientation the winding order of the submesh
  70047. * @param vertexBufferKind The type of vertex attribute
  70048. * @param meshAttributeArray The vertex attribute data
  70049. * @param byteOffset The offset to the binary data
  70050. * @param binaryWriter The binary data for the glTF file
  70051. */
  70052. private reorderTriangleFillMode;
  70053. /**
  70054. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70055. * clock-wise during export to glTF
  70056. * @param submesh BabylonJS submesh
  70057. * @param primitiveMode Primitive mode of the mesh
  70058. * @param sideOrientation the winding order of the submesh
  70059. * @param vertexBufferKind The type of vertex attribute
  70060. * @param meshAttributeArray The vertex attribute data
  70061. * @param byteOffset The offset to the binary data
  70062. * @param binaryWriter The binary data for the glTF file
  70063. */
  70064. private reorderTriangleStripDrawMode;
  70065. /**
  70066. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70067. * clock-wise during export to glTF
  70068. * @param submesh BabylonJS submesh
  70069. * @param primitiveMode Primitive mode of the mesh
  70070. * @param sideOrientation the winding order of the submesh
  70071. * @param vertexBufferKind The type of vertex attribute
  70072. * @param meshAttributeArray The vertex attribute data
  70073. * @param byteOffset The offset to the binary data
  70074. * @param binaryWriter The binary data for the glTF file
  70075. */
  70076. private reorderTriangleFanMode;
  70077. /**
  70078. * Writes the vertex attribute data to binary
  70079. * @param vertices The vertices to write to the binary writer
  70080. * @param byteOffset The offset into the binary writer to overwrite binary data
  70081. * @param vertexAttributeKind The vertex attribute type
  70082. * @param meshAttributeArray The vertex attribute data
  70083. * @param binaryWriter The writer containing the binary data
  70084. */
  70085. private writeVertexAttributeData;
  70086. /**
  70087. * Writes mesh attribute data to a data buffer
  70088. * Returns the bytelength of the data
  70089. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70090. * @param meshAttributeArray Array containing the attribute data
  70091. * @param binaryWriter The buffer to write the binary data to
  70092. * @param indices Used to specify the order of the vertex data
  70093. */
  70094. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70095. /**
  70096. * Generates glTF json data
  70097. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70098. * @param glTFPrefix Text to use when prefixing a glTF file
  70099. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70100. * @returns json data as string
  70101. */
  70102. private generateJSON;
  70103. /**
  70104. * Generates data for .gltf and .bin files based on the glTF prefix string
  70105. * @param glTFPrefix Text to use when prefixing a glTF file
  70106. * @returns GLTFData with glTF file data
  70107. */
  70108. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70109. /**
  70110. * Creates a binary buffer for glTF
  70111. * @returns array buffer for binary data
  70112. */
  70113. private _generateBinaryAsync;
  70114. /**
  70115. * Pads the number to a multiple of 4
  70116. * @param num number to pad
  70117. * @returns padded number
  70118. */
  70119. private _getPadding;
  70120. /**
  70121. * Generates a glb file from the json and binary data
  70122. * Returns an object with the glb file name as the key and data as the value
  70123. * @param glTFPrefix
  70124. * @returns object with glb filename as key and data as value
  70125. */
  70126. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70127. /**
  70128. * Sets the TRS for each node
  70129. * @param node glTF Node for storing the transformation data
  70130. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70131. */
  70132. private setNodeTransformation;
  70133. private getVertexBufferFromMesh;
  70134. /**
  70135. * Creates a bufferview based on the vertices type for the Babylon mesh
  70136. * @param kind Indicates the type of vertices data
  70137. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70138. * @param binaryWriter The buffer to write the bufferview data to
  70139. */
  70140. private createBufferViewKind;
  70141. /**
  70142. * The primitive mode of the Babylon mesh
  70143. * @param babylonMesh The BabylonJS mesh
  70144. */
  70145. private getMeshPrimitiveMode;
  70146. /**
  70147. * Sets the primitive mode of the glTF mesh primitive
  70148. * @param meshPrimitive glTF mesh primitive
  70149. * @param primitiveMode The primitive mode
  70150. */
  70151. private setPrimitiveMode;
  70152. /**
  70153. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70154. * @param meshPrimitive glTF mesh primitive
  70155. * @param attributeKind vertex attribute
  70156. * @returns boolean specifying if uv coordinates are present
  70157. */
  70158. private setAttributeKind;
  70159. /**
  70160. * Sets data for the primitive attributes of each submesh
  70161. * @param mesh glTF Mesh object to store the primitive attribute information
  70162. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70163. * @param binaryWriter Buffer to write the attribute data to
  70164. */
  70165. private setPrimitiveAttributesAsync;
  70166. /**
  70167. * Creates a glTF scene based on the array of meshes
  70168. * Returns the the total byte offset
  70169. * @param babylonScene Babylon scene to get the mesh data from
  70170. * @param binaryWriter Buffer to write binary data to
  70171. */
  70172. private createSceneAsync;
  70173. /**
  70174. * Creates a mapping of Node unique id to node index and handles animations
  70175. * @param babylonScene Babylon Scene
  70176. * @param nodes Babylon transform nodes
  70177. * @param binaryWriter Buffer to write binary data to
  70178. * @returns Node mapping of unique id to index
  70179. */
  70180. private createNodeMapAndAnimationsAsync;
  70181. /**
  70182. * Creates a glTF node from a Babylon mesh
  70183. * @param babylonMesh Source Babylon mesh
  70184. * @param binaryWriter Buffer for storing geometry data
  70185. * @returns glTF node
  70186. */
  70187. private createNodeAsync;
  70188. }
  70189. /**
  70190. * @hidden
  70191. *
  70192. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70193. */
  70194. export class _BinaryWriter {
  70195. /**
  70196. * Array buffer which stores all binary data
  70197. */
  70198. private _arrayBuffer;
  70199. /**
  70200. * View of the array buffer
  70201. */
  70202. private _dataView;
  70203. /**
  70204. * byte offset of data in array buffer
  70205. */
  70206. private _byteOffset;
  70207. /**
  70208. * Initialize binary writer with an initial byte length
  70209. * @param byteLength Initial byte length of the array buffer
  70210. */
  70211. constructor(byteLength: number);
  70212. /**
  70213. * Resize the array buffer to the specified byte length
  70214. * @param byteLength
  70215. */
  70216. private resizeBuffer;
  70217. /**
  70218. * Get an array buffer with the length of the byte offset
  70219. * @returns ArrayBuffer resized to the byte offset
  70220. */
  70221. getArrayBuffer(): ArrayBuffer;
  70222. /**
  70223. * Get the byte offset of the array buffer
  70224. * @returns byte offset
  70225. */
  70226. getByteOffset(): number;
  70227. /**
  70228. * Stores an UInt8 in the array buffer
  70229. * @param entry
  70230. * @param byteOffset If defined, specifies where to set the value as an offset.
  70231. */
  70232. setUInt8(entry: number, byteOffset?: number): void;
  70233. /**
  70234. * Gets an UInt32 in the array buffer
  70235. * @param entry
  70236. * @param byteOffset If defined, specifies where to set the value as an offset.
  70237. */
  70238. getUInt32(byteOffset: number): number;
  70239. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70240. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70241. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70242. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70243. /**
  70244. * Stores a Float32 in the array buffer
  70245. * @param entry
  70246. */
  70247. setFloat32(entry: number, byteOffset?: number): void;
  70248. /**
  70249. * Stores an UInt32 in the array buffer
  70250. * @param entry
  70251. * @param byteOffset If defined, specifies where to set the value as an offset.
  70252. */
  70253. setUInt32(entry: number, byteOffset?: number): void;
  70254. }
  70255. }
  70256. declare module BABYLON.GLTF2.Exporter {
  70257. /**
  70258. * @hidden
  70259. * Interface to store animation data.
  70260. */
  70261. export interface _IAnimationData {
  70262. /**
  70263. * Keyframe data.
  70264. */
  70265. inputs: number[];
  70266. /**
  70267. * Value data.
  70268. */
  70269. outputs: number[][];
  70270. /**
  70271. * Animation interpolation data.
  70272. */
  70273. samplerInterpolation: AnimationSamplerInterpolation;
  70274. /**
  70275. * Minimum keyframe value.
  70276. */
  70277. inputsMin: number;
  70278. /**
  70279. * Maximum keyframe value.
  70280. */
  70281. inputsMax: number;
  70282. }
  70283. /**
  70284. * @hidden
  70285. */
  70286. export interface _IAnimationInfo {
  70287. /**
  70288. * The target channel for the animation
  70289. */
  70290. animationChannelTargetPath: AnimationChannelTargetPath;
  70291. /**
  70292. * The glTF accessor type for the data.
  70293. */
  70294. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70295. /**
  70296. * Specifies if quaternions should be used.
  70297. */
  70298. useQuaternion: boolean;
  70299. }
  70300. /**
  70301. * @hidden
  70302. * Utility class for generating glTF animation data from BabylonJS.
  70303. */
  70304. export class _GLTFAnimation {
  70305. /**
  70306. * @ignore
  70307. *
  70308. * Creates glTF channel animation from BabylonJS animation.
  70309. * @param babylonTransformNode - BabylonJS mesh.
  70310. * @param animation - animation.
  70311. * @param animationChannelTargetPath - The target animation channel.
  70312. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70313. * @param useQuaternion - Specifies if quaternions are used.
  70314. * @returns nullable IAnimationData
  70315. */
  70316. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70317. private static _DeduceAnimationInfo;
  70318. /**
  70319. * @ignore
  70320. * Create node animations from the transform node animations
  70321. * @param babylonNode
  70322. * @param runtimeGLTFAnimation
  70323. * @param idleGLTFAnimations
  70324. * @param nodeMap
  70325. * @param nodes
  70326. * @param binaryWriter
  70327. * @param bufferViews
  70328. * @param accessors
  70329. * @param convertToRightHandedSystem
  70330. */
  70331. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70332. [key: number]: number;
  70333. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70334. /**
  70335. * @ignore
  70336. * Create node animations from the animation groups
  70337. * @param babylonScene
  70338. * @param glTFAnimations
  70339. * @param nodeMap
  70340. * @param nodes
  70341. * @param binaryWriter
  70342. * @param bufferViews
  70343. * @param accessors
  70344. * @param convertToRightHandedSystem
  70345. */
  70346. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70347. [key: number]: number;
  70348. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70349. private static AddAnimation;
  70350. /**
  70351. * Create a baked animation
  70352. * @param babylonTransformNode BabylonJS mesh
  70353. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70354. * @param animationChannelTargetPath animation target channel
  70355. * @param minFrame minimum animation frame
  70356. * @param maxFrame maximum animation frame
  70357. * @param fps frames per second of the animation
  70358. * @param inputs input key frames of the animation
  70359. * @param outputs output key frame data of the animation
  70360. * @param convertToRightHandedSystem converts the values to right-handed
  70361. * @param useQuaternion specifies if quaternions should be used
  70362. */
  70363. private static _CreateBakedAnimation;
  70364. private static _ConvertFactorToVector3OrQuaternion;
  70365. private static _SetInterpolatedValue;
  70366. /**
  70367. * Creates linear animation from the animation key frames
  70368. * @param babylonTransformNode BabylonJS mesh
  70369. * @param animation BabylonJS animation
  70370. * @param animationChannelTargetPath The target animation channel
  70371. * @param frameDelta The difference between the last and first frame of the animation
  70372. * @param inputs Array to store the key frame times
  70373. * @param outputs Array to store the key frame data
  70374. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70375. * @param useQuaternion Specifies if quaternions are used in the animation
  70376. */
  70377. private static _CreateLinearOrStepAnimation;
  70378. /**
  70379. * Creates cubic spline animation from the animation key frames
  70380. * @param babylonTransformNode BabylonJS mesh
  70381. * @param animation BabylonJS animation
  70382. * @param animationChannelTargetPath The target animation channel
  70383. * @param frameDelta The difference between the last and first frame of the animation
  70384. * @param inputs Array to store the key frame times
  70385. * @param outputs Array to store the key frame data
  70386. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70387. * @param useQuaternion Specifies if quaternions are used in the animation
  70388. */
  70389. private static _CreateCubicSplineAnimation;
  70390. private static _GetBasePositionRotationOrScale;
  70391. /**
  70392. * Adds a key frame value
  70393. * @param keyFrame
  70394. * @param animation
  70395. * @param outputs
  70396. * @param animationChannelTargetPath
  70397. * @param basePositionRotationOrScale
  70398. * @param convertToRightHandedSystem
  70399. * @param useQuaternion
  70400. */
  70401. private static _AddKeyframeValue;
  70402. /**
  70403. * Determine the interpolation based on the key frames
  70404. * @param keyFrames
  70405. * @param animationChannelTargetPath
  70406. * @param useQuaternion
  70407. */
  70408. private static _DeduceInterpolation;
  70409. /**
  70410. * Adds an input tangent or output tangent to the output data
  70411. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70412. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70413. * @param outputs The animation data by keyframe
  70414. * @param animationChannelTargetPath The target animation channel
  70415. * @param interpolation The interpolation type
  70416. * @param keyFrame The key frame with the animation data
  70417. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70418. * @param useQuaternion Specifies if quaternions are used
  70419. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70420. */
  70421. private static AddSplineTangent;
  70422. /**
  70423. * Get the minimum and maximum key frames' frame values
  70424. * @param keyFrames animation key frames
  70425. * @returns the minimum and maximum key frame value
  70426. */
  70427. private static calculateMinMaxKeyFrames;
  70428. }
  70429. }
  70430. declare module BABYLON.GLTF2.Exporter {
  70431. /** @hidden */
  70432. export var textureTransformPixelShader: {
  70433. name: string;
  70434. shader: string;
  70435. };
  70436. }
  70437. declare module BABYLON.GLTF2.Exporter.Extensions {
  70438. /**
  70439. * @hidden
  70440. */
  70441. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70442. /** Name of this extension */
  70443. readonly name: string;
  70444. /** Defines whether this extension is enabled */
  70445. enabled: boolean;
  70446. /** Defines whether this extension is required */
  70447. required: boolean;
  70448. /** Reference to the glTF exporter */
  70449. private _exporter;
  70450. constructor(exporter: _Exporter);
  70451. dispose(): void;
  70452. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70453. /**
  70454. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70455. * @param babylonTexture
  70456. * @param offset
  70457. * @param rotation
  70458. * @param scale
  70459. * @param scene
  70460. */
  70461. private _textureTransformTextureAsync;
  70462. }
  70463. }
  70464. declare module BABYLON.GLTF2.Exporter.Extensions {
  70465. /**
  70466. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70467. */
  70468. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70469. /** The name of this extension. */
  70470. readonly name: string;
  70471. /** Defines whether this extension is enabled. */
  70472. enabled: boolean;
  70473. /** Defines whether this extension is required */
  70474. required: boolean;
  70475. /** Reference to the glTF exporter */
  70476. private _exporter;
  70477. private _lights;
  70478. /** @hidden */
  70479. constructor(exporter: _Exporter);
  70480. /** @hidden */
  70481. dispose(): void;
  70482. /** @hidden */
  70483. onExporting(): void;
  70484. /**
  70485. * Define this method to modify the default behavior when exporting a node
  70486. * @param context The context when exporting the node
  70487. * @param node glTF node
  70488. * @param babylonNode BabylonJS node
  70489. * @returns nullable INode promise
  70490. */
  70491. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70492. }
  70493. }
  70494. declare module BABYLON {
  70495. /**
  70496. * Class for generating STL data from a Babylon scene.
  70497. */
  70498. export class STLExport {
  70499. /**
  70500. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70501. * @param meshes list defines the mesh to serialize
  70502. * @param download triggers the automatic download of the file.
  70503. * @param fileName changes the downloads fileName.
  70504. * @param binary changes the STL to a binary type.
  70505. * @param isLittleEndian toggle for binary type exporter.
  70506. * @returns the STL as UTF8 string
  70507. */
  70508. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70509. }
  70510. }
  70511. declare module "babylonjs-gltf2interface" {
  70512. export = BABYLON.GLTF2;
  70513. }
  70514. /**
  70515. * Module for glTF 2.0 Interface
  70516. */
  70517. declare module BABYLON.GLTF2 {
  70518. /**
  70519. * The datatype of the components in the attribute
  70520. */
  70521. const enum AccessorComponentType {
  70522. /**
  70523. * Byte
  70524. */
  70525. BYTE = 5120,
  70526. /**
  70527. * Unsigned Byte
  70528. */
  70529. UNSIGNED_BYTE = 5121,
  70530. /**
  70531. * Short
  70532. */
  70533. SHORT = 5122,
  70534. /**
  70535. * Unsigned Short
  70536. */
  70537. UNSIGNED_SHORT = 5123,
  70538. /**
  70539. * Unsigned Int
  70540. */
  70541. UNSIGNED_INT = 5125,
  70542. /**
  70543. * Float
  70544. */
  70545. FLOAT = 5126,
  70546. }
  70547. /**
  70548. * Specifies if the attirbute is a scalar, vector, or matrix
  70549. */
  70550. const enum AccessorType {
  70551. /**
  70552. * Scalar
  70553. */
  70554. SCALAR = "SCALAR",
  70555. /**
  70556. * Vector2
  70557. */
  70558. VEC2 = "VEC2",
  70559. /**
  70560. * Vector3
  70561. */
  70562. VEC3 = "VEC3",
  70563. /**
  70564. * Vector4
  70565. */
  70566. VEC4 = "VEC4",
  70567. /**
  70568. * Matrix2x2
  70569. */
  70570. MAT2 = "MAT2",
  70571. /**
  70572. * Matrix3x3
  70573. */
  70574. MAT3 = "MAT3",
  70575. /**
  70576. * Matrix4x4
  70577. */
  70578. MAT4 = "MAT4",
  70579. }
  70580. /**
  70581. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70582. */
  70583. const enum AnimationChannelTargetPath {
  70584. /**
  70585. * Translation
  70586. */
  70587. TRANSLATION = "translation",
  70588. /**
  70589. * Rotation
  70590. */
  70591. ROTATION = "rotation",
  70592. /**
  70593. * Scale
  70594. */
  70595. SCALE = "scale",
  70596. /**
  70597. * Weights
  70598. */
  70599. WEIGHTS = "weights",
  70600. }
  70601. /**
  70602. * Interpolation algorithm
  70603. */
  70604. const enum AnimationSamplerInterpolation {
  70605. /**
  70606. * The animated values are linearly interpolated between keyframes
  70607. */
  70608. LINEAR = "LINEAR",
  70609. /**
  70610. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70611. */
  70612. STEP = "STEP",
  70613. /**
  70614. * The animation's interpolation is computed using a cubic spline with specified tangents
  70615. */
  70616. CUBICSPLINE = "CUBICSPLINE",
  70617. }
  70618. /**
  70619. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70620. */
  70621. const enum CameraType {
  70622. /**
  70623. * A perspective camera containing properties to create a perspective projection matrix
  70624. */
  70625. PERSPECTIVE = "perspective",
  70626. /**
  70627. * An orthographic camera containing properties to create an orthographic projection matrix
  70628. */
  70629. ORTHOGRAPHIC = "orthographic",
  70630. }
  70631. /**
  70632. * The mime-type of the image
  70633. */
  70634. const enum ImageMimeType {
  70635. /**
  70636. * JPEG Mime-type
  70637. */
  70638. JPEG = "image/jpeg",
  70639. /**
  70640. * PNG Mime-type
  70641. */
  70642. PNG = "image/png",
  70643. }
  70644. /**
  70645. * The alpha rendering mode of the material
  70646. */
  70647. const enum MaterialAlphaMode {
  70648. /**
  70649. * The alpha value is ignored and the rendered output is fully opaque
  70650. */
  70651. OPAQUE = "OPAQUE",
  70652. /**
  70653. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70654. */
  70655. MASK = "MASK",
  70656. /**
  70657. * 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)
  70658. */
  70659. BLEND = "BLEND",
  70660. }
  70661. /**
  70662. * The type of the primitives to render
  70663. */
  70664. const enum MeshPrimitiveMode {
  70665. /**
  70666. * Points
  70667. */
  70668. POINTS = 0,
  70669. /**
  70670. * Lines
  70671. */
  70672. LINES = 1,
  70673. /**
  70674. * Line Loop
  70675. */
  70676. LINE_LOOP = 2,
  70677. /**
  70678. * Line Strip
  70679. */
  70680. LINE_STRIP = 3,
  70681. /**
  70682. * Triangles
  70683. */
  70684. TRIANGLES = 4,
  70685. /**
  70686. * Triangle Strip
  70687. */
  70688. TRIANGLE_STRIP = 5,
  70689. /**
  70690. * Triangle Fan
  70691. */
  70692. TRIANGLE_FAN = 6,
  70693. }
  70694. /**
  70695. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70696. */
  70697. const enum TextureMagFilter {
  70698. /**
  70699. * Nearest
  70700. */
  70701. NEAREST = 9728,
  70702. /**
  70703. * Linear
  70704. */
  70705. LINEAR = 9729,
  70706. }
  70707. /**
  70708. * Minification filter. All valid values correspond to WebGL enums
  70709. */
  70710. const enum TextureMinFilter {
  70711. /**
  70712. * Nearest
  70713. */
  70714. NEAREST = 9728,
  70715. /**
  70716. * Linear
  70717. */
  70718. LINEAR = 9729,
  70719. /**
  70720. * Nearest Mip-Map Nearest
  70721. */
  70722. NEAREST_MIPMAP_NEAREST = 9984,
  70723. /**
  70724. * Linear Mipmap Nearest
  70725. */
  70726. LINEAR_MIPMAP_NEAREST = 9985,
  70727. /**
  70728. * Nearest Mipmap Linear
  70729. */
  70730. NEAREST_MIPMAP_LINEAR = 9986,
  70731. /**
  70732. * Linear Mipmap Linear
  70733. */
  70734. LINEAR_MIPMAP_LINEAR = 9987,
  70735. }
  70736. /**
  70737. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70738. */
  70739. const enum TextureWrapMode {
  70740. /**
  70741. * Clamp to Edge
  70742. */
  70743. CLAMP_TO_EDGE = 33071,
  70744. /**
  70745. * Mirrored Repeat
  70746. */
  70747. MIRRORED_REPEAT = 33648,
  70748. /**
  70749. * Repeat
  70750. */
  70751. REPEAT = 10497,
  70752. }
  70753. /**
  70754. * glTF Property
  70755. */
  70756. interface IProperty {
  70757. /**
  70758. * Dictionary object with extension-specific objects
  70759. */
  70760. extensions?: {
  70761. [key: string]: any;
  70762. };
  70763. /**
  70764. * Application-Specific data
  70765. */
  70766. extras?: any;
  70767. }
  70768. /**
  70769. * glTF Child of Root Property
  70770. */
  70771. interface IChildRootProperty extends IProperty {
  70772. /**
  70773. * The user-defined name of this object
  70774. */
  70775. name?: string;
  70776. }
  70777. /**
  70778. * Indices of those attributes that deviate from their initialization value
  70779. */
  70780. interface IAccessorSparseIndices extends IProperty {
  70781. /**
  70782. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70783. */
  70784. bufferView: number;
  70785. /**
  70786. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70787. */
  70788. byteOffset?: number;
  70789. /**
  70790. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70791. */
  70792. componentType: AccessorComponentType;
  70793. }
  70794. /**
  70795. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70796. */
  70797. interface IAccessorSparseValues extends IProperty {
  70798. /**
  70799. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70800. */
  70801. bufferView: number;
  70802. /**
  70803. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70804. */
  70805. byteOffset?: number;
  70806. }
  70807. /**
  70808. * Sparse storage of attributes that deviate from their initialization value
  70809. */
  70810. interface IAccessorSparse extends IProperty {
  70811. /**
  70812. * The number of attributes encoded in this sparse accessor
  70813. */
  70814. count: number;
  70815. /**
  70816. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70817. */
  70818. indices: IAccessorSparseIndices;
  70819. /**
  70820. * 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
  70821. */
  70822. values: IAccessorSparseValues;
  70823. }
  70824. /**
  70825. * 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
  70826. */
  70827. interface IAccessor extends IChildRootProperty {
  70828. /**
  70829. * The index of the bufferview
  70830. */
  70831. bufferView?: number;
  70832. /**
  70833. * The offset relative to the start of the bufferView in bytes
  70834. */
  70835. byteOffset?: number;
  70836. /**
  70837. * The datatype of components in the attribute
  70838. */
  70839. componentType: AccessorComponentType;
  70840. /**
  70841. * Specifies whether integer data values should be normalized
  70842. */
  70843. normalized?: boolean;
  70844. /**
  70845. * The number of attributes referenced by this accessor
  70846. */
  70847. count: number;
  70848. /**
  70849. * Specifies if the attribute is a scalar, vector, or matrix
  70850. */
  70851. type: AccessorType;
  70852. /**
  70853. * Maximum value of each component in this attribute
  70854. */
  70855. max?: number[];
  70856. /**
  70857. * Minimum value of each component in this attribute
  70858. */
  70859. min?: number[];
  70860. /**
  70861. * Sparse storage of attributes that deviate from their initialization value
  70862. */
  70863. sparse?: IAccessorSparse;
  70864. }
  70865. /**
  70866. * Targets an animation's sampler at a node's property
  70867. */
  70868. interface IAnimationChannel extends IProperty {
  70869. /**
  70870. * The index of a sampler in this animation used to compute the value for the target
  70871. */
  70872. sampler: number;
  70873. /**
  70874. * The index of the node and TRS property to target
  70875. */
  70876. target: IAnimationChannelTarget;
  70877. }
  70878. /**
  70879. * The index of the node and TRS property that an animation channel targets
  70880. */
  70881. interface IAnimationChannelTarget extends IProperty {
  70882. /**
  70883. * The index of the node to target
  70884. */
  70885. node: number;
  70886. /**
  70887. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70888. */
  70889. path: AnimationChannelTargetPath;
  70890. }
  70891. /**
  70892. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70893. */
  70894. interface IAnimationSampler extends IProperty {
  70895. /**
  70896. * The index of an accessor containing keyframe input values, e.g., time
  70897. */
  70898. input: number;
  70899. /**
  70900. * Interpolation algorithm
  70901. */
  70902. interpolation?: AnimationSamplerInterpolation;
  70903. /**
  70904. * The index of an accessor, containing keyframe output values
  70905. */
  70906. output: number;
  70907. }
  70908. /**
  70909. * A keyframe animation
  70910. */
  70911. interface IAnimation extends IChildRootProperty {
  70912. /**
  70913. * An array of channels, each of which targets an animation's sampler at a node's property
  70914. */
  70915. channels: IAnimationChannel[];
  70916. /**
  70917. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70918. */
  70919. samplers: IAnimationSampler[];
  70920. }
  70921. /**
  70922. * Metadata about the glTF asset
  70923. */
  70924. interface IAsset extends IChildRootProperty {
  70925. /**
  70926. * A copyright message suitable for display to credit the content creator
  70927. */
  70928. copyright?: string;
  70929. /**
  70930. * Tool that generated this glTF model. Useful for debugging
  70931. */
  70932. generator?: string;
  70933. /**
  70934. * The glTF version that this asset targets
  70935. */
  70936. version: string;
  70937. /**
  70938. * The minimum glTF version that this asset targets
  70939. */
  70940. minVersion?: string;
  70941. }
  70942. /**
  70943. * A buffer points to binary geometry, animation, or skins
  70944. */
  70945. interface IBuffer extends IChildRootProperty {
  70946. /**
  70947. * 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
  70948. */
  70949. uri?: string;
  70950. /**
  70951. * The length of the buffer in bytes
  70952. */
  70953. byteLength: number;
  70954. }
  70955. /**
  70956. * A view into a buffer generally representing a subset of the buffer
  70957. */
  70958. interface IBufferView extends IChildRootProperty {
  70959. /**
  70960. * The index of the buffer
  70961. */
  70962. buffer: number;
  70963. /**
  70964. * The offset into the buffer in bytes
  70965. */
  70966. byteOffset?: number;
  70967. /**
  70968. * The lenth of the bufferView in bytes
  70969. */
  70970. byteLength: number;
  70971. /**
  70972. * The stride, in bytes
  70973. */
  70974. byteStride?: number;
  70975. }
  70976. /**
  70977. * An orthographic camera containing properties to create an orthographic projection matrix
  70978. */
  70979. interface ICameraOrthographic extends IProperty {
  70980. /**
  70981. * The floating-point horizontal magnification of the view. Must not be zero
  70982. */
  70983. xmag: number;
  70984. /**
  70985. * The floating-point vertical magnification of the view. Must not be zero
  70986. */
  70987. ymag: number;
  70988. /**
  70989. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70990. */
  70991. zfar: number;
  70992. /**
  70993. * The floating-point distance to the near clipping plane
  70994. */
  70995. znear: number;
  70996. }
  70997. /**
  70998. * A perspective camera containing properties to create a perspective projection matrix
  70999. */
  71000. interface ICameraPerspective extends IProperty {
  71001. /**
  71002. * The floating-point aspect ratio of the field of view
  71003. */
  71004. aspectRatio?: number;
  71005. /**
  71006. * The floating-point vertical field of view in radians
  71007. */
  71008. yfov: number;
  71009. /**
  71010. * The floating-point distance to the far clipping plane
  71011. */
  71012. zfar?: number;
  71013. /**
  71014. * The floating-point distance to the near clipping plane
  71015. */
  71016. znear: number;
  71017. }
  71018. /**
  71019. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71020. */
  71021. interface ICamera extends IChildRootProperty {
  71022. /**
  71023. * An orthographic camera containing properties to create an orthographic projection matrix
  71024. */
  71025. orthographic?: ICameraOrthographic;
  71026. /**
  71027. * A perspective camera containing properties to create a perspective projection matrix
  71028. */
  71029. perspective?: ICameraPerspective;
  71030. /**
  71031. * Specifies if the camera uses a perspective or orthographic projection
  71032. */
  71033. type: CameraType;
  71034. }
  71035. /**
  71036. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71037. */
  71038. interface IImage extends IChildRootProperty {
  71039. /**
  71040. * 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
  71041. */
  71042. uri?: string;
  71043. /**
  71044. * The image's MIME type
  71045. */
  71046. mimeType?: ImageMimeType;
  71047. /**
  71048. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71049. */
  71050. bufferView?: number;
  71051. }
  71052. /**
  71053. * Material Normal Texture Info
  71054. */
  71055. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71056. /**
  71057. * The scalar multiplier applied to each normal vector of the normal texture
  71058. */
  71059. scale?: number;
  71060. }
  71061. /**
  71062. * Material Occlusion Texture Info
  71063. */
  71064. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71065. /**
  71066. * A scalar multiplier controlling the amount of occlusion applied
  71067. */
  71068. strength?: number;
  71069. }
  71070. /**
  71071. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71072. */
  71073. interface IMaterialPbrMetallicRoughness {
  71074. /**
  71075. * The material's base color factor
  71076. */
  71077. baseColorFactor?: number[];
  71078. /**
  71079. * The base color texture
  71080. */
  71081. baseColorTexture?: ITextureInfo;
  71082. /**
  71083. * The metalness of the material
  71084. */
  71085. metallicFactor?: number;
  71086. /**
  71087. * The roughness of the material
  71088. */
  71089. roughnessFactor?: number;
  71090. /**
  71091. * The metallic-roughness texture
  71092. */
  71093. metallicRoughnessTexture?: ITextureInfo;
  71094. }
  71095. /**
  71096. * The material appearance of a primitive
  71097. */
  71098. interface IMaterial extends IChildRootProperty {
  71099. /**
  71100. * 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
  71101. */
  71102. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71103. /**
  71104. * The normal map texture
  71105. */
  71106. normalTexture?: IMaterialNormalTextureInfo;
  71107. /**
  71108. * The occlusion map texture
  71109. */
  71110. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71111. /**
  71112. * The emissive map texture
  71113. */
  71114. emissiveTexture?: ITextureInfo;
  71115. /**
  71116. * 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
  71117. */
  71118. emissiveFactor?: number[];
  71119. /**
  71120. * The alpha rendering mode of the material
  71121. */
  71122. alphaMode?: MaterialAlphaMode;
  71123. /**
  71124. * The alpha cutoff value of the material
  71125. */
  71126. alphaCutoff?: number;
  71127. /**
  71128. * Specifies whether the material is double sided
  71129. */
  71130. doubleSided?: boolean;
  71131. }
  71132. /**
  71133. * Geometry to be rendered with the given material
  71134. */
  71135. interface IMeshPrimitive extends IProperty {
  71136. /**
  71137. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71138. */
  71139. attributes: {
  71140. [name: string]: number;
  71141. };
  71142. /**
  71143. * The index of the accessor that contains the indices
  71144. */
  71145. indices?: number;
  71146. /**
  71147. * The index of the material to apply to this primitive when rendering
  71148. */
  71149. material?: number;
  71150. /**
  71151. * The type of primitives to render. All valid values correspond to WebGL enums
  71152. */
  71153. mode?: MeshPrimitiveMode;
  71154. /**
  71155. * 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
  71156. */
  71157. targets?: {
  71158. [name: string]: number;
  71159. }[];
  71160. }
  71161. /**
  71162. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71163. */
  71164. interface IMesh extends IChildRootProperty {
  71165. /**
  71166. * An array of primitives, each defining geometry to be rendered with a material
  71167. */
  71168. primitives: IMeshPrimitive[];
  71169. /**
  71170. * Array of weights to be applied to the Morph Targets
  71171. */
  71172. weights?: number[];
  71173. }
  71174. /**
  71175. * A node in the node hierarchy
  71176. */
  71177. interface INode extends IChildRootProperty {
  71178. /**
  71179. * The index of the camera referenced by this node
  71180. */
  71181. camera?: number;
  71182. /**
  71183. * The indices of this node's children
  71184. */
  71185. children?: number[];
  71186. /**
  71187. * The index of the skin referenced by this node
  71188. */
  71189. skin?: number;
  71190. /**
  71191. * A floating-point 4x4 transformation matrix stored in column-major order
  71192. */
  71193. matrix?: number[];
  71194. /**
  71195. * The index of the mesh in this node
  71196. */
  71197. mesh?: number;
  71198. /**
  71199. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71200. */
  71201. rotation?: number[];
  71202. /**
  71203. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71204. */
  71205. scale?: number[];
  71206. /**
  71207. * The node's translation along the x, y, and z axes
  71208. */
  71209. translation?: number[];
  71210. /**
  71211. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71212. */
  71213. weights?: number[];
  71214. }
  71215. /**
  71216. * Texture sampler properties for filtering and wrapping modes
  71217. */
  71218. interface ISampler extends IChildRootProperty {
  71219. /**
  71220. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71221. */
  71222. magFilter?: TextureMagFilter;
  71223. /**
  71224. * Minification filter. All valid values correspond to WebGL enums
  71225. */
  71226. minFilter?: TextureMinFilter;
  71227. /**
  71228. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71229. */
  71230. wrapS?: TextureWrapMode;
  71231. /**
  71232. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71233. */
  71234. wrapT?: TextureWrapMode;
  71235. }
  71236. /**
  71237. * The root nodes of a scene
  71238. */
  71239. interface IScene extends IChildRootProperty {
  71240. /**
  71241. * The indices of each root node
  71242. */
  71243. nodes: number[];
  71244. }
  71245. /**
  71246. * Joints and matrices defining a skin
  71247. */
  71248. interface ISkin extends IChildRootProperty {
  71249. /**
  71250. * 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
  71251. */
  71252. inverseBindMatrices?: number;
  71253. /**
  71254. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71255. */
  71256. skeleton?: number;
  71257. /**
  71258. * 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)
  71259. */
  71260. joints: number[];
  71261. }
  71262. /**
  71263. * A texture and its sampler
  71264. */
  71265. interface ITexture extends IChildRootProperty {
  71266. /**
  71267. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71268. */
  71269. sampler?: number;
  71270. /**
  71271. * The index of the image used by this texture
  71272. */
  71273. source: number;
  71274. }
  71275. /**
  71276. * Reference to a texture
  71277. */
  71278. interface ITextureInfo extends IProperty {
  71279. /**
  71280. * The index of the texture
  71281. */
  71282. index: number;
  71283. /**
  71284. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71285. */
  71286. texCoord?: number;
  71287. }
  71288. /**
  71289. * The root object for a glTF asset
  71290. */
  71291. interface IGLTF extends IProperty {
  71292. /**
  71293. * An array of accessors. An accessor is a typed view into a bufferView
  71294. */
  71295. accessors?: IAccessor[];
  71296. /**
  71297. * An array of keyframe animations
  71298. */
  71299. animations?: IAnimation[];
  71300. /**
  71301. * Metadata about the glTF asset
  71302. */
  71303. asset: IAsset;
  71304. /**
  71305. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71306. */
  71307. buffers?: IBuffer[];
  71308. /**
  71309. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71310. */
  71311. bufferViews?: IBufferView[];
  71312. /**
  71313. * An array of cameras
  71314. */
  71315. cameras?: ICamera[];
  71316. /**
  71317. * Names of glTF extensions used somewhere in this asset
  71318. */
  71319. extensionsUsed?: string[];
  71320. /**
  71321. * Names of glTF extensions required to properly load this asset
  71322. */
  71323. extensionsRequired?: string[];
  71324. /**
  71325. * An array of images. An image defines data used to create a texture
  71326. */
  71327. images?: IImage[];
  71328. /**
  71329. * An array of materials. A material defines the appearance of a primitive
  71330. */
  71331. materials?: IMaterial[];
  71332. /**
  71333. * An array of meshes. A mesh is a set of primitives to be rendered
  71334. */
  71335. meshes?: IMesh[];
  71336. /**
  71337. * An array of nodes
  71338. */
  71339. nodes?: INode[];
  71340. /**
  71341. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71342. */
  71343. samplers?: ISampler[];
  71344. /**
  71345. * The index of the default scene
  71346. */
  71347. scene?: number;
  71348. /**
  71349. * An array of scenes
  71350. */
  71351. scenes?: IScene[];
  71352. /**
  71353. * An array of skins. A skin is defined by joints and matrices
  71354. */
  71355. skins?: ISkin[];
  71356. /**
  71357. * An array of textures
  71358. */
  71359. textures?: ITexture[];
  71360. }
  71361. /**
  71362. * The glTF validation results
  71363. * @ignore
  71364. */
  71365. interface IGLTFValidationResults {
  71366. info: {
  71367. generator: string;
  71368. hasAnimations: boolean;
  71369. hasDefaultScene: boolean;
  71370. hasMaterials: boolean;
  71371. hasMorphTargets: boolean;
  71372. hasSkins: boolean;
  71373. hasTextures: boolean;
  71374. maxAttributesUsed: number;
  71375. primitivesCount: number
  71376. };
  71377. issues: {
  71378. messages: Array<string>;
  71379. numErrors: number;
  71380. numHints: number;
  71381. numInfos: number;
  71382. numWarnings: number;
  71383. truncated: boolean
  71384. };
  71385. mimeType: string;
  71386. uri: string;
  71387. validatedAt: string;
  71388. validatorVersion: string;
  71389. }
  71390. /**
  71391. * The glTF validation options
  71392. */
  71393. interface IGLTFValidationOptions {
  71394. /** Uri to use */
  71395. uri?: string;
  71396. /** Function used to load external resources */
  71397. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71398. /** Boolean indicating that we need to validate accessor data */
  71399. validateAccessorData?: boolean;
  71400. /** max number of issues allowed */
  71401. maxIssues?: number;
  71402. /** Ignored issues */
  71403. ignoredIssues?: Array<string>;
  71404. /** Value to override severy settings */
  71405. severityOverrides?: Object;
  71406. }
  71407. /**
  71408. * The glTF validator object
  71409. * @ignore
  71410. */
  71411. interface IGLTFValidator {
  71412. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71413. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71414. }
  71415. }
  71416. declare module BABYLON {
  71417. /** @hidden */
  71418. export var cellPixelShader: {
  71419. name: string;
  71420. shader: string;
  71421. };
  71422. }
  71423. declare module BABYLON {
  71424. /** @hidden */
  71425. export var cellVertexShader: {
  71426. name: string;
  71427. shader: string;
  71428. };
  71429. }
  71430. declare module BABYLON {
  71431. export class CellMaterial extends BABYLON.PushMaterial {
  71432. private _diffuseTexture;
  71433. diffuseTexture: BABYLON.BaseTexture;
  71434. diffuseColor: BABYLON.Color3;
  71435. _computeHighLevel: boolean;
  71436. computeHighLevel: boolean;
  71437. private _disableLighting;
  71438. disableLighting: boolean;
  71439. private _maxSimultaneousLights;
  71440. maxSimultaneousLights: number;
  71441. private _renderId;
  71442. constructor(name: string, scene: BABYLON.Scene);
  71443. needAlphaBlending(): boolean;
  71444. needAlphaTesting(): boolean;
  71445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71446. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71447. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71448. getAnimatables(): BABYLON.IAnimatable[];
  71449. getActiveTextures(): BABYLON.BaseTexture[];
  71450. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71451. dispose(forceDisposeEffect?: boolean): void;
  71452. getClassName(): string;
  71453. clone(name: string): CellMaterial;
  71454. serialize(): any;
  71455. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71456. }
  71457. }
  71458. declare module BABYLON {
  71459. export class CustomShaderStructure {
  71460. FragmentStore: string;
  71461. VertexStore: string;
  71462. constructor();
  71463. }
  71464. export class ShaderSpecialParts {
  71465. constructor();
  71466. Fragment_Begin: string;
  71467. Fragment_Definitions: string;
  71468. Fragment_MainBegin: string;
  71469. Fragment_Custom_Diffuse: string;
  71470. Fragment_Before_Lights: string;
  71471. Fragment_Before_Fog: string;
  71472. Fragment_Custom_Alpha: string;
  71473. Fragment_Before_FragColor: string;
  71474. Vertex_Begin: string;
  71475. Vertex_Definitions: string;
  71476. Vertex_MainBegin: string;
  71477. Vertex_Before_PositionUpdated: string;
  71478. Vertex_Before_NormalUpdated: string;
  71479. Vertex_MainEnd: string;
  71480. }
  71481. export class CustomMaterial extends BABYLON.StandardMaterial {
  71482. static ShaderIndexer: number;
  71483. CustomParts: ShaderSpecialParts;
  71484. _isCreatedShader: boolean;
  71485. _createdShaderName: string;
  71486. _customUniform: string[];
  71487. _newUniforms: string[];
  71488. _newUniformInstances: any[];
  71489. _newSamplerInstances: BABYLON.Texture[];
  71490. FragmentShader: string;
  71491. VertexShader: string;
  71492. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71493. ReviewUniform(name: string, arr: string[]): string[];
  71494. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71495. constructor(name: string, scene: BABYLON.Scene);
  71496. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71497. Fragment_Begin(shaderPart: string): CustomMaterial;
  71498. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71499. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71500. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71501. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71502. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71503. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71504. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71505. Vertex_Begin(shaderPart: string): CustomMaterial;
  71506. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71507. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71508. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71509. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71510. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71511. }
  71512. }
  71513. declare module BABYLON {
  71514. export class ShaderAlebdoParts {
  71515. constructor();
  71516. Fragment_Begin: string;
  71517. Fragment_Definitions: string;
  71518. Fragment_MainBegin: string;
  71519. Fragment_Custom_Albedo: string;
  71520. Fragment_Before_Lights: string;
  71521. Fragment_Custom_MetallicRoughness: string;
  71522. Fragment_Custom_MicroSurface: string;
  71523. Fragment_Before_Fog: string;
  71524. Fragment_Custom_Alpha: string;
  71525. Fragment_Before_FragColor: string;
  71526. Vertex_Begin: string;
  71527. Vertex_Definitions: string;
  71528. Vertex_MainBegin: string;
  71529. Vertex_Before_PositionUpdated: string;
  71530. Vertex_Before_NormalUpdated: string;
  71531. Vertex_MainEnd: string;
  71532. }
  71533. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71534. static ShaderIndexer: number;
  71535. CustomParts: ShaderAlebdoParts;
  71536. _isCreatedShader: boolean;
  71537. _createdShaderName: string;
  71538. _customUniform: string[];
  71539. _newUniforms: string[];
  71540. _newUniformInstances: any[];
  71541. _newSamplerInstances: BABYLON.Texture[];
  71542. FragmentShader: string;
  71543. VertexShader: string;
  71544. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71545. ReviewUniform(name: string, arr: string[]): string[];
  71546. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71547. constructor(name: string, scene: BABYLON.Scene);
  71548. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71549. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71550. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71551. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71552. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71553. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71554. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71555. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71556. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71557. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71558. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71559. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71560. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71561. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71562. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71563. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71564. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71565. }
  71566. }
  71567. declare module BABYLON {
  71568. /** @hidden */
  71569. export var firePixelShader: {
  71570. name: string;
  71571. shader: string;
  71572. };
  71573. }
  71574. declare module BABYLON {
  71575. /** @hidden */
  71576. export var fireVertexShader: {
  71577. name: string;
  71578. shader: string;
  71579. };
  71580. }
  71581. declare module BABYLON {
  71582. export class FireMaterial extends BABYLON.PushMaterial {
  71583. private _diffuseTexture;
  71584. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71585. private _distortionTexture;
  71586. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71587. private _opacityTexture;
  71588. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71589. diffuseColor: BABYLON.Color3;
  71590. speed: number;
  71591. private _scaledDiffuse;
  71592. private _renderId;
  71593. private _lastTime;
  71594. constructor(name: string, scene: BABYLON.Scene);
  71595. needAlphaBlending(): boolean;
  71596. needAlphaTesting(): boolean;
  71597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71600. getAnimatables(): BABYLON.IAnimatable[];
  71601. getActiveTextures(): BABYLON.BaseTexture[];
  71602. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71603. getClassName(): string;
  71604. dispose(forceDisposeEffect?: boolean): void;
  71605. clone(name: string): FireMaterial;
  71606. serialize(): any;
  71607. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71608. }
  71609. }
  71610. declare module BABYLON {
  71611. /** @hidden */
  71612. export var furPixelShader: {
  71613. name: string;
  71614. shader: string;
  71615. };
  71616. }
  71617. declare module BABYLON {
  71618. /** @hidden */
  71619. export var furVertexShader: {
  71620. name: string;
  71621. shader: string;
  71622. };
  71623. }
  71624. declare module BABYLON {
  71625. export class FurMaterial extends BABYLON.PushMaterial {
  71626. private _diffuseTexture;
  71627. diffuseTexture: BABYLON.BaseTexture;
  71628. private _heightTexture;
  71629. heightTexture: BABYLON.BaseTexture;
  71630. diffuseColor: BABYLON.Color3;
  71631. furLength: number;
  71632. furAngle: number;
  71633. furColor: BABYLON.Color3;
  71634. furOffset: number;
  71635. furSpacing: number;
  71636. furGravity: BABYLON.Vector3;
  71637. furSpeed: number;
  71638. furDensity: number;
  71639. furOcclusion: number;
  71640. furTexture: BABYLON.DynamicTexture;
  71641. private _disableLighting;
  71642. disableLighting: boolean;
  71643. private _maxSimultaneousLights;
  71644. maxSimultaneousLights: number;
  71645. highLevelFur: boolean;
  71646. _meshes: BABYLON.AbstractMesh[];
  71647. private _renderId;
  71648. private _furTime;
  71649. constructor(name: string, scene: BABYLON.Scene);
  71650. furTime: number;
  71651. needAlphaBlending(): boolean;
  71652. needAlphaTesting(): boolean;
  71653. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71654. updateFur(): void;
  71655. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71656. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71657. getAnimatables(): BABYLON.IAnimatable[];
  71658. getActiveTextures(): BABYLON.BaseTexture[];
  71659. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71660. dispose(forceDisposeEffect?: boolean): void;
  71661. clone(name: string): FurMaterial;
  71662. serialize(): any;
  71663. getClassName(): string;
  71664. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71665. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71666. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. /** @hidden */
  71671. export var gradientPixelShader: {
  71672. name: string;
  71673. shader: string;
  71674. };
  71675. }
  71676. declare module BABYLON {
  71677. /** @hidden */
  71678. export var gradientVertexShader: {
  71679. name: string;
  71680. shader: string;
  71681. };
  71682. }
  71683. declare module BABYLON {
  71684. export class GradientMaterial extends BABYLON.PushMaterial {
  71685. private _maxSimultaneousLights;
  71686. maxSimultaneousLights: number;
  71687. topColor: BABYLON.Color3;
  71688. topColorAlpha: number;
  71689. bottomColor: BABYLON.Color3;
  71690. bottomColorAlpha: number;
  71691. offset: number;
  71692. scale: number;
  71693. smoothness: number;
  71694. private _disableLighting;
  71695. disableLighting: boolean;
  71696. private _renderId;
  71697. constructor(name: string, scene: BABYLON.Scene);
  71698. needAlphaBlending(): boolean;
  71699. needAlphaTesting(): boolean;
  71700. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71701. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71702. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71703. getAnimatables(): BABYLON.IAnimatable[];
  71704. dispose(forceDisposeEffect?: boolean): void;
  71705. clone(name: string): GradientMaterial;
  71706. serialize(): any;
  71707. getClassName(): string;
  71708. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71709. }
  71710. }
  71711. declare module BABYLON {
  71712. /** @hidden */
  71713. export var gridPixelShader: {
  71714. name: string;
  71715. shader: string;
  71716. };
  71717. }
  71718. declare module BABYLON {
  71719. /** @hidden */
  71720. export var gridVertexShader: {
  71721. name: string;
  71722. shader: string;
  71723. };
  71724. }
  71725. declare module BABYLON {
  71726. /**
  71727. * The grid materials allows you to wrap any shape with a grid.
  71728. * Colors are customizable.
  71729. */
  71730. export class GridMaterial extends BABYLON.PushMaterial {
  71731. /**
  71732. * Main color of the grid (e.g. between lines)
  71733. */
  71734. mainColor: BABYLON.Color3;
  71735. /**
  71736. * Color of the grid lines.
  71737. */
  71738. lineColor: BABYLON.Color3;
  71739. /**
  71740. * The scale of the grid compared to unit.
  71741. */
  71742. gridRatio: number;
  71743. /**
  71744. * Allows setting an offset for the grid lines.
  71745. */
  71746. gridOffset: BABYLON.Vector3;
  71747. /**
  71748. * The frequency of thicker lines.
  71749. */
  71750. majorUnitFrequency: number;
  71751. /**
  71752. * The visibility of minor units in the grid.
  71753. */
  71754. minorUnitVisibility: number;
  71755. /**
  71756. * The grid opacity outside of the lines.
  71757. */
  71758. opacity: number;
  71759. /**
  71760. * Determine RBG output is premultiplied by alpha value.
  71761. */
  71762. preMultiplyAlpha: boolean;
  71763. private _opacityTexture;
  71764. opacityTexture: BABYLON.BaseTexture;
  71765. private _gridControl;
  71766. private _renderId;
  71767. /**
  71768. * constructor
  71769. * @param name The name given to the material in order to identify it afterwards.
  71770. * @param scene The scene the material is used in.
  71771. */
  71772. constructor(name: string, scene: BABYLON.Scene);
  71773. /**
  71774. * Returns wehter or not the grid requires alpha blending.
  71775. */
  71776. needAlphaBlending(): boolean;
  71777. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71778. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71779. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71780. /**
  71781. * Dispose the material and its associated resources.
  71782. * @param forceDisposeEffect will also dispose the used effect when true
  71783. */
  71784. dispose(forceDisposeEffect?: boolean): void;
  71785. clone(name: string): GridMaterial;
  71786. serialize(): any;
  71787. getClassName(): string;
  71788. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71789. }
  71790. }
  71791. declare module BABYLON {
  71792. /** @hidden */
  71793. export var lavaPixelShader: {
  71794. name: string;
  71795. shader: string;
  71796. };
  71797. }
  71798. declare module BABYLON {
  71799. /** @hidden */
  71800. export var lavaVertexShader: {
  71801. name: string;
  71802. shader: string;
  71803. };
  71804. }
  71805. declare module BABYLON {
  71806. export class LavaMaterial extends BABYLON.PushMaterial {
  71807. private _diffuseTexture;
  71808. diffuseTexture: BABYLON.BaseTexture;
  71809. noiseTexture: BABYLON.BaseTexture;
  71810. fogColor: BABYLON.Color3;
  71811. speed: number;
  71812. movingSpeed: number;
  71813. lowFrequencySpeed: number;
  71814. fogDensity: number;
  71815. private _lastTime;
  71816. diffuseColor: BABYLON.Color3;
  71817. private _disableLighting;
  71818. disableLighting: boolean;
  71819. private _unlit;
  71820. unlit: boolean;
  71821. private _maxSimultaneousLights;
  71822. maxSimultaneousLights: number;
  71823. private _scaledDiffuse;
  71824. private _renderId;
  71825. constructor(name: string, scene: BABYLON.Scene);
  71826. needAlphaBlending(): boolean;
  71827. needAlphaTesting(): boolean;
  71828. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71829. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71830. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71831. getAnimatables(): BABYLON.IAnimatable[];
  71832. getActiveTextures(): BABYLON.BaseTexture[];
  71833. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71834. dispose(forceDisposeEffect?: boolean): void;
  71835. clone(name: string): LavaMaterial;
  71836. serialize(): any;
  71837. getClassName(): string;
  71838. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71839. }
  71840. }
  71841. declare module BABYLON {
  71842. /** @hidden */
  71843. export var mixPixelShader: {
  71844. name: string;
  71845. shader: string;
  71846. };
  71847. }
  71848. declare module BABYLON {
  71849. /** @hidden */
  71850. export var mixVertexShader: {
  71851. name: string;
  71852. shader: string;
  71853. };
  71854. }
  71855. declare module BABYLON {
  71856. export class MixMaterial extends BABYLON.PushMaterial {
  71857. /**
  71858. * Mix textures
  71859. */
  71860. private _mixTexture1;
  71861. mixTexture1: BABYLON.BaseTexture;
  71862. private _mixTexture2;
  71863. mixTexture2: BABYLON.BaseTexture;
  71864. /**
  71865. * Diffuse textures
  71866. */
  71867. private _diffuseTexture1;
  71868. diffuseTexture1: BABYLON.Texture;
  71869. private _diffuseTexture2;
  71870. diffuseTexture2: BABYLON.Texture;
  71871. private _diffuseTexture3;
  71872. diffuseTexture3: BABYLON.Texture;
  71873. private _diffuseTexture4;
  71874. diffuseTexture4: BABYLON.Texture;
  71875. private _diffuseTexture5;
  71876. diffuseTexture5: BABYLON.Texture;
  71877. private _diffuseTexture6;
  71878. diffuseTexture6: BABYLON.Texture;
  71879. private _diffuseTexture7;
  71880. diffuseTexture7: BABYLON.Texture;
  71881. private _diffuseTexture8;
  71882. diffuseTexture8: BABYLON.Texture;
  71883. /**
  71884. * Uniforms
  71885. */
  71886. diffuseColor: BABYLON.Color3;
  71887. specularColor: BABYLON.Color3;
  71888. specularPower: number;
  71889. private _disableLighting;
  71890. disableLighting: boolean;
  71891. private _maxSimultaneousLights;
  71892. maxSimultaneousLights: number;
  71893. private _renderId;
  71894. constructor(name: string, scene: BABYLON.Scene);
  71895. needAlphaBlending(): boolean;
  71896. needAlphaTesting(): boolean;
  71897. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71898. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71899. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71900. getAnimatables(): BABYLON.IAnimatable[];
  71901. getActiveTextures(): BABYLON.BaseTexture[];
  71902. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71903. dispose(forceDisposeEffect?: boolean): void;
  71904. clone(name: string): MixMaterial;
  71905. serialize(): any;
  71906. getClassName(): string;
  71907. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71908. }
  71909. }
  71910. declare module BABYLON {
  71911. /** @hidden */
  71912. export var normalPixelShader: {
  71913. name: string;
  71914. shader: string;
  71915. };
  71916. }
  71917. declare module BABYLON {
  71918. /** @hidden */
  71919. export var normalVertexShader: {
  71920. name: string;
  71921. shader: string;
  71922. };
  71923. }
  71924. declare module BABYLON {
  71925. export class NormalMaterial extends BABYLON.PushMaterial {
  71926. private _diffuseTexture;
  71927. diffuseTexture: BABYLON.BaseTexture;
  71928. diffuseColor: BABYLON.Color3;
  71929. private _disableLighting;
  71930. disableLighting: boolean;
  71931. private _maxSimultaneousLights;
  71932. maxSimultaneousLights: number;
  71933. private _renderId;
  71934. constructor(name: string, scene: BABYLON.Scene);
  71935. needAlphaBlending(): boolean;
  71936. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71937. needAlphaTesting(): boolean;
  71938. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71939. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71940. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71941. getAnimatables(): BABYLON.IAnimatable[];
  71942. getActiveTextures(): BABYLON.BaseTexture[];
  71943. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71944. dispose(forceDisposeEffect?: boolean): void;
  71945. clone(name: string): NormalMaterial;
  71946. serialize(): any;
  71947. getClassName(): string;
  71948. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71949. }
  71950. }
  71951. declare module BABYLON {
  71952. /** @hidden */
  71953. export var shadowOnlyPixelShader: {
  71954. name: string;
  71955. shader: string;
  71956. };
  71957. }
  71958. declare module BABYLON {
  71959. /** @hidden */
  71960. export var shadowOnlyVertexShader: {
  71961. name: string;
  71962. shader: string;
  71963. };
  71964. }
  71965. declare module BABYLON {
  71966. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71967. private _renderId;
  71968. private _activeLight;
  71969. constructor(name: string, scene: BABYLON.Scene);
  71970. shadowColor: BABYLON.Color3;
  71971. needAlphaBlending(): boolean;
  71972. needAlphaTesting(): boolean;
  71973. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71974. activeLight: BABYLON.IShadowLight;
  71975. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71976. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71977. clone(name: string): ShadowOnlyMaterial;
  71978. serialize(): any;
  71979. getClassName(): string;
  71980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /** @hidden */
  71985. export var simplePixelShader: {
  71986. name: string;
  71987. shader: string;
  71988. };
  71989. }
  71990. declare module BABYLON {
  71991. /** @hidden */
  71992. export var simpleVertexShader: {
  71993. name: string;
  71994. shader: string;
  71995. };
  71996. }
  71997. declare module BABYLON {
  71998. export class SimpleMaterial extends BABYLON.PushMaterial {
  71999. private _diffuseTexture;
  72000. diffuseTexture: BABYLON.BaseTexture;
  72001. diffuseColor: BABYLON.Color3;
  72002. private _disableLighting;
  72003. disableLighting: boolean;
  72004. private _maxSimultaneousLights;
  72005. maxSimultaneousLights: number;
  72006. private _renderId;
  72007. constructor(name: string, scene: BABYLON.Scene);
  72008. needAlphaBlending(): boolean;
  72009. needAlphaTesting(): boolean;
  72010. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72013. getAnimatables(): BABYLON.IAnimatable[];
  72014. getActiveTextures(): BABYLON.BaseTexture[];
  72015. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72016. dispose(forceDisposeEffect?: boolean): void;
  72017. clone(name: string): SimpleMaterial;
  72018. serialize(): any;
  72019. getClassName(): string;
  72020. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72021. }
  72022. }
  72023. declare module BABYLON {
  72024. /** @hidden */
  72025. export var skyPixelShader: {
  72026. name: string;
  72027. shader: string;
  72028. };
  72029. }
  72030. declare module BABYLON {
  72031. /** @hidden */
  72032. export var skyVertexShader: {
  72033. name: string;
  72034. shader: string;
  72035. };
  72036. }
  72037. declare module BABYLON {
  72038. /**
  72039. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72040. * @see https://doc.babylonjs.com/extensions/sky
  72041. */
  72042. export class SkyMaterial extends BABYLON.PushMaterial {
  72043. /**
  72044. * Defines the overall luminance of sky in interval ]0, 1[.
  72045. */
  72046. luminance: number;
  72047. /**
  72048. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72049. */
  72050. turbidity: number;
  72051. /**
  72052. * Defines the sky appearance (light intensity).
  72053. */
  72054. rayleigh: number;
  72055. /**
  72056. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72057. */
  72058. mieCoefficient: number;
  72059. /**
  72060. * Defines the amount of haze particles following the Mie scattering theory.
  72061. */
  72062. mieDirectionalG: number;
  72063. /**
  72064. * Defines the distance of the sun according to the active scene camera.
  72065. */
  72066. distance: number;
  72067. /**
  72068. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72069. * "inclined".
  72070. */
  72071. inclination: number;
  72072. /**
  72073. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72074. * an object direction and a reference direction.
  72075. */
  72076. azimuth: number;
  72077. /**
  72078. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72079. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72080. */
  72081. sunPosition: BABYLON.Vector3;
  72082. /**
  72083. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72084. * .sunPosition property.
  72085. */
  72086. useSunPosition: boolean;
  72087. /**
  72088. * Defines an offset vector used to get a horizon offset.
  72089. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72090. */
  72091. cameraOffset: BABYLON.Vector3;
  72092. private _cameraPosition;
  72093. private _renderId;
  72094. /**
  72095. * Instantiates a new sky material.
  72096. * This material allows to create dynamic and texture free
  72097. * effects for skyboxes by taking care of the atmosphere state.
  72098. * @see https://doc.babylonjs.com/extensions/sky
  72099. * @param name Define the name of the material in the scene
  72100. * @param scene Define the scene the material belong to
  72101. */
  72102. constructor(name: string, scene: BABYLON.Scene);
  72103. /**
  72104. * Specifies if the material will require alpha blending
  72105. * @returns a boolean specifying if alpha blending is needed
  72106. */
  72107. needAlphaBlending(): boolean;
  72108. /**
  72109. * Specifies if this material should be rendered in alpha test mode
  72110. * @returns false as the sky material doesn't need alpha testing.
  72111. */
  72112. needAlphaTesting(): boolean;
  72113. /**
  72114. * Get the texture used for alpha test purpose.
  72115. * @returns null as the sky material has no texture.
  72116. */
  72117. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72118. /**
  72119. * Get if the submesh is ready to be used and all its information available.
  72120. * Child classes can use it to update shaders
  72121. * @param mesh defines the mesh to check
  72122. * @param subMesh defines which submesh to check
  72123. * @param useInstances specifies that instances should be used
  72124. * @returns a boolean indicating that the submesh is ready or not
  72125. */
  72126. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72127. /**
  72128. * Binds the submesh to this material by preparing the effect and shader to draw
  72129. * @param world defines the world transformation matrix
  72130. * @param mesh defines the mesh containing the submesh
  72131. * @param subMesh defines the submesh to bind the material to
  72132. */
  72133. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72134. /**
  72135. * Get the list of animatables in the material.
  72136. * @returns the list of animatables object used in the material
  72137. */
  72138. getAnimatables(): BABYLON.IAnimatable[];
  72139. /**
  72140. * Disposes the material
  72141. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72142. */
  72143. dispose(forceDisposeEffect?: boolean): void;
  72144. /**
  72145. * Makes a duplicate of the material, and gives it a new name
  72146. * @param name defines the new name for the duplicated material
  72147. * @returns the cloned material
  72148. */
  72149. clone(name: string): SkyMaterial;
  72150. /**
  72151. * Serializes this material in a JSON representation
  72152. * @returns the serialized material object
  72153. */
  72154. serialize(): any;
  72155. /**
  72156. * Gets the current class name of the material e.g. "SkyMaterial"
  72157. * Mainly use in serialization.
  72158. * @returns the class name
  72159. */
  72160. getClassName(): string;
  72161. /**
  72162. * Creates a sky material from parsed material data
  72163. * @param source defines the JSON representation of the material
  72164. * @param scene defines the hosting scene
  72165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72166. * @returns a new sky material
  72167. */
  72168. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72169. }
  72170. }
  72171. declare module BABYLON {
  72172. /** @hidden */
  72173. export var terrainPixelShader: {
  72174. name: string;
  72175. shader: string;
  72176. };
  72177. }
  72178. declare module BABYLON {
  72179. /** @hidden */
  72180. export var terrainVertexShader: {
  72181. name: string;
  72182. shader: string;
  72183. };
  72184. }
  72185. declare module BABYLON {
  72186. export class TerrainMaterial extends BABYLON.PushMaterial {
  72187. private _mixTexture;
  72188. mixTexture: BABYLON.BaseTexture;
  72189. private _diffuseTexture1;
  72190. diffuseTexture1: BABYLON.Texture;
  72191. private _diffuseTexture2;
  72192. diffuseTexture2: BABYLON.Texture;
  72193. private _diffuseTexture3;
  72194. diffuseTexture3: BABYLON.Texture;
  72195. private _bumpTexture1;
  72196. bumpTexture1: BABYLON.Texture;
  72197. private _bumpTexture2;
  72198. bumpTexture2: BABYLON.Texture;
  72199. private _bumpTexture3;
  72200. bumpTexture3: BABYLON.Texture;
  72201. diffuseColor: BABYLON.Color3;
  72202. specularColor: BABYLON.Color3;
  72203. specularPower: number;
  72204. private _disableLighting;
  72205. disableLighting: boolean;
  72206. private _maxSimultaneousLights;
  72207. maxSimultaneousLights: number;
  72208. private _renderId;
  72209. constructor(name: string, scene: BABYLON.Scene);
  72210. needAlphaBlending(): boolean;
  72211. needAlphaTesting(): boolean;
  72212. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72213. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72214. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72215. getAnimatables(): BABYLON.IAnimatable[];
  72216. getActiveTextures(): BABYLON.BaseTexture[];
  72217. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72218. dispose(forceDisposeEffect?: boolean): void;
  72219. clone(name: string): TerrainMaterial;
  72220. serialize(): any;
  72221. getClassName(): string;
  72222. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72223. }
  72224. }
  72225. declare module BABYLON {
  72226. /** @hidden */
  72227. export var triplanarPixelShader: {
  72228. name: string;
  72229. shader: string;
  72230. };
  72231. }
  72232. declare module BABYLON {
  72233. /** @hidden */
  72234. export var triplanarVertexShader: {
  72235. name: string;
  72236. shader: string;
  72237. };
  72238. }
  72239. declare module BABYLON {
  72240. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72241. mixTexture: BABYLON.BaseTexture;
  72242. private _diffuseTextureX;
  72243. diffuseTextureX: BABYLON.BaseTexture;
  72244. private _diffuseTextureY;
  72245. diffuseTextureY: BABYLON.BaseTexture;
  72246. private _diffuseTextureZ;
  72247. diffuseTextureZ: BABYLON.BaseTexture;
  72248. private _normalTextureX;
  72249. normalTextureX: BABYLON.BaseTexture;
  72250. private _normalTextureY;
  72251. normalTextureY: BABYLON.BaseTexture;
  72252. private _normalTextureZ;
  72253. normalTextureZ: BABYLON.BaseTexture;
  72254. tileSize: number;
  72255. diffuseColor: BABYLON.Color3;
  72256. specularColor: BABYLON.Color3;
  72257. specularPower: number;
  72258. private _disableLighting;
  72259. disableLighting: boolean;
  72260. private _maxSimultaneousLights;
  72261. maxSimultaneousLights: number;
  72262. private _renderId;
  72263. constructor(name: string, scene: BABYLON.Scene);
  72264. needAlphaBlending(): boolean;
  72265. needAlphaTesting(): boolean;
  72266. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72267. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72268. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72269. getAnimatables(): BABYLON.IAnimatable[];
  72270. getActiveTextures(): BABYLON.BaseTexture[];
  72271. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72272. dispose(forceDisposeEffect?: boolean): void;
  72273. clone(name: string): TriPlanarMaterial;
  72274. serialize(): any;
  72275. getClassName(): string;
  72276. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72277. }
  72278. }
  72279. declare module BABYLON {
  72280. /** @hidden */
  72281. export var waterPixelShader: {
  72282. name: string;
  72283. shader: string;
  72284. };
  72285. }
  72286. declare module BABYLON {
  72287. /** @hidden */
  72288. export var waterVertexShader: {
  72289. name: string;
  72290. shader: string;
  72291. };
  72292. }
  72293. declare module BABYLON {
  72294. export class WaterMaterial extends BABYLON.PushMaterial {
  72295. renderTargetSize: BABYLON.Vector2;
  72296. private _bumpTexture;
  72297. bumpTexture: BABYLON.BaseTexture;
  72298. diffuseColor: BABYLON.Color3;
  72299. specularColor: BABYLON.Color3;
  72300. specularPower: number;
  72301. private _disableLighting;
  72302. disableLighting: boolean;
  72303. private _maxSimultaneousLights;
  72304. maxSimultaneousLights: number;
  72305. /**
  72306. * @param {number}: Represents the wind force
  72307. */
  72308. windForce: number;
  72309. /**
  72310. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72311. */
  72312. windDirection: BABYLON.Vector2;
  72313. /**
  72314. * @param {number}: Wave height, represents the height of the waves
  72315. */
  72316. waveHeight: number;
  72317. /**
  72318. * @param {number}: Bump height, represents the bump height related to the bump map
  72319. */
  72320. bumpHeight: number;
  72321. /**
  72322. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72323. */
  72324. private _bumpSuperimpose;
  72325. bumpSuperimpose: boolean;
  72326. /**
  72327. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72328. */
  72329. private _fresnelSeparate;
  72330. fresnelSeparate: boolean;
  72331. /**
  72332. * @param {boolean}: bump Waves modify the reflection.
  72333. */
  72334. private _bumpAffectsReflection;
  72335. bumpAffectsReflection: boolean;
  72336. /**
  72337. * @param {number}: The water color blended with the refraction (near)
  72338. */
  72339. waterColor: BABYLON.Color3;
  72340. /**
  72341. * @param {number}: The blend factor related to the water color
  72342. */
  72343. colorBlendFactor: number;
  72344. /**
  72345. * @param {number}: The water color blended with the reflection (far)
  72346. */
  72347. waterColor2: BABYLON.Color3;
  72348. /**
  72349. * @param {number}: The blend factor related to the water color (reflection, far)
  72350. */
  72351. colorBlendFactor2: number;
  72352. /**
  72353. * @param {number}: Represents the maximum length of a wave
  72354. */
  72355. waveLength: number;
  72356. /**
  72357. * @param {number}: Defines the waves speed
  72358. */
  72359. waveSpeed: number;
  72360. /**
  72361. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72362. * will avoid calculating useless pixels in the pixel shader of the water material.
  72363. */
  72364. disableClipPlane: boolean;
  72365. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72366. private _mesh;
  72367. private _refractionRTT;
  72368. private _reflectionRTT;
  72369. private _reflectionTransform;
  72370. private _lastTime;
  72371. private _lastDeltaTime;
  72372. private _renderId;
  72373. private _useLogarithmicDepth;
  72374. private _waitingRenderList;
  72375. private _imageProcessingConfiguration;
  72376. private _imageProcessingObserver;
  72377. /**
  72378. * Gets a boolean indicating that current material needs to register RTT
  72379. */
  72380. readonly hasRenderTargetTextures: boolean;
  72381. /**
  72382. * Constructor
  72383. */
  72384. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72385. useLogarithmicDepth: boolean;
  72386. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72387. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72388. addToRenderList(node: any): void;
  72389. enableRenderTargets(enable: boolean): void;
  72390. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72391. readonly renderTargetsEnabled: boolean;
  72392. needAlphaBlending(): boolean;
  72393. needAlphaTesting(): boolean;
  72394. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72395. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72396. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72397. private _createRenderTargets;
  72398. getAnimatables(): BABYLON.IAnimatable[];
  72399. getActiveTextures(): BABYLON.BaseTexture[];
  72400. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72401. dispose(forceDisposeEffect?: boolean): void;
  72402. clone(name: string): WaterMaterial;
  72403. serialize(): any;
  72404. getClassName(): string;
  72405. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72406. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72407. }
  72408. }
  72409. declare module BABYLON {
  72410. /** @hidden */
  72411. export var asciiartPixelShader: {
  72412. name: string;
  72413. shader: string;
  72414. };
  72415. }
  72416. declare module BABYLON {
  72417. /**
  72418. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72419. *
  72420. * It basically takes care rendering the font front the given font size to a texture.
  72421. * This is used later on in the postprocess.
  72422. */
  72423. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72424. private _font;
  72425. private _text;
  72426. private _charSize;
  72427. /**
  72428. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72429. */
  72430. readonly charSize: number;
  72431. /**
  72432. * Create a new instance of the Ascii Art FontTexture class
  72433. * @param name the name of the texture
  72434. * @param font the font to use, use the W3C CSS notation
  72435. * @param text the caracter set to use in the rendering.
  72436. * @param scene the scene that owns the texture
  72437. */
  72438. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72439. /**
  72440. * Gets the max char width of a font.
  72441. * @param font the font to use, use the W3C CSS notation
  72442. * @return the max char width
  72443. */
  72444. private getFontWidth;
  72445. /**
  72446. * Gets the max char height of a font.
  72447. * @param font the font to use, use the W3C CSS notation
  72448. * @return the max char height
  72449. */
  72450. private getFontHeight;
  72451. /**
  72452. * Clones the current AsciiArtTexture.
  72453. * @return the clone of the texture.
  72454. */
  72455. clone(): AsciiArtFontTexture;
  72456. /**
  72457. * Parses a json object representing the texture and returns an instance of it.
  72458. * @param source the source JSON representation
  72459. * @param scene the scene to create the texture for
  72460. * @return the parsed texture
  72461. */
  72462. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72463. }
  72464. /**
  72465. * Option available in the Ascii Art Post Process.
  72466. */
  72467. export interface IAsciiArtPostProcessOptions {
  72468. /**
  72469. * The font to use following the w3c font definition.
  72470. */
  72471. font?: string;
  72472. /**
  72473. * The character set to use in the postprocess.
  72474. */
  72475. characterSet?: string;
  72476. /**
  72477. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72478. * This number is defined between 0 and 1;
  72479. */
  72480. mixToTile?: number;
  72481. /**
  72482. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72483. * This number is defined between 0 and 1;
  72484. */
  72485. mixToNormal?: number;
  72486. }
  72487. /**
  72488. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72489. *
  72490. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72491. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72492. */
  72493. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72494. /**
  72495. * The font texture used to render the char in the post process.
  72496. */
  72497. private _asciiArtFontTexture;
  72498. /**
  72499. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72500. * This number is defined between 0 and 1;
  72501. */
  72502. mixToTile: number;
  72503. /**
  72504. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72505. * This number is defined between 0 and 1;
  72506. */
  72507. mixToNormal: number;
  72508. /**
  72509. * Instantiates a new Ascii Art Post Process.
  72510. * @param name the name to give to the postprocess
  72511. * @camera the camera to apply the post process to.
  72512. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72513. */
  72514. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72515. }
  72516. }
  72517. declare module BABYLON {
  72518. /** @hidden */
  72519. export var digitalrainPixelShader: {
  72520. name: string;
  72521. shader: string;
  72522. };
  72523. }
  72524. declare module BABYLON {
  72525. /**
  72526. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72527. *
  72528. * It basically takes care rendering the font front the given font size to a texture.
  72529. * This is used later on in the postprocess.
  72530. */
  72531. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72532. private _font;
  72533. private _text;
  72534. private _charSize;
  72535. /**
  72536. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72537. */
  72538. readonly charSize: number;
  72539. /**
  72540. * Create a new instance of the Digital Rain FontTexture class
  72541. * @param name the name of the texture
  72542. * @param font the font to use, use the W3C CSS notation
  72543. * @param text the caracter set to use in the rendering.
  72544. * @param scene the scene that owns the texture
  72545. */
  72546. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72547. /**
  72548. * Gets the max char width of a font.
  72549. * @param font the font to use, use the W3C CSS notation
  72550. * @return the max char width
  72551. */
  72552. private getFontWidth;
  72553. /**
  72554. * Gets the max char height of a font.
  72555. * @param font the font to use, use the W3C CSS notation
  72556. * @return the max char height
  72557. */
  72558. private getFontHeight;
  72559. /**
  72560. * Clones the current DigitalRainFontTexture.
  72561. * @return the clone of the texture.
  72562. */
  72563. clone(): DigitalRainFontTexture;
  72564. /**
  72565. * Parses a json object representing the texture and returns an instance of it.
  72566. * @param source the source JSON representation
  72567. * @param scene the scene to create the texture for
  72568. * @return the parsed texture
  72569. */
  72570. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72571. }
  72572. /**
  72573. * Option available in the Digital Rain Post Process.
  72574. */
  72575. export interface IDigitalRainPostProcessOptions {
  72576. /**
  72577. * The font to use following the w3c font definition.
  72578. */
  72579. font?: string;
  72580. /**
  72581. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72582. * This number is defined between 0 and 1;
  72583. */
  72584. mixToTile?: number;
  72585. /**
  72586. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72587. * This number is defined between 0 and 1;
  72588. */
  72589. mixToNormal?: number;
  72590. }
  72591. /**
  72592. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72593. *
  72594. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72595. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72596. */
  72597. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72598. /**
  72599. * The font texture used to render the char in the post process.
  72600. */
  72601. private _digitalRainFontTexture;
  72602. /**
  72603. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72604. * This number is defined between 0 and 1;
  72605. */
  72606. mixToTile: number;
  72607. /**
  72608. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72609. * This number is defined between 0 and 1;
  72610. */
  72611. mixToNormal: number;
  72612. /**
  72613. * Instantiates a new Digital Rain Post Process.
  72614. * @param name the name to give to the postprocess
  72615. * @camera the camera to apply the post process to.
  72616. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72617. */
  72618. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72619. }
  72620. }
  72621. declare module BABYLON {
  72622. /** @hidden */
  72623. export var oceanPostProcessPixelShader: {
  72624. name: string;
  72625. shader: string;
  72626. };
  72627. }
  72628. declare module BABYLON {
  72629. /**
  72630. * Option available in the Ocean Post Process.
  72631. */
  72632. export interface IOceanPostProcessOptions {
  72633. /**
  72634. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72635. */
  72636. reflectionSize?: number | {
  72637. width: number;
  72638. height: number;
  72639. } | {
  72640. ratio: number;
  72641. };
  72642. /**
  72643. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72644. */
  72645. refractionSize?: number | {
  72646. width: number;
  72647. height: number;
  72648. } | {
  72649. ratio: number;
  72650. };
  72651. }
  72652. /**
  72653. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72654. *
  72655. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72656. * Example usage:
  72657. * var pp = new OceanPostProcess("myOcean", camera);
  72658. * pp.reflectionEnabled = true;
  72659. * pp.refractionEnabled = true;
  72660. */
  72661. export class OceanPostProcess extends BABYLON.PostProcess {
  72662. /**
  72663. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72664. */
  72665. /**
  72666. * Sets weither or not the real-time reflection is enabled on the ocean.
  72667. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72668. */
  72669. reflectionEnabled: boolean;
  72670. /**
  72671. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72672. */
  72673. /**
  72674. * Sets weither or not the real-time refraction is enabled on the ocean.
  72675. * Is set to true, the refraction render target texture will be used as refraction texture.
  72676. */
  72677. refractionEnabled: boolean;
  72678. /**
  72679. * Gets wether or not the post-processes is supported by the running hardware.
  72680. * This requires draw buffer supports.
  72681. */
  72682. readonly isSupported: boolean;
  72683. /**
  72684. * This is the reflection mirror texture used to display reflections on the ocean.
  72685. * By default, render list is empty.
  72686. */
  72687. reflectionTexture: BABYLON.MirrorTexture;
  72688. /**
  72689. * This is the refraction render target texture used to display refraction on the ocean.
  72690. * By default, render list is empty.
  72691. */
  72692. refractionTexture: BABYLON.RenderTargetTexture;
  72693. private _time;
  72694. private _cameraRotation;
  72695. private _cameraViewMatrix;
  72696. private _reflectionEnabled;
  72697. private _refractionEnabled;
  72698. private _geometryRenderer;
  72699. /**
  72700. * Instantiates a new Ocean Post Process.
  72701. * @param name the name to give to the postprocess.
  72702. * @camera the camera to apply the post process to.
  72703. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72704. */
  72705. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72706. /**
  72707. * Returns the appropriate defines according to the current configuration.
  72708. */
  72709. private _getDefines;
  72710. /**
  72711. * Computes the current camera rotation as the shader requires a camera rotation.
  72712. */
  72713. private _computeCameraRotation;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /** @hidden */
  72718. export var brickProceduralTexturePixelShader: {
  72719. name: string;
  72720. shader: string;
  72721. };
  72722. }
  72723. declare module BABYLON {
  72724. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72725. private _numberOfBricksHeight;
  72726. private _numberOfBricksWidth;
  72727. private _jointColor;
  72728. private _brickColor;
  72729. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72730. updateShaderUniforms(): void;
  72731. numberOfBricksHeight: number;
  72732. numberOfBricksWidth: number;
  72733. jointColor: BABYLON.Color3;
  72734. brickColor: BABYLON.Color3;
  72735. /**
  72736. * Serializes this brick procedural texture
  72737. * @returns a serialized brick procedural texture object
  72738. */
  72739. serialize(): any;
  72740. /**
  72741. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72742. * @param parsedTexture defines parsed texture data
  72743. * @param scene defines the current scene
  72744. * @param rootUrl defines the root URL containing brick procedural texture information
  72745. * @returns a parsed Brick Procedural BABYLON.Texture
  72746. */
  72747. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72748. }
  72749. }
  72750. declare module BABYLON {
  72751. /** @hidden */
  72752. export var cloudProceduralTexturePixelShader: {
  72753. name: string;
  72754. shader: string;
  72755. };
  72756. }
  72757. declare module BABYLON {
  72758. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72759. private _skyColor;
  72760. private _cloudColor;
  72761. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72762. updateShaderUniforms(): void;
  72763. skyColor: BABYLON.Color4;
  72764. cloudColor: BABYLON.Color4;
  72765. /**
  72766. * Serializes this cloud procedural texture
  72767. * @returns a serialized cloud procedural texture object
  72768. */
  72769. serialize(): any;
  72770. /**
  72771. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72772. * @param parsedTexture defines parsed texture data
  72773. * @param scene defines the current scene
  72774. * @param rootUrl defines the root URL containing cloud procedural texture information
  72775. * @returns a parsed Cloud Procedural BABYLON.Texture
  72776. */
  72777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72778. }
  72779. }
  72780. declare module BABYLON {
  72781. /** @hidden */
  72782. export var fireProceduralTexturePixelShader: {
  72783. name: string;
  72784. shader: string;
  72785. };
  72786. }
  72787. declare module BABYLON {
  72788. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72789. private _time;
  72790. private _speed;
  72791. private _autoGenerateTime;
  72792. private _fireColors;
  72793. private _alphaThreshold;
  72794. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72795. updateShaderUniforms(): void;
  72796. render(useCameraPostProcess?: boolean): void;
  72797. static readonly PurpleFireColors: BABYLON.Color3[];
  72798. static readonly GreenFireColors: BABYLON.Color3[];
  72799. static readonly RedFireColors: BABYLON.Color3[];
  72800. static readonly BlueFireColors: BABYLON.Color3[];
  72801. autoGenerateTime: boolean;
  72802. fireColors: BABYLON.Color3[];
  72803. time: number;
  72804. speed: BABYLON.Vector2;
  72805. alphaThreshold: number;
  72806. /**
  72807. * Serializes this fire procedural texture
  72808. * @returns a serialized fire procedural texture object
  72809. */
  72810. serialize(): any;
  72811. /**
  72812. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72813. * @param parsedTexture defines parsed texture data
  72814. * @param scene defines the current scene
  72815. * @param rootUrl defines the root URL containing fire procedural texture information
  72816. * @returns a parsed Fire Procedural BABYLON.Texture
  72817. */
  72818. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72819. }
  72820. }
  72821. declare module BABYLON {
  72822. /** @hidden */
  72823. export var grassProceduralTexturePixelShader: {
  72824. name: string;
  72825. shader: string;
  72826. };
  72827. }
  72828. declare module BABYLON {
  72829. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72830. private _grassColors;
  72831. private _groundColor;
  72832. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72833. updateShaderUniforms(): void;
  72834. grassColors: BABYLON.Color3[];
  72835. groundColor: BABYLON.Color3;
  72836. /**
  72837. * Serializes this grass procedural texture
  72838. * @returns a serialized grass procedural texture object
  72839. */
  72840. serialize(): any;
  72841. /**
  72842. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72843. * @param parsedTexture defines parsed texture data
  72844. * @param scene defines the current scene
  72845. * @param rootUrl defines the root URL containing grass procedural texture information
  72846. * @returns a parsed Grass Procedural BABYLON.Texture
  72847. */
  72848. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72849. }
  72850. }
  72851. declare module BABYLON {
  72852. /** @hidden */
  72853. export var marbleProceduralTexturePixelShader: {
  72854. name: string;
  72855. shader: string;
  72856. };
  72857. }
  72858. declare module BABYLON {
  72859. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72860. private _numberOfTilesHeight;
  72861. private _numberOfTilesWidth;
  72862. private _amplitude;
  72863. private _jointColor;
  72864. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72865. updateShaderUniforms(): void;
  72866. numberOfTilesHeight: number;
  72867. amplitude: number;
  72868. numberOfTilesWidth: number;
  72869. jointColor: BABYLON.Color3;
  72870. /**
  72871. * Serializes this marble procedural texture
  72872. * @returns a serialized marble procedural texture object
  72873. */
  72874. serialize(): any;
  72875. /**
  72876. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72877. * @param parsedTexture defines parsed texture data
  72878. * @param scene defines the current scene
  72879. * @param rootUrl defines the root URL containing marble procedural texture information
  72880. * @returns a parsed Marble Procedural BABYLON.Texture
  72881. */
  72882. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72883. }
  72884. }
  72885. declare module BABYLON {
  72886. /** @hidden */
  72887. export var normalMapProceduralTexturePixelShader: {
  72888. name: string;
  72889. shader: string;
  72890. };
  72891. }
  72892. declare module BABYLON {
  72893. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72894. private _baseTexture;
  72895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72896. updateShaderUniforms(): void;
  72897. render(useCameraPostProcess?: boolean): void;
  72898. resize(size: any, generateMipMaps: any): void;
  72899. baseTexture: BABYLON.Texture;
  72900. /**
  72901. * Serializes this normal map procedural texture
  72902. * @returns a serialized normal map procedural texture object
  72903. */
  72904. serialize(): any;
  72905. /**
  72906. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72907. * @param parsedTexture defines parsed texture data
  72908. * @param scene defines the current scene
  72909. * @param rootUrl defines the root URL containing normal map procedural texture information
  72910. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72911. */
  72912. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72913. }
  72914. }
  72915. declare module BABYLON {
  72916. /** @hidden */
  72917. export var perlinNoiseProceduralTexturePixelShader: {
  72918. name: string;
  72919. shader: string;
  72920. };
  72921. }
  72922. declare module BABYLON {
  72923. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72924. time: number;
  72925. timeScale: number;
  72926. translationSpeed: number;
  72927. private _currentTranslation;
  72928. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72929. updateShaderUniforms(): void;
  72930. render(useCameraPostProcess?: boolean): void;
  72931. resize(size: any, generateMipMaps: any): void;
  72932. /**
  72933. * Serializes this perlin noise procedural texture
  72934. * @returns a serialized perlin noise procedural texture object
  72935. */
  72936. serialize(): any;
  72937. /**
  72938. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72939. * @param parsedTexture defines parsed texture data
  72940. * @param scene defines the current scene
  72941. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72942. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72943. */
  72944. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /** @hidden */
  72949. export var roadProceduralTexturePixelShader: {
  72950. name: string;
  72951. shader: string;
  72952. };
  72953. }
  72954. declare module BABYLON {
  72955. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72956. private _roadColor;
  72957. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72958. updateShaderUniforms(): void;
  72959. roadColor: BABYLON.Color3;
  72960. /**
  72961. * Serializes this road procedural texture
  72962. * @returns a serialized road procedural texture object
  72963. */
  72964. serialize(): any;
  72965. /**
  72966. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72967. * @param parsedTexture defines parsed texture data
  72968. * @param scene defines the current scene
  72969. * @param rootUrl defines the root URL containing road procedural texture information
  72970. * @returns a parsed Road Procedural BABYLON.Texture
  72971. */
  72972. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72973. }
  72974. }
  72975. declare module BABYLON {
  72976. /** @hidden */
  72977. export var starfieldProceduralTexturePixelShader: {
  72978. name: string;
  72979. shader: string;
  72980. };
  72981. }
  72982. declare module BABYLON {
  72983. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72984. private _time;
  72985. private _alpha;
  72986. private _beta;
  72987. private _zoom;
  72988. private _formuparam;
  72989. private _stepsize;
  72990. private _tile;
  72991. private _brightness;
  72992. private _darkmatter;
  72993. private _distfading;
  72994. private _saturation;
  72995. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72996. updateShaderUniforms(): void;
  72997. time: number;
  72998. alpha: number;
  72999. beta: number;
  73000. formuparam: number;
  73001. stepsize: number;
  73002. zoom: number;
  73003. tile: number;
  73004. brightness: number;
  73005. darkmatter: number;
  73006. distfading: number;
  73007. saturation: number;
  73008. /**
  73009. * Serializes this starfield procedural texture
  73010. * @returns a serialized starfield procedural texture object
  73011. */
  73012. serialize(): any;
  73013. /**
  73014. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73015. * @param parsedTexture defines parsed texture data
  73016. * @param scene defines the current scene
  73017. * @param rootUrl defines the root URL containing startfield procedural texture information
  73018. * @returns a parsed Starfield Procedural BABYLON.Texture
  73019. */
  73020. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73021. }
  73022. }
  73023. declare module BABYLON {
  73024. /** @hidden */
  73025. export var woodProceduralTexturePixelShader: {
  73026. name: string;
  73027. shader: string;
  73028. };
  73029. }
  73030. declare module BABYLON {
  73031. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73032. private _ampScale;
  73033. private _woodColor;
  73034. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73035. updateShaderUniforms(): void;
  73036. ampScale: number;
  73037. woodColor: BABYLON.Color3;
  73038. /**
  73039. * Serializes this wood procedural texture
  73040. * @returns a serialized wood procedural texture object
  73041. */
  73042. serialize(): any;
  73043. /**
  73044. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73045. * @param parsedTexture defines parsed texture data
  73046. * @param scene defines the current scene
  73047. * @param rootUrl defines the root URL containing wood procedural texture information
  73048. * @returns a parsed Wood Procedural BABYLON.Texture
  73049. */
  73050. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73051. }
  73052. }