documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4090. static readonly GEQUAL: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areLightsDisposed: boolean;
  7614. /** @hidden */
  7615. _areAttributesDirty: boolean;
  7616. /** @hidden */
  7617. _areTexturesDirty: boolean;
  7618. /** @hidden */
  7619. _areFresnelDirty: boolean;
  7620. /** @hidden */
  7621. _areMiscDirty: boolean;
  7622. /** @hidden */
  7623. _areImageProcessingDirty: boolean;
  7624. /** @hidden */
  7625. _normals: boolean;
  7626. /** @hidden */
  7627. _uvs: boolean;
  7628. /** @hidden */
  7629. _needNormals: boolean;
  7630. /** @hidden */
  7631. _needUVs: boolean;
  7632. [id: string]: any;
  7633. /**
  7634. * Specifies if the material needs to be re-calculated
  7635. */
  7636. readonly isDirty: boolean;
  7637. /**
  7638. * Marks the material to indicate that it has been re-calculated
  7639. */
  7640. markAsProcessed(): void;
  7641. /**
  7642. * Marks the material to indicate that it needs to be re-calculated
  7643. */
  7644. markAsUnprocessed(): void;
  7645. /**
  7646. * Marks the material to indicate all of its defines need to be re-calculated
  7647. */
  7648. markAllAsDirty(): void;
  7649. /**
  7650. * Marks the material to indicate that image processing needs to be re-calculated
  7651. */
  7652. markAsImageProcessingDirty(): void;
  7653. /**
  7654. * Marks the material to indicate the lights need to be re-calculated
  7655. * @param disposed Defines whether the light is dirty due to dispose or not
  7656. */
  7657. markAsLightDirty(disposed?: boolean): void;
  7658. /**
  7659. * Marks the attribute state as changed
  7660. */
  7661. markAsAttributesDirty(): void;
  7662. /**
  7663. * Marks the texture state as changed
  7664. */
  7665. markAsTexturesDirty(): void;
  7666. /**
  7667. * Marks the fresnel state as changed
  7668. */
  7669. markAsFresnelDirty(): void;
  7670. /**
  7671. * Marks the misc state as changed
  7672. */
  7673. markAsMiscDirty(): void;
  7674. /**
  7675. * Rebuilds the material defines
  7676. */
  7677. rebuild(): void;
  7678. /**
  7679. * Specifies if two material defines are equal
  7680. * @param other - A material define instance to compare to
  7681. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7682. */
  7683. isEqual(other: MaterialDefines): boolean;
  7684. /**
  7685. * Clones this instance's defines to another instance
  7686. * @param other - material defines to clone values to
  7687. */
  7688. cloneTo(other: MaterialDefines): void;
  7689. /**
  7690. * Resets the material define values
  7691. */
  7692. reset(): void;
  7693. /**
  7694. * Converts the material define values to a string
  7695. * @returns - String of material define information
  7696. */
  7697. toString(): string;
  7698. }
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7704. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7706. */
  7707. export class ColorCurves {
  7708. private _dirty;
  7709. private _tempColor;
  7710. private _globalCurve;
  7711. private _highlightsCurve;
  7712. private _midtonesCurve;
  7713. private _shadowsCurve;
  7714. private _positiveCurve;
  7715. private _negativeCurve;
  7716. private _globalHue;
  7717. private _globalDensity;
  7718. private _globalSaturation;
  7719. private _globalExposure;
  7720. /**
  7721. * Gets the global Hue value.
  7722. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7723. */
  7724. /**
  7725. * Sets the global Hue value.
  7726. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7727. */
  7728. globalHue: number;
  7729. /**
  7730. * Gets the global Density value.
  7731. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7732. * Values less than zero provide a filter of opposite hue.
  7733. */
  7734. /**
  7735. * Sets the global Density value.
  7736. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. globalDensity: number;
  7740. /**
  7741. * Gets the global Saturation value.
  7742. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7743. */
  7744. /**
  7745. * Sets the global Saturation value.
  7746. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7747. */
  7748. globalSaturation: number;
  7749. /**
  7750. * Gets the global Exposure value.
  7751. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7752. */
  7753. /**
  7754. * Sets the global Exposure value.
  7755. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7756. */
  7757. globalExposure: number;
  7758. private _highlightsHue;
  7759. private _highlightsDensity;
  7760. private _highlightsSaturation;
  7761. private _highlightsExposure;
  7762. /**
  7763. * Gets the highlights Hue value.
  7764. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7765. */
  7766. /**
  7767. * Sets the highlights Hue value.
  7768. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7769. */
  7770. highlightsHue: number;
  7771. /**
  7772. * Gets the highlights Density value.
  7773. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7774. * Values less than zero provide a filter of opposite hue.
  7775. */
  7776. /**
  7777. * Sets the highlights Density value.
  7778. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. highlightsDensity: number;
  7782. /**
  7783. * Gets the highlights Saturation value.
  7784. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7785. */
  7786. /**
  7787. * Sets the highlights Saturation value.
  7788. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7789. */
  7790. highlightsSaturation: number;
  7791. /**
  7792. * Gets the highlights Exposure value.
  7793. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7794. */
  7795. /**
  7796. * Sets the highlights Exposure value.
  7797. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7798. */
  7799. highlightsExposure: number;
  7800. private _midtonesHue;
  7801. private _midtonesDensity;
  7802. private _midtonesSaturation;
  7803. private _midtonesExposure;
  7804. /**
  7805. * Gets the midtones Hue value.
  7806. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7807. */
  7808. /**
  7809. * Sets the midtones Hue value.
  7810. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7811. */
  7812. midtonesHue: number;
  7813. /**
  7814. * Gets the midtones Density value.
  7815. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the midtones Density value.
  7820. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. midtonesDensity: number;
  7824. /**
  7825. * Gets the midtones Saturation value.
  7826. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7827. */
  7828. /**
  7829. * Sets the midtones Saturation value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7831. */
  7832. midtonesSaturation: number;
  7833. /**
  7834. * Gets the midtones Exposure value.
  7835. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7836. */
  7837. /**
  7838. * Sets the midtones Exposure value.
  7839. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7840. */
  7841. midtonesExposure: number;
  7842. private _shadowsHue;
  7843. private _shadowsDensity;
  7844. private _shadowsSaturation;
  7845. private _shadowsExposure;
  7846. /**
  7847. * Gets the shadows Hue value.
  7848. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7849. */
  7850. /**
  7851. * Sets the shadows Hue value.
  7852. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7853. */
  7854. shadowsHue: number;
  7855. /**
  7856. * Gets the shadows Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the shadows Density value.
  7862. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. shadowsDensity: number;
  7866. /**
  7867. * Gets the shadows Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. /**
  7871. * Sets the shadows Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. shadowsSaturation: number;
  7875. /**
  7876. * Gets the shadows Exposure value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7878. */
  7879. /**
  7880. * Sets the shadows Exposure value.
  7881. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7882. */
  7883. shadowsExposure: number;
  7884. /**
  7885. * Returns the class name
  7886. * @returns The class name
  7887. */
  7888. getClassName(): string;
  7889. /**
  7890. * Binds the color curves to the shader.
  7891. * @param colorCurves The color curve to bind
  7892. * @param effect The effect to bind to
  7893. * @param positiveUniform The positive uniform shader parameter
  7894. * @param neutralUniform The neutral uniform shader parameter
  7895. * @param negativeUniform The negative uniform shader parameter
  7896. */
  7897. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7898. /**
  7899. * Prepare the list of uniforms associated with the ColorCurves effects.
  7900. * @param uniformsList The list of uniforms used in the effect
  7901. */
  7902. static PrepareUniforms(uniformsList: string[]): void;
  7903. /**
  7904. * Returns color grading data based on a hue, density, saturation and exposure value.
  7905. * @param filterHue The hue of the color filter.
  7906. * @param filterDensity The density of the color filter.
  7907. * @param saturation The saturation.
  7908. * @param exposure The exposure.
  7909. * @param result The result data container.
  7910. */
  7911. private getColorGradingDataToRef;
  7912. /**
  7913. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7914. * @param value The input slider value in range [-100,100].
  7915. * @returns Adjusted value.
  7916. */
  7917. private static applyColorGradingSliderNonlinear;
  7918. /**
  7919. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7920. * @param hue The hue (H) input.
  7921. * @param saturation The saturation (S) input.
  7922. * @param brightness The brightness (B) input.
  7923. * @result An RGBA color represented as Vector4.
  7924. */
  7925. private static fromHSBToRef;
  7926. /**
  7927. * Returns a value clamped between min and max
  7928. * @param value The value to clamp
  7929. * @param min The minimum of value
  7930. * @param max The maximum of value
  7931. * @returns The clamped value.
  7932. */
  7933. private static clamp;
  7934. /**
  7935. * Clones the current color curve instance.
  7936. * @return The cloned curves
  7937. */
  7938. clone(): ColorCurves;
  7939. /**
  7940. * Serializes the current color curve instance to a json representation.
  7941. * @return a JSON representation
  7942. */
  7943. serialize(): any;
  7944. /**
  7945. * Parses the color curve from a json representation.
  7946. * @param source the JSON source to parse
  7947. * @return The parsed curves
  7948. */
  7949. static Parse(source: any): ColorCurves;
  7950. }
  7951. }
  7952. declare module BABYLON {
  7953. /**
  7954. * Interface to follow in your material defines to integrate easily the
  7955. * Image proccessing functions.
  7956. * @hidden
  7957. */
  7958. export interface IImageProcessingConfigurationDefines {
  7959. IMAGEPROCESSING: boolean;
  7960. VIGNETTE: boolean;
  7961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7962. VIGNETTEBLENDMODEOPAQUE: boolean;
  7963. TONEMAPPING: boolean;
  7964. TONEMAPPING_ACES: boolean;
  7965. CONTRAST: boolean;
  7966. EXPOSURE: boolean;
  7967. COLORCURVES: boolean;
  7968. COLORGRADING: boolean;
  7969. COLORGRADING3D: boolean;
  7970. SAMPLER3DGREENDEPTH: boolean;
  7971. SAMPLER3DBGRMAP: boolean;
  7972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7973. }
  7974. /**
  7975. * @hidden
  7976. */
  7977. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7978. IMAGEPROCESSING: boolean;
  7979. VIGNETTE: boolean;
  7980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7981. VIGNETTEBLENDMODEOPAQUE: boolean;
  7982. TONEMAPPING: boolean;
  7983. TONEMAPPING_ACES: boolean;
  7984. CONTRAST: boolean;
  7985. COLORCURVES: boolean;
  7986. COLORGRADING: boolean;
  7987. COLORGRADING3D: boolean;
  7988. SAMPLER3DGREENDEPTH: boolean;
  7989. SAMPLER3DBGRMAP: boolean;
  7990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7991. EXPOSURE: boolean;
  7992. constructor();
  7993. }
  7994. /**
  7995. * This groups together the common properties used for image processing either in direct forward pass
  7996. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7997. * or not.
  7998. */
  7999. export class ImageProcessingConfiguration {
  8000. /**
  8001. * Default tone mapping applied in BabylonJS.
  8002. */
  8003. static readonly TONEMAPPING_STANDARD: number;
  8004. /**
  8005. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8006. * to other engines rendering to increase portability.
  8007. */
  8008. static readonly TONEMAPPING_ACES: number;
  8009. /**
  8010. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8011. */
  8012. colorCurves: Nullable<ColorCurves>;
  8013. private _colorCurvesEnabled;
  8014. /**
  8015. * Gets wether the color curves effect is enabled.
  8016. */
  8017. /**
  8018. * Sets wether the color curves effect is enabled.
  8019. */
  8020. colorCurvesEnabled: boolean;
  8021. private _colorGradingTexture;
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. /**
  8026. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8027. */
  8028. colorGradingTexture: Nullable<BaseTexture>;
  8029. private _colorGradingEnabled;
  8030. /**
  8031. * Gets wether the color grading effect is enabled.
  8032. */
  8033. /**
  8034. * Sets wether the color grading effect is enabled.
  8035. */
  8036. colorGradingEnabled: boolean;
  8037. private _colorGradingWithGreenDepth;
  8038. /**
  8039. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. /**
  8042. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8043. */
  8044. colorGradingWithGreenDepth: boolean;
  8045. private _colorGradingBGR;
  8046. /**
  8047. * Gets wether the color grading texture contains BGR values.
  8048. */
  8049. /**
  8050. * Sets wether the color grading texture contains BGR values.
  8051. */
  8052. colorGradingBGR: boolean;
  8053. /** @hidden */
  8054. _exposure: number;
  8055. /**
  8056. * Gets the Exposure used in the effect.
  8057. */
  8058. /**
  8059. * Sets the Exposure used in the effect.
  8060. */
  8061. exposure: number;
  8062. private _toneMappingEnabled;
  8063. /**
  8064. * Gets wether the tone mapping effect is enabled.
  8065. */
  8066. /**
  8067. * Sets wether the tone mapping effect is enabled.
  8068. */
  8069. toneMappingEnabled: boolean;
  8070. private _toneMappingType;
  8071. /**
  8072. * Gets the type of tone mapping effect.
  8073. */
  8074. /**
  8075. * Sets the type of tone mapping effect used in BabylonJS.
  8076. */
  8077. toneMappingType: number;
  8078. protected _contrast: number;
  8079. /**
  8080. * Gets the contrast used in the effect.
  8081. */
  8082. /**
  8083. * Sets the contrast used in the effect.
  8084. */
  8085. contrast: number;
  8086. /**
  8087. * Vignette stretch size.
  8088. */
  8089. vignetteStretch: number;
  8090. /**
  8091. * Vignette centre X Offset.
  8092. */
  8093. vignetteCentreX: number;
  8094. /**
  8095. * Vignette centre Y Offset.
  8096. */
  8097. vignetteCentreY: number;
  8098. /**
  8099. * Vignette weight or intensity of the vignette effect.
  8100. */
  8101. vignetteWeight: number;
  8102. /**
  8103. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8104. * if vignetteEnabled is set to true.
  8105. */
  8106. vignetteColor: Color4;
  8107. /**
  8108. * Camera field of view used by the Vignette effect.
  8109. */
  8110. vignetteCameraFov: number;
  8111. private _vignetteBlendMode;
  8112. /**
  8113. * Gets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. /**
  8116. * Sets the vignette blend mode allowing different kind of effect.
  8117. */
  8118. vignetteBlendMode: number;
  8119. private _vignetteEnabled;
  8120. /**
  8121. * Gets wether the vignette effect is enabled.
  8122. */
  8123. /**
  8124. * Sets wether the vignette effect is enabled.
  8125. */
  8126. vignetteEnabled: boolean;
  8127. private _applyByPostProcess;
  8128. /**
  8129. * Gets wether the image processing is applied through a post process or not.
  8130. */
  8131. /**
  8132. * Sets wether the image processing is applied through a post process or not.
  8133. */
  8134. applyByPostProcess: boolean;
  8135. private _isEnabled;
  8136. /**
  8137. * Gets wether the image processing is enabled or not.
  8138. */
  8139. /**
  8140. * Sets wether the image processing is enabled or not.
  8141. */
  8142. isEnabled: boolean;
  8143. /**
  8144. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8145. */
  8146. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8147. /**
  8148. * Method called each time the image processing information changes requires to recompile the effect.
  8149. */
  8150. protected _updateParameters(): void;
  8151. /**
  8152. * Gets the current class name.
  8153. * @return "ImageProcessingConfiguration"
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Prepare the list of uniforms associated with the Image Processing effects.
  8158. * @param uniforms The list of uniforms used in the effect
  8159. * @param defines the list of defines currently in use
  8160. */
  8161. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8162. /**
  8163. * Prepare the list of samplers associated with the Image Processing effects.
  8164. * @param samplersList The list of uniforms used in the effect
  8165. * @param defines the list of defines currently in use
  8166. */
  8167. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8168. /**
  8169. * Prepare the list of defines associated to the shader.
  8170. * @param defines the list of defines to complete
  8171. * @param forPostProcess Define if we are currently in post process mode or not
  8172. */
  8173. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8174. /**
  8175. * Returns true if all the image processing information are ready.
  8176. * @returns True if ready, otherwise, false
  8177. */
  8178. isReady(): boolean;
  8179. /**
  8180. * Binds the image processing to the shader.
  8181. * @param effect The effect to bind to
  8182. * @param aspectRatio Define the current aspect ratio of the effect
  8183. */
  8184. bind(effect: Effect, aspectRatio?: number): void;
  8185. /**
  8186. * Clones the current image processing instance.
  8187. * @return The cloned image processing
  8188. */
  8189. clone(): ImageProcessingConfiguration;
  8190. /**
  8191. * Serializes the current image processing instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the image processing from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed image processing
  8199. */
  8200. static Parse(source: any): ImageProcessingConfiguration;
  8201. private static _VIGNETTEMODE_MULTIPLY;
  8202. private static _VIGNETTEMODE_OPAQUE;
  8203. /**
  8204. * Used to apply the vignette as a mix with the pixel color.
  8205. */
  8206. static readonly VIGNETTEMODE_MULTIPLY: number;
  8207. /**
  8208. * Used to apply the vignette as a replacement of the pixel color.
  8209. */
  8210. static readonly VIGNETTEMODE_OPAQUE: number;
  8211. }
  8212. }
  8213. declare module BABYLON {
  8214. /** @hidden */
  8215. export var postprocessVertexShader: {
  8216. name: string;
  8217. shader: string;
  8218. };
  8219. }
  8220. declare module BABYLON {
  8221. /** Defines supported spaces */
  8222. export enum Space {
  8223. /** Local (object) space */
  8224. LOCAL = 0,
  8225. /** World space */
  8226. WORLD = 1,
  8227. /** Bone space */
  8228. BONE = 2
  8229. }
  8230. /** Defines the 3 main axes */
  8231. export class Axis {
  8232. /** X axis */
  8233. static X: Vector3;
  8234. /** Y axis */
  8235. static Y: Vector3;
  8236. /** Z axis */
  8237. static Z: Vector3;
  8238. }
  8239. }
  8240. declare module BABYLON {
  8241. /**
  8242. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8243. * This is the base of the follow, arc rotate cameras and Free camera
  8244. * @see http://doc.babylonjs.com/features/cameras
  8245. */
  8246. export class TargetCamera extends Camera {
  8247. private static _RigCamTransformMatrix;
  8248. private static _TargetTransformMatrix;
  8249. private static _TargetFocalPoint;
  8250. /**
  8251. * Define the current direction the camera is moving to
  8252. */
  8253. cameraDirection: Vector3;
  8254. /**
  8255. * Define the current rotation the camera is rotating to
  8256. */
  8257. cameraRotation: Vector2;
  8258. /**
  8259. * When set, the up vector of the camera will be updated by the rotation of the camera
  8260. */
  8261. updateUpVectorFromRotation: boolean;
  8262. private _tmpQuaternion;
  8263. /**
  8264. * Define the current rotation of the camera
  8265. */
  8266. rotation: Vector3;
  8267. /**
  8268. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8269. */
  8270. rotationQuaternion: Quaternion;
  8271. /**
  8272. * Define the current speed of the camera
  8273. */
  8274. speed: number;
  8275. /**
  8276. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8277. * around all axis.
  8278. */
  8279. noRotationConstraint: boolean;
  8280. /**
  8281. * Define the current target of the camera as an object or a position.
  8282. */
  8283. lockedTarget: any;
  8284. /** @hidden */
  8285. _currentTarget: Vector3;
  8286. /** @hidden */
  8287. _initialFocalDistance: number;
  8288. /** @hidden */
  8289. _viewMatrix: Matrix;
  8290. /** @hidden */
  8291. _camMatrix: Matrix;
  8292. /** @hidden */
  8293. _cameraTransformMatrix: Matrix;
  8294. /** @hidden */
  8295. _cameraRotationMatrix: Matrix;
  8296. /** @hidden */
  8297. _referencePoint: Vector3;
  8298. /** @hidden */
  8299. _transformedReferencePoint: Vector3;
  8300. protected _globalCurrentTarget: Vector3;
  8301. protected _globalCurrentUpVector: Vector3;
  8302. /** @hidden */
  8303. _reset: () => void;
  8304. private _defaultUp;
  8305. /**
  8306. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8307. * This is the base of the follow, arc rotate cameras and Free camera
  8308. * @see http://doc.babylonjs.com/features/cameras
  8309. * @param name Defines the name of the camera in the scene
  8310. * @param position Defines the start position of the camera in the scene
  8311. * @param scene Defines the scene the camera belongs to
  8312. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8313. */
  8314. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8315. /**
  8316. * Gets the position in front of the camera at a given distance.
  8317. * @param distance The distance from the camera we want the position to be
  8318. * @returns the position
  8319. */
  8320. getFrontPosition(distance: number): Vector3;
  8321. /** @hidden */
  8322. _getLockedTargetPosition(): Nullable<Vector3>;
  8323. private _storedPosition;
  8324. private _storedRotation;
  8325. private _storedRotationQuaternion;
  8326. /**
  8327. * Store current camera state of the camera (fov, position, rotation, etc..)
  8328. * @returns the camera
  8329. */
  8330. storeState(): Camera;
  8331. /**
  8332. * Restored camera state. You must call storeState() first
  8333. * @returns whether it was successful or not
  8334. * @hidden
  8335. */
  8336. _restoreStateValues(): boolean;
  8337. /** @hidden */
  8338. _initCache(): void;
  8339. /** @hidden */
  8340. _updateCache(ignoreParentClass?: boolean): void;
  8341. /** @hidden */
  8342. _isSynchronizedViewMatrix(): boolean;
  8343. /** @hidden */
  8344. _computeLocalCameraSpeed(): number;
  8345. /**
  8346. * Defines the target the camera should look at.
  8347. * @param target Defines the new target as a Vector or a mesh
  8348. */
  8349. setTarget(target: Vector3): void;
  8350. /**
  8351. * Return the current target position of the camera. This value is expressed in local space.
  8352. * @returns the target position
  8353. */
  8354. getTarget(): Vector3;
  8355. /** @hidden */
  8356. _decideIfNeedsToMove(): boolean;
  8357. /** @hidden */
  8358. _updatePosition(): void;
  8359. /** @hidden */
  8360. _checkInputs(): void;
  8361. protected _updateCameraRotationMatrix(): void;
  8362. /**
  8363. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8364. * @returns the current camera
  8365. */
  8366. private _rotateUpVectorWithCameraRotationMatrix;
  8367. private _cachedRotationZ;
  8368. private _cachedQuaternionRotationZ;
  8369. /** @hidden */
  8370. _getViewMatrix(): Matrix;
  8371. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8372. /**
  8373. * @hidden
  8374. */
  8375. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8376. /**
  8377. * @hidden
  8378. */
  8379. _updateRigCameras(): void;
  8380. private _getRigCamPositionAndTarget;
  8381. /**
  8382. * Gets the current object class name.
  8383. * @return the class name
  8384. */
  8385. getClassName(): string;
  8386. }
  8387. }
  8388. declare module BABYLON {
  8389. /**
  8390. * Gather the list of keyboard event types as constants.
  8391. */
  8392. export class KeyboardEventTypes {
  8393. /**
  8394. * The keydown event is fired when a key becomes active (pressed).
  8395. */
  8396. static readonly KEYDOWN: number;
  8397. /**
  8398. * The keyup event is fired when a key has been released.
  8399. */
  8400. static readonly KEYUP: number;
  8401. }
  8402. /**
  8403. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8404. */
  8405. export class KeyboardInfo {
  8406. /**
  8407. * Defines the type of event (KeyboardEventTypes)
  8408. */
  8409. type: number;
  8410. /**
  8411. * Defines the related dom event
  8412. */
  8413. event: KeyboardEvent;
  8414. /**
  8415. * Instantiates a new keyboard info.
  8416. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8417. * @param type Defines the type of event (KeyboardEventTypes)
  8418. * @param event Defines the related dom event
  8419. */
  8420. constructor(
  8421. /**
  8422. * Defines the type of event (KeyboardEventTypes)
  8423. */
  8424. type: number,
  8425. /**
  8426. * Defines the related dom event
  8427. */
  8428. event: KeyboardEvent);
  8429. }
  8430. /**
  8431. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8432. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8433. */
  8434. export class KeyboardInfoPre extends KeyboardInfo {
  8435. /**
  8436. * Defines the type of event (KeyboardEventTypes)
  8437. */
  8438. type: number;
  8439. /**
  8440. * Defines the related dom event
  8441. */
  8442. event: KeyboardEvent;
  8443. /**
  8444. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8445. */
  8446. skipOnPointerObservable: boolean;
  8447. /**
  8448. * Instantiates a new keyboard pre info.
  8449. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8450. * @param type Defines the type of event (KeyboardEventTypes)
  8451. * @param event Defines the related dom event
  8452. */
  8453. constructor(
  8454. /**
  8455. * Defines the type of event (KeyboardEventTypes)
  8456. */
  8457. type: number,
  8458. /**
  8459. * Defines the related dom event
  8460. */
  8461. event: KeyboardEvent);
  8462. }
  8463. }
  8464. declare module BABYLON {
  8465. /**
  8466. * Manage the keyboard inputs to control the movement of a free camera.
  8467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8468. */
  8469. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8470. /**
  8471. * Defines the camera the input is attached to.
  8472. */
  8473. camera: FreeCamera;
  8474. /**
  8475. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8476. */
  8477. keysUp: number[];
  8478. /**
  8479. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8480. */
  8481. keysDown: number[];
  8482. /**
  8483. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8484. */
  8485. keysLeft: number[];
  8486. /**
  8487. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8488. */
  8489. keysRight: number[];
  8490. private _keys;
  8491. private _onCanvasBlurObserver;
  8492. private _onKeyboardObserver;
  8493. private _engine;
  8494. private _scene;
  8495. /**
  8496. * Attach the input controls to a specific dom element to get the input from.
  8497. * @param element Defines the element the controls should be listened from
  8498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8499. */
  8500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8501. /**
  8502. * Detach the current controls from the specified dom element.
  8503. * @param element Defines the element to stop listening the inputs from
  8504. */
  8505. detachControl(element: Nullable<HTMLElement>): void;
  8506. /**
  8507. * Update the current camera state depending on the inputs that have been used this frame.
  8508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8509. */
  8510. checkInputs(): void;
  8511. /**
  8512. * Gets the class name of the current intput.
  8513. * @returns the class name
  8514. */
  8515. getClassName(): string;
  8516. /** @hidden */
  8517. _onLostFocus(): void;
  8518. /**
  8519. * Get the friendly name associated with the input class.
  8520. * @returns the input friendly name
  8521. */
  8522. getSimpleName(): string;
  8523. }
  8524. }
  8525. declare module BABYLON {
  8526. /**
  8527. * Interface describing all the common properties and methods a shadow light needs to implement.
  8528. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8529. * as well as binding the different shadow properties to the effects.
  8530. */
  8531. export interface IShadowLight extends Light {
  8532. /**
  8533. * The light id in the scene (used in scene.findLighById for instance)
  8534. */
  8535. id: string;
  8536. /**
  8537. * The position the shdow will be casted from.
  8538. */
  8539. position: Vector3;
  8540. /**
  8541. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8542. */
  8543. direction: Vector3;
  8544. /**
  8545. * The transformed position. Position of the light in world space taking parenting in account.
  8546. */
  8547. transformedPosition: Vector3;
  8548. /**
  8549. * The transformed direction. Direction of the light in world space taking parenting in account.
  8550. */
  8551. transformedDirection: Vector3;
  8552. /**
  8553. * The friendly name of the light in the scene.
  8554. */
  8555. name: string;
  8556. /**
  8557. * Defines the shadow projection clipping minimum z value.
  8558. */
  8559. shadowMinZ: number;
  8560. /**
  8561. * Defines the shadow projection clipping maximum z value.
  8562. */
  8563. shadowMaxZ: number;
  8564. /**
  8565. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8566. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8567. */
  8568. computeTransformedInformation(): boolean;
  8569. /**
  8570. * Gets the scene the light belongs to.
  8571. * @returns The scene
  8572. */
  8573. getScene(): Scene;
  8574. /**
  8575. * Callback defining a custom Projection Matrix Builder.
  8576. * This can be used to override the default projection matrix computation.
  8577. */
  8578. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8579. /**
  8580. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8581. * @param matrix The materix to updated with the projection information
  8582. * @param viewMatrix The transform matrix of the light
  8583. * @param renderList The list of mesh to render in the map
  8584. * @returns The current light
  8585. */
  8586. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8587. /**
  8588. * Gets the current depth scale used in ESM.
  8589. * @returns The scale
  8590. */
  8591. getDepthScale(): number;
  8592. /**
  8593. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8594. * @returns true if a cube texture needs to be use
  8595. */
  8596. needCube(): boolean;
  8597. /**
  8598. * Detects if the projection matrix requires to be recomputed this frame.
  8599. * @returns true if it requires to be recomputed otherwise, false.
  8600. */
  8601. needProjectionMatrixCompute(): boolean;
  8602. /**
  8603. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8604. */
  8605. forceProjectionMatrixCompute(): void;
  8606. /**
  8607. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8608. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8609. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8610. */
  8611. getShadowDirection(faceIndex?: number): Vector3;
  8612. /**
  8613. * Gets the minZ used for shadow according to both the scene and the light.
  8614. * @param activeCamera The camera we are returning the min for
  8615. * @returns the depth min z
  8616. */
  8617. getDepthMinZ(activeCamera: Camera): number;
  8618. /**
  8619. * Gets the maxZ used for shadow according to both the scene and the light.
  8620. * @param activeCamera The camera we are returning the max for
  8621. * @returns the depth max z
  8622. */
  8623. getDepthMaxZ(activeCamera: Camera): number;
  8624. }
  8625. /**
  8626. * Base implementation IShadowLight
  8627. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8628. */
  8629. export abstract class ShadowLight extends Light implements IShadowLight {
  8630. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8631. protected _position: Vector3;
  8632. protected _setPosition(value: Vector3): void;
  8633. /**
  8634. * Sets the position the shadow will be casted from. Also use as the light position for both
  8635. * point and spot lights.
  8636. */
  8637. /**
  8638. * Sets the position the shadow will be casted from. Also use as the light position for both
  8639. * point and spot lights.
  8640. */
  8641. position: Vector3;
  8642. protected _direction: Vector3;
  8643. protected _setDirection(value: Vector3): void;
  8644. /**
  8645. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8646. * Also use as the light direction on spot and directional lights.
  8647. */
  8648. /**
  8649. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8650. * Also use as the light direction on spot and directional lights.
  8651. */
  8652. direction: Vector3;
  8653. private _shadowMinZ;
  8654. /**
  8655. * Gets the shadow projection clipping minimum z value.
  8656. */
  8657. /**
  8658. * Sets the shadow projection clipping minimum z value.
  8659. */
  8660. shadowMinZ: number;
  8661. private _shadowMaxZ;
  8662. /**
  8663. * Sets the shadow projection clipping maximum z value.
  8664. */
  8665. /**
  8666. * Gets the shadow projection clipping maximum z value.
  8667. */
  8668. shadowMaxZ: number;
  8669. /**
  8670. * Callback defining a custom Projection Matrix Builder.
  8671. * This can be used to override the default projection matrix computation.
  8672. */
  8673. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8674. /**
  8675. * The transformed position. Position of the light in world space taking parenting in account.
  8676. */
  8677. transformedPosition: Vector3;
  8678. /**
  8679. * The transformed direction. Direction of the light in world space taking parenting in account.
  8680. */
  8681. transformedDirection: Vector3;
  8682. private _needProjectionMatrixCompute;
  8683. /**
  8684. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8685. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8686. */
  8687. computeTransformedInformation(): boolean;
  8688. /**
  8689. * Return the depth scale used for the shadow map.
  8690. * @returns the depth scale.
  8691. */
  8692. getDepthScale(): number;
  8693. /**
  8694. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8695. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8696. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8697. */
  8698. getShadowDirection(faceIndex?: number): Vector3;
  8699. /**
  8700. * Returns the ShadowLight absolute position in the World.
  8701. * @returns the position vector in world space
  8702. */
  8703. getAbsolutePosition(): Vector3;
  8704. /**
  8705. * Sets the ShadowLight direction toward the passed target.
  8706. * @param target The point to target in local space
  8707. * @returns the updated ShadowLight direction
  8708. */
  8709. setDirectionToTarget(target: Vector3): Vector3;
  8710. /**
  8711. * Returns the light rotation in euler definition.
  8712. * @returns the x y z rotation in local space.
  8713. */
  8714. getRotation(): Vector3;
  8715. /**
  8716. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8717. * @returns true if a cube texture needs to be use
  8718. */
  8719. needCube(): boolean;
  8720. /**
  8721. * Detects if the projection matrix requires to be recomputed this frame.
  8722. * @returns true if it requires to be recomputed otherwise, false.
  8723. */
  8724. needProjectionMatrixCompute(): boolean;
  8725. /**
  8726. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8727. */
  8728. forceProjectionMatrixCompute(): void;
  8729. /** @hidden */
  8730. _initCache(): void;
  8731. /** @hidden */
  8732. _isSynchronized(): boolean;
  8733. /**
  8734. * Computes the world matrix of the node
  8735. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8736. * @returns the world matrix
  8737. */
  8738. computeWorldMatrix(force?: boolean): Matrix;
  8739. /**
  8740. * Gets the minZ used for shadow according to both the scene and the light.
  8741. * @param activeCamera The camera we are returning the min for
  8742. * @returns the depth min z
  8743. */
  8744. getDepthMinZ(activeCamera: Camera): number;
  8745. /**
  8746. * Gets the maxZ used for shadow according to both the scene and the light.
  8747. * @param activeCamera The camera we are returning the max for
  8748. * @returns the depth max z
  8749. */
  8750. getDepthMaxZ(activeCamera: Camera): number;
  8751. /**
  8752. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8753. * @param matrix The materix to updated with the projection information
  8754. * @param viewMatrix The transform matrix of the light
  8755. * @param renderList The list of mesh to render in the map
  8756. * @returns The current light
  8757. */
  8758. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8759. }
  8760. }
  8761. declare module BABYLON {
  8762. /**
  8763. * "Static Class" containing the most commonly used helper while dealing with material for
  8764. * rendering purpose.
  8765. *
  8766. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8767. *
  8768. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8769. */
  8770. export class MaterialHelper {
  8771. /**
  8772. * Bind the current view position to an effect.
  8773. * @param effect The effect to be bound
  8774. * @param scene The scene the eyes position is used from
  8775. */
  8776. static BindEyePosition(effect: Effect, scene: Scene): void;
  8777. /**
  8778. * Helps preparing the defines values about the UVs in used in the effect.
  8779. * UVs are shared as much as we can accross channels in the shaders.
  8780. * @param texture The texture we are preparing the UVs for
  8781. * @param defines The defines to update
  8782. * @param key The channel key "diffuse", "specular"... used in the shader
  8783. */
  8784. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8785. /**
  8786. * Binds a texture matrix value to its corrsponding uniform
  8787. * @param texture The texture to bind the matrix for
  8788. * @param uniformBuffer The uniform buffer receivin the data
  8789. * @param key The channel key "diffuse", "specular"... used in the shader
  8790. */
  8791. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8792. /**
  8793. * Gets the current status of the fog (should it be enabled?)
  8794. * @param mesh defines the mesh to evaluate for fog support
  8795. * @param scene defines the hosting scene
  8796. * @returns true if fog must be enabled
  8797. */
  8798. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8799. /**
  8800. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8801. * @param mesh defines the current mesh
  8802. * @param scene defines the current scene
  8803. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8804. * @param pointsCloud defines if point cloud rendering has to be turned on
  8805. * @param fogEnabled defines if fog has to be turned on
  8806. * @param alphaTest defines if alpha testing has to be turned on
  8807. * @param defines defines the current list of defines
  8808. */
  8809. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8810. /**
  8811. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8812. * @param scene defines the current scene
  8813. * @param engine defines the current engine
  8814. * @param defines specifies the list of active defines
  8815. * @param useInstances defines if instances have to be turned on
  8816. * @param useClipPlane defines if clip plane have to be turned on
  8817. */
  8818. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8819. /**
  8820. * Prepares the defines for bones
  8821. * @param mesh The mesh containing the geometry data we will draw
  8822. * @param defines The defines to update
  8823. */
  8824. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8825. /**
  8826. * Prepares the defines for morph targets
  8827. * @param mesh The mesh containing the geometry data we will draw
  8828. * @param defines The defines to update
  8829. */
  8830. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8831. /**
  8832. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8833. * @param mesh The mesh containing the geometry data we will draw
  8834. * @param defines The defines to update
  8835. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8836. * @param useBones Precise whether bones should be used or not (override mesh info)
  8837. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8838. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8839. * @returns false if defines are considered not dirty and have not been checked
  8840. */
  8841. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8842. /**
  8843. * Prepares the defines related to multiview
  8844. * @param scene The scene we are intending to draw
  8845. * @param defines The defines to update
  8846. */
  8847. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8848. /**
  8849. * Prepares the defines related to the light information passed in parameter
  8850. * @param scene The scene we are intending to draw
  8851. * @param mesh The mesh the effect is compiling for
  8852. * @param light The light the effect is compiling for
  8853. * @param lightIndex The index of the light
  8854. * @param defines The defines to update
  8855. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8856. * @param state Defines the current state regarding what is needed (normals, etc...)
  8857. */
  8858. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8859. needNormals: boolean;
  8860. needRebuild: boolean;
  8861. shadowEnabled: boolean;
  8862. specularEnabled: boolean;
  8863. lightmapMode: boolean;
  8864. }): void;
  8865. /**
  8866. * Prepares the defines related to the light information passed in parameter
  8867. * @param scene The scene we are intending to draw
  8868. * @param mesh The mesh the effect is compiling for
  8869. * @param defines The defines to update
  8870. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8871. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8872. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8873. * @returns true if normals will be required for the rest of the effect
  8874. */
  8875. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8876. /**
  8877. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8878. * @param lightIndex defines the light index
  8879. * @param uniformsList The uniform list
  8880. * @param samplersList The sampler list
  8881. * @param projectedLightTexture defines if projected texture must be used
  8882. * @param uniformBuffersList defines an optional list of uniform buffers
  8883. */
  8884. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8885. /**
  8886. * Prepares the uniforms and samplers list to be used in the effect
  8887. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8888. * @param samplersList The sampler list
  8889. * @param defines The defines helping in the list generation
  8890. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8891. */
  8892. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8893. /**
  8894. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8895. * @param defines The defines to update while falling back
  8896. * @param fallbacks The authorized effect fallbacks
  8897. * @param maxSimultaneousLights The maximum number of lights allowed
  8898. * @param rank the current rank of the Effect
  8899. * @returns The newly affected rank
  8900. */
  8901. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8902. private static _TmpMorphInfluencers;
  8903. /**
  8904. * Prepares the list of attributes required for morph targets according to the effect defines.
  8905. * @param attribs The current list of supported attribs
  8906. * @param mesh The mesh to prepare the morph targets attributes for
  8907. * @param influencers The number of influencers
  8908. */
  8909. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8910. /**
  8911. * Prepares the list of attributes required for morph targets according to the effect defines.
  8912. * @param attribs The current list of supported attribs
  8913. * @param mesh The mesh to prepare the morph targets attributes for
  8914. * @param defines The current Defines of the effect
  8915. */
  8916. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8917. /**
  8918. * Prepares the list of attributes required for bones according to the effect defines.
  8919. * @param attribs The current list of supported attribs
  8920. * @param mesh The mesh to prepare the bones attributes for
  8921. * @param defines The current Defines of the effect
  8922. * @param fallbacks The current efffect fallback strategy
  8923. */
  8924. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8925. /**
  8926. * Check and prepare the list of attributes required for instances according to the effect defines.
  8927. * @param attribs The current list of supported attribs
  8928. * @param defines The current MaterialDefines of the effect
  8929. */
  8930. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8931. /**
  8932. * Add the list of attributes required for instances to the attribs array.
  8933. * @param attribs The current list of supported attribs
  8934. */
  8935. static PushAttributesForInstances(attribs: string[]): void;
  8936. /**
  8937. * Binds the light shadow information to the effect for the given mesh.
  8938. * @param light The light containing the generator
  8939. * @param scene The scene the lights belongs to
  8940. * @param mesh The mesh we are binding the information to render
  8941. * @param lightIndex The light index in the effect used to render the mesh
  8942. * @param effect The effect we are binding the data to
  8943. */
  8944. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8945. /**
  8946. * Binds the light information to the effect.
  8947. * @param light The light containing the generator
  8948. * @param effect The effect we are binding the data to
  8949. * @param lightIndex The light index in the effect used to render
  8950. */
  8951. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8952. /**
  8953. * Binds the lights information from the scene to the effect for the given mesh.
  8954. * @param light Light to bind
  8955. * @param lightIndex Light index
  8956. * @param scene The scene where the light belongs to
  8957. * @param mesh The mesh we are binding the information to render
  8958. * @param effect The effect we are binding the data to
  8959. * @param useSpecular Defines if specular is supported
  8960. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8961. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8962. */
  8963. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8964. /**
  8965. * Binds the lights information from the scene to the effect for the given mesh.
  8966. * @param scene The scene the lights belongs to
  8967. * @param mesh The mesh we are binding the information to render
  8968. * @param effect The effect we are binding the data to
  8969. * @param defines The generated defines for the effect
  8970. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8971. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8972. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8973. */
  8974. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8975. private static _tempFogColor;
  8976. /**
  8977. * Binds the fog information from the scene to the effect for the given mesh.
  8978. * @param scene The scene the lights belongs to
  8979. * @param mesh The mesh we are binding the information to render
  8980. * @param effect The effect we are binding the data to
  8981. * @param linearSpace Defines if the fog effect is applied in linear space
  8982. */
  8983. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8984. /**
  8985. * Binds the bones information from the mesh to the effect.
  8986. * @param mesh The mesh we are binding the information to render
  8987. * @param effect The effect we are binding the data to
  8988. */
  8989. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8990. /**
  8991. * Binds the morph targets information from the mesh to the effect.
  8992. * @param abstractMesh The mesh we are binding the information to render
  8993. * @param effect The effect we are binding the data to
  8994. */
  8995. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8996. /**
  8997. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8998. * @param defines The generated defines used in the effect
  8999. * @param effect The effect we are binding the data to
  9000. * @param scene The scene we are willing to render with logarithmic scale for
  9001. */
  9002. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9003. /**
  9004. * Binds the clip plane information from the scene to the effect.
  9005. * @param scene The scene the clip plane information are extracted from
  9006. * @param effect The effect we are binding the data to
  9007. */
  9008. static BindClipPlane(effect: Effect, scene: Scene): void;
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /** @hidden */
  9013. export var packingFunctions: {
  9014. name: string;
  9015. shader: string;
  9016. };
  9017. }
  9018. declare module BABYLON {
  9019. /** @hidden */
  9020. export var shadowMapPixelShader: {
  9021. name: string;
  9022. shader: string;
  9023. };
  9024. }
  9025. declare module BABYLON {
  9026. /** @hidden */
  9027. export var bonesDeclaration: {
  9028. name: string;
  9029. shader: string;
  9030. };
  9031. }
  9032. declare module BABYLON {
  9033. /** @hidden */
  9034. export var morphTargetsVertexGlobalDeclaration: {
  9035. name: string;
  9036. shader: string;
  9037. };
  9038. }
  9039. declare module BABYLON {
  9040. /** @hidden */
  9041. export var morphTargetsVertexDeclaration: {
  9042. name: string;
  9043. shader: string;
  9044. };
  9045. }
  9046. declare module BABYLON {
  9047. /** @hidden */
  9048. export var instancesDeclaration: {
  9049. name: string;
  9050. shader: string;
  9051. };
  9052. }
  9053. declare module BABYLON {
  9054. /** @hidden */
  9055. export var helperFunctions: {
  9056. name: string;
  9057. shader: string;
  9058. };
  9059. }
  9060. declare module BABYLON {
  9061. /** @hidden */
  9062. export var morphTargetsVertex: {
  9063. name: string;
  9064. shader: string;
  9065. };
  9066. }
  9067. declare module BABYLON {
  9068. /** @hidden */
  9069. export var instancesVertex: {
  9070. name: string;
  9071. shader: string;
  9072. };
  9073. }
  9074. declare module BABYLON {
  9075. /** @hidden */
  9076. export var bonesVertex: {
  9077. name: string;
  9078. shader: string;
  9079. };
  9080. }
  9081. declare module BABYLON {
  9082. /** @hidden */
  9083. export var shadowMapVertexShader: {
  9084. name: string;
  9085. shader: string;
  9086. };
  9087. }
  9088. declare module BABYLON {
  9089. /** @hidden */
  9090. export var depthBoxBlurPixelShader: {
  9091. name: string;
  9092. shader: string;
  9093. };
  9094. }
  9095. declare module BABYLON {
  9096. /**
  9097. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9098. */
  9099. export interface ICustomShaderOptions {
  9100. /**
  9101. * Gets or sets the custom shader name to use
  9102. */
  9103. shaderName: string;
  9104. /**
  9105. * The list of attribute names used in the shader
  9106. */
  9107. attributes?: string[];
  9108. /**
  9109. * The list of unifrom names used in the shader
  9110. */
  9111. uniforms?: string[];
  9112. /**
  9113. * The list of sampler names used in the shader
  9114. */
  9115. samplers?: string[];
  9116. /**
  9117. * The list of defines used in the shader
  9118. */
  9119. defines?: string[];
  9120. }
  9121. /**
  9122. * Interface to implement to create a shadow generator compatible with BJS.
  9123. */
  9124. export interface IShadowGenerator {
  9125. /**
  9126. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9127. * @returns The render target texture if present otherwise, null
  9128. */
  9129. getShadowMap(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9132. * @returns The render target texture if the shadow map is present otherwise, null
  9133. */
  9134. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9137. * @param subMesh The submesh we want to render in the shadow map
  9138. * @param useInstances Defines wether will draw in the map using instances
  9139. * @returns true if ready otherwise, false
  9140. */
  9141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9142. /**
  9143. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9144. * @param defines Defines of the material we want to update
  9145. * @param lightIndex Index of the light in the enabled light list of the material
  9146. */
  9147. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9148. /**
  9149. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9150. * defined in the generator but impacting the effect).
  9151. * It implies the unifroms available on the materials are the standard BJS ones.
  9152. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9153. * @param effect The effect we are binfing the information for
  9154. */
  9155. bindShadowLight(lightIndex: string, effect: Effect): void;
  9156. /**
  9157. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9158. * (eq to shadow prjection matrix * light transform matrix)
  9159. * @returns The transform matrix used to create the shadow map
  9160. */
  9161. getTransformMatrix(): Matrix;
  9162. /**
  9163. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9164. * Cube and 2D textures for instance.
  9165. */
  9166. recreateShadowMap(): void;
  9167. /**
  9168. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9169. * @param onCompiled Callback triggered at the and of the effects compilation
  9170. * @param options Sets of optional options forcing the compilation with different modes
  9171. */
  9172. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9173. useInstances: boolean;
  9174. }>): void;
  9175. /**
  9176. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9177. * @param options Sets of optional options forcing the compilation with different modes
  9178. * @returns A promise that resolves when the compilation completes
  9179. */
  9180. forceCompilationAsync(options?: Partial<{
  9181. useInstances: boolean;
  9182. }>): Promise<void>;
  9183. /**
  9184. * Serializes the shadow generator setup to a json object.
  9185. * @returns The serialized JSON object
  9186. */
  9187. serialize(): any;
  9188. /**
  9189. * Disposes the Shadow map and related Textures and effects.
  9190. */
  9191. dispose(): void;
  9192. }
  9193. /**
  9194. * Default implementation IShadowGenerator.
  9195. * This is the main object responsible of generating shadows in the framework.
  9196. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9197. */
  9198. export class ShadowGenerator implements IShadowGenerator {
  9199. /**
  9200. * Shadow generator mode None: no filtering applied.
  9201. */
  9202. static readonly FILTER_NONE: number;
  9203. /**
  9204. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9206. */
  9207. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9208. /**
  9209. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9210. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9211. */
  9212. static readonly FILTER_POISSONSAMPLING: number;
  9213. /**
  9214. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9216. */
  9217. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9218. /**
  9219. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9220. * edge artifacts on steep falloff.
  9221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9222. */
  9223. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9224. /**
  9225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9226. * edge artifacts on steep falloff.
  9227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9228. */
  9229. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9230. /**
  9231. * Shadow generator mode PCF: Percentage Closer Filtering
  9232. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9233. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9234. */
  9235. static readonly FILTER_PCF: number;
  9236. /**
  9237. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9239. * Contact Hardening
  9240. */
  9241. static readonly FILTER_PCSS: number;
  9242. /**
  9243. * Reserved for PCF and PCSS
  9244. * Highest Quality.
  9245. *
  9246. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9247. *
  9248. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9249. */
  9250. static readonly QUALITY_HIGH: number;
  9251. /**
  9252. * Reserved for PCF and PCSS
  9253. * Good tradeoff for quality/perf cross devices
  9254. *
  9255. * Execute PCF on a 3*3 kernel.
  9256. *
  9257. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9258. */
  9259. static readonly QUALITY_MEDIUM: number;
  9260. /**
  9261. * Reserved for PCF and PCSS
  9262. * The lowest quality but the fastest.
  9263. *
  9264. * Execute PCF on a 1*1 kernel.
  9265. *
  9266. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9267. */
  9268. static readonly QUALITY_LOW: number;
  9269. /** Gets or sets the custom shader name to use */
  9270. customShaderOptions: ICustomShaderOptions;
  9271. /**
  9272. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9273. */
  9274. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9275. /**
  9276. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9277. */
  9278. onAfterShadowMapRenderObservable: Observable<Effect>;
  9279. /**
  9280. * Observable triggered before a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9282. */
  9283. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. /**
  9285. * Observable triggered after a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9287. */
  9288. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. private _bias;
  9290. /**
  9291. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9292. */
  9293. /**
  9294. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9295. */
  9296. bias: number;
  9297. private _normalBias;
  9298. /**
  9299. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9300. */
  9301. /**
  9302. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9303. */
  9304. normalBias: number;
  9305. private _blurBoxOffset;
  9306. /**
  9307. * Gets the blur box offset: offset applied during the blur pass.
  9308. * Only useful if useKernelBlur = false
  9309. */
  9310. /**
  9311. * Sets the blur box offset: offset applied during the blur pass.
  9312. * Only useful if useKernelBlur = false
  9313. */
  9314. blurBoxOffset: number;
  9315. private _blurScale;
  9316. /**
  9317. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9318. * 2 means half of the size.
  9319. */
  9320. /**
  9321. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9322. * 2 means half of the size.
  9323. */
  9324. blurScale: number;
  9325. private _blurKernel;
  9326. /**
  9327. * Gets the blur kernel: kernel size of the blur pass.
  9328. * Only useful if useKernelBlur = true
  9329. */
  9330. /**
  9331. * Sets the blur kernel: kernel size of the blur pass.
  9332. * Only useful if useKernelBlur = true
  9333. */
  9334. blurKernel: number;
  9335. private _useKernelBlur;
  9336. /**
  9337. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9338. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9339. */
  9340. /**
  9341. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9342. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9343. */
  9344. useKernelBlur: boolean;
  9345. private _depthScale;
  9346. /**
  9347. * Gets the depth scale used in ESM mode.
  9348. */
  9349. /**
  9350. * Sets the depth scale used in ESM mode.
  9351. * This can override the scale stored on the light.
  9352. */
  9353. depthScale: number;
  9354. private _filter;
  9355. /**
  9356. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9357. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9358. */
  9359. /**
  9360. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9361. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9362. */
  9363. filter: number;
  9364. /**
  9365. * Gets if the current filter is set to Poisson Sampling.
  9366. */
  9367. /**
  9368. * Sets the current filter to Poisson Sampling.
  9369. */
  9370. usePoissonSampling: boolean;
  9371. /**
  9372. * Gets if the current filter is set to ESM.
  9373. */
  9374. /**
  9375. * Sets the current filter is to ESM.
  9376. */
  9377. useExponentialShadowMap: boolean;
  9378. /**
  9379. * Gets if the current filter is set to filtered ESM.
  9380. */
  9381. /**
  9382. * Gets if the current filter is set to filtered ESM.
  9383. */
  9384. useBlurExponentialShadowMap: boolean;
  9385. /**
  9386. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9387. * exponential to prevent steep falloff artifacts).
  9388. */
  9389. /**
  9390. * Sets the current filter to "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. useCloseExponentialShadowMap: boolean;
  9394. /**
  9395. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. /**
  9399. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9400. * exponential to prevent steep falloff artifacts).
  9401. */
  9402. useBlurCloseExponentialShadowMap: boolean;
  9403. /**
  9404. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9405. */
  9406. /**
  9407. * Sets the current filter to "PCF" (percentage closer filtering).
  9408. */
  9409. usePercentageCloserFiltering: boolean;
  9410. private _filteringQuality;
  9411. /**
  9412. * Gets the PCF or PCSS Quality.
  9413. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9414. */
  9415. /**
  9416. * Sets the PCF or PCSS Quality.
  9417. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9418. */
  9419. filteringQuality: number;
  9420. /**
  9421. * Gets if the current filter is set to "PCSS" (contact hardening).
  9422. */
  9423. /**
  9424. * Sets the current filter to "PCSS" (contact hardening).
  9425. */
  9426. useContactHardeningShadow: boolean;
  9427. private _contactHardeningLightSizeUVRatio;
  9428. /**
  9429. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9430. * Using a ratio helps keeping shape stability independently of the map size.
  9431. *
  9432. * It does not account for the light projection as it was having too much
  9433. * instability during the light setup or during light position changes.
  9434. *
  9435. * Only valid if useContactHardeningShadow is true.
  9436. */
  9437. /**
  9438. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9439. * Using a ratio helps keeping shape stability independently of the map size.
  9440. *
  9441. * It does not account for the light projection as it was having too much
  9442. * instability during the light setup or during light position changes.
  9443. *
  9444. * Only valid if useContactHardeningShadow is true.
  9445. */
  9446. contactHardeningLightSizeUVRatio: number;
  9447. private _darkness;
  9448. /** Gets or sets the actual darkness of a shadow */
  9449. darkness: number;
  9450. /**
  9451. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9452. * 0 means strongest and 1 would means no shadow.
  9453. * @returns the darkness.
  9454. */
  9455. getDarkness(): number;
  9456. /**
  9457. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9458. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9459. * @returns the shadow generator allowing fluent coding.
  9460. */
  9461. setDarkness(darkness: number): ShadowGenerator;
  9462. private _transparencyShadow;
  9463. /** Gets or sets the ability to have transparent shadow */
  9464. transparencyShadow: boolean;
  9465. /**
  9466. * Sets the ability to have transparent shadow (boolean).
  9467. * @param transparent True if transparent else False
  9468. * @returns the shadow generator allowing fluent coding
  9469. */
  9470. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9471. private _shadowMap;
  9472. private _shadowMap2;
  9473. /**
  9474. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9475. * @returns The render target texture if present otherwise, null
  9476. */
  9477. getShadowMap(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9480. * @returns The render target texture if the shadow map is present otherwise, null
  9481. */
  9482. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the class name of that object
  9485. * @returns "ShadowGenerator"
  9486. */
  9487. getClassName(): string;
  9488. /**
  9489. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9490. * @param mesh Mesh to add
  9491. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9492. * @returns the Shadow Generator itself
  9493. */
  9494. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9495. /**
  9496. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9497. * @param mesh Mesh to remove
  9498. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9499. * @returns the Shadow Generator itself
  9500. */
  9501. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9502. /**
  9503. * Controls the extent to which the shadows fade out at the edge of the frustum
  9504. * Used only by directionals and spots
  9505. */
  9506. frustumEdgeFalloff: number;
  9507. private _light;
  9508. /**
  9509. * Returns the associated light object.
  9510. * @returns the light generating the shadow
  9511. */
  9512. getLight(): IShadowLight;
  9513. /**
  9514. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9515. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9516. * It might on the other hand introduce peter panning.
  9517. */
  9518. forceBackFacesOnly: boolean;
  9519. private _scene;
  9520. private _lightDirection;
  9521. private _effect;
  9522. private _viewMatrix;
  9523. private _projectionMatrix;
  9524. private _transformMatrix;
  9525. private _cachedPosition;
  9526. private _cachedDirection;
  9527. private _cachedDefines;
  9528. private _currentRenderID;
  9529. private _boxBlurPostprocess;
  9530. private _kernelBlurXPostprocess;
  9531. private _kernelBlurYPostprocess;
  9532. private _blurPostProcesses;
  9533. private _mapSize;
  9534. private _currentFaceIndex;
  9535. private _currentFaceIndexCache;
  9536. private _textureType;
  9537. private _defaultTextureMatrix;
  9538. /** @hidden */
  9539. static _SceneComponentInitialization: (scene: Scene) => void;
  9540. /**
  9541. * Creates a ShadowGenerator object.
  9542. * A ShadowGenerator is the required tool to use the shadows.
  9543. * Each light casting shadows needs to use its own ShadowGenerator.
  9544. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9545. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9546. * @param light The light object generating the shadows.
  9547. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9548. */
  9549. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9550. private _initializeGenerator;
  9551. private _initializeShadowMap;
  9552. private _initializeBlurRTTAndPostProcesses;
  9553. private _renderForShadowMap;
  9554. private _renderSubMeshForShadowMap;
  9555. private _applyFilterValues;
  9556. /**
  9557. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9558. * @param onCompiled Callback triggered at the and of the effects compilation
  9559. * @param options Sets of optional options forcing the compilation with different modes
  9560. */
  9561. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9562. useInstances: boolean;
  9563. }>): void;
  9564. /**
  9565. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9566. * @param options Sets of optional options forcing the compilation with different modes
  9567. * @returns A promise that resolves when the compilation completes
  9568. */
  9569. forceCompilationAsync(options?: Partial<{
  9570. useInstances: boolean;
  9571. }>): Promise<void>;
  9572. /**
  9573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9574. * @param subMesh The submesh we want to render in the shadow map
  9575. * @param useInstances Defines wether will draw in the map using instances
  9576. * @returns true if ready otherwise, false
  9577. */
  9578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9579. /**
  9580. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9581. * @param defines Defines of the material we want to update
  9582. * @param lightIndex Index of the light in the enabled light list of the material
  9583. */
  9584. prepareDefines(defines: any, lightIndex: number): void;
  9585. /**
  9586. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9587. * defined in the generator but impacting the effect).
  9588. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9589. * @param effect The effect we are binfing the information for
  9590. */
  9591. bindShadowLight(lightIndex: string, effect: Effect): void;
  9592. /**
  9593. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9594. * (eq to shadow prjection matrix * light transform matrix)
  9595. * @returns The transform matrix used to create the shadow map
  9596. */
  9597. getTransformMatrix(): Matrix;
  9598. /**
  9599. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9600. * Cube and 2D textures for instance.
  9601. */
  9602. recreateShadowMap(): void;
  9603. private _disposeBlurPostProcesses;
  9604. private _disposeRTTandPostProcesses;
  9605. /**
  9606. * Disposes the ShadowGenerator.
  9607. * Returns nothing.
  9608. */
  9609. dispose(): void;
  9610. /**
  9611. * Serializes the shadow generator setup to a json object.
  9612. * @returns The serialized JSON object
  9613. */
  9614. serialize(): any;
  9615. /**
  9616. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9617. * @param parsedShadowGenerator The JSON object to parse
  9618. * @param scene The scene to create the shadow map for
  9619. * @returns The parsed shadow generator
  9620. */
  9621. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9622. }
  9623. }
  9624. declare module BABYLON {
  9625. /**
  9626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9628. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9629. */
  9630. export abstract class Light extends Node {
  9631. /**
  9632. * Falloff Default: light is falling off following the material specification:
  9633. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9634. */
  9635. static readonly FALLOFF_DEFAULT: number;
  9636. /**
  9637. * Falloff Physical: light is falling off following the inverse squared distance law.
  9638. */
  9639. static readonly FALLOFF_PHYSICAL: number;
  9640. /**
  9641. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9642. * to enhance interoperability with other engines.
  9643. */
  9644. static readonly FALLOFF_GLTF: number;
  9645. /**
  9646. * Falloff Standard: light is falling off like in the standard material
  9647. * to enhance interoperability with other materials.
  9648. */
  9649. static readonly FALLOFF_STANDARD: number;
  9650. /**
  9651. * If every light affecting the material is in this lightmapMode,
  9652. * material.lightmapTexture adds or multiplies
  9653. * (depends on material.useLightmapAsShadowmap)
  9654. * after every other light calculations.
  9655. */
  9656. static readonly LIGHTMAP_DEFAULT: number;
  9657. /**
  9658. * material.lightmapTexture as only diffuse lighting from this light
  9659. * adds only specular lighting from this light
  9660. * adds dynamic shadows
  9661. */
  9662. static readonly LIGHTMAP_SPECULAR: number;
  9663. /**
  9664. * material.lightmapTexture as only lighting
  9665. * no light calculation from this light
  9666. * only adds dynamic shadows from this light
  9667. */
  9668. static readonly LIGHTMAP_SHADOWSONLY: number;
  9669. /**
  9670. * Each light type uses the default quantity according to its type:
  9671. * point/spot lights use luminous intensity
  9672. * directional lights use illuminance
  9673. */
  9674. static readonly INTENSITYMODE_AUTOMATIC: number;
  9675. /**
  9676. * lumen (lm)
  9677. */
  9678. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9679. /**
  9680. * candela (lm/sr)
  9681. */
  9682. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9683. /**
  9684. * lux (lm/m^2)
  9685. */
  9686. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9687. /**
  9688. * nit (cd/m^2)
  9689. */
  9690. static readonly INTENSITYMODE_LUMINANCE: number;
  9691. /**
  9692. * Light type const id of the point light.
  9693. */
  9694. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9695. /**
  9696. * Light type const id of the directional light.
  9697. */
  9698. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9699. /**
  9700. * Light type const id of the spot light.
  9701. */
  9702. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9703. /**
  9704. * Light type const id of the hemispheric light.
  9705. */
  9706. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9707. /**
  9708. * Diffuse gives the basic color to an object.
  9709. */
  9710. diffuse: Color3;
  9711. /**
  9712. * Specular produces a highlight color on an object.
  9713. * Note: This is note affecting PBR materials.
  9714. */
  9715. specular: Color3;
  9716. /**
  9717. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9718. * falling off base on range or angle.
  9719. * This can be set to any values in Light.FALLOFF_x.
  9720. *
  9721. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9722. * other types of materials.
  9723. */
  9724. falloffType: number;
  9725. /**
  9726. * Strength of the light.
  9727. * Note: By default it is define in the framework own unit.
  9728. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9729. */
  9730. intensity: number;
  9731. private _range;
  9732. protected _inverseSquaredRange: number;
  9733. /**
  9734. * Defines how far from the source the light is impacting in scene units.
  9735. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9736. */
  9737. /**
  9738. * Defines how far from the source the light is impacting in scene units.
  9739. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9740. */
  9741. range: number;
  9742. /**
  9743. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9744. * of light.
  9745. */
  9746. private _photometricScale;
  9747. private _intensityMode;
  9748. /**
  9749. * Gets the photometric scale used to interpret the intensity.
  9750. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9751. */
  9752. /**
  9753. * Sets the photometric scale used to interpret the intensity.
  9754. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9755. */
  9756. intensityMode: number;
  9757. private _radius;
  9758. /**
  9759. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9760. */
  9761. /**
  9762. * sets the light radius used by PBR Materials to simulate soft area lights.
  9763. */
  9764. radius: number;
  9765. private _renderPriority;
  9766. /**
  9767. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9768. * exceeding the number allowed of the materials.
  9769. */
  9770. renderPriority: number;
  9771. private _shadowEnabled;
  9772. /**
  9773. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9774. * the current shadow generator.
  9775. */
  9776. /**
  9777. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9778. * the current shadow generator.
  9779. */
  9780. shadowEnabled: boolean;
  9781. private _includedOnlyMeshes;
  9782. /**
  9783. * Gets the only meshes impacted by this light.
  9784. */
  9785. /**
  9786. * Sets the only meshes impacted by this light.
  9787. */
  9788. includedOnlyMeshes: AbstractMesh[];
  9789. private _excludedMeshes;
  9790. /**
  9791. * Gets the meshes not impacted by this light.
  9792. */
  9793. /**
  9794. * Sets the meshes not impacted by this light.
  9795. */
  9796. excludedMeshes: AbstractMesh[];
  9797. private _excludeWithLayerMask;
  9798. /**
  9799. * Gets the layer id use to find what meshes are not impacted by the light.
  9800. * Inactive if 0
  9801. */
  9802. /**
  9803. * Sets the layer id use to find what meshes are not impacted by the light.
  9804. * Inactive if 0
  9805. */
  9806. excludeWithLayerMask: number;
  9807. private _includeOnlyWithLayerMask;
  9808. /**
  9809. * Gets the layer id use to find what meshes are impacted by the light.
  9810. * Inactive if 0
  9811. */
  9812. /**
  9813. * Sets the layer id use to find what meshes are impacted by the light.
  9814. * Inactive if 0
  9815. */
  9816. includeOnlyWithLayerMask: number;
  9817. private _lightmapMode;
  9818. /**
  9819. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9820. */
  9821. /**
  9822. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9823. */
  9824. lightmapMode: number;
  9825. /**
  9826. * Shadow generator associted to the light.
  9827. * @hidden Internal use only.
  9828. */
  9829. _shadowGenerator: Nullable<IShadowGenerator>;
  9830. /**
  9831. * @hidden Internal use only.
  9832. */
  9833. _excludedMeshesIds: string[];
  9834. /**
  9835. * @hidden Internal use only.
  9836. */
  9837. _includedOnlyMeshesIds: string[];
  9838. /**
  9839. * The current light unifom buffer.
  9840. * @hidden Internal use only.
  9841. */
  9842. _uniformBuffer: UniformBuffer;
  9843. /**
  9844. * Creates a Light object in the scene.
  9845. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9846. * @param name The firendly name of the light
  9847. * @param scene The scene the light belongs too
  9848. */
  9849. constructor(name: string, scene: Scene);
  9850. protected abstract _buildUniformLayout(): void;
  9851. /**
  9852. * Sets the passed Effect "effect" with the Light information.
  9853. * @param effect The effect to update
  9854. * @param lightIndex The index of the light in the effect to update
  9855. * @returns The light
  9856. */
  9857. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9858. /**
  9859. * Sets the passed Effect "effect" with the Light information.
  9860. * @param effect The effect to update
  9861. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9862. * @returns The light
  9863. */
  9864. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9865. /**
  9866. * Returns the string "Light".
  9867. * @returns the class name
  9868. */
  9869. getClassName(): string;
  9870. /** @hidden */
  9871. readonly _isLight: boolean;
  9872. /**
  9873. * Converts the light information to a readable string for debug purpose.
  9874. * @param fullDetails Supports for multiple levels of logging within scene loading
  9875. * @returns the human readable light info
  9876. */
  9877. toString(fullDetails?: boolean): string;
  9878. /** @hidden */
  9879. protected _syncParentEnabledState(): void;
  9880. /**
  9881. * Set the enabled state of this node.
  9882. * @param value - the new enabled state
  9883. */
  9884. setEnabled(value: boolean): void;
  9885. /**
  9886. * Returns the Light associated shadow generator if any.
  9887. * @return the associated shadow generator.
  9888. */
  9889. getShadowGenerator(): Nullable<IShadowGenerator>;
  9890. /**
  9891. * Returns a Vector3, the absolute light position in the World.
  9892. * @returns the world space position of the light
  9893. */
  9894. getAbsolutePosition(): Vector3;
  9895. /**
  9896. * Specifies if the light will affect the passed mesh.
  9897. * @param mesh The mesh to test against the light
  9898. * @return true the mesh is affected otherwise, false.
  9899. */
  9900. canAffectMesh(mesh: AbstractMesh): boolean;
  9901. /**
  9902. * Sort function to order lights for rendering.
  9903. * @param a First Light object to compare to second.
  9904. * @param b Second Light object to compare first.
  9905. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9906. */
  9907. static CompareLightsPriority(a: Light, b: Light): number;
  9908. /**
  9909. * Releases resources associated with this node.
  9910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9912. */
  9913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9914. /**
  9915. * Returns the light type ID (integer).
  9916. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9917. */
  9918. getTypeID(): number;
  9919. /**
  9920. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9921. * @returns the scaled intensity in intensity mode unit
  9922. */
  9923. getScaledIntensity(): number;
  9924. /**
  9925. * Returns a new Light object, named "name", from the current one.
  9926. * @param name The name of the cloned light
  9927. * @returns the new created light
  9928. */
  9929. clone(name: string): Nullable<Light>;
  9930. /**
  9931. * Serializes the current light into a Serialization object.
  9932. * @returns the serialized object.
  9933. */
  9934. serialize(): any;
  9935. /**
  9936. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9937. * This new light is named "name" and added to the passed scene.
  9938. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9939. * @param name The friendly name of the light
  9940. * @param scene The scene the new light will belong to
  9941. * @returns the constructor function
  9942. */
  9943. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9944. /**
  9945. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9946. * @param parsedLight The JSON representation of the light
  9947. * @param scene The scene to create the parsed light in
  9948. * @returns the created light after parsing
  9949. */
  9950. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9951. private _hookArrayForExcluded;
  9952. private _hookArrayForIncludedOnly;
  9953. private _resyncMeshes;
  9954. /**
  9955. * Forces the meshes to update their light related information in their rendering used effects
  9956. * @hidden Internal Use Only
  9957. */
  9958. _markMeshesAsLightDirty(): void;
  9959. /**
  9960. * Recomputes the cached photometric scale if needed.
  9961. */
  9962. private _computePhotometricScale;
  9963. /**
  9964. * Returns the Photometric Scale according to the light type and intensity mode.
  9965. */
  9966. private _getPhotometricScale;
  9967. /**
  9968. * Reorder the light in the scene according to their defined priority.
  9969. * @hidden Internal Use Only
  9970. */
  9971. _reorderLightsInScene(): void;
  9972. /**
  9973. * Prepares the list of defines specific to the light type.
  9974. * @param defines the list of defines
  9975. * @param lightIndex defines the index of the light for the effect
  9976. */
  9977. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9978. }
  9979. }
  9980. declare module BABYLON {
  9981. /**
  9982. * Interface used to define Action
  9983. */
  9984. export interface IAction {
  9985. /**
  9986. * Trigger for the action
  9987. */
  9988. trigger: number;
  9989. /** Options of the trigger */
  9990. triggerOptions: any;
  9991. /**
  9992. * Gets the trigger parameters
  9993. * @returns the trigger parameters
  9994. */
  9995. getTriggerParameter(): any;
  9996. /**
  9997. * Internal only - executes current action event
  9998. * @hidden
  9999. */
  10000. _executeCurrent(evt?: ActionEvent): void;
  10001. /**
  10002. * Serialize placeholder for child classes
  10003. * @param parent of child
  10004. * @returns the serialized object
  10005. */
  10006. serialize(parent: any): any;
  10007. /**
  10008. * Internal only
  10009. * @hidden
  10010. */
  10011. _prepare(): void;
  10012. /**
  10013. * Internal only - manager for action
  10014. * @hidden
  10015. */
  10016. _actionManager: AbstractActionManager;
  10017. /**
  10018. * Adds action to chain of actions, may be a DoNothingAction
  10019. * @param action defines the next action to execute
  10020. * @returns The action passed in
  10021. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10022. */
  10023. then(action: IAction): IAction;
  10024. }
  10025. /**
  10026. * The action to be carried out following a trigger
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10028. */
  10029. export class Action implements IAction {
  10030. /** the trigger, with or without parameters, for the action */
  10031. triggerOptions: any;
  10032. /**
  10033. * Trigger for the action
  10034. */
  10035. trigger: number;
  10036. /**
  10037. * Internal only - manager for action
  10038. * @hidden
  10039. */
  10040. _actionManager: ActionManager;
  10041. private _nextActiveAction;
  10042. private _child;
  10043. private _condition?;
  10044. private _triggerParameter;
  10045. /**
  10046. * An event triggered prior to action being executed.
  10047. */
  10048. onBeforeExecuteObservable: Observable<Action>;
  10049. /**
  10050. * Creates a new Action
  10051. * @param triggerOptions the trigger, with or without parameters, for the action
  10052. * @param condition an optional determinant of action
  10053. */
  10054. constructor(
  10055. /** the trigger, with or without parameters, for the action */
  10056. triggerOptions: any, condition?: Condition);
  10057. /**
  10058. * Internal only
  10059. * @hidden
  10060. */
  10061. _prepare(): void;
  10062. /**
  10063. * Gets the trigger parameters
  10064. * @returns the trigger parameters
  10065. */
  10066. getTriggerParameter(): any;
  10067. /**
  10068. * Internal only - executes current action event
  10069. * @hidden
  10070. */
  10071. _executeCurrent(evt?: ActionEvent): void;
  10072. /**
  10073. * Execute placeholder for child classes
  10074. * @param evt optional action event
  10075. */
  10076. execute(evt?: ActionEvent): void;
  10077. /**
  10078. * Skips to next active action
  10079. */
  10080. skipToNextActiveAction(): void;
  10081. /**
  10082. * Adds action to chain of actions, may be a DoNothingAction
  10083. * @param action defines the next action to execute
  10084. * @returns The action passed in
  10085. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10086. */
  10087. then(action: Action): Action;
  10088. /**
  10089. * Internal only
  10090. * @hidden
  10091. */
  10092. _getProperty(propertyPath: string): string;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */
  10097. _getEffectiveTarget(target: any, propertyPath: string): any;
  10098. /**
  10099. * Serialize placeholder for child classes
  10100. * @param parent of child
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. /**
  10105. * Internal only called by serialize
  10106. * @hidden
  10107. */
  10108. protected _serialize(serializedAction: any, parent?: any): any;
  10109. /**
  10110. * Internal only
  10111. * @hidden
  10112. */
  10113. static _SerializeValueAsString: (value: any) => string;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. static _GetTargetProperty: (target: Node | Scene) => {
  10119. name: string;
  10120. targetType: string;
  10121. value: string;
  10122. };
  10123. }
  10124. }
  10125. declare module BABYLON {
  10126. /**
  10127. * A Condition applied to an Action
  10128. */
  10129. export class Condition {
  10130. /**
  10131. * Internal only - manager for action
  10132. * @hidden
  10133. */
  10134. _actionManager: ActionManager;
  10135. /**
  10136. * Internal only
  10137. * @hidden
  10138. */
  10139. _evaluationId: number;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _currentResult: boolean;
  10145. /**
  10146. * Creates a new Condition
  10147. * @param actionManager the manager of the action the condition is applied to
  10148. */
  10149. constructor(actionManager: ActionManager);
  10150. /**
  10151. * Check if the current condition is valid
  10152. * @returns a boolean
  10153. */
  10154. isValid(): boolean;
  10155. /**
  10156. * Internal only
  10157. * @hidden
  10158. */
  10159. _getProperty(propertyPath: string): string;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getEffectiveTarget(target: any, propertyPath: string): any;
  10165. /**
  10166. * Serialize placeholder for child classes
  10167. * @returns the serialized object
  10168. */
  10169. serialize(): any;
  10170. /**
  10171. * Internal only
  10172. * @hidden
  10173. */
  10174. protected _serialize(serializedCondition: any): any;
  10175. }
  10176. /**
  10177. * Defines specific conditional operators as extensions of Condition
  10178. */
  10179. export class ValueCondition extends Condition {
  10180. /** path to specify the property of the target the conditional operator uses */
  10181. propertyPath: string;
  10182. /** the value compared by the conditional operator against the current value of the property */
  10183. value: any;
  10184. /** the conditional operator, default ValueCondition.IsEqual */
  10185. operator: number;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. private static _IsEqual;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsDifferent;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsGreater;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. private static _IsLesser;
  10206. /**
  10207. * returns the number for IsEqual
  10208. */
  10209. static readonly IsEqual: number;
  10210. /**
  10211. * Returns the number for IsDifferent
  10212. */
  10213. static readonly IsDifferent: number;
  10214. /**
  10215. * Returns the number for IsGreater
  10216. */
  10217. static readonly IsGreater: number;
  10218. /**
  10219. * Returns the number for IsLesser
  10220. */
  10221. static readonly IsLesser: number;
  10222. /**
  10223. * Internal only The action manager for the condition
  10224. * @hidden
  10225. */
  10226. _actionManager: ActionManager;
  10227. /**
  10228. * Internal only
  10229. * @hidden
  10230. */
  10231. private _target;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _effectiveTarget;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private _property;
  10242. /**
  10243. * Creates a new ValueCondition
  10244. * @param actionManager manager for the action the condition applies to
  10245. * @param target for the action
  10246. * @param propertyPath path to specify the property of the target the conditional operator uses
  10247. * @param value the value compared by the conditional operator against the current value of the property
  10248. * @param operator the conditional operator, default ValueCondition.IsEqual
  10249. */
  10250. constructor(actionManager: ActionManager, target: any,
  10251. /** path to specify the property of the target the conditional operator uses */
  10252. propertyPath: string,
  10253. /** the value compared by the conditional operator against the current value of the property */
  10254. value: any,
  10255. /** the conditional operator, default ValueCondition.IsEqual */
  10256. operator?: number);
  10257. /**
  10258. * Compares the given value with the property value for the specified conditional operator
  10259. * @returns the result of the comparison
  10260. */
  10261. isValid(): boolean;
  10262. /**
  10263. * Serialize the ValueCondition into a JSON compatible object
  10264. * @returns serialization object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Gets the name of the conditional operator for the ValueCondition
  10269. * @param operator the conditional operator
  10270. * @returns the name
  10271. */
  10272. static GetOperatorName(operator: number): string;
  10273. }
  10274. /**
  10275. * Defines a predicate condition as an extension of Condition
  10276. */
  10277. export class PredicateCondition extends Condition {
  10278. /** defines the predicate function used to validate the condition */
  10279. predicate: () => boolean;
  10280. /**
  10281. * Internal only - manager for action
  10282. * @hidden
  10283. */
  10284. _actionManager: ActionManager;
  10285. /**
  10286. * Creates a new PredicateCondition
  10287. * @param actionManager manager for the action the condition applies to
  10288. * @param predicate defines the predicate function used to validate the condition
  10289. */
  10290. constructor(actionManager: ActionManager,
  10291. /** defines the predicate function used to validate the condition */
  10292. predicate: () => boolean);
  10293. /**
  10294. * @returns the validity of the predicate condition
  10295. */
  10296. isValid(): boolean;
  10297. }
  10298. /**
  10299. * Defines a state condition as an extension of Condition
  10300. */
  10301. export class StateCondition extends Condition {
  10302. /** Value to compare with target state */
  10303. value: string;
  10304. /**
  10305. * Internal only - manager for action
  10306. * @hidden
  10307. */
  10308. _actionManager: ActionManager;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. private _target;
  10314. /**
  10315. * Creates a new StateCondition
  10316. * @param actionManager manager for the action the condition applies to
  10317. * @param target of the condition
  10318. * @param value to compare with target state
  10319. */
  10320. constructor(actionManager: ActionManager, target: any,
  10321. /** Value to compare with target state */
  10322. value: string);
  10323. /**
  10324. * Gets a boolean indicating if the current condition is met
  10325. * @returns the validity of the state
  10326. */
  10327. isValid(): boolean;
  10328. /**
  10329. * Serialize the StateCondition into a JSON compatible object
  10330. * @returns serialization object
  10331. */
  10332. serialize(): any;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * This defines an action responsible to toggle a boolean once triggered.
  10338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10339. */
  10340. export class SwitchBooleanAction extends Action {
  10341. /**
  10342. * The path to the boolean property in the target object
  10343. */
  10344. propertyPath: string;
  10345. private _target;
  10346. private _effectiveTarget;
  10347. private _property;
  10348. /**
  10349. * Instantiate the action
  10350. * @param triggerOptions defines the trigger options
  10351. * @param target defines the object containing the boolean
  10352. * @param propertyPath defines the path to the boolean property in the target object
  10353. * @param condition defines the trigger related conditions
  10354. */
  10355. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10356. /** @hidden */
  10357. _prepare(): void;
  10358. /**
  10359. * Execute the action toggle the boolean value.
  10360. */
  10361. execute(): void;
  10362. /**
  10363. * Serializes the actions and its related information.
  10364. * @param parent defines the object to serialize in
  10365. * @returns the serialized object
  10366. */
  10367. serialize(parent: any): any;
  10368. }
  10369. /**
  10370. * This defines an action responsible to set a the state field of the target
  10371. * to a desired value once triggered.
  10372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10373. */
  10374. export class SetStateAction extends Action {
  10375. /**
  10376. * The value to store in the state field.
  10377. */
  10378. value: string;
  10379. private _target;
  10380. /**
  10381. * Instantiate the action
  10382. * @param triggerOptions defines the trigger options
  10383. * @param target defines the object containing the state property
  10384. * @param value defines the value to store in the state field
  10385. * @param condition defines the trigger related conditions
  10386. */
  10387. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10388. /**
  10389. * Execute the action and store the value on the target state property.
  10390. */
  10391. execute(): void;
  10392. /**
  10393. * Serializes the actions and its related information.
  10394. * @param parent defines the object to serialize in
  10395. * @returns the serialized object
  10396. */
  10397. serialize(parent: any): any;
  10398. }
  10399. /**
  10400. * This defines an action responsible to set a property of the target
  10401. * to a desired value once triggered.
  10402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10403. */
  10404. export class SetValueAction extends Action {
  10405. /**
  10406. * The path of the property to set in the target.
  10407. */
  10408. propertyPath: string;
  10409. /**
  10410. * The value to set in the property
  10411. */
  10412. value: any;
  10413. private _target;
  10414. private _effectiveTarget;
  10415. private _property;
  10416. /**
  10417. * Instantiate the action
  10418. * @param triggerOptions defines the trigger options
  10419. * @param target defines the object containing the property
  10420. * @param propertyPath defines the path of the property to set in the target
  10421. * @param value defines the value to set in the property
  10422. * @param condition defines the trigger related conditions
  10423. */
  10424. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10425. /** @hidden */
  10426. _prepare(): void;
  10427. /**
  10428. * Execute the action and set the targetted property to the desired value.
  10429. */
  10430. execute(): void;
  10431. /**
  10432. * Serializes the actions and its related information.
  10433. * @param parent defines the object to serialize in
  10434. * @returns the serialized object
  10435. */
  10436. serialize(parent: any): any;
  10437. }
  10438. /**
  10439. * This defines an action responsible to increment the target value
  10440. * to a desired value once triggered.
  10441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10442. */
  10443. export class IncrementValueAction extends Action {
  10444. /**
  10445. * The path of the property to increment in the target.
  10446. */
  10447. propertyPath: string;
  10448. /**
  10449. * The value we should increment the property by.
  10450. */
  10451. value: any;
  10452. private _target;
  10453. private _effectiveTarget;
  10454. private _property;
  10455. /**
  10456. * Instantiate the action
  10457. * @param triggerOptions defines the trigger options
  10458. * @param target defines the object containing the property
  10459. * @param propertyPath defines the path of the property to increment in the target
  10460. * @param value defines the value value we should increment the property by
  10461. * @param condition defines the trigger related conditions
  10462. */
  10463. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10464. /** @hidden */
  10465. _prepare(): void;
  10466. /**
  10467. * Execute the action and increment the target of the value amount.
  10468. */
  10469. execute(): void;
  10470. /**
  10471. * Serializes the actions and its related information.
  10472. * @param parent defines the object to serialize in
  10473. * @returns the serialized object
  10474. */
  10475. serialize(parent: any): any;
  10476. }
  10477. /**
  10478. * This defines an action responsible to start an animation once triggered.
  10479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10480. */
  10481. export class PlayAnimationAction extends Action {
  10482. /**
  10483. * Where the animation should start (animation frame)
  10484. */
  10485. from: number;
  10486. /**
  10487. * Where the animation should stop (animation frame)
  10488. */
  10489. to: number;
  10490. /**
  10491. * Define if the animation should loop or stop after the first play.
  10492. */
  10493. loop?: boolean;
  10494. private _target;
  10495. /**
  10496. * Instantiate the action
  10497. * @param triggerOptions defines the trigger options
  10498. * @param target defines the target animation or animation name
  10499. * @param from defines from where the animation should start (animation frame)
  10500. * @param end defines where the animation should stop (animation frame)
  10501. * @param loop defines if the animation should loop or stop after the first play
  10502. * @param condition defines the trigger related conditions
  10503. */
  10504. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10505. /** @hidden */
  10506. _prepare(): void;
  10507. /**
  10508. * Execute the action and play the animation.
  10509. */
  10510. execute(): void;
  10511. /**
  10512. * Serializes the actions and its related information.
  10513. * @param parent defines the object to serialize in
  10514. * @returns the serialized object
  10515. */
  10516. serialize(parent: any): any;
  10517. }
  10518. /**
  10519. * This defines an action responsible to stop an animation once triggered.
  10520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10521. */
  10522. export class StopAnimationAction extends Action {
  10523. private _target;
  10524. /**
  10525. * Instantiate the action
  10526. * @param triggerOptions defines the trigger options
  10527. * @param target defines the target animation or animation name
  10528. * @param condition defines the trigger related conditions
  10529. */
  10530. constructor(triggerOptions: any, target: any, condition?: Condition);
  10531. /** @hidden */
  10532. _prepare(): void;
  10533. /**
  10534. * Execute the action and stop the animation.
  10535. */
  10536. execute(): void;
  10537. /**
  10538. * Serializes the actions and its related information.
  10539. * @param parent defines the object to serialize in
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. }
  10544. /**
  10545. * This defines an action responsible that does nothing once triggered.
  10546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10547. */
  10548. export class DoNothingAction extends Action {
  10549. /**
  10550. * Instantiate the action
  10551. * @param triggerOptions defines the trigger options
  10552. * @param condition defines the trigger related conditions
  10553. */
  10554. constructor(triggerOptions?: any, condition?: Condition);
  10555. /**
  10556. * Execute the action and do nothing.
  10557. */
  10558. execute(): void;
  10559. /**
  10560. * Serializes the actions and its related information.
  10561. * @param parent defines the object to serialize in
  10562. * @returns the serialized object
  10563. */
  10564. serialize(parent: any): any;
  10565. }
  10566. /**
  10567. * This defines an action responsible to trigger several actions once triggered.
  10568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10569. */
  10570. export class CombineAction extends Action {
  10571. /**
  10572. * The list of aggregated animations to run.
  10573. */
  10574. children: Action[];
  10575. /**
  10576. * Instantiate the action
  10577. * @param triggerOptions defines the trigger options
  10578. * @param children defines the list of aggregated animations to run
  10579. * @param condition defines the trigger related conditions
  10580. */
  10581. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10582. /** @hidden */
  10583. _prepare(): void;
  10584. /**
  10585. * Execute the action and executes all the aggregated actions.
  10586. */
  10587. execute(evt: ActionEvent): void;
  10588. /**
  10589. * Serializes the actions and its related information.
  10590. * @param parent defines the object to serialize in
  10591. * @returns the serialized object
  10592. */
  10593. serialize(parent: any): any;
  10594. }
  10595. /**
  10596. * This defines an action responsible to run code (external event) once triggered.
  10597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10598. */
  10599. export class ExecuteCodeAction extends Action {
  10600. /**
  10601. * The callback function to run.
  10602. */
  10603. func: (evt: ActionEvent) => void;
  10604. /**
  10605. * Instantiate the action
  10606. * @param triggerOptions defines the trigger options
  10607. * @param func defines the callback function to run
  10608. * @param condition defines the trigger related conditions
  10609. */
  10610. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10611. /**
  10612. * Execute the action and run the attached code.
  10613. */
  10614. execute(evt: ActionEvent): void;
  10615. }
  10616. /**
  10617. * This defines an action responsible to set the parent property of the target once triggered.
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10619. */
  10620. export class SetParentAction extends Action {
  10621. private _parent;
  10622. private _target;
  10623. /**
  10624. * Instantiate the action
  10625. * @param triggerOptions defines the trigger options
  10626. * @param target defines the target containing the parent property
  10627. * @param parent defines from where the animation should start (animation frame)
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10631. /** @hidden */
  10632. _prepare(): void;
  10633. /**
  10634. * Execute the action and set the parent property.
  10635. */
  10636. execute(): void;
  10637. /**
  10638. * Serializes the actions and its related information.
  10639. * @param parent defines the object to serialize in
  10640. * @returns the serialized object
  10641. */
  10642. serialize(parent: any): any;
  10643. }
  10644. }
  10645. declare module BABYLON {
  10646. /**
  10647. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10648. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10650. */
  10651. export class ActionManager extends AbstractActionManager {
  10652. /**
  10653. * Nothing
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10655. */
  10656. static readonly NothingTrigger: number;
  10657. /**
  10658. * On pick
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly OnPickTrigger: number;
  10662. /**
  10663. * On left pick
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnLeftPickTrigger: number;
  10667. /**
  10668. * On right pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnRightPickTrigger: number;
  10672. /**
  10673. * On center pick
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnCenterPickTrigger: number;
  10677. /**
  10678. * On pick down
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnPickDownTrigger: number;
  10682. /**
  10683. * On double pick
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnDoublePickTrigger: number;
  10687. /**
  10688. * On pick up
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnPickUpTrigger: number;
  10692. /**
  10693. * On pick out.
  10694. * This trigger will only be raised if you also declared a OnPickDown
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10696. */
  10697. static readonly OnPickOutTrigger: number;
  10698. /**
  10699. * On long press
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnLongPressTrigger: number;
  10703. /**
  10704. * On pointer over
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnPointerOverTrigger: number;
  10708. /**
  10709. * On pointer out
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPointerOutTrigger: number;
  10713. /**
  10714. * On every frame
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnEveryFrameTrigger: number;
  10718. /**
  10719. * On intersection enter
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnIntersectionEnterTrigger: number;
  10723. /**
  10724. * On intersection exit
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnIntersectionExitTrigger: number;
  10728. /**
  10729. * On key down
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnKeyDownTrigger: number;
  10733. /**
  10734. * On key up
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnKeyUpTrigger: number;
  10738. private _scene;
  10739. /**
  10740. * Creates a new action manager
  10741. * @param scene defines the hosting scene
  10742. */
  10743. constructor(scene: Scene);
  10744. /**
  10745. * Releases all associated resources
  10746. */
  10747. dispose(): void;
  10748. /**
  10749. * Gets hosting scene
  10750. * @returns the hosting scene
  10751. */
  10752. getScene(): Scene;
  10753. /**
  10754. * Does this action manager handles actions of any of the given triggers
  10755. * @param triggers defines the triggers to be tested
  10756. * @return a boolean indicating whether one (or more) of the triggers is handled
  10757. */
  10758. hasSpecificTriggers(triggers: number[]): boolean;
  10759. /**
  10760. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10761. * speed.
  10762. * @param triggerA defines the trigger to be tested
  10763. * @param triggerB defines the trigger to be tested
  10764. * @return a boolean indicating whether one (or more) of the triggers is handled
  10765. */
  10766. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10767. /**
  10768. * Does this action manager handles actions of a given trigger
  10769. * @param trigger defines the trigger to be tested
  10770. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10771. * @return whether the trigger is handled
  10772. */
  10773. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10774. /**
  10775. * Does this action manager has pointer triggers
  10776. */
  10777. readonly hasPointerTriggers: boolean;
  10778. /**
  10779. * Does this action manager has pick triggers
  10780. */
  10781. readonly hasPickTriggers: boolean;
  10782. /**
  10783. * Registers an action to this action manager
  10784. * @param action defines the action to be registered
  10785. * @return the action amended (prepared) after registration
  10786. */
  10787. registerAction(action: IAction): Nullable<IAction>;
  10788. /**
  10789. * Unregisters an action to this action manager
  10790. * @param action defines the action to be unregistered
  10791. * @return a boolean indicating whether the action has been unregistered
  10792. */
  10793. unregisterAction(action: IAction): Boolean;
  10794. /**
  10795. * Process a specific trigger
  10796. * @param trigger defines the trigger to process
  10797. * @param evt defines the event details to be processed
  10798. */
  10799. processTrigger(trigger: number, evt?: IActionEvent): void;
  10800. /** @hidden */
  10801. _getEffectiveTarget(target: any, propertyPath: string): any;
  10802. /** @hidden */
  10803. _getProperty(propertyPath: string): string;
  10804. /**
  10805. * Serialize this manager to a JSON object
  10806. * @param name defines the property name to store this manager
  10807. * @returns a JSON representation of this manager
  10808. */
  10809. serialize(name: string): any;
  10810. /**
  10811. * Creates a new ActionManager from a JSON data
  10812. * @param parsedActions defines the JSON data to read from
  10813. * @param object defines the hosting mesh
  10814. * @param scene defines the hosting scene
  10815. */
  10816. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10817. /**
  10818. * Get a trigger name by index
  10819. * @param trigger defines the trigger index
  10820. * @returns a trigger name
  10821. */
  10822. static GetTriggerName(trigger: number): string;
  10823. }
  10824. }
  10825. declare module BABYLON {
  10826. /**
  10827. * Class representing a ray with position and direction
  10828. */
  10829. export class Ray {
  10830. /** origin point */
  10831. origin: Vector3;
  10832. /** direction */
  10833. direction: Vector3;
  10834. /** length of the ray */
  10835. length: number;
  10836. private static readonly TmpVector3;
  10837. private _tmpRay;
  10838. /**
  10839. * Creates a new ray
  10840. * @param origin origin point
  10841. * @param direction direction
  10842. * @param length length of the ray
  10843. */
  10844. constructor(
  10845. /** origin point */
  10846. origin: Vector3,
  10847. /** direction */
  10848. direction: Vector3,
  10849. /** length of the ray */
  10850. length?: number);
  10851. /**
  10852. * Checks if the ray intersects a box
  10853. * @param minimum bound of the box
  10854. * @param maximum bound of the box
  10855. * @param intersectionTreshold extra extend to be added to the box in all direction
  10856. * @returns if the box was hit
  10857. */
  10858. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10859. /**
  10860. * Checks if the ray intersects a box
  10861. * @param box the bounding box to check
  10862. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10863. * @returns if the box was hit
  10864. */
  10865. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10866. /**
  10867. * If the ray hits a sphere
  10868. * @param sphere the bounding sphere to check
  10869. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10870. * @returns true if it hits the sphere
  10871. */
  10872. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10873. /**
  10874. * If the ray hits a triange
  10875. * @param vertex0 triangle vertex
  10876. * @param vertex1 triangle vertex
  10877. * @param vertex2 triangle vertex
  10878. * @returns intersection information if hit
  10879. */
  10880. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10881. /**
  10882. * Checks if ray intersects a plane
  10883. * @param plane the plane to check
  10884. * @returns the distance away it was hit
  10885. */
  10886. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10887. /**
  10888. * Calculate the intercept of a ray on a given axis
  10889. * @param axis to check 'x' | 'y' | 'z'
  10890. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10891. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10892. */
  10893. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10894. /**
  10895. * Checks if ray intersects a mesh
  10896. * @param mesh the mesh to check
  10897. * @param fastCheck if only the bounding box should checked
  10898. * @returns picking info of the intersecton
  10899. */
  10900. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10901. /**
  10902. * Checks if ray intersects a mesh
  10903. * @param meshes the meshes to check
  10904. * @param fastCheck if only the bounding box should checked
  10905. * @param results array to store result in
  10906. * @returns Array of picking infos
  10907. */
  10908. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10909. private _comparePickingInfo;
  10910. private static smallnum;
  10911. private static rayl;
  10912. /**
  10913. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10914. * @param sega the first point of the segment to test the intersection against
  10915. * @param segb the second point of the segment to test the intersection against
  10916. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10917. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10918. */
  10919. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10920. /**
  10921. * Update the ray from viewport position
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns this ray updated
  10930. */
  10931. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * Creates a ray with origin and direction of 0,0,0
  10934. * @returns the new ray
  10935. */
  10936. static Zero(): Ray;
  10937. /**
  10938. * Creates a new ray from screen space and viewport
  10939. * @param x position
  10940. * @param y y position
  10941. * @param viewportWidth viewport width
  10942. * @param viewportHeight viewport height
  10943. * @param world world matrix
  10944. * @param view view matrix
  10945. * @param projection projection matrix
  10946. * @returns new ray
  10947. */
  10948. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10949. /**
  10950. * 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
  10951. * transformed to the given world matrix.
  10952. * @param origin The origin point
  10953. * @param end The end point
  10954. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10955. * @returns the new ray
  10956. */
  10957. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Transforms a ray by a matrix
  10960. * @param ray ray to transform
  10961. * @param matrix matrix to apply
  10962. * @returns the resulting new ray
  10963. */
  10964. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10965. /**
  10966. * Transforms a ray by a matrix
  10967. * @param ray ray to transform
  10968. * @param matrix matrix to apply
  10969. * @param result ray to store result in
  10970. */
  10971. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10972. /**
  10973. * Unproject a ray from screen space to object space
  10974. * @param sourceX defines the screen space x coordinate to use
  10975. * @param sourceY defines the screen space y coordinate to use
  10976. * @param viewportWidth defines the current width of the viewport
  10977. * @param viewportHeight defines the current height of the viewport
  10978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10979. * @param view defines the view matrix to use
  10980. * @param projection defines the projection matrix to use
  10981. */
  10982. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10983. }
  10984. /**
  10985. * Type used to define predicate used to select faces when a mesh intersection is detected
  10986. */
  10987. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10988. interface Scene {
  10989. /** @hidden */
  10990. _tempPickingRay: Nullable<Ray>;
  10991. /** @hidden */
  10992. _cachedRayForTransform: Ray;
  10993. /** @hidden */
  10994. _pickWithRayInverseMatrix: Matrix;
  10995. /** @hidden */
  10996. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10997. /** @hidden */
  10998. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10999. }
  11000. }
  11001. declare module BABYLON {
  11002. /**
  11003. * Groups all the scene component constants in one place to ease maintenance.
  11004. * @hidden
  11005. */
  11006. export class SceneComponentConstants {
  11007. static readonly NAME_EFFECTLAYER: string;
  11008. static readonly NAME_LAYER: string;
  11009. static readonly NAME_LENSFLARESYSTEM: string;
  11010. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11011. static readonly NAME_PARTICLESYSTEM: string;
  11012. static readonly NAME_GAMEPAD: string;
  11013. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11014. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11015. static readonly NAME_DEPTHRENDERER: string;
  11016. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11017. static readonly NAME_SPRITE: string;
  11018. static readonly NAME_OUTLINERENDERER: string;
  11019. static readonly NAME_PROCEDURALTEXTURE: string;
  11020. static readonly NAME_SHADOWGENERATOR: string;
  11021. static readonly NAME_OCTREE: string;
  11022. static readonly NAME_PHYSICSENGINE: string;
  11023. static readonly NAME_AUDIO: string;
  11024. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11025. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11026. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11027. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11028. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11029. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11030. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11031. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11032. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11033. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11034. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11035. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11036. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11037. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11038. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11039. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11040. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11041. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11042. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11043. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11044. static readonly STEP_AFTERRENDER_AUDIO: number;
  11045. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11046. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11047. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11048. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11049. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11050. static readonly STEP_POINTERMOVE_SPRITE: number;
  11051. static readonly STEP_POINTERDOWN_SPRITE: number;
  11052. static readonly STEP_POINTERUP_SPRITE: number;
  11053. }
  11054. /**
  11055. * This represents a scene component.
  11056. *
  11057. * This is used to decouple the dependency the scene is having on the different workloads like
  11058. * layers, post processes...
  11059. */
  11060. export interface ISceneComponent {
  11061. /**
  11062. * The name of the component. Each component must have a unique name.
  11063. */
  11064. name: string;
  11065. /**
  11066. * The scene the component belongs to.
  11067. */
  11068. scene: Scene;
  11069. /**
  11070. * Register the component to one instance of a scene.
  11071. */
  11072. register(): void;
  11073. /**
  11074. * Rebuilds the elements related to this component in case of
  11075. * context lost for instance.
  11076. */
  11077. rebuild(): void;
  11078. /**
  11079. * Disposes the component and the associated ressources.
  11080. */
  11081. dispose(): void;
  11082. }
  11083. /**
  11084. * This represents a SERIALIZABLE scene component.
  11085. *
  11086. * This extends Scene Component to add Serialization methods on top.
  11087. */
  11088. export interface ISceneSerializableComponent extends ISceneComponent {
  11089. /**
  11090. * Adds all the elements from the container to the scene
  11091. * @param container the container holding the elements
  11092. */
  11093. addFromContainer(container: AbstractScene): void;
  11094. /**
  11095. * Removes all the elements in the container from the scene
  11096. * @param container contains the elements to remove
  11097. * @param dispose if the removed element should be disposed (default: false)
  11098. */
  11099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11100. /**
  11101. * Serializes the component data to the specified json object
  11102. * @param serializationObject The object to serialize to
  11103. */
  11104. serialize(serializationObject: any): void;
  11105. }
  11106. /**
  11107. * Strong typing of a Mesh related stage step action
  11108. */
  11109. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11110. /**
  11111. * Strong typing of a Evaluate Sub Mesh related stage step action
  11112. */
  11113. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11114. /**
  11115. * Strong typing of a Active Mesh related stage step action
  11116. */
  11117. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11118. /**
  11119. * Strong typing of a Camera related stage step action
  11120. */
  11121. export type CameraStageAction = (camera: Camera) => void;
  11122. /**
  11123. * Strong typing of a Camera Frame buffer related stage step action
  11124. */
  11125. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11126. /**
  11127. * Strong typing of a Render Target related stage step action
  11128. */
  11129. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11130. /**
  11131. * Strong typing of a RenderingGroup related stage step action
  11132. */
  11133. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11134. /**
  11135. * Strong typing of a Mesh Render related stage step action
  11136. */
  11137. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11138. /**
  11139. * Strong typing of a simple stage step action
  11140. */
  11141. export type SimpleStageAction = () => void;
  11142. /**
  11143. * Strong typing of a render target action.
  11144. */
  11145. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11146. /**
  11147. * Strong typing of a pointer move action.
  11148. */
  11149. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11150. /**
  11151. * Strong typing of a pointer up/down action.
  11152. */
  11153. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11154. /**
  11155. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11156. * @hidden
  11157. */
  11158. export class Stage<T extends Function> extends Array<{
  11159. index: number;
  11160. component: ISceneComponent;
  11161. action: T;
  11162. }> {
  11163. /**
  11164. * Hide ctor from the rest of the world.
  11165. * @param items The items to add.
  11166. */
  11167. private constructor();
  11168. /**
  11169. * Creates a new Stage.
  11170. * @returns A new instance of a Stage
  11171. */
  11172. static Create<T extends Function>(): Stage<T>;
  11173. /**
  11174. * Registers a step in an ordered way in the targeted stage.
  11175. * @param index Defines the position to register the step in
  11176. * @param component Defines the component attached to the step
  11177. * @param action Defines the action to launch during the step
  11178. */
  11179. registerStep(index: number, component: ISceneComponent, action: T): void;
  11180. /**
  11181. * Clears all the steps from the stage.
  11182. */
  11183. clear(): void;
  11184. }
  11185. }
  11186. declare module BABYLON {
  11187. interface Scene {
  11188. /** @hidden */
  11189. _pointerOverSprite: Nullable<Sprite>;
  11190. /** @hidden */
  11191. _pickedDownSprite: Nullable<Sprite>;
  11192. /** @hidden */
  11193. _tempSpritePickingRay: Nullable<Ray>;
  11194. /**
  11195. * All of the sprite managers added to this scene
  11196. * @see http://doc.babylonjs.com/babylon101/sprites
  11197. */
  11198. spriteManagers: Array<ISpriteManager>;
  11199. /**
  11200. * An event triggered when sprites rendering is about to start
  11201. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11202. */
  11203. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11204. /**
  11205. * An event triggered when sprites rendering is done
  11206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11207. */
  11208. onAfterSpritesRenderingObservable: Observable<Scene>;
  11209. /** @hidden */
  11210. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11211. /** Launch a ray to try to pick a sprite in the scene
  11212. * @param x position on screen
  11213. * @param y position on screen
  11214. * @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
  11215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11216. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11217. * @returns a PickingInfo
  11218. */
  11219. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11220. /** Use the given ray to pick a sprite in the scene
  11221. * @param ray The ray (in world space) to use to pick meshes
  11222. * @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
  11223. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11224. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11225. * @returns a PickingInfo
  11226. */
  11227. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11228. /** @hidden */
  11229. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11230. /** Launch a ray to try to pick sprites in the scene
  11231. * @param x position on screen
  11232. * @param y position on screen
  11233. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11234. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11235. * @returns a PickingInfo array
  11236. */
  11237. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11238. /** Use the given ray to pick sprites in the scene
  11239. * @param ray The ray (in world space) to use to pick meshes
  11240. * @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
  11241. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11242. * @returns a PickingInfo array
  11243. */
  11244. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11245. /**
  11246. * Force the sprite under the pointer
  11247. * @param sprite defines the sprite to use
  11248. */
  11249. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11250. /**
  11251. * Gets the sprite under the pointer
  11252. * @returns a Sprite or null if no sprite is under the pointer
  11253. */
  11254. getPointerOverSprite(): Nullable<Sprite>;
  11255. }
  11256. /**
  11257. * Defines the sprite scene component responsible to manage sprites
  11258. * in a given scene.
  11259. */
  11260. export class SpriteSceneComponent implements ISceneComponent {
  11261. /**
  11262. * The component name helpfull to identify the component in the list of scene components.
  11263. */
  11264. readonly name: string;
  11265. /**
  11266. * The scene the component belongs to.
  11267. */
  11268. scene: Scene;
  11269. /** @hidden */
  11270. private _spritePredicate;
  11271. /**
  11272. * Creates a new instance of the component for the given scene
  11273. * @param scene Defines the scene to register the component in
  11274. */
  11275. constructor(scene: Scene);
  11276. /**
  11277. * Registers the component in a given scene
  11278. */
  11279. register(): void;
  11280. /**
  11281. * Rebuilds the elements related to this component in case of
  11282. * context lost for instance.
  11283. */
  11284. rebuild(): void;
  11285. /**
  11286. * Disposes the component and the associated ressources.
  11287. */
  11288. dispose(): void;
  11289. private _pickSpriteButKeepRay;
  11290. private _pointerMove;
  11291. private _pointerDown;
  11292. private _pointerUp;
  11293. }
  11294. }
  11295. declare module BABYLON {
  11296. /** @hidden */
  11297. export var fogFragmentDeclaration: {
  11298. name: string;
  11299. shader: string;
  11300. };
  11301. }
  11302. declare module BABYLON {
  11303. /** @hidden */
  11304. export var fogFragment: {
  11305. name: string;
  11306. shader: string;
  11307. };
  11308. }
  11309. declare module BABYLON {
  11310. /** @hidden */
  11311. export var spritesPixelShader: {
  11312. name: string;
  11313. shader: string;
  11314. };
  11315. }
  11316. declare module BABYLON {
  11317. /** @hidden */
  11318. export var fogVertexDeclaration: {
  11319. name: string;
  11320. shader: string;
  11321. };
  11322. }
  11323. declare module BABYLON {
  11324. /** @hidden */
  11325. export var spritesVertexShader: {
  11326. name: string;
  11327. shader: string;
  11328. };
  11329. }
  11330. declare module BABYLON {
  11331. /**
  11332. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11333. */
  11334. export interface ISpriteManager extends IDisposable {
  11335. /**
  11336. * Restricts the camera to viewing objects with the same layerMask.
  11337. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11338. */
  11339. layerMask: number;
  11340. /**
  11341. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11342. */
  11343. isPickable: boolean;
  11344. /**
  11345. * Specifies the rendering group id for this mesh (0 by default)
  11346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11347. */
  11348. renderingGroupId: number;
  11349. /**
  11350. * Defines the list of sprites managed by the manager.
  11351. */
  11352. sprites: Array<Sprite>;
  11353. /**
  11354. * Tests the intersection of a sprite with a specific ray.
  11355. * @param ray The ray we are sending to test the collision
  11356. * @param camera The camera space we are sending rays in
  11357. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11358. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11359. * @returns picking info or null.
  11360. */
  11361. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11362. /**
  11363. * Intersects the sprites with a ray
  11364. * @param ray defines the ray to intersect with
  11365. * @param camera defines the current active camera
  11366. * @param predicate defines a predicate used to select candidate sprites
  11367. * @returns null if no hit or a PickingInfo array
  11368. */
  11369. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11370. /**
  11371. * Renders the list of sprites on screen.
  11372. */
  11373. render(): void;
  11374. }
  11375. /**
  11376. * Class used to manage multiple sprites on the same spritesheet
  11377. * @see http://doc.babylonjs.com/babylon101/sprites
  11378. */
  11379. export class SpriteManager implements ISpriteManager {
  11380. /** defines the manager's name */
  11381. name: string;
  11382. /** Gets the list of sprites */
  11383. sprites: Sprite[];
  11384. /** Gets or sets the rendering group id (0 by default) */
  11385. renderingGroupId: number;
  11386. /** Gets or sets camera layer mask */
  11387. layerMask: number;
  11388. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11389. fogEnabled: boolean;
  11390. /** Gets or sets a boolean indicating if the sprites are pickable */
  11391. isPickable: boolean;
  11392. /** Defines the default width of a cell in the spritesheet */
  11393. cellWidth: number;
  11394. /** Defines the default height of a cell in the spritesheet */
  11395. cellHeight: number;
  11396. /** Associative array from JSON sprite data file */
  11397. private _cellData;
  11398. /** Array of sprite names from JSON sprite data file */
  11399. private _spriteMap;
  11400. /** True when packed cell data from JSON file is ready*/
  11401. private _packedAndReady;
  11402. /**
  11403. * An event triggered when the manager is disposed.
  11404. */
  11405. onDisposeObservable: Observable<SpriteManager>;
  11406. private _onDisposeObserver;
  11407. /**
  11408. * Callback called when the manager is disposed
  11409. */
  11410. onDispose: () => void;
  11411. private _capacity;
  11412. private _fromPacked;
  11413. private _spriteTexture;
  11414. private _epsilon;
  11415. private _scene;
  11416. private _vertexData;
  11417. private _buffer;
  11418. private _vertexBuffers;
  11419. private _indexBuffer;
  11420. private _effectBase;
  11421. private _effectFog;
  11422. /**
  11423. * Gets or sets the spritesheet texture
  11424. */
  11425. texture: Texture;
  11426. /**
  11427. * Creates a new sprite manager
  11428. * @param name defines the manager's name
  11429. * @param imgUrl defines the sprite sheet url
  11430. * @param capacity defines the maximum allowed number of sprites
  11431. * @param cellSize defines the size of a sprite cell
  11432. * @param scene defines the hosting scene
  11433. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11434. * @param samplingMode defines the smapling mode to use with spritesheet
  11435. * @param fromPacked set to false; do not alter
  11436. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11437. */
  11438. constructor(
  11439. /** defines the manager's name */
  11440. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11441. private _makePacked;
  11442. private _appendSpriteVertex;
  11443. /**
  11444. * Intersects the sprites with a ray
  11445. * @param ray defines the ray to intersect with
  11446. * @param camera defines the current active camera
  11447. * @param predicate defines a predicate used to select candidate sprites
  11448. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11449. * @returns null if no hit or a PickingInfo
  11450. */
  11451. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11452. /**
  11453. * Intersects the sprites with a ray
  11454. * @param ray defines the ray to intersect with
  11455. * @param camera defines the current active camera
  11456. * @param predicate defines a predicate used to select candidate sprites
  11457. * @returns null if no hit or a PickingInfo array
  11458. */
  11459. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11460. /**
  11461. * Render all child sprites
  11462. */
  11463. render(): void;
  11464. /**
  11465. * Release associated resources
  11466. */
  11467. dispose(): void;
  11468. }
  11469. }
  11470. declare module BABYLON {
  11471. /**
  11472. * Class used to represent a sprite
  11473. * @see http://doc.babylonjs.com/babylon101/sprites
  11474. */
  11475. export class Sprite {
  11476. /** defines the name */
  11477. name: string;
  11478. /** Gets or sets the current world position */
  11479. position: Vector3;
  11480. /** Gets or sets the main color */
  11481. color: Color4;
  11482. /** Gets or sets the width */
  11483. width: number;
  11484. /** Gets or sets the height */
  11485. height: number;
  11486. /** Gets or sets rotation angle */
  11487. angle: number;
  11488. /** Gets or sets the cell index in the sprite sheet */
  11489. cellIndex: number;
  11490. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11491. cellRef: string;
  11492. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11493. invertU: number;
  11494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11495. invertV: number;
  11496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11497. disposeWhenFinishedAnimating: boolean;
  11498. /** Gets the list of attached animations */
  11499. animations: Animation[];
  11500. /** Gets or sets a boolean indicating if the sprite can be picked */
  11501. isPickable: boolean;
  11502. /**
  11503. * Gets or sets the associated action manager
  11504. */
  11505. actionManager: Nullable<ActionManager>;
  11506. private _animationStarted;
  11507. private _loopAnimation;
  11508. private _fromIndex;
  11509. private _toIndex;
  11510. private _delay;
  11511. private _direction;
  11512. private _manager;
  11513. private _time;
  11514. private _onAnimationEnd;
  11515. /**
  11516. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11517. */
  11518. isVisible: boolean;
  11519. /**
  11520. * Gets or sets the sprite size
  11521. */
  11522. size: number;
  11523. /**
  11524. * Creates a new Sprite
  11525. * @param name defines the name
  11526. * @param manager defines the manager
  11527. */
  11528. constructor(
  11529. /** defines the name */
  11530. name: string, manager: ISpriteManager);
  11531. /**
  11532. * Starts an animation
  11533. * @param from defines the initial key
  11534. * @param to defines the end key
  11535. * @param loop defines if the animation must loop
  11536. * @param delay defines the start delay (in ms)
  11537. * @param onAnimationEnd defines a callback to call when animation ends
  11538. */
  11539. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11540. /** Stops current animation (if any) */
  11541. stopAnimation(): void;
  11542. /** @hidden */
  11543. _animate(deltaTime: number): void;
  11544. /** Release associated resources */
  11545. dispose(): void;
  11546. }
  11547. }
  11548. declare module BABYLON {
  11549. /**
  11550. * Information about the result of picking within a scene
  11551. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11552. */
  11553. export class PickingInfo {
  11554. /** @hidden */
  11555. _pickingUnavailable: boolean;
  11556. /**
  11557. * If the pick collided with an object
  11558. */
  11559. hit: boolean;
  11560. /**
  11561. * Distance away where the pick collided
  11562. */
  11563. distance: number;
  11564. /**
  11565. * The location of pick collision
  11566. */
  11567. pickedPoint: Nullable<Vector3>;
  11568. /**
  11569. * The mesh corresponding the the pick collision
  11570. */
  11571. pickedMesh: Nullable<AbstractMesh>;
  11572. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11573. bu: number;
  11574. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11575. bv: number;
  11576. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11577. faceId: number;
  11578. /** Id of the the submesh that was picked */
  11579. subMeshId: number;
  11580. /** If a sprite was picked, this will be the sprite the pick collided with */
  11581. pickedSprite: Nullable<Sprite>;
  11582. /**
  11583. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11584. */
  11585. originMesh: Nullable<AbstractMesh>;
  11586. /**
  11587. * The ray that was used to perform the picking.
  11588. */
  11589. ray: Nullable<Ray>;
  11590. /**
  11591. * Gets the normal correspodning to the face the pick collided with
  11592. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11593. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11594. * @returns The normal correspodning to the face the pick collided with
  11595. */
  11596. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11597. /**
  11598. * Gets the texture coordinates of where the pick occured
  11599. * @returns the vector containing the coordnates of the texture
  11600. */
  11601. getTextureCoordinates(): Nullable<Vector2>;
  11602. }
  11603. }
  11604. declare module BABYLON {
  11605. /**
  11606. * Gather the list of pointer event types as constants.
  11607. */
  11608. export class PointerEventTypes {
  11609. /**
  11610. * 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.
  11611. */
  11612. static readonly POINTERDOWN: number;
  11613. /**
  11614. * The pointerup event is fired when a pointer is no longer active.
  11615. */
  11616. static readonly POINTERUP: number;
  11617. /**
  11618. * The pointermove event is fired when a pointer changes coordinates.
  11619. */
  11620. static readonly POINTERMOVE: number;
  11621. /**
  11622. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11623. */
  11624. static readonly POINTERWHEEL: number;
  11625. /**
  11626. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11627. */
  11628. static readonly POINTERPICK: number;
  11629. /**
  11630. * The pointertap event is fired when a the object has been touched and released without drag.
  11631. */
  11632. static readonly POINTERTAP: number;
  11633. /**
  11634. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11635. */
  11636. static readonly POINTERDOUBLETAP: number;
  11637. }
  11638. /**
  11639. * Base class of pointer info types.
  11640. */
  11641. export class PointerInfoBase {
  11642. /**
  11643. * Defines the type of event (PointerEventTypes)
  11644. */
  11645. type: number;
  11646. /**
  11647. * Defines the related dom event
  11648. */
  11649. event: PointerEvent | MouseWheelEvent;
  11650. /**
  11651. * Instantiates the base class of pointers info.
  11652. * @param type Defines the type of event (PointerEventTypes)
  11653. * @param event Defines the related dom event
  11654. */
  11655. constructor(
  11656. /**
  11657. * Defines the type of event (PointerEventTypes)
  11658. */
  11659. type: number,
  11660. /**
  11661. * Defines the related dom event
  11662. */
  11663. event: PointerEvent | MouseWheelEvent);
  11664. }
  11665. /**
  11666. * This class is used to store pointer related info for the onPrePointerObservable event.
  11667. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11668. */
  11669. export class PointerInfoPre extends PointerInfoBase {
  11670. /**
  11671. * Ray from a pointer if availible (eg. 6dof controller)
  11672. */
  11673. ray: Nullable<Ray>;
  11674. /**
  11675. * Defines the local position of the pointer on the canvas.
  11676. */
  11677. localPosition: Vector2;
  11678. /**
  11679. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11680. */
  11681. skipOnPointerObservable: boolean;
  11682. /**
  11683. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11684. * @param type Defines the type of event (PointerEventTypes)
  11685. * @param event Defines the related dom event
  11686. * @param localX Defines the local x coordinates of the pointer when the event occured
  11687. * @param localY Defines the local y coordinates of the pointer when the event occured
  11688. */
  11689. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11690. }
  11691. /**
  11692. * This type contains all the data related to a pointer event in Babylon.js.
  11693. * 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.
  11694. */
  11695. export class PointerInfo extends PointerInfoBase {
  11696. /**
  11697. * Defines the picking info associated to the info (if any)\
  11698. */
  11699. pickInfo: Nullable<PickingInfo>;
  11700. /**
  11701. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11702. * @param type Defines the type of event (PointerEventTypes)
  11703. * @param event Defines the related dom event
  11704. * @param pickInfo Defines the picking info associated to the info (if any)\
  11705. */
  11706. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11707. /**
  11708. * Defines the picking info associated to the info (if any)\
  11709. */
  11710. pickInfo: Nullable<PickingInfo>);
  11711. }
  11712. /**
  11713. * Data relating to a touch event on the screen.
  11714. */
  11715. export interface PointerTouch {
  11716. /**
  11717. * X coordinate of touch.
  11718. */
  11719. x: number;
  11720. /**
  11721. * Y coordinate of touch.
  11722. */
  11723. y: number;
  11724. /**
  11725. * Id of touch. Unique for each finger.
  11726. */
  11727. pointerId: number;
  11728. /**
  11729. * Event type passed from DOM.
  11730. */
  11731. type: any;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. /**
  11736. * Manage the mouse inputs to control the movement of a free camera.
  11737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11738. */
  11739. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11740. /**
  11741. * Define if touch is enabled in the mouse input
  11742. */
  11743. touchEnabled: boolean;
  11744. /**
  11745. * Defines the camera the input is attached to.
  11746. */
  11747. camera: FreeCamera;
  11748. /**
  11749. * Defines the buttons associated with the input to handle camera move.
  11750. */
  11751. buttons: number[];
  11752. /**
  11753. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11754. */
  11755. angularSensibility: number;
  11756. private _pointerInput;
  11757. private _onMouseMove;
  11758. private _observer;
  11759. private previousPosition;
  11760. /**
  11761. * Observable for when a pointer move event occurs containing the move offset
  11762. */
  11763. onPointerMovedObservable: Observable<{
  11764. offsetX: number;
  11765. offsetY: number;
  11766. }>;
  11767. /**
  11768. * @hidden
  11769. * If the camera should be rotated automatically based on pointer movement
  11770. */
  11771. _allowCameraRotation: boolean;
  11772. /**
  11773. * Manage the mouse inputs to control the movement of a free camera.
  11774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11775. * @param touchEnabled Defines if touch is enabled or not
  11776. */
  11777. constructor(
  11778. /**
  11779. * Define if touch is enabled in the mouse input
  11780. */
  11781. touchEnabled?: boolean);
  11782. /**
  11783. * Attach the input controls to a specific dom element to get the input from.
  11784. * @param element Defines the element the controls should be listened from
  11785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11786. */
  11787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11788. /**
  11789. * Called on JS contextmenu event.
  11790. * Override this method to provide functionality.
  11791. */
  11792. protected onContextMenu(evt: PointerEvent): void;
  11793. /**
  11794. * Detach the current controls from the specified dom element.
  11795. * @param element Defines the element to stop listening the inputs from
  11796. */
  11797. detachControl(element: Nullable<HTMLElement>): void;
  11798. /**
  11799. * Gets the class name of the current intput.
  11800. * @returns the class name
  11801. */
  11802. getClassName(): string;
  11803. /**
  11804. * Get the friendly name associated with the input class.
  11805. * @returns the input friendly name
  11806. */
  11807. getSimpleName(): string;
  11808. }
  11809. }
  11810. declare module BABYLON {
  11811. /**
  11812. * Manage the touch inputs to control the movement of a free camera.
  11813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11814. */
  11815. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11816. /**
  11817. * Defines the camera the input is attached to.
  11818. */
  11819. camera: FreeCamera;
  11820. /**
  11821. * Defines the touch sensibility for rotation.
  11822. * The higher the faster.
  11823. */
  11824. touchAngularSensibility: number;
  11825. /**
  11826. * Defines the touch sensibility for move.
  11827. * The higher the faster.
  11828. */
  11829. touchMoveSensibility: number;
  11830. private _offsetX;
  11831. private _offsetY;
  11832. private _pointerPressed;
  11833. private _pointerInput;
  11834. private _observer;
  11835. private _onLostFocus;
  11836. /**
  11837. * Attach the input controls to a specific dom element to get the input from.
  11838. * @param element Defines the element the controls should be listened from
  11839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11840. */
  11841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11842. /**
  11843. * Detach the current controls from the specified dom element.
  11844. * @param element Defines the element to stop listening the inputs from
  11845. */
  11846. detachControl(element: Nullable<HTMLElement>): void;
  11847. /**
  11848. * Update the current camera state depending on the inputs that have been used this frame.
  11849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11850. */
  11851. checkInputs(): void;
  11852. /**
  11853. * Gets the class name of the current intput.
  11854. * @returns the class name
  11855. */
  11856. getClassName(): string;
  11857. /**
  11858. * Get the friendly name associated with the input class.
  11859. * @returns the input friendly name
  11860. */
  11861. getSimpleName(): string;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * Default Inputs manager for the FreeCamera.
  11867. * It groups all the default supported inputs for ease of use.
  11868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11869. */
  11870. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11871. /**
  11872. * @hidden
  11873. */
  11874. _mouseInput: Nullable<FreeCameraMouseInput>;
  11875. /**
  11876. * Instantiates a new FreeCameraInputsManager.
  11877. * @param camera Defines the camera the inputs belong to
  11878. */
  11879. constructor(camera: FreeCamera);
  11880. /**
  11881. * Add keyboard input support to the input manager.
  11882. * @returns the current input manager
  11883. */
  11884. addKeyboard(): FreeCameraInputsManager;
  11885. /**
  11886. * Add mouse input support to the input manager.
  11887. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11888. * @returns the current input manager
  11889. */
  11890. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11891. /**
  11892. * Removes the mouse input support from the manager
  11893. * @returns the current input manager
  11894. */
  11895. removeMouse(): FreeCameraInputsManager;
  11896. /**
  11897. * Add touch input support to the input manager.
  11898. * @returns the current input manager
  11899. */
  11900. addTouch(): FreeCameraInputsManager;
  11901. /**
  11902. * Remove all attached input methods from a camera
  11903. */
  11904. clear(): void;
  11905. }
  11906. }
  11907. declare module BABYLON {
  11908. /**
  11909. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11910. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11911. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11912. */
  11913. export class FreeCamera extends TargetCamera {
  11914. /**
  11915. * Define the collision ellipsoid of the camera.
  11916. * This is helpful to simulate a camera body like the player body around the camera
  11917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11918. */
  11919. ellipsoid: Vector3;
  11920. /**
  11921. * Define an offset for the position of the ellipsoid around the camera.
  11922. * This can be helpful to determine the center of the body near the gravity center of the body
  11923. * instead of its head.
  11924. */
  11925. ellipsoidOffset: Vector3;
  11926. /**
  11927. * Enable or disable collisions of the camera with the rest of the scene objects.
  11928. */
  11929. checkCollisions: boolean;
  11930. /**
  11931. * Enable or disable gravity on the camera.
  11932. */
  11933. applyGravity: boolean;
  11934. /**
  11935. * Define the input manager associated to the camera.
  11936. */
  11937. inputs: FreeCameraInputsManager;
  11938. /**
  11939. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11940. * Higher values reduce sensitivity.
  11941. */
  11942. /**
  11943. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11944. * Higher values reduce sensitivity.
  11945. */
  11946. angularSensibility: number;
  11947. /**
  11948. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11949. */
  11950. keysUp: number[];
  11951. /**
  11952. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11953. */
  11954. keysDown: number[];
  11955. /**
  11956. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11957. */
  11958. keysLeft: number[];
  11959. /**
  11960. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11961. */
  11962. keysRight: number[];
  11963. /**
  11964. * Event raised when the camera collide with a mesh in the scene.
  11965. */
  11966. onCollide: (collidedMesh: AbstractMesh) => void;
  11967. private _collider;
  11968. private _needMoveForGravity;
  11969. private _oldPosition;
  11970. private _diffPosition;
  11971. private _newPosition;
  11972. /** @hidden */
  11973. _localDirection: Vector3;
  11974. /** @hidden */
  11975. _transformedDirection: Vector3;
  11976. /**
  11977. * Instantiates a Free Camera.
  11978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11979. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11981. * @param name Define the name of the camera in the scene
  11982. * @param position Define the start position of the camera in the scene
  11983. * @param scene Define the scene the camera belongs to
  11984. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11985. */
  11986. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11987. /**
  11988. * Attached controls to the current camera.
  11989. * @param element Defines the element the controls should be listened from
  11990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11991. */
  11992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11993. /**
  11994. * Detach the current controls from the camera.
  11995. * The camera will stop reacting to inputs.
  11996. * @param element Defines the element to stop listening the inputs from
  11997. */
  11998. detachControl(element: HTMLElement): void;
  11999. private _collisionMask;
  12000. /**
  12001. * Define a collision mask to limit the list of object the camera can collide with
  12002. */
  12003. collisionMask: number;
  12004. /** @hidden */
  12005. _collideWithWorld(displacement: Vector3): void;
  12006. private _onCollisionPositionChange;
  12007. /** @hidden */
  12008. _checkInputs(): void;
  12009. /** @hidden */
  12010. _decideIfNeedsToMove(): boolean;
  12011. /** @hidden */
  12012. _updatePosition(): void;
  12013. /**
  12014. * Destroy the camera and release the current resources hold by it.
  12015. */
  12016. dispose(): void;
  12017. /**
  12018. * Gets the current object class name.
  12019. * @return the class name
  12020. */
  12021. getClassName(): string;
  12022. }
  12023. }
  12024. declare module BABYLON {
  12025. /**
  12026. * Represents a gamepad control stick position
  12027. */
  12028. export class StickValues {
  12029. /**
  12030. * The x component of the control stick
  12031. */
  12032. x: number;
  12033. /**
  12034. * The y component of the control stick
  12035. */
  12036. y: number;
  12037. /**
  12038. * Initializes the gamepad x and y control stick values
  12039. * @param x The x component of the gamepad control stick value
  12040. * @param y The y component of the gamepad control stick value
  12041. */
  12042. constructor(
  12043. /**
  12044. * The x component of the control stick
  12045. */
  12046. x: number,
  12047. /**
  12048. * The y component of the control stick
  12049. */
  12050. y: number);
  12051. }
  12052. /**
  12053. * An interface which manages callbacks for gamepad button changes
  12054. */
  12055. export interface GamepadButtonChanges {
  12056. /**
  12057. * Called when a gamepad has been changed
  12058. */
  12059. changed: boolean;
  12060. /**
  12061. * Called when a gamepad press event has been triggered
  12062. */
  12063. pressChanged: boolean;
  12064. /**
  12065. * Called when a touch event has been triggered
  12066. */
  12067. touchChanged: boolean;
  12068. /**
  12069. * Called when a value has changed
  12070. */
  12071. valueChanged: boolean;
  12072. }
  12073. /**
  12074. * Represents a gamepad
  12075. */
  12076. export class Gamepad {
  12077. /**
  12078. * The id of the gamepad
  12079. */
  12080. id: string;
  12081. /**
  12082. * The index of the gamepad
  12083. */
  12084. index: number;
  12085. /**
  12086. * The browser gamepad
  12087. */
  12088. browserGamepad: any;
  12089. /**
  12090. * Specifies what type of gamepad this represents
  12091. */
  12092. type: number;
  12093. private _leftStick;
  12094. private _rightStick;
  12095. /** @hidden */
  12096. _isConnected: boolean;
  12097. private _leftStickAxisX;
  12098. private _leftStickAxisY;
  12099. private _rightStickAxisX;
  12100. private _rightStickAxisY;
  12101. /**
  12102. * Triggered when the left control stick has been changed
  12103. */
  12104. private _onleftstickchanged;
  12105. /**
  12106. * Triggered when the right control stick has been changed
  12107. */
  12108. private _onrightstickchanged;
  12109. /**
  12110. * Represents a gamepad controller
  12111. */
  12112. static GAMEPAD: number;
  12113. /**
  12114. * Represents a generic controller
  12115. */
  12116. static GENERIC: number;
  12117. /**
  12118. * Represents an XBox controller
  12119. */
  12120. static XBOX: number;
  12121. /**
  12122. * Represents a pose-enabled controller
  12123. */
  12124. static POSE_ENABLED: number;
  12125. /**
  12126. * Represents an Dual Shock controller
  12127. */
  12128. static DUALSHOCK: number;
  12129. /**
  12130. * Specifies whether the left control stick should be Y-inverted
  12131. */
  12132. protected _invertLeftStickY: boolean;
  12133. /**
  12134. * Specifies if the gamepad has been connected
  12135. */
  12136. readonly isConnected: boolean;
  12137. /**
  12138. * Initializes the gamepad
  12139. * @param id The id of the gamepad
  12140. * @param index The index of the gamepad
  12141. * @param browserGamepad The browser gamepad
  12142. * @param leftStickX The x component of the left joystick
  12143. * @param leftStickY The y component of the left joystick
  12144. * @param rightStickX The x component of the right joystick
  12145. * @param rightStickY The y component of the right joystick
  12146. */
  12147. constructor(
  12148. /**
  12149. * The id of the gamepad
  12150. */
  12151. id: string,
  12152. /**
  12153. * The index of the gamepad
  12154. */
  12155. index: number,
  12156. /**
  12157. * The browser gamepad
  12158. */
  12159. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12160. /**
  12161. * Callback triggered when the left joystick has changed
  12162. * @param callback
  12163. */
  12164. onleftstickchanged(callback: (values: StickValues) => void): void;
  12165. /**
  12166. * Callback triggered when the right joystick has changed
  12167. * @param callback
  12168. */
  12169. onrightstickchanged(callback: (values: StickValues) => void): void;
  12170. /**
  12171. * Gets the left joystick
  12172. */
  12173. /**
  12174. * Sets the left joystick values
  12175. */
  12176. leftStick: StickValues;
  12177. /**
  12178. * Gets the right joystick
  12179. */
  12180. /**
  12181. * Sets the right joystick value
  12182. */
  12183. rightStick: StickValues;
  12184. /**
  12185. * Updates the gamepad joystick positions
  12186. */
  12187. update(): void;
  12188. /**
  12189. * Disposes the gamepad
  12190. */
  12191. dispose(): void;
  12192. }
  12193. /**
  12194. * Represents a generic gamepad
  12195. */
  12196. export class GenericPad extends Gamepad {
  12197. private _buttons;
  12198. private _onbuttondown;
  12199. private _onbuttonup;
  12200. /**
  12201. * Observable triggered when a button has been pressed
  12202. */
  12203. onButtonDownObservable: Observable<number>;
  12204. /**
  12205. * Observable triggered when a button has been released
  12206. */
  12207. onButtonUpObservable: Observable<number>;
  12208. /**
  12209. * Callback triggered when a button has been pressed
  12210. * @param callback Called when a button has been pressed
  12211. */
  12212. onbuttondown(callback: (buttonPressed: number) => void): void;
  12213. /**
  12214. * Callback triggered when a button has been released
  12215. * @param callback Called when a button has been released
  12216. */
  12217. onbuttonup(callback: (buttonReleased: number) => void): void;
  12218. /**
  12219. * Initializes the generic gamepad
  12220. * @param id The id of the generic gamepad
  12221. * @param index The index of the generic gamepad
  12222. * @param browserGamepad The browser gamepad
  12223. */
  12224. constructor(id: string, index: number, browserGamepad: any);
  12225. private _setButtonValue;
  12226. /**
  12227. * Updates the generic gamepad
  12228. */
  12229. update(): void;
  12230. /**
  12231. * Disposes the generic gamepad
  12232. */
  12233. dispose(): void;
  12234. }
  12235. }
  12236. declare module BABYLON {
  12237. interface Engine {
  12238. /**
  12239. * Creates a raw texture
  12240. * @param data defines the data to store in the texture
  12241. * @param width defines the width of the texture
  12242. * @param height defines the height of the texture
  12243. * @param format defines the format of the data
  12244. * @param generateMipMaps defines if the engine should generate the mip levels
  12245. * @param invertY defines if data must be stored with Y axis inverted
  12246. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12247. * @param compression defines the compression used (null by default)
  12248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12249. * @returns the raw texture inside an InternalTexture
  12250. */
  12251. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12252. /**
  12253. * Update a raw texture
  12254. * @param texture defines the texture to update
  12255. * @param data defines the data to store in the texture
  12256. * @param format defines the format of the data
  12257. * @param invertY defines if data must be stored with Y axis inverted
  12258. */
  12259. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12260. /**
  12261. * Update a raw texture
  12262. * @param texture defines the texture to update
  12263. * @param data defines the data to store in the texture
  12264. * @param format defines the format of the data
  12265. * @param invertY defines if data must be stored with Y axis inverted
  12266. * @param compression defines the compression used (null by default)
  12267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12268. */
  12269. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12270. /**
  12271. * Creates a new raw cube texture
  12272. * @param data defines the array of data to use to create each face
  12273. * @param size defines the size of the textures
  12274. * @param format defines the format of the data
  12275. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12276. * @param generateMipMaps defines if the engine should generate the mip levels
  12277. * @param invertY defines if data must be stored with Y axis inverted
  12278. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12279. * @param compression defines the compression used (null by default)
  12280. * @returns the cube texture as an InternalTexture
  12281. */
  12282. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12283. /**
  12284. * Update a raw cube texture
  12285. * @param texture defines the texture to udpdate
  12286. * @param data defines the data to store
  12287. * @param format defines the data format
  12288. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12289. * @param invertY defines if data must be stored with Y axis inverted
  12290. */
  12291. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12292. /**
  12293. * Update a raw cube texture
  12294. * @param texture defines the texture to udpdate
  12295. * @param data defines the data to store
  12296. * @param format defines the data format
  12297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12298. * @param invertY defines if data must be stored with Y axis inverted
  12299. * @param compression defines the compression used (null by default)
  12300. */
  12301. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12302. /**
  12303. * Update a raw cube texture
  12304. * @param texture defines the texture to udpdate
  12305. * @param data defines the data to store
  12306. * @param format defines the data format
  12307. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12308. * @param invertY defines if data must be stored with Y axis inverted
  12309. * @param compression defines the compression used (null by default)
  12310. * @param level defines which level of the texture to update
  12311. */
  12312. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12313. /**
  12314. * Creates a new raw cube texture from a specified url
  12315. * @param url defines the url where the data is located
  12316. * @param scene defines the current scene
  12317. * @param size defines the size of the textures
  12318. * @param format defines the format of the data
  12319. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12320. * @param noMipmap defines if the engine should avoid generating the mip levels
  12321. * @param callback defines a callback used to extract texture data from loaded data
  12322. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12323. * @param onLoad defines a callback called when texture is loaded
  12324. * @param onError defines a callback called if there is an error
  12325. * @returns the cube texture as an InternalTexture
  12326. */
  12327. 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;
  12328. /**
  12329. * Creates a new raw cube texture from a specified url
  12330. * @param url defines the url where the data is located
  12331. * @param scene defines the current scene
  12332. * @param size defines the size of the textures
  12333. * @param format defines the format of the data
  12334. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12335. * @param noMipmap defines if the engine should avoid generating the mip levels
  12336. * @param callback defines a callback used to extract texture data from loaded data
  12337. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12338. * @param onLoad defines a callback called when texture is loaded
  12339. * @param onError defines a callback called if there is an error
  12340. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12341. * @param invertY defines if data must be stored with Y axis inverted
  12342. * @returns the cube texture as an InternalTexture
  12343. */
  12344. 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;
  12345. /**
  12346. * Creates a new raw 3D texture
  12347. * @param data defines the data used to create the texture
  12348. * @param width defines the width of the texture
  12349. * @param height defines the height of the texture
  12350. * @param depth defines the depth of the texture
  12351. * @param format defines the format of the texture
  12352. * @param generateMipMaps defines if the engine must generate mip levels
  12353. * @param invertY defines if data must be stored with Y axis inverted
  12354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12355. * @param compression defines the compressed used (can be null)
  12356. * @param textureType defines the compressed used (can be null)
  12357. * @returns a new raw 3D texture (stored in an InternalTexture)
  12358. */
  12359. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12360. /**
  12361. * Update a raw 3D texture
  12362. * @param texture defines the texture to update
  12363. * @param data defines the data to store
  12364. * @param format defines the data format
  12365. * @param invertY defines if data must be stored with Y axis inverted
  12366. */
  12367. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12368. /**
  12369. * Update a raw 3D texture
  12370. * @param texture defines the texture to update
  12371. * @param data defines the data to store
  12372. * @param format defines the data format
  12373. * @param invertY defines if data must be stored with Y axis inverted
  12374. * @param compression defines the used compression (can be null)
  12375. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12376. */
  12377. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12378. }
  12379. }
  12380. declare module BABYLON {
  12381. /**
  12382. * Raw texture can help creating a texture directly from an array of data.
  12383. * This can be super useful if you either get the data from an uncompressed source or
  12384. * if you wish to create your texture pixel by pixel.
  12385. */
  12386. export class RawTexture extends Texture {
  12387. /**
  12388. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12389. */
  12390. format: number;
  12391. private _engine;
  12392. /**
  12393. * Instantiates a new RawTexture.
  12394. * Raw texture can help creating a texture directly from an array of data.
  12395. * This can be super useful if you either get the data from an uncompressed source or
  12396. * if you wish to create your texture pixel by pixel.
  12397. * @param data define the array of data to use to create the texture
  12398. * @param width define the width of the texture
  12399. * @param height define the height of the texture
  12400. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12401. * @param scene define the scene the texture belongs to
  12402. * @param generateMipMaps define whether mip maps should be generated or not
  12403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12405. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12406. */
  12407. constructor(data: ArrayBufferView, width: number, height: number,
  12408. /**
  12409. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12410. */
  12411. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12412. /**
  12413. * Updates the texture underlying data.
  12414. * @param data Define the new data of the texture
  12415. */
  12416. update(data: ArrayBufferView): void;
  12417. /**
  12418. * Creates a luminance texture from some data.
  12419. * @param data Define the texture data
  12420. * @param width Define the width of the texture
  12421. * @param height Define the height of the texture
  12422. * @param scene Define the scene the texture belongs to
  12423. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12424. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12425. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12426. * @returns the luminance texture
  12427. */
  12428. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12429. /**
  12430. * Creates a luminance alpha texture from some data.
  12431. * @param data Define the texture data
  12432. * @param width Define the width of the texture
  12433. * @param height Define the height of the texture
  12434. * @param scene Define the scene the texture belongs to
  12435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12438. * @returns the luminance alpha texture
  12439. */
  12440. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12441. /**
  12442. * Creates an alpha texture from some data.
  12443. * @param data Define the texture data
  12444. * @param width Define the width of the texture
  12445. * @param height Define the height of the texture
  12446. * @param scene Define the scene the texture belongs to
  12447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12450. * @returns the alpha texture
  12451. */
  12452. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12453. /**
  12454. * Creates a RGB texture from some data.
  12455. * @param data Define the texture data
  12456. * @param width Define the width of the texture
  12457. * @param height Define the height of the texture
  12458. * @param scene Define the scene the texture belongs to
  12459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12462. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12463. * @returns the RGB alpha texture
  12464. */
  12465. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12466. /**
  12467. * Creates a RGBA texture from some data.
  12468. * @param data Define the texture data
  12469. * @param width Define the width of the texture
  12470. * @param height Define the height of the texture
  12471. * @param scene Define the scene the texture belongs to
  12472. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12473. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12474. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12475. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12476. * @returns the RGBA texture
  12477. */
  12478. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12479. /**
  12480. * Creates a R texture from some data.
  12481. * @param data Define the texture data
  12482. * @param width Define the width of the texture
  12483. * @param height Define the height of the texture
  12484. * @param scene Define the scene the texture belongs to
  12485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12488. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12489. * @returns the R texture
  12490. */
  12491. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12492. }
  12493. }
  12494. declare module BABYLON {
  12495. /**
  12496. * Interface for the size containing width and height
  12497. */
  12498. export interface ISize {
  12499. /**
  12500. * Width
  12501. */
  12502. width: number;
  12503. /**
  12504. * Heighht
  12505. */
  12506. height: number;
  12507. }
  12508. /**
  12509. * Size containing widht and height
  12510. */
  12511. export class Size implements ISize {
  12512. /**
  12513. * Width
  12514. */
  12515. width: number;
  12516. /**
  12517. * Height
  12518. */
  12519. height: number;
  12520. /**
  12521. * Creates a Size object from the given width and height (floats).
  12522. * @param width width of the new size
  12523. * @param height height of the new size
  12524. */
  12525. constructor(width: number, height: number);
  12526. /**
  12527. * Returns a string with the Size width and height
  12528. * @returns a string with the Size width and height
  12529. */
  12530. toString(): string;
  12531. /**
  12532. * "Size"
  12533. * @returns the string "Size"
  12534. */
  12535. getClassName(): string;
  12536. /**
  12537. * Returns the Size hash code.
  12538. * @returns a hash code for a unique width and height
  12539. */
  12540. getHashCode(): number;
  12541. /**
  12542. * Updates the current size from the given one.
  12543. * @param src the given size
  12544. */
  12545. copyFrom(src: Size): void;
  12546. /**
  12547. * Updates in place the current Size from the given floats.
  12548. * @param width width of the new size
  12549. * @param height height of the new size
  12550. * @returns the updated Size.
  12551. */
  12552. copyFromFloats(width: number, height: number): Size;
  12553. /**
  12554. * Updates in place the current Size from the given floats.
  12555. * @param width width to set
  12556. * @param height height to set
  12557. * @returns the updated Size.
  12558. */
  12559. set(width: number, height: number): Size;
  12560. /**
  12561. * Multiplies the width and height by numbers
  12562. * @param w factor to multiple the width by
  12563. * @param h factor to multiple the height by
  12564. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12565. */
  12566. multiplyByFloats(w: number, h: number): Size;
  12567. /**
  12568. * Clones the size
  12569. * @returns a new Size copied from the given one.
  12570. */
  12571. clone(): Size;
  12572. /**
  12573. * True if the current Size and the given one width and height are strictly equal.
  12574. * @param other the other size to compare against
  12575. * @returns True if the current Size and the given one width and height are strictly equal.
  12576. */
  12577. equals(other: Size): boolean;
  12578. /**
  12579. * The surface of the Size : width * height (float).
  12580. */
  12581. readonly surface: number;
  12582. /**
  12583. * Create a new size of zero
  12584. * @returns a new Size set to (0.0, 0.0)
  12585. */
  12586. static Zero(): Size;
  12587. /**
  12588. * Sums the width and height of two sizes
  12589. * @param otherSize size to add to this size
  12590. * @returns a new Size set as the addition result of the current Size and the given one.
  12591. */
  12592. add(otherSize: Size): Size;
  12593. /**
  12594. * Subtracts the width and height of two
  12595. * @param otherSize size to subtract to this size
  12596. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12597. */
  12598. subtract(otherSize: Size): Size;
  12599. /**
  12600. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12601. * @param start starting size to lerp between
  12602. * @param end end size to lerp between
  12603. * @param amount amount to lerp between the start and end values
  12604. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12605. */
  12606. static Lerp(start: Size, end: Size, amount: number): Size;
  12607. }
  12608. }
  12609. declare module BABYLON {
  12610. /**
  12611. * Defines a runtime animation
  12612. */
  12613. export class RuntimeAnimation {
  12614. private _events;
  12615. /**
  12616. * The current frame of the runtime animation
  12617. */
  12618. private _currentFrame;
  12619. /**
  12620. * The animation used by the runtime animation
  12621. */
  12622. private _animation;
  12623. /**
  12624. * The target of the runtime animation
  12625. */
  12626. private _target;
  12627. /**
  12628. * The initiating animatable
  12629. */
  12630. private _host;
  12631. /**
  12632. * The original value of the runtime animation
  12633. */
  12634. private _originalValue;
  12635. /**
  12636. * The original blend value of the runtime animation
  12637. */
  12638. private _originalBlendValue;
  12639. /**
  12640. * The offsets cache of the runtime animation
  12641. */
  12642. private _offsetsCache;
  12643. /**
  12644. * The high limits cache of the runtime animation
  12645. */
  12646. private _highLimitsCache;
  12647. /**
  12648. * Specifies if the runtime animation has been stopped
  12649. */
  12650. private _stopped;
  12651. /**
  12652. * The blending factor of the runtime animation
  12653. */
  12654. private _blendingFactor;
  12655. /**
  12656. * The BabylonJS scene
  12657. */
  12658. private _scene;
  12659. /**
  12660. * The current value of the runtime animation
  12661. */
  12662. private _currentValue;
  12663. /** @hidden */
  12664. _animationState: _IAnimationState;
  12665. /**
  12666. * The active target of the runtime animation
  12667. */
  12668. private _activeTargets;
  12669. private _currentActiveTarget;
  12670. private _directTarget;
  12671. /**
  12672. * The target path of the runtime animation
  12673. */
  12674. private _targetPath;
  12675. /**
  12676. * The weight of the runtime animation
  12677. */
  12678. private _weight;
  12679. /**
  12680. * The ratio offset of the runtime animation
  12681. */
  12682. private _ratioOffset;
  12683. /**
  12684. * The previous delay of the runtime animation
  12685. */
  12686. private _previousDelay;
  12687. /**
  12688. * The previous ratio of the runtime animation
  12689. */
  12690. private _previousRatio;
  12691. private _enableBlending;
  12692. private _keys;
  12693. private _minFrame;
  12694. private _maxFrame;
  12695. private _minValue;
  12696. private _maxValue;
  12697. private _targetIsArray;
  12698. /**
  12699. * Gets the current frame of the runtime animation
  12700. */
  12701. readonly currentFrame: number;
  12702. /**
  12703. * Gets the weight of the runtime animation
  12704. */
  12705. readonly weight: number;
  12706. /**
  12707. * Gets the current value of the runtime animation
  12708. */
  12709. readonly currentValue: any;
  12710. /**
  12711. * Gets the target path of the runtime animation
  12712. */
  12713. readonly targetPath: string;
  12714. /**
  12715. * Gets the actual target of the runtime animation
  12716. */
  12717. readonly target: any;
  12718. /** @hidden */
  12719. _onLoop: () => void;
  12720. /**
  12721. * Create a new RuntimeAnimation object
  12722. * @param target defines the target of the animation
  12723. * @param animation defines the source animation object
  12724. * @param scene defines the hosting scene
  12725. * @param host defines the initiating Animatable
  12726. */
  12727. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12728. private _preparePath;
  12729. /**
  12730. * Gets the animation from the runtime animation
  12731. */
  12732. readonly animation: Animation;
  12733. /**
  12734. * Resets the runtime animation to the beginning
  12735. * @param restoreOriginal defines whether to restore the target property to the original value
  12736. */
  12737. reset(restoreOriginal?: boolean): void;
  12738. /**
  12739. * Specifies if the runtime animation is stopped
  12740. * @returns Boolean specifying if the runtime animation is stopped
  12741. */
  12742. isStopped(): boolean;
  12743. /**
  12744. * Disposes of the runtime animation
  12745. */
  12746. dispose(): void;
  12747. /**
  12748. * Apply the interpolated value to the target
  12749. * @param currentValue defines the value computed by the animation
  12750. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12751. */
  12752. setValue(currentValue: any, weight: number): void;
  12753. private _getOriginalValues;
  12754. private _setValue;
  12755. /**
  12756. * Gets the loop pmode of the runtime animation
  12757. * @returns Loop Mode
  12758. */
  12759. private _getCorrectLoopMode;
  12760. /**
  12761. * Move the current animation to a given frame
  12762. * @param frame defines the frame to move to
  12763. */
  12764. goToFrame(frame: number): void;
  12765. /**
  12766. * @hidden Internal use only
  12767. */
  12768. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12769. /**
  12770. * Execute the current animation
  12771. * @param delay defines the delay to add to the current frame
  12772. * @param from defines the lower bound of the animation range
  12773. * @param to defines the upper bound of the animation range
  12774. * @param loop defines if the current animation must loop
  12775. * @param speedRatio defines the current speed ratio
  12776. * @param weight defines the weight of the animation (default is -1 so no weight)
  12777. * @param onLoop optional callback called when animation loops
  12778. * @returns a boolean indicating if the animation is running
  12779. */
  12780. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12781. }
  12782. }
  12783. declare module BABYLON {
  12784. /**
  12785. * Class used to store an actual running animation
  12786. */
  12787. export class Animatable {
  12788. /** defines the target object */
  12789. target: any;
  12790. /** defines the starting frame number (default is 0) */
  12791. fromFrame: number;
  12792. /** defines the ending frame number (default is 100) */
  12793. toFrame: number;
  12794. /** defines if the animation must loop (default is false) */
  12795. loopAnimation: boolean;
  12796. /** defines a callback to call when animation ends if it is not looping */
  12797. onAnimationEnd?: (() => void) | null | undefined;
  12798. /** defines a callback to call when animation loops */
  12799. onAnimationLoop?: (() => void) | null | undefined;
  12800. private _localDelayOffset;
  12801. private _pausedDelay;
  12802. private _runtimeAnimations;
  12803. private _paused;
  12804. private _scene;
  12805. private _speedRatio;
  12806. private _weight;
  12807. private _syncRoot;
  12808. /**
  12809. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12810. * This will only apply for non looping animation (default is true)
  12811. */
  12812. disposeOnEnd: boolean;
  12813. /**
  12814. * Gets a boolean indicating if the animation has started
  12815. */
  12816. animationStarted: boolean;
  12817. /**
  12818. * Observer raised when the animation ends
  12819. */
  12820. onAnimationEndObservable: Observable<Animatable>;
  12821. /**
  12822. * Observer raised when the animation loops
  12823. */
  12824. onAnimationLoopObservable: Observable<Animatable>;
  12825. /**
  12826. * Gets the root Animatable used to synchronize and normalize animations
  12827. */
  12828. readonly syncRoot: Nullable<Animatable>;
  12829. /**
  12830. * Gets the current frame of the first RuntimeAnimation
  12831. * Used to synchronize Animatables
  12832. */
  12833. readonly masterFrame: number;
  12834. /**
  12835. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12836. */
  12837. weight: number;
  12838. /**
  12839. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12840. */
  12841. speedRatio: number;
  12842. /**
  12843. * Creates a new Animatable
  12844. * @param scene defines the hosting scene
  12845. * @param target defines the target object
  12846. * @param fromFrame defines the starting frame number (default is 0)
  12847. * @param toFrame defines the ending frame number (default is 100)
  12848. * @param loopAnimation defines if the animation must loop (default is false)
  12849. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12850. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12851. * @param animations defines a group of animation to add to the new Animatable
  12852. * @param onAnimationLoop defines a callback to call when animation loops
  12853. */
  12854. constructor(scene: Scene,
  12855. /** defines the target object */
  12856. target: any,
  12857. /** defines the starting frame number (default is 0) */
  12858. fromFrame?: number,
  12859. /** defines the ending frame number (default is 100) */
  12860. toFrame?: number,
  12861. /** defines if the animation must loop (default is false) */
  12862. loopAnimation?: boolean, speedRatio?: number,
  12863. /** defines a callback to call when animation ends if it is not looping */
  12864. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12865. /** defines a callback to call when animation loops */
  12866. onAnimationLoop?: (() => void) | null | undefined);
  12867. /**
  12868. * Synchronize and normalize current Animatable with a source Animatable
  12869. * This is useful when using animation weights and when animations are not of the same length
  12870. * @param root defines the root Animatable to synchronize with
  12871. * @returns the current Animatable
  12872. */
  12873. syncWith(root: Animatable): Animatable;
  12874. /**
  12875. * Gets the list of runtime animations
  12876. * @returns an array of RuntimeAnimation
  12877. */
  12878. getAnimations(): RuntimeAnimation[];
  12879. /**
  12880. * Adds more animations to the current animatable
  12881. * @param target defines the target of the animations
  12882. * @param animations defines the new animations to add
  12883. */
  12884. appendAnimations(target: any, animations: Animation[]): void;
  12885. /**
  12886. * Gets the source animation for a specific property
  12887. * @param property defines the propertyu to look for
  12888. * @returns null or the source animation for the given property
  12889. */
  12890. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12891. /**
  12892. * Gets the runtime animation for a specific property
  12893. * @param property defines the propertyu to look for
  12894. * @returns null or the runtime animation for the given property
  12895. */
  12896. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12897. /**
  12898. * Resets the animatable to its original state
  12899. */
  12900. reset(): void;
  12901. /**
  12902. * Allows the animatable to blend with current running animations
  12903. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12904. * @param blendingSpeed defines the blending speed to use
  12905. */
  12906. enableBlending(blendingSpeed: number): void;
  12907. /**
  12908. * Disable animation blending
  12909. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12910. */
  12911. disableBlending(): void;
  12912. /**
  12913. * Jump directly to a given frame
  12914. * @param frame defines the frame to jump to
  12915. */
  12916. goToFrame(frame: number): void;
  12917. /**
  12918. * Pause the animation
  12919. */
  12920. pause(): void;
  12921. /**
  12922. * Restart the animation
  12923. */
  12924. restart(): void;
  12925. private _raiseOnAnimationEnd;
  12926. /**
  12927. * Stop and delete the current animation
  12928. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12929. * @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)
  12930. */
  12931. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12932. /**
  12933. * Wait asynchronously for the animation to end
  12934. * @returns a promise which will be fullfilled when the animation ends
  12935. */
  12936. waitAsync(): Promise<Animatable>;
  12937. /** @hidden */
  12938. _animate(delay: number): boolean;
  12939. }
  12940. interface Scene {
  12941. /** @hidden */
  12942. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12943. /** @hidden */
  12944. _processLateAnimationBindingsForMatrices(holder: {
  12945. totalWeight: number;
  12946. animations: RuntimeAnimation[];
  12947. originalValue: Matrix;
  12948. }): any;
  12949. /** @hidden */
  12950. _processLateAnimationBindingsForQuaternions(holder: {
  12951. totalWeight: number;
  12952. animations: RuntimeAnimation[];
  12953. originalValue: Quaternion;
  12954. }, refQuaternion: Quaternion): Quaternion;
  12955. /** @hidden */
  12956. _processLateAnimationBindings(): void;
  12957. /**
  12958. * Will start the animation sequence of a given target
  12959. * @param target defines the target
  12960. * @param from defines from which frame should animation start
  12961. * @param to defines until which frame should animation run.
  12962. * @param weight defines the weight to apply to the animation (1.0 by default)
  12963. * @param loop defines if the animation loops
  12964. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12965. * @param onAnimationEnd defines the function to be executed when the animation ends
  12966. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12967. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12968. * @param onAnimationLoop defines the callback to call when an animation loops
  12969. * @returns the animatable object created for this animation
  12970. */
  12971. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12972. /**
  12973. * Will start the animation sequence of a given target
  12974. * @param target defines the target
  12975. * @param from defines from which frame should animation start
  12976. * @param to defines until which frame should animation run.
  12977. * @param loop defines if the animation loops
  12978. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12979. * @param onAnimationEnd defines the function to be executed when the animation ends
  12980. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12981. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12982. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12983. * @param onAnimationLoop defines the callback to call when an animation loops
  12984. * @returns the animatable object created for this animation
  12985. */
  12986. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12987. /**
  12988. * Will start the animation sequence of a given target and its hierarchy
  12989. * @param target defines the target
  12990. * @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.
  12991. * @param from defines from which frame should animation start
  12992. * @param to defines until which frame should animation run.
  12993. * @param loop defines if the animation loops
  12994. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12995. * @param onAnimationEnd defines the function to be executed when the animation ends
  12996. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12997. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12998. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12999. * @param onAnimationLoop defines the callback to call when an animation loops
  13000. * @returns the list of created animatables
  13001. */
  13002. 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[];
  13003. /**
  13004. * Begin a new animation on a given node
  13005. * @param target defines the target where the animation will take place
  13006. * @param animations defines the list of animations to start
  13007. * @param from defines the initial value
  13008. * @param to defines the final value
  13009. * @param loop defines if you want animation to loop (off by default)
  13010. * @param speedRatio defines the speed ratio to apply to all animations
  13011. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13012. * @param onAnimationLoop defines the callback to call when an animation loops
  13013. * @returns the list of created animatables
  13014. */
  13015. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13016. /**
  13017. * Begin a new animation on a given node and its hierarchy
  13018. * @param target defines the root node where the animation will take place
  13019. * @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.
  13020. * @param animations defines the list of animations to start
  13021. * @param from defines the initial value
  13022. * @param to defines the final value
  13023. * @param loop defines if you want animation to loop (off by default)
  13024. * @param speedRatio defines the speed ratio to apply to all animations
  13025. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13026. * @param onAnimationLoop defines the callback to call when an animation loops
  13027. * @returns the list of animatables created for all nodes
  13028. */
  13029. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13030. /**
  13031. * Gets the animatable associated with a specific target
  13032. * @param target defines the target of the animatable
  13033. * @returns the required animatable if found
  13034. */
  13035. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13036. /**
  13037. * Gets all animatables associated with a given target
  13038. * @param target defines the target to look animatables for
  13039. * @returns an array of Animatables
  13040. */
  13041. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13042. /**
  13043. * Stops and removes all animations that have been applied to the scene
  13044. */
  13045. stopAllAnimations(): void;
  13046. }
  13047. interface Bone {
  13048. /**
  13049. * Copy an animation range from another bone
  13050. * @param source defines the source bone
  13051. * @param rangeName defines the range name to copy
  13052. * @param frameOffset defines the frame offset
  13053. * @param rescaleAsRequired defines if rescaling must be applied if required
  13054. * @param skelDimensionsRatio defines the scaling ratio
  13055. * @returns true if operation was successful
  13056. */
  13057. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13058. }
  13059. }
  13060. declare module BABYLON {
  13061. /**
  13062. * Class used to override all child animations of a given target
  13063. */
  13064. export class AnimationPropertiesOverride {
  13065. /**
  13066. * Gets or sets a value indicating if animation blending must be used
  13067. */
  13068. enableBlending: boolean;
  13069. /**
  13070. * Gets or sets the blending speed to use when enableBlending is true
  13071. */
  13072. blendingSpeed: number;
  13073. /**
  13074. * Gets or sets the default loop mode to use
  13075. */
  13076. loopMode: number;
  13077. }
  13078. }
  13079. declare module BABYLON {
  13080. /**
  13081. * Class used to handle skinning animations
  13082. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13083. */
  13084. export class Skeleton implements IAnimatable {
  13085. /** defines the skeleton name */
  13086. name: string;
  13087. /** defines the skeleton Id */
  13088. id: string;
  13089. /**
  13090. * Defines the list of child bones
  13091. */
  13092. bones: Bone[];
  13093. /**
  13094. * Defines an estimate of the dimension of the skeleton at rest
  13095. */
  13096. dimensionsAtRest: Vector3;
  13097. /**
  13098. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13099. */
  13100. needInitialSkinMatrix: boolean;
  13101. /**
  13102. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13103. */
  13104. overrideMesh: Nullable<AbstractMesh>;
  13105. /**
  13106. * Gets the list of animations attached to this skeleton
  13107. */
  13108. animations: Array<Animation>;
  13109. private _scene;
  13110. private _isDirty;
  13111. private _transformMatrices;
  13112. private _transformMatrixTexture;
  13113. private _meshesWithPoseMatrix;
  13114. private _animatables;
  13115. private _identity;
  13116. private _synchronizedWithMesh;
  13117. private _ranges;
  13118. private _lastAbsoluteTransformsUpdateId;
  13119. private _canUseTextureForBones;
  13120. private _uniqueId;
  13121. /** @hidden */
  13122. _numBonesWithLinkedTransformNode: number;
  13123. /** @hidden */
  13124. _hasWaitingData: Nullable<boolean>;
  13125. /**
  13126. * Specifies if the skeleton should be serialized
  13127. */
  13128. doNotSerialize: boolean;
  13129. private _useTextureToStoreBoneMatrices;
  13130. /**
  13131. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13132. * Please note that this option is not available if the hardware does not support it
  13133. */
  13134. useTextureToStoreBoneMatrices: boolean;
  13135. private _animationPropertiesOverride;
  13136. /**
  13137. * Gets or sets the animation properties override
  13138. */
  13139. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13140. /**
  13141. * List of inspectable custom properties (used by the Inspector)
  13142. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13143. */
  13144. inspectableCustomProperties: IInspectable[];
  13145. /**
  13146. * An observable triggered before computing the skeleton's matrices
  13147. */
  13148. onBeforeComputeObservable: Observable<Skeleton>;
  13149. /**
  13150. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13151. */
  13152. readonly isUsingTextureForMatrices: boolean;
  13153. /**
  13154. * Gets the unique ID of this skeleton
  13155. */
  13156. readonly uniqueId: number;
  13157. /**
  13158. * Creates a new skeleton
  13159. * @param name defines the skeleton name
  13160. * @param id defines the skeleton Id
  13161. * @param scene defines the hosting scene
  13162. */
  13163. constructor(
  13164. /** defines the skeleton name */
  13165. name: string,
  13166. /** defines the skeleton Id */
  13167. id: string, scene: Scene);
  13168. /**
  13169. * Gets the current object class name.
  13170. * @return the class name
  13171. */
  13172. getClassName(): string;
  13173. /**
  13174. * Returns an array containing the root bones
  13175. * @returns an array containing the root bones
  13176. */
  13177. getChildren(): Array<Bone>;
  13178. /**
  13179. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13180. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13181. * @returns a Float32Array containing matrices data
  13182. */
  13183. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13184. /**
  13185. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13186. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13187. * @returns a raw texture containing the data
  13188. */
  13189. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13190. /**
  13191. * Gets the current hosting scene
  13192. * @returns a scene object
  13193. */
  13194. getScene(): Scene;
  13195. /**
  13196. * Gets a string representing the current skeleton data
  13197. * @param fullDetails defines a boolean indicating if we want a verbose version
  13198. * @returns a string representing the current skeleton data
  13199. */
  13200. toString(fullDetails?: boolean): string;
  13201. /**
  13202. * Get bone's index searching by name
  13203. * @param name defines bone's name to search for
  13204. * @return the indice of the bone. Returns -1 if not found
  13205. */
  13206. getBoneIndexByName(name: string): number;
  13207. /**
  13208. * Creater a new animation range
  13209. * @param name defines the name of the range
  13210. * @param from defines the start key
  13211. * @param to defines the end key
  13212. */
  13213. createAnimationRange(name: string, from: number, to: number): void;
  13214. /**
  13215. * Delete a specific animation range
  13216. * @param name defines the name of the range
  13217. * @param deleteFrames defines if frames must be removed as well
  13218. */
  13219. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13220. /**
  13221. * Gets a specific animation range
  13222. * @param name defines the name of the range to look for
  13223. * @returns the requested animation range or null if not found
  13224. */
  13225. getAnimationRange(name: string): Nullable<AnimationRange>;
  13226. /**
  13227. * Gets the list of all animation ranges defined on this skeleton
  13228. * @returns an array
  13229. */
  13230. getAnimationRanges(): Nullable<AnimationRange>[];
  13231. /**
  13232. * Copy animation range from a source skeleton.
  13233. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13234. * @param source defines the source skeleton
  13235. * @param name defines the name of the range to copy
  13236. * @param rescaleAsRequired defines if rescaling must be applied if required
  13237. * @returns true if operation was successful
  13238. */
  13239. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13240. /**
  13241. * Forces the skeleton to go to rest pose
  13242. */
  13243. returnToRest(): void;
  13244. private _getHighestAnimationFrame;
  13245. /**
  13246. * Begin a specific animation range
  13247. * @param name defines the name of the range to start
  13248. * @param loop defines if looping must be turned on (false by default)
  13249. * @param speedRatio defines the speed ratio to apply (1 by default)
  13250. * @param onAnimationEnd defines a callback which will be called when animation will end
  13251. * @returns a new animatable
  13252. */
  13253. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13254. /** @hidden */
  13255. _markAsDirty(): void;
  13256. /** @hidden */
  13257. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13258. /** @hidden */
  13259. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13260. private _computeTransformMatrices;
  13261. /**
  13262. * Build all resources required to render a skeleton
  13263. */
  13264. prepare(): void;
  13265. /**
  13266. * Gets the list of animatables currently running for this skeleton
  13267. * @returns an array of animatables
  13268. */
  13269. getAnimatables(): IAnimatable[];
  13270. /**
  13271. * Clone the current skeleton
  13272. * @param name defines the name of the new skeleton
  13273. * @param id defines the id of the new skeleton
  13274. * @returns the new skeleton
  13275. */
  13276. clone(name: string, id: string): Skeleton;
  13277. /**
  13278. * Enable animation blending for this skeleton
  13279. * @param blendingSpeed defines the blending speed to apply
  13280. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13281. */
  13282. enableBlending(blendingSpeed?: number): void;
  13283. /**
  13284. * Releases all resources associated with the current skeleton
  13285. */
  13286. dispose(): void;
  13287. /**
  13288. * Serialize the skeleton in a JSON object
  13289. * @returns a JSON object
  13290. */
  13291. serialize(): any;
  13292. /**
  13293. * Creates a new skeleton from serialized data
  13294. * @param parsedSkeleton defines the serialized data
  13295. * @param scene defines the hosting scene
  13296. * @returns a new skeleton
  13297. */
  13298. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13299. /**
  13300. * Compute all node absolute transforms
  13301. * @param forceUpdate defines if computation must be done even if cache is up to date
  13302. */
  13303. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13304. /**
  13305. * Gets the root pose matrix
  13306. * @returns a matrix
  13307. */
  13308. getPoseMatrix(): Nullable<Matrix>;
  13309. /**
  13310. * Sorts bones per internal index
  13311. */
  13312. sortBones(): void;
  13313. private _sortBones;
  13314. }
  13315. }
  13316. declare module BABYLON {
  13317. /**
  13318. * Class used to store bone information
  13319. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13320. */
  13321. export class Bone extends Node {
  13322. /**
  13323. * defines the bone name
  13324. */
  13325. name: string;
  13326. private static _tmpVecs;
  13327. private static _tmpQuat;
  13328. private static _tmpMats;
  13329. /**
  13330. * Gets the list of child bones
  13331. */
  13332. children: Bone[];
  13333. /** Gets the animations associated with this bone */
  13334. animations: Animation[];
  13335. /**
  13336. * Gets or sets bone length
  13337. */
  13338. length: number;
  13339. /**
  13340. * @hidden Internal only
  13341. * Set this value to map this bone to a different index in the transform matrices
  13342. * Set this value to -1 to exclude the bone from the transform matrices
  13343. */
  13344. _index: Nullable<number>;
  13345. private _skeleton;
  13346. private _localMatrix;
  13347. private _restPose;
  13348. private _baseMatrix;
  13349. private _absoluteTransform;
  13350. private _invertedAbsoluteTransform;
  13351. private _parent;
  13352. private _scalingDeterminant;
  13353. private _worldTransform;
  13354. private _localScaling;
  13355. private _localRotation;
  13356. private _localPosition;
  13357. private _needToDecompose;
  13358. private _needToCompose;
  13359. /** @hidden */
  13360. _linkedTransformNode: Nullable<TransformNode>;
  13361. /** @hidden */
  13362. _waitingTransformNodeId: Nullable<string>;
  13363. /** @hidden */
  13364. /** @hidden */
  13365. _matrix: Matrix;
  13366. /**
  13367. * Create a new bone
  13368. * @param name defines the bone name
  13369. * @param skeleton defines the parent skeleton
  13370. * @param parentBone defines the parent (can be null if the bone is the root)
  13371. * @param localMatrix defines the local matrix
  13372. * @param restPose defines the rest pose matrix
  13373. * @param baseMatrix defines the base matrix
  13374. * @param index defines index of the bone in the hiearchy
  13375. */
  13376. constructor(
  13377. /**
  13378. * defines the bone name
  13379. */
  13380. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13381. /**
  13382. * Gets the current object class name.
  13383. * @return the class name
  13384. */
  13385. getClassName(): string;
  13386. /**
  13387. * Gets the parent skeleton
  13388. * @returns a skeleton
  13389. */
  13390. getSkeleton(): Skeleton;
  13391. /**
  13392. * Gets parent bone
  13393. * @returns a bone or null if the bone is the root of the bone hierarchy
  13394. */
  13395. getParent(): Nullable<Bone>;
  13396. /**
  13397. * Returns an array containing the root bones
  13398. * @returns an array containing the root bones
  13399. */
  13400. getChildren(): Array<Bone>;
  13401. /**
  13402. * Sets the parent bone
  13403. * @param parent defines the parent (can be null if the bone is the root)
  13404. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13405. */
  13406. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13407. /**
  13408. * Gets the local matrix
  13409. * @returns a matrix
  13410. */
  13411. getLocalMatrix(): Matrix;
  13412. /**
  13413. * Gets the base matrix (initial matrix which remains unchanged)
  13414. * @returns a matrix
  13415. */
  13416. getBaseMatrix(): Matrix;
  13417. /**
  13418. * Gets the rest pose matrix
  13419. * @returns a matrix
  13420. */
  13421. getRestPose(): Matrix;
  13422. /**
  13423. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13424. */
  13425. getWorldMatrix(): Matrix;
  13426. /**
  13427. * Sets the local matrix to rest pose matrix
  13428. */
  13429. returnToRest(): void;
  13430. /**
  13431. * Gets the inverse of the absolute transform matrix.
  13432. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13433. * @returns a matrix
  13434. */
  13435. getInvertedAbsoluteTransform(): Matrix;
  13436. /**
  13437. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13438. * @returns a matrix
  13439. */
  13440. getAbsoluteTransform(): Matrix;
  13441. /**
  13442. * Links with the given transform node.
  13443. * The local matrix of this bone is copied from the transform node every frame.
  13444. * @param transformNode defines the transform node to link to
  13445. */
  13446. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13447. /**
  13448. * Gets the node used to drive the bone's transformation
  13449. * @returns a transform node or null
  13450. */
  13451. getTransformNode(): Nullable<TransformNode>;
  13452. /** Gets or sets current position (in local space) */
  13453. position: Vector3;
  13454. /** Gets or sets current rotation (in local space) */
  13455. rotation: Vector3;
  13456. /** Gets or sets current rotation quaternion (in local space) */
  13457. rotationQuaternion: Quaternion;
  13458. /** Gets or sets current scaling (in local space) */
  13459. scaling: Vector3;
  13460. /**
  13461. * Gets the animation properties override
  13462. */
  13463. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13464. private _decompose;
  13465. private _compose;
  13466. /**
  13467. * Update the base and local matrices
  13468. * @param matrix defines the new base or local matrix
  13469. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13470. * @param updateLocalMatrix defines if the local matrix should be updated
  13471. */
  13472. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13473. /** @hidden */
  13474. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13475. /**
  13476. * Flag the bone as dirty (Forcing it to update everything)
  13477. */
  13478. markAsDirty(): void;
  13479. /** @hidden */
  13480. _markAsDirtyAndCompose(): void;
  13481. private _markAsDirtyAndDecompose;
  13482. /**
  13483. * Translate the bone in local or world space
  13484. * @param vec The amount to translate the bone
  13485. * @param space The space that the translation is in
  13486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13487. */
  13488. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13489. /**
  13490. * Set the postion of the bone in local or world space
  13491. * @param position The position to set the bone
  13492. * @param space The space that the position is in
  13493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13494. */
  13495. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13496. /**
  13497. * Set the absolute position of the bone (world space)
  13498. * @param position The position to set the bone
  13499. * @param mesh The mesh that this bone is attached to
  13500. */
  13501. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13502. /**
  13503. * Scale the bone on the x, y and z axes (in local space)
  13504. * @param x The amount to scale the bone on the x axis
  13505. * @param y The amount to scale the bone on the y axis
  13506. * @param z The amount to scale the bone on the z axis
  13507. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13508. */
  13509. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13510. /**
  13511. * Set the bone scaling in local space
  13512. * @param scale defines the scaling vector
  13513. */
  13514. setScale(scale: Vector3): void;
  13515. /**
  13516. * Gets the current scaling in local space
  13517. * @returns the current scaling vector
  13518. */
  13519. getScale(): Vector3;
  13520. /**
  13521. * Gets the current scaling in local space and stores it in a target vector
  13522. * @param result defines the target vector
  13523. */
  13524. getScaleToRef(result: Vector3): void;
  13525. /**
  13526. * Set the yaw, pitch, and roll of the bone in local or world space
  13527. * @param yaw The rotation of the bone on the y axis
  13528. * @param pitch The rotation of the bone on the x axis
  13529. * @param roll The rotation of the bone on the z axis
  13530. * @param space The space that the axes of rotation are in
  13531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13532. */
  13533. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13534. /**
  13535. * Add a rotation to the bone on an axis in local or world space
  13536. * @param axis The axis to rotate the bone on
  13537. * @param amount The amount to rotate the bone
  13538. * @param space The space that the axis is in
  13539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13540. */
  13541. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13542. /**
  13543. * Set the rotation of the bone to a particular axis angle in local or world space
  13544. * @param axis The axis to rotate the bone on
  13545. * @param angle The angle that the bone should be rotated to
  13546. * @param space The space that the axis is in
  13547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13548. */
  13549. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13550. /**
  13551. * Set the euler rotation of the bone in local of world space
  13552. * @param rotation The euler rotation that the bone should be set to
  13553. * @param space The space that the rotation is in
  13554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13555. */
  13556. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13557. /**
  13558. * Set the quaternion rotation of the bone in local of world space
  13559. * @param quat The quaternion rotation that the bone should be set to
  13560. * @param space The space that the rotation is in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. */
  13563. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13564. /**
  13565. * Set the rotation matrix of the bone in local of world space
  13566. * @param rotMat The rotation matrix that the bone should be set to
  13567. * @param space The space that the rotation is in
  13568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13569. */
  13570. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13571. private _rotateWithMatrix;
  13572. private _getNegativeRotationToRef;
  13573. /**
  13574. * Get the position of the bone in local or world space
  13575. * @param space The space that the returned position is in
  13576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13577. * @returns The position of the bone
  13578. */
  13579. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13580. /**
  13581. * Copy the position of the bone to a vector3 in local or world space
  13582. * @param space The space that the returned position is in
  13583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13584. * @param result The vector3 to copy the position to
  13585. */
  13586. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13587. /**
  13588. * Get the absolute position of the bone (world space)
  13589. * @param mesh The mesh that this bone is attached to
  13590. * @returns The absolute position of the bone
  13591. */
  13592. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13593. /**
  13594. * Copy the absolute position of the bone (world space) to the result param
  13595. * @param mesh The mesh that this bone is attached to
  13596. * @param result The vector3 to copy the absolute position to
  13597. */
  13598. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13599. /**
  13600. * Compute the absolute transforms of this bone and its children
  13601. */
  13602. computeAbsoluteTransforms(): void;
  13603. /**
  13604. * Get the world direction from an axis that is in the local space of the bone
  13605. * @param localAxis The local direction that is used to compute the world direction
  13606. * @param mesh The mesh that this bone is attached to
  13607. * @returns The world direction
  13608. */
  13609. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13610. /**
  13611. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13612. * @param localAxis The local direction that is used to compute the world direction
  13613. * @param mesh The mesh that this bone is attached to
  13614. * @param result The vector3 that the world direction will be copied to
  13615. */
  13616. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13617. /**
  13618. * Get the euler rotation of the bone in local or world space
  13619. * @param space The space that the rotation should be in
  13620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13621. * @returns The euler rotation
  13622. */
  13623. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13624. /**
  13625. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13626. * @param space The space that the rotation should be in
  13627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13628. * @param result The vector3 that the rotation should be copied to
  13629. */
  13630. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13631. /**
  13632. * Get the quaternion rotation of the bone in either local or world space
  13633. * @param space The space that the rotation should be in
  13634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13635. * @returns The quaternion rotation
  13636. */
  13637. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13638. /**
  13639. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13640. * @param space The space that the rotation should be in
  13641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13642. * @param result The quaternion that the rotation should be copied to
  13643. */
  13644. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13645. /**
  13646. * Get the rotation matrix of the bone in local or world space
  13647. * @param space The space that the rotation should be in
  13648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13649. * @returns The rotation matrix
  13650. */
  13651. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13652. /**
  13653. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13654. * @param space The space that the rotation should be in
  13655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13656. * @param result The quaternion that the rotation should be copied to
  13657. */
  13658. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13659. /**
  13660. * Get the world position of a point that is in the local space of the bone
  13661. * @param position The local position
  13662. * @param mesh The mesh that this bone is attached to
  13663. * @returns The world position
  13664. */
  13665. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13666. /**
  13667. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13668. * @param position The local position
  13669. * @param mesh The mesh that this bone is attached to
  13670. * @param result The vector3 that the world position should be copied to
  13671. */
  13672. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13673. /**
  13674. * Get the local position of a point that is in world space
  13675. * @param position The world position
  13676. * @param mesh The mesh that this bone is attached to
  13677. * @returns The local position
  13678. */
  13679. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13680. /**
  13681. * Get the local position of a point that is in world space and copy it to the result param
  13682. * @param position The world position
  13683. * @param mesh The mesh that this bone is attached to
  13684. * @param result The vector3 that the local position should be copied to
  13685. */
  13686. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13687. }
  13688. }
  13689. declare module BABYLON {
  13690. /**
  13691. * 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.
  13692. * @see https://doc.babylonjs.com/how_to/transformnode
  13693. */
  13694. export class TransformNode extends Node {
  13695. /**
  13696. * Object will not rotate to face the camera
  13697. */
  13698. static BILLBOARDMODE_NONE: number;
  13699. /**
  13700. * Object will rotate to face the camera but only on the x axis
  13701. */
  13702. static BILLBOARDMODE_X: number;
  13703. /**
  13704. * Object will rotate to face the camera but only on the y axis
  13705. */
  13706. static BILLBOARDMODE_Y: number;
  13707. /**
  13708. * Object will rotate to face the camera but only on the z axis
  13709. */
  13710. static BILLBOARDMODE_Z: number;
  13711. /**
  13712. * Object will rotate to face the camera
  13713. */
  13714. static BILLBOARDMODE_ALL: number;
  13715. /**
  13716. * Object will rotate to face the camera's position instead of orientation
  13717. */
  13718. static BILLBOARDMODE_USE_POSITION: number;
  13719. private _forward;
  13720. private _forwardInverted;
  13721. private _up;
  13722. private _right;
  13723. private _rightInverted;
  13724. private _position;
  13725. private _rotation;
  13726. private _rotationQuaternion;
  13727. protected _scaling: Vector3;
  13728. protected _isDirty: boolean;
  13729. private _transformToBoneReferal;
  13730. private _isAbsoluteSynced;
  13731. private _billboardMode;
  13732. /**
  13733. * Gets or sets the billboard mode. Default is 0.
  13734. *
  13735. * | Value | Type | Description |
  13736. * | --- | --- | --- |
  13737. * | 0 | BILLBOARDMODE_NONE | |
  13738. * | 1 | BILLBOARDMODE_X | |
  13739. * | 2 | BILLBOARDMODE_Y | |
  13740. * | 4 | BILLBOARDMODE_Z | |
  13741. * | 7 | BILLBOARDMODE_ALL | |
  13742. *
  13743. */
  13744. billboardMode: number;
  13745. private _preserveParentRotationForBillboard;
  13746. /**
  13747. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13748. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13749. */
  13750. preserveParentRotationForBillboard: boolean;
  13751. /**
  13752. * 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
  13753. */
  13754. scalingDeterminant: number;
  13755. private _infiniteDistance;
  13756. /**
  13757. * Gets or sets the distance of the object to max, often used by skybox
  13758. */
  13759. infiniteDistance: boolean;
  13760. /**
  13761. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13762. * By default the system will update normals to compensate
  13763. */
  13764. ignoreNonUniformScaling: boolean;
  13765. /**
  13766. * 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
  13767. */
  13768. reIntegrateRotationIntoRotationQuaternion: boolean;
  13769. /** @hidden */
  13770. _poseMatrix: Nullable<Matrix>;
  13771. /** @hidden */
  13772. _localMatrix: Matrix;
  13773. private _usePivotMatrix;
  13774. private _absolutePosition;
  13775. private _absoluteScaling;
  13776. private _absoluteRotationQuaternion;
  13777. private _pivotMatrix;
  13778. private _pivotMatrixInverse;
  13779. protected _postMultiplyPivotMatrix: boolean;
  13780. protected _isWorldMatrixFrozen: boolean;
  13781. /** @hidden */
  13782. _indexInSceneTransformNodesArray: number;
  13783. /**
  13784. * An event triggered after the world matrix is updated
  13785. */
  13786. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13787. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13788. /**
  13789. * Gets a string identifying the name of the class
  13790. * @returns "TransformNode" string
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13795. */
  13796. position: Vector3;
  13797. /**
  13798. * 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)).
  13799. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13800. */
  13801. rotation: Vector3;
  13802. /**
  13803. * 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)).
  13804. */
  13805. scaling: Vector3;
  13806. /**
  13807. * 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).
  13808. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13809. */
  13810. rotationQuaternion: Nullable<Quaternion>;
  13811. /**
  13812. * The forward direction of that transform in world space.
  13813. */
  13814. readonly forward: Vector3;
  13815. /**
  13816. * The up direction of that transform in world space.
  13817. */
  13818. readonly up: Vector3;
  13819. /**
  13820. * The right direction of that transform in world space.
  13821. */
  13822. readonly right: Vector3;
  13823. /**
  13824. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13825. * @param matrix the matrix to copy the pose from
  13826. * @returns this TransformNode.
  13827. */
  13828. updatePoseMatrix(matrix: Matrix): TransformNode;
  13829. /**
  13830. * Returns the mesh Pose matrix.
  13831. * @returns the pose matrix
  13832. */
  13833. getPoseMatrix(): Matrix;
  13834. /** @hidden */
  13835. _isSynchronized(): boolean;
  13836. /** @hidden */
  13837. _initCache(): void;
  13838. /**
  13839. * Flag the transform node as dirty (Forcing it to update everything)
  13840. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13841. * @returns this transform node
  13842. */
  13843. markAsDirty(property: string): TransformNode;
  13844. /**
  13845. * Returns the current mesh absolute position.
  13846. * Returns a Vector3.
  13847. */
  13848. readonly absolutePosition: Vector3;
  13849. /**
  13850. * Returns the current mesh absolute scaling.
  13851. * Returns a Vector3.
  13852. */
  13853. readonly absoluteScaling: Vector3;
  13854. /**
  13855. * Returns the current mesh absolute rotation.
  13856. * Returns a Quaternion.
  13857. */
  13858. readonly absoluteRotationQuaternion: Quaternion;
  13859. /**
  13860. * Sets a new matrix to apply before all other transformation
  13861. * @param matrix defines the transform matrix
  13862. * @returns the current TransformNode
  13863. */
  13864. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13865. /**
  13866. * Sets a new pivot matrix to the current node
  13867. * @param matrix defines the new pivot matrix to use
  13868. * @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
  13869. * @returns the current TransformNode
  13870. */
  13871. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13872. /**
  13873. * Returns the mesh pivot matrix.
  13874. * Default : Identity.
  13875. * @returns the matrix
  13876. */
  13877. getPivotMatrix(): Matrix;
  13878. /**
  13879. * Instantiate (when possible) or clone that node with its hierarchy
  13880. * @param newParent defines the new parent to use for the instance (or clone)
  13881. * @returns an instance (or a clone) of the current node with its hiearchy
  13882. */
  13883. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13884. /**
  13885. * Prevents the World matrix to be computed any longer
  13886. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13887. * @returns the TransformNode.
  13888. */
  13889. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13890. /**
  13891. * Allows back the World matrix computation.
  13892. * @returns the TransformNode.
  13893. */
  13894. unfreezeWorldMatrix(): this;
  13895. /**
  13896. * True if the World matrix has been frozen.
  13897. */
  13898. readonly isWorldMatrixFrozen: boolean;
  13899. /**
  13900. * Retuns the mesh absolute position in the World.
  13901. * @returns a Vector3.
  13902. */
  13903. getAbsolutePosition(): Vector3;
  13904. /**
  13905. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13906. * @param absolutePosition the absolute position to set
  13907. * @returns the TransformNode.
  13908. */
  13909. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13910. /**
  13911. * Sets the mesh position in its local space.
  13912. * @param vector3 the position to set in localspace
  13913. * @returns the TransformNode.
  13914. */
  13915. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13916. /**
  13917. * Returns the mesh position in the local space from the current World matrix values.
  13918. * @returns a new Vector3.
  13919. */
  13920. getPositionExpressedInLocalSpace(): Vector3;
  13921. /**
  13922. * Translates the mesh along the passed Vector3 in its local space.
  13923. * @param vector3 the distance to translate in localspace
  13924. * @returns the TransformNode.
  13925. */
  13926. locallyTranslate(vector3: Vector3): TransformNode;
  13927. private static _lookAtVectorCache;
  13928. /**
  13929. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13930. * @param targetPoint the position (must be in same space as current mesh) to look at
  13931. * @param yawCor optional yaw (y-axis) correction in radians
  13932. * @param pitchCor optional pitch (x-axis) correction in radians
  13933. * @param rollCor optional roll (z-axis) correction in radians
  13934. * @param space the choosen space of the target
  13935. * @returns the TransformNode.
  13936. */
  13937. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13938. /**
  13939. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13940. * This Vector3 is expressed in the World space.
  13941. * @param localAxis axis to rotate
  13942. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13943. */
  13944. getDirection(localAxis: Vector3): Vector3;
  13945. /**
  13946. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13947. * localAxis is expressed in the mesh local space.
  13948. * result is computed in the Wordl space from the mesh World matrix.
  13949. * @param localAxis axis to rotate
  13950. * @param result the resulting transformnode
  13951. * @returns this TransformNode.
  13952. */
  13953. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13954. /**
  13955. * Sets this transform node rotation to the given local axis.
  13956. * @param localAxis the axis in local space
  13957. * @param yawCor optional yaw (y-axis) correction in radians
  13958. * @param pitchCor optional pitch (x-axis) correction in radians
  13959. * @param rollCor optional roll (z-axis) correction in radians
  13960. * @returns this TransformNode
  13961. */
  13962. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13963. /**
  13964. * Sets a new pivot point to the current node
  13965. * @param point defines the new pivot point to use
  13966. * @param space defines if the point is in world or local space (local by default)
  13967. * @returns the current TransformNode
  13968. */
  13969. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13970. /**
  13971. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13972. * @returns the pivot point
  13973. */
  13974. getPivotPoint(): Vector3;
  13975. /**
  13976. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13977. * @param result the vector3 to store the result
  13978. * @returns this TransformNode.
  13979. */
  13980. getPivotPointToRef(result: Vector3): TransformNode;
  13981. /**
  13982. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13983. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13984. */
  13985. getAbsolutePivotPoint(): Vector3;
  13986. /**
  13987. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13988. * @param result vector3 to store the result
  13989. * @returns this TransformNode.
  13990. */
  13991. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13992. /**
  13993. * Defines the passed node as the parent of the current node.
  13994. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13995. * @see https://doc.babylonjs.com/how_to/parenting
  13996. * @param node the node ot set as the parent
  13997. * @returns this TransformNode.
  13998. */
  13999. setParent(node: Nullable<Node>): TransformNode;
  14000. private _nonUniformScaling;
  14001. /**
  14002. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14003. */
  14004. readonly nonUniformScaling: boolean;
  14005. /** @hidden */
  14006. _updateNonUniformScalingState(value: boolean): boolean;
  14007. /**
  14008. * Attach the current TransformNode to another TransformNode associated with a bone
  14009. * @param bone Bone affecting the TransformNode
  14010. * @param affectedTransformNode TransformNode associated with the bone
  14011. * @returns this object
  14012. */
  14013. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14014. /**
  14015. * Detach the transform node if its associated with a bone
  14016. * @returns this object
  14017. */
  14018. detachFromBone(): TransformNode;
  14019. private static _rotationAxisCache;
  14020. /**
  14021. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14022. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14023. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14024. * The passed axis is also normalized.
  14025. * @param axis the axis to rotate around
  14026. * @param amount the amount to rotate in radians
  14027. * @param space Space to rotate in (Default: local)
  14028. * @returns the TransformNode.
  14029. */
  14030. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14031. /**
  14032. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14033. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14034. * The passed axis is also normalized. .
  14035. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14036. * @param point the point to rotate around
  14037. * @param axis the axis to rotate around
  14038. * @param amount the amount to rotate in radians
  14039. * @returns the TransformNode
  14040. */
  14041. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14042. /**
  14043. * Translates the mesh along the axis vector for the passed distance in the given space.
  14044. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14045. * @param axis the axis to translate in
  14046. * @param distance the distance to translate
  14047. * @param space Space to rotate in (Default: local)
  14048. * @returns the TransformNode.
  14049. */
  14050. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14051. /**
  14052. * Adds a rotation step to the mesh current rotation.
  14053. * x, y, z are Euler angles expressed in radians.
  14054. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14055. * This means this rotation is made in the mesh local space only.
  14056. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14057. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14058. * ```javascript
  14059. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14060. * ```
  14061. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14062. * 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.
  14063. * @param x Rotation to add
  14064. * @param y Rotation to add
  14065. * @param z Rotation to add
  14066. * @returns the TransformNode.
  14067. */
  14068. addRotation(x: number, y: number, z: number): TransformNode;
  14069. /**
  14070. * @hidden
  14071. */
  14072. protected _getEffectiveParent(): Nullable<Node>;
  14073. /**
  14074. * Computes the world matrix of the node
  14075. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14076. * @returns the world matrix
  14077. */
  14078. computeWorldMatrix(force?: boolean): Matrix;
  14079. protected _afterComputeWorldMatrix(): void;
  14080. /**
  14081. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14082. * @param func callback function to add
  14083. *
  14084. * @returns the TransformNode.
  14085. */
  14086. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14087. /**
  14088. * Removes a registered callback function.
  14089. * @param func callback function to remove
  14090. * @returns the TransformNode.
  14091. */
  14092. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14093. /**
  14094. * Gets the position of the current mesh in camera space
  14095. * @param camera defines the camera to use
  14096. * @returns a position
  14097. */
  14098. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14099. /**
  14100. * Returns the distance from the mesh to the active camera
  14101. * @param camera defines the camera to use
  14102. * @returns the distance
  14103. */
  14104. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14105. /**
  14106. * Clone the current transform node
  14107. * @param name Name of the new clone
  14108. * @param newParent New parent for the clone
  14109. * @param doNotCloneChildren Do not clone children hierarchy
  14110. * @returns the new transform node
  14111. */
  14112. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14113. /**
  14114. * Serializes the objects information.
  14115. * @param currentSerializationObject defines the object to serialize in
  14116. * @returns the serialized object
  14117. */
  14118. serialize(currentSerializationObject?: any): any;
  14119. /**
  14120. * Returns a new TransformNode object parsed from the source provided.
  14121. * @param parsedTransformNode is the source.
  14122. * @param scene the scne the object belongs to
  14123. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14124. * @returns a new TransformNode object parsed from the source provided.
  14125. */
  14126. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14127. /**
  14128. * Get all child-transformNodes of this node
  14129. * @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
  14130. * @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
  14131. * @returns an array of TransformNode
  14132. */
  14133. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14134. /**
  14135. * Releases resources associated with this transform node.
  14136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14138. */
  14139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14140. /**
  14141. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14142. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14143. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14144. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14145. * @returns the current mesh
  14146. */
  14147. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14148. private _syncAbsoluteScalingAndRotation;
  14149. }
  14150. }
  14151. declare module BABYLON {
  14152. /**
  14153. * Defines the types of pose enabled controllers that are supported
  14154. */
  14155. export enum PoseEnabledControllerType {
  14156. /**
  14157. * HTC Vive
  14158. */
  14159. VIVE = 0,
  14160. /**
  14161. * Oculus Rift
  14162. */
  14163. OCULUS = 1,
  14164. /**
  14165. * Windows mixed reality
  14166. */
  14167. WINDOWS = 2,
  14168. /**
  14169. * Samsung gear VR
  14170. */
  14171. GEAR_VR = 3,
  14172. /**
  14173. * Google Daydream
  14174. */
  14175. DAYDREAM = 4,
  14176. /**
  14177. * Generic
  14178. */
  14179. GENERIC = 5
  14180. }
  14181. /**
  14182. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14183. */
  14184. export interface MutableGamepadButton {
  14185. /**
  14186. * Value of the button/trigger
  14187. */
  14188. value: number;
  14189. /**
  14190. * If the button/trigger is currently touched
  14191. */
  14192. touched: boolean;
  14193. /**
  14194. * If the button/trigger is currently pressed
  14195. */
  14196. pressed: boolean;
  14197. }
  14198. /**
  14199. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14200. * @hidden
  14201. */
  14202. export interface ExtendedGamepadButton extends GamepadButton {
  14203. /**
  14204. * If the button/trigger is currently pressed
  14205. */
  14206. readonly pressed: boolean;
  14207. /**
  14208. * If the button/trigger is currently touched
  14209. */
  14210. readonly touched: boolean;
  14211. /**
  14212. * Value of the button/trigger
  14213. */
  14214. readonly value: number;
  14215. }
  14216. /** @hidden */
  14217. export interface _GamePadFactory {
  14218. /**
  14219. * Returns wether or not the current gamepad can be created for this type of controller.
  14220. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14221. * @returns true if it can be created, otherwise false
  14222. */
  14223. canCreate(gamepadInfo: any): boolean;
  14224. /**
  14225. * Creates a new instance of the Gamepad.
  14226. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14227. * @returns the new gamepad instance
  14228. */
  14229. create(gamepadInfo: any): Gamepad;
  14230. }
  14231. /**
  14232. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14233. */
  14234. export class PoseEnabledControllerHelper {
  14235. /** @hidden */
  14236. static _ControllerFactories: _GamePadFactory[];
  14237. /** @hidden */
  14238. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14239. /**
  14240. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14241. * @param vrGamepad the gamepad to initialized
  14242. * @returns a vr controller of the type the gamepad identified as
  14243. */
  14244. static InitiateController(vrGamepad: any): Gamepad;
  14245. }
  14246. /**
  14247. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14248. */
  14249. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14250. /**
  14251. * If the controller is used in a webXR session
  14252. */
  14253. isXR: boolean;
  14254. private _deviceRoomPosition;
  14255. private _deviceRoomRotationQuaternion;
  14256. /**
  14257. * The device position in babylon space
  14258. */
  14259. devicePosition: Vector3;
  14260. /**
  14261. * The device rotation in babylon space
  14262. */
  14263. deviceRotationQuaternion: Quaternion;
  14264. /**
  14265. * The scale factor of the device in babylon space
  14266. */
  14267. deviceScaleFactor: number;
  14268. /**
  14269. * (Likely devicePosition should be used instead) The device position in its room space
  14270. */
  14271. position: Vector3;
  14272. /**
  14273. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14274. */
  14275. rotationQuaternion: Quaternion;
  14276. /**
  14277. * The type of controller (Eg. Windows mixed reality)
  14278. */
  14279. controllerType: PoseEnabledControllerType;
  14280. protected _calculatedPosition: Vector3;
  14281. private _calculatedRotation;
  14282. /**
  14283. * The raw pose from the device
  14284. */
  14285. rawPose: DevicePose;
  14286. private _trackPosition;
  14287. private _maxRotationDistFromHeadset;
  14288. private _draggedRoomRotation;
  14289. /**
  14290. * @hidden
  14291. */
  14292. _disableTrackPosition(fixedPosition: Vector3): void;
  14293. /**
  14294. * Internal, the mesh attached to the controller
  14295. * @hidden
  14296. */
  14297. _mesh: Nullable<AbstractMesh>;
  14298. private _poseControlledCamera;
  14299. private _leftHandSystemQuaternion;
  14300. /**
  14301. * Internal, matrix used to convert room space to babylon space
  14302. * @hidden
  14303. */
  14304. _deviceToWorld: Matrix;
  14305. /**
  14306. * Node to be used when casting a ray from the controller
  14307. * @hidden
  14308. */
  14309. _pointingPoseNode: Nullable<TransformNode>;
  14310. /**
  14311. * Name of the child mesh that can be used to cast a ray from the controller
  14312. */
  14313. static readonly POINTING_POSE: string;
  14314. /**
  14315. * Creates a new PoseEnabledController from a gamepad
  14316. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14317. */
  14318. constructor(browserGamepad: any);
  14319. private _workingMatrix;
  14320. /**
  14321. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14322. */
  14323. update(): void;
  14324. /**
  14325. * Updates only the pose device and mesh without doing any button event checking
  14326. */
  14327. protected _updatePoseAndMesh(): void;
  14328. /**
  14329. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14330. * @param poseData raw pose fromthe device
  14331. */
  14332. updateFromDevice(poseData: DevicePose): void;
  14333. /**
  14334. * @hidden
  14335. */
  14336. _meshAttachedObservable: Observable<AbstractMesh>;
  14337. /**
  14338. * Attaches a mesh to the controller
  14339. * @param mesh the mesh to be attached
  14340. */
  14341. attachToMesh(mesh: AbstractMesh): void;
  14342. /**
  14343. * Attaches the controllers mesh to a camera
  14344. * @param camera the camera the mesh should be attached to
  14345. */
  14346. attachToPoseControlledCamera(camera: TargetCamera): void;
  14347. /**
  14348. * Disposes of the controller
  14349. */
  14350. dispose(): void;
  14351. /**
  14352. * The mesh that is attached to the controller
  14353. */
  14354. readonly mesh: Nullable<AbstractMesh>;
  14355. /**
  14356. * Gets the ray of the controller in the direction the controller is pointing
  14357. * @param length the length the resulting ray should be
  14358. * @returns a ray in the direction the controller is pointing
  14359. */
  14360. getForwardRay(length?: number): Ray;
  14361. }
  14362. }
  14363. declare module BABYLON {
  14364. /**
  14365. * Defines the WebVRController object that represents controllers tracked in 3D space
  14366. */
  14367. export abstract class WebVRController extends PoseEnabledController {
  14368. /**
  14369. * Internal, the default controller model for the controller
  14370. */
  14371. protected _defaultModel: AbstractMesh;
  14372. /**
  14373. * Fired when the trigger state has changed
  14374. */
  14375. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14376. /**
  14377. * Fired when the main button state has changed
  14378. */
  14379. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14380. /**
  14381. * Fired when the secondary button state has changed
  14382. */
  14383. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14384. /**
  14385. * Fired when the pad state has changed
  14386. */
  14387. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14388. /**
  14389. * Fired when controllers stick values have changed
  14390. */
  14391. onPadValuesChangedObservable: Observable<StickValues>;
  14392. /**
  14393. * Array of button availible on the controller
  14394. */
  14395. protected _buttons: Array<MutableGamepadButton>;
  14396. private _onButtonStateChange;
  14397. /**
  14398. * Fired when a controller button's state has changed
  14399. * @param callback the callback containing the button that was modified
  14400. */
  14401. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14402. /**
  14403. * X and Y axis corresponding to the controllers joystick
  14404. */
  14405. pad: StickValues;
  14406. /**
  14407. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14408. */
  14409. hand: string;
  14410. /**
  14411. * The default controller model for the controller
  14412. */
  14413. readonly defaultModel: AbstractMesh;
  14414. /**
  14415. * Creates a new WebVRController from a gamepad
  14416. * @param vrGamepad the gamepad that the WebVRController should be created from
  14417. */
  14418. constructor(vrGamepad: any);
  14419. /**
  14420. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14421. */
  14422. update(): void;
  14423. /**
  14424. * Function to be called when a button is modified
  14425. */
  14426. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14427. /**
  14428. * Loads a mesh and attaches it to the controller
  14429. * @param scene the scene the mesh should be added to
  14430. * @param meshLoaded callback for when the mesh has been loaded
  14431. */
  14432. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14433. private _setButtonValue;
  14434. private _changes;
  14435. private _checkChanges;
  14436. /**
  14437. * Disposes of th webVRCOntroller
  14438. */
  14439. dispose(): void;
  14440. }
  14441. }
  14442. declare module BABYLON {
  14443. /**
  14444. * The HemisphericLight simulates the ambient environment light,
  14445. * so the passed direction is the light reflection direction, not the incoming direction.
  14446. */
  14447. export class HemisphericLight extends Light {
  14448. /**
  14449. * The groundColor is the light in the opposite direction to the one specified during creation.
  14450. * 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.
  14451. */
  14452. groundColor: Color3;
  14453. /**
  14454. * The light reflection direction, not the incoming direction.
  14455. */
  14456. direction: Vector3;
  14457. /**
  14458. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14459. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14460. * The HemisphericLight can't cast shadows.
  14461. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14462. * @param name The friendly name of the light
  14463. * @param direction The direction of the light reflection
  14464. * @param scene The scene the light belongs to
  14465. */
  14466. constructor(name: string, direction: Vector3, scene: Scene);
  14467. protected _buildUniformLayout(): void;
  14468. /**
  14469. * Returns the string "HemisphericLight".
  14470. * @return The class name
  14471. */
  14472. getClassName(): string;
  14473. /**
  14474. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14475. * Returns the updated direction.
  14476. * @param target The target the direction should point to
  14477. * @return The computed direction
  14478. */
  14479. setDirectionToTarget(target: Vector3): Vector3;
  14480. /**
  14481. * Returns the shadow generator associated to the light.
  14482. * @returns Always null for hemispheric lights because it does not support shadows.
  14483. */
  14484. getShadowGenerator(): Nullable<IShadowGenerator>;
  14485. /**
  14486. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14487. * @param effect The effect to update
  14488. * @param lightIndex The index of the light in the effect to update
  14489. * @returns The hemispheric light
  14490. */
  14491. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14492. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14493. /**
  14494. * Computes the world matrix of the node
  14495. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14496. * @param useWasUpdatedFlag defines a reserved property
  14497. * @returns the world matrix
  14498. */
  14499. computeWorldMatrix(): Matrix;
  14500. /**
  14501. * Returns the integer 3.
  14502. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14503. */
  14504. getTypeID(): number;
  14505. /**
  14506. * Prepares the list of defines specific to the light type.
  14507. * @param defines the list of defines
  14508. * @param lightIndex defines the index of the light for the effect
  14509. */
  14510. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /** @hidden */
  14515. export var vrMultiviewToSingleviewPixelShader: {
  14516. name: string;
  14517. shader: string;
  14518. };
  14519. }
  14520. declare module BABYLON {
  14521. /**
  14522. * Renders to multiple views with a single draw call
  14523. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14524. */
  14525. export class MultiviewRenderTarget extends RenderTargetTexture {
  14526. /**
  14527. * Creates a multiview render target
  14528. * @param scene scene used with the render target
  14529. * @param size the size of the render target (used for each view)
  14530. */
  14531. constructor(scene: Scene, size?: number | {
  14532. width: number;
  14533. height: number;
  14534. } | {
  14535. ratio: number;
  14536. });
  14537. /**
  14538. * @hidden
  14539. * @param faceIndex the face index, if its a cube texture
  14540. */
  14541. _bindFrameBuffer(faceIndex?: number): void;
  14542. /**
  14543. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14544. * @returns the view count
  14545. */
  14546. getViewCount(): number;
  14547. }
  14548. }
  14549. declare module BABYLON {
  14550. /**
  14551. * Reprasents a camera frustum
  14552. */
  14553. export class Frustum {
  14554. /**
  14555. * Gets the planes representing the frustum
  14556. * @param transform matrix to be applied to the returned planes
  14557. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14558. */
  14559. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14560. /**
  14561. * Gets the near frustum plane transformed by the transform matrix
  14562. * @param transform transformation matrix to be applied to the resulting frustum plane
  14563. * @param frustumPlane the resuling frustum plane
  14564. */
  14565. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14566. /**
  14567. * Gets the far frustum plane transformed by the transform matrix
  14568. * @param transform transformation matrix to be applied to the resulting frustum plane
  14569. * @param frustumPlane the resuling frustum plane
  14570. */
  14571. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14572. /**
  14573. * Gets the left frustum plane transformed by the transform matrix
  14574. * @param transform transformation matrix to be applied to the resulting frustum plane
  14575. * @param frustumPlane the resuling frustum plane
  14576. */
  14577. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14578. /**
  14579. * Gets the right frustum plane transformed by the transform matrix
  14580. * @param transform transformation matrix to be applied to the resulting frustum plane
  14581. * @param frustumPlane the resuling frustum plane
  14582. */
  14583. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14584. /**
  14585. * Gets the top frustum plane transformed by the transform matrix
  14586. * @param transform transformation matrix to be applied to the resulting frustum plane
  14587. * @param frustumPlane the resuling frustum plane
  14588. */
  14589. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14590. /**
  14591. * Gets the bottom frustum plane transformed by the transform matrix
  14592. * @param transform transformation matrix to be applied to the resulting frustum plane
  14593. * @param frustumPlane the resuling frustum plane
  14594. */
  14595. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14596. /**
  14597. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14598. * @param transform transformation matrix to be applied to the resulting frustum planes
  14599. * @param frustumPlanes the resuling frustum planes
  14600. */
  14601. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14602. }
  14603. }
  14604. declare module BABYLON {
  14605. interface Engine {
  14606. /**
  14607. * Creates a new multiview render target
  14608. * @param width defines the width of the texture
  14609. * @param height defines the height of the texture
  14610. * @returns the created multiview texture
  14611. */
  14612. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14613. /**
  14614. * Binds a multiview framebuffer to be drawn to
  14615. * @param multiviewTexture texture to bind
  14616. */
  14617. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14618. }
  14619. interface Camera {
  14620. /**
  14621. * @hidden
  14622. * 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)
  14623. */
  14624. _useMultiviewToSingleView: boolean;
  14625. /**
  14626. * @hidden
  14627. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14628. */
  14629. _multiviewTexture: Nullable<RenderTargetTexture>;
  14630. /**
  14631. * @hidden
  14632. * ensures the multiview texture of the camera exists and has the specified width/height
  14633. * @param width height to set on the multiview texture
  14634. * @param height width to set on the multiview texture
  14635. */
  14636. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14637. }
  14638. interface Scene {
  14639. /** @hidden */
  14640. _transformMatrixR: Matrix;
  14641. /** @hidden */
  14642. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14643. /** @hidden */
  14644. _createMultiviewUbo(): void;
  14645. /** @hidden */
  14646. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14647. /** @hidden */
  14648. _renderMultiviewToSingleView(camera: Camera): void;
  14649. }
  14650. }
  14651. declare module BABYLON {
  14652. /**
  14653. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14654. * This will not be used for webXR as it supports displaying texture arrays directly
  14655. */
  14656. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14657. /**
  14658. * Initializes a VRMultiviewToSingleview
  14659. * @param name name of the post process
  14660. * @param camera camera to be applied to
  14661. * @param scaleFactor scaling factor to the size of the output texture
  14662. */
  14663. constructor(name: string, camera: Camera, scaleFactor: number);
  14664. }
  14665. }
  14666. declare module BABYLON {
  14667. interface Engine {
  14668. /** @hidden */
  14669. _vrDisplay: any;
  14670. /** @hidden */
  14671. _vrSupported: boolean;
  14672. /** @hidden */
  14673. _oldSize: Size;
  14674. /** @hidden */
  14675. _oldHardwareScaleFactor: number;
  14676. /** @hidden */
  14677. _vrExclusivePointerMode: boolean;
  14678. /** @hidden */
  14679. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14680. /** @hidden */
  14681. _onVRDisplayPointerRestricted: () => void;
  14682. /** @hidden */
  14683. _onVRDisplayPointerUnrestricted: () => void;
  14684. /** @hidden */
  14685. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14686. /** @hidden */
  14687. _onVrDisplayDisconnect: Nullable<() => void>;
  14688. /** @hidden */
  14689. _onVrDisplayPresentChange: Nullable<() => void>;
  14690. /**
  14691. * Observable signaled when VR display mode changes
  14692. */
  14693. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14694. /**
  14695. * Observable signaled when VR request present is complete
  14696. */
  14697. onVRRequestPresentComplete: Observable<boolean>;
  14698. /**
  14699. * Observable signaled when VR request present starts
  14700. */
  14701. onVRRequestPresentStart: Observable<Engine>;
  14702. /**
  14703. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14704. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14705. */
  14706. isInVRExclusivePointerMode: boolean;
  14707. /**
  14708. * Gets a boolean indicating if a webVR device was detected
  14709. * @returns true if a webVR device was detected
  14710. */
  14711. isVRDevicePresent(): boolean;
  14712. /**
  14713. * Gets the current webVR device
  14714. * @returns the current webVR device (or null)
  14715. */
  14716. getVRDevice(): any;
  14717. /**
  14718. * Initializes a webVR display and starts listening to display change events
  14719. * The onVRDisplayChangedObservable will be notified upon these changes
  14720. * @returns A promise containing a VRDisplay and if vr is supported
  14721. */
  14722. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14723. /** @hidden */
  14724. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14725. /**
  14726. * Call this function to switch to webVR mode
  14727. * Will do nothing if webVR is not supported or if there is no webVR device
  14728. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14729. */
  14730. enableVR(): void;
  14731. /** @hidden */
  14732. _onVRFullScreenTriggered(): void;
  14733. }
  14734. }
  14735. declare module BABYLON {
  14736. /**
  14737. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14738. * IMPORTANT!! The data is right-hand data.
  14739. * @export
  14740. * @interface DevicePose
  14741. */
  14742. export interface DevicePose {
  14743. /**
  14744. * The position of the device, values in array are [x,y,z].
  14745. */
  14746. readonly position: Nullable<Float32Array>;
  14747. /**
  14748. * The linearVelocity of the device, values in array are [x,y,z].
  14749. */
  14750. readonly linearVelocity: Nullable<Float32Array>;
  14751. /**
  14752. * The linearAcceleration of the device, values in array are [x,y,z].
  14753. */
  14754. readonly linearAcceleration: Nullable<Float32Array>;
  14755. /**
  14756. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14757. */
  14758. readonly orientation: Nullable<Float32Array>;
  14759. /**
  14760. * The angularVelocity of the device, values in array are [x,y,z].
  14761. */
  14762. readonly angularVelocity: Nullable<Float32Array>;
  14763. /**
  14764. * The angularAcceleration of the device, values in array are [x,y,z].
  14765. */
  14766. readonly angularAcceleration: Nullable<Float32Array>;
  14767. }
  14768. /**
  14769. * Interface representing a pose controlled object in Babylon.
  14770. * A pose controlled object has both regular pose values as well as pose values
  14771. * from an external device such as a VR head mounted display
  14772. */
  14773. export interface PoseControlled {
  14774. /**
  14775. * The position of the object in babylon space.
  14776. */
  14777. position: Vector3;
  14778. /**
  14779. * The rotation quaternion of the object in babylon space.
  14780. */
  14781. rotationQuaternion: Quaternion;
  14782. /**
  14783. * The position of the device in babylon space.
  14784. */
  14785. devicePosition?: Vector3;
  14786. /**
  14787. * The rotation quaternion of the device in babylon space.
  14788. */
  14789. deviceRotationQuaternion: Quaternion;
  14790. /**
  14791. * The raw pose coming from the device.
  14792. */
  14793. rawPose: Nullable<DevicePose>;
  14794. /**
  14795. * The scale of the device to be used when translating from device space to babylon space.
  14796. */
  14797. deviceScaleFactor: number;
  14798. /**
  14799. * Updates the poseControlled values based on the input device pose.
  14800. * @param poseData the pose data to update the object with
  14801. */
  14802. updateFromDevice(poseData: DevicePose): void;
  14803. }
  14804. /**
  14805. * Set of options to customize the webVRCamera
  14806. */
  14807. export interface WebVROptions {
  14808. /**
  14809. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14810. */
  14811. trackPosition?: boolean;
  14812. /**
  14813. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14814. */
  14815. positionScale?: number;
  14816. /**
  14817. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14818. */
  14819. displayName?: string;
  14820. /**
  14821. * Should the native controller meshes be initialized. (default: true)
  14822. */
  14823. controllerMeshes?: boolean;
  14824. /**
  14825. * Creating a default HemiLight only on controllers. (default: true)
  14826. */
  14827. defaultLightingOnControllers?: boolean;
  14828. /**
  14829. * If you don't want to use the default VR button of the helper. (default: false)
  14830. */
  14831. useCustomVRButton?: boolean;
  14832. /**
  14833. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14834. */
  14835. customVRButton?: HTMLButtonElement;
  14836. /**
  14837. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14838. */
  14839. rayLength?: number;
  14840. /**
  14841. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14842. */
  14843. defaultHeight?: number;
  14844. /**
  14845. * If multiview should be used if availible (default: false)
  14846. */
  14847. useMultiview?: boolean;
  14848. }
  14849. /**
  14850. * This represents a WebVR camera.
  14851. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14852. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14853. */
  14854. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14855. private webVROptions;
  14856. /**
  14857. * @hidden
  14858. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14859. */
  14860. _vrDevice: any;
  14861. /**
  14862. * The rawPose of the vrDevice.
  14863. */
  14864. rawPose: Nullable<DevicePose>;
  14865. private _onVREnabled;
  14866. private _specsVersion;
  14867. private _attached;
  14868. private _frameData;
  14869. protected _descendants: Array<Node>;
  14870. private _deviceRoomPosition;
  14871. /** @hidden */
  14872. _deviceRoomRotationQuaternion: Quaternion;
  14873. private _standingMatrix;
  14874. /**
  14875. * Represents device position in babylon space.
  14876. */
  14877. devicePosition: Vector3;
  14878. /**
  14879. * Represents device rotation in babylon space.
  14880. */
  14881. deviceRotationQuaternion: Quaternion;
  14882. /**
  14883. * The scale of the device to be used when translating from device space to babylon space.
  14884. */
  14885. deviceScaleFactor: number;
  14886. private _deviceToWorld;
  14887. private _worldToDevice;
  14888. /**
  14889. * References to the webVR controllers for the vrDevice.
  14890. */
  14891. controllers: Array<WebVRController>;
  14892. /**
  14893. * Emits an event when a controller is attached.
  14894. */
  14895. onControllersAttachedObservable: Observable<WebVRController[]>;
  14896. /**
  14897. * Emits an event when a controller's mesh has been loaded;
  14898. */
  14899. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14900. /**
  14901. * Emits an event when the HMD's pose has been updated.
  14902. */
  14903. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14904. private _poseSet;
  14905. /**
  14906. * If the rig cameras be used as parent instead of this camera.
  14907. */
  14908. rigParenting: boolean;
  14909. private _lightOnControllers;
  14910. private _defaultHeight?;
  14911. /**
  14912. * Instantiates a WebVRFreeCamera.
  14913. * @param name The name of the WebVRFreeCamera
  14914. * @param position The starting anchor position for the camera
  14915. * @param scene The scene the camera belongs to
  14916. * @param webVROptions a set of customizable options for the webVRCamera
  14917. */
  14918. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14919. /**
  14920. * Gets the device distance from the ground in meters.
  14921. * @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.
  14922. */
  14923. deviceDistanceToRoomGround(): number;
  14924. /**
  14925. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14926. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14927. */
  14928. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14929. /**
  14930. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14931. * @returns A promise with a boolean set to if the standing matrix is supported.
  14932. */
  14933. useStandingMatrixAsync(): Promise<boolean>;
  14934. /**
  14935. * Disposes the camera
  14936. */
  14937. dispose(): void;
  14938. /**
  14939. * Gets a vrController by name.
  14940. * @param name The name of the controller to retreive
  14941. * @returns the controller matching the name specified or null if not found
  14942. */
  14943. getControllerByName(name: string): Nullable<WebVRController>;
  14944. private _leftController;
  14945. /**
  14946. * The controller corresponding to the users left hand.
  14947. */
  14948. readonly leftController: Nullable<WebVRController>;
  14949. private _rightController;
  14950. /**
  14951. * The controller corresponding to the users right hand.
  14952. */
  14953. readonly rightController: Nullable<WebVRController>;
  14954. /**
  14955. * Casts a ray forward from the vrCamera's gaze.
  14956. * @param length Length of the ray (default: 100)
  14957. * @returns the ray corresponding to the gaze
  14958. */
  14959. getForwardRay(length?: number): Ray;
  14960. /**
  14961. * @hidden
  14962. * Updates the camera based on device's frame data
  14963. */
  14964. _checkInputs(): void;
  14965. /**
  14966. * Updates the poseControlled values based on the input device pose.
  14967. * @param poseData Pose coming from the device
  14968. */
  14969. updateFromDevice(poseData: DevicePose): void;
  14970. private _htmlElementAttached;
  14971. private _detachIfAttached;
  14972. /**
  14973. * WebVR's attach control will start broadcasting frames to the device.
  14974. * Note that in certain browsers (chrome for example) this function must be called
  14975. * within a user-interaction callback. Example:
  14976. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14977. *
  14978. * @param element html element to attach the vrDevice to
  14979. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14980. */
  14981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14982. /**
  14983. * Detaches the camera from the html element and disables VR
  14984. *
  14985. * @param element html element to detach from
  14986. */
  14987. detachControl(element: HTMLElement): void;
  14988. /**
  14989. * @returns the name of this class
  14990. */
  14991. getClassName(): string;
  14992. /**
  14993. * Calls resetPose on the vrDisplay
  14994. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14995. */
  14996. resetToCurrentRotation(): void;
  14997. /**
  14998. * @hidden
  14999. * Updates the rig cameras (left and right eye)
  15000. */
  15001. _updateRigCameras(): void;
  15002. private _workingVector;
  15003. private _oneVector;
  15004. private _workingMatrix;
  15005. private updateCacheCalled;
  15006. private _correctPositionIfNotTrackPosition;
  15007. /**
  15008. * @hidden
  15009. * Updates the cached values of the camera
  15010. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15011. */
  15012. _updateCache(ignoreParentClass?: boolean): void;
  15013. /**
  15014. * @hidden
  15015. * Get current device position in babylon world
  15016. */
  15017. _computeDevicePosition(): void;
  15018. /**
  15019. * Updates the current device position and rotation in the babylon world
  15020. */
  15021. update(): void;
  15022. /**
  15023. * @hidden
  15024. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15025. * @returns an identity matrix
  15026. */
  15027. _getViewMatrix(): Matrix;
  15028. private _tmpMatrix;
  15029. /**
  15030. * This function is called by the two RIG cameras.
  15031. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15032. * @hidden
  15033. */
  15034. _getWebVRViewMatrix(): Matrix;
  15035. /** @hidden */
  15036. _getWebVRProjectionMatrix(): Matrix;
  15037. private _onGamepadConnectedObserver;
  15038. private _onGamepadDisconnectedObserver;
  15039. private _updateCacheWhenTrackingDisabledObserver;
  15040. /**
  15041. * Initializes the controllers and their meshes
  15042. */
  15043. initControllers(): void;
  15044. }
  15045. }
  15046. declare module BABYLON {
  15047. /**
  15048. * Size options for a post process
  15049. */
  15050. export type PostProcessOptions = {
  15051. width: number;
  15052. height: number;
  15053. };
  15054. /**
  15055. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15056. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15057. */
  15058. export class PostProcess {
  15059. /** Name of the PostProcess. */
  15060. name: string;
  15061. /**
  15062. * Gets or sets the unique id of the post process
  15063. */
  15064. uniqueId: number;
  15065. /**
  15066. * Width of the texture to apply the post process on
  15067. */
  15068. width: number;
  15069. /**
  15070. * Height of the texture to apply the post process on
  15071. */
  15072. height: number;
  15073. /**
  15074. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15075. * @hidden
  15076. */
  15077. _outputTexture: Nullable<InternalTexture>;
  15078. /**
  15079. * Sampling mode used by the shader
  15080. * See https://doc.babylonjs.com/classes/3.1/texture
  15081. */
  15082. renderTargetSamplingMode: number;
  15083. /**
  15084. * Clear color to use when screen clearing
  15085. */
  15086. clearColor: Color4;
  15087. /**
  15088. * If the buffer needs to be cleared before applying the post process. (default: true)
  15089. * Should be set to false if shader will overwrite all previous pixels.
  15090. */
  15091. autoClear: boolean;
  15092. /**
  15093. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15094. */
  15095. alphaMode: number;
  15096. /**
  15097. * Sets the setAlphaBlendConstants of the babylon engine
  15098. */
  15099. alphaConstants: Color4;
  15100. /**
  15101. * Animations to be used for the post processing
  15102. */
  15103. animations: Animation[];
  15104. /**
  15105. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15106. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15107. */
  15108. enablePixelPerfectMode: boolean;
  15109. /**
  15110. * Force the postprocess to be applied without taking in account viewport
  15111. */
  15112. forceFullscreenViewport: boolean;
  15113. /**
  15114. * List of inspectable custom properties (used by the Inspector)
  15115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15116. */
  15117. inspectableCustomProperties: IInspectable[];
  15118. /**
  15119. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15120. *
  15121. * | Value | Type | Description |
  15122. * | ----- | ----------------------------------- | ----------- |
  15123. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15124. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15125. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15126. *
  15127. */
  15128. scaleMode: number;
  15129. /**
  15130. * Force textures to be a power of two (default: false)
  15131. */
  15132. alwaysForcePOT: boolean;
  15133. private _samples;
  15134. /**
  15135. * Number of sample textures (default: 1)
  15136. */
  15137. samples: number;
  15138. /**
  15139. * Modify the scale of the post process to be the same as the viewport (default: false)
  15140. */
  15141. adaptScaleToCurrentViewport: boolean;
  15142. private _camera;
  15143. private _scene;
  15144. private _engine;
  15145. private _options;
  15146. private _reusable;
  15147. private _textureType;
  15148. /**
  15149. * Smart array of input and output textures for the post process.
  15150. * @hidden
  15151. */
  15152. _textures: SmartArray<InternalTexture>;
  15153. /**
  15154. * The index in _textures that corresponds to the output texture.
  15155. * @hidden
  15156. */
  15157. _currentRenderTextureInd: number;
  15158. private _effect;
  15159. private _samplers;
  15160. private _fragmentUrl;
  15161. private _vertexUrl;
  15162. private _parameters;
  15163. private _scaleRatio;
  15164. protected _indexParameters: any;
  15165. private _shareOutputWithPostProcess;
  15166. private _texelSize;
  15167. private _forcedOutputTexture;
  15168. /**
  15169. * Returns the fragment url or shader name used in the post process.
  15170. * @returns the fragment url or name in the shader store.
  15171. */
  15172. getEffectName(): string;
  15173. /**
  15174. * An event triggered when the postprocess is activated.
  15175. */
  15176. onActivateObservable: Observable<Camera>;
  15177. private _onActivateObserver;
  15178. /**
  15179. * A function that is added to the onActivateObservable
  15180. */
  15181. onActivate: Nullable<(camera: Camera) => void>;
  15182. /**
  15183. * An event triggered when the postprocess changes its size.
  15184. */
  15185. onSizeChangedObservable: Observable<PostProcess>;
  15186. private _onSizeChangedObserver;
  15187. /**
  15188. * A function that is added to the onSizeChangedObservable
  15189. */
  15190. onSizeChanged: (postProcess: PostProcess) => void;
  15191. /**
  15192. * An event triggered when the postprocess applies its effect.
  15193. */
  15194. onApplyObservable: Observable<Effect>;
  15195. private _onApplyObserver;
  15196. /**
  15197. * A function that is added to the onApplyObservable
  15198. */
  15199. onApply: (effect: Effect) => void;
  15200. /**
  15201. * An event triggered before rendering the postprocess
  15202. */
  15203. onBeforeRenderObservable: Observable<Effect>;
  15204. private _onBeforeRenderObserver;
  15205. /**
  15206. * A function that is added to the onBeforeRenderObservable
  15207. */
  15208. onBeforeRender: (effect: Effect) => void;
  15209. /**
  15210. * An event triggered after rendering the postprocess
  15211. */
  15212. onAfterRenderObservable: Observable<Effect>;
  15213. private _onAfterRenderObserver;
  15214. /**
  15215. * A function that is added to the onAfterRenderObservable
  15216. */
  15217. onAfterRender: (efect: Effect) => void;
  15218. /**
  15219. * 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
  15220. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15221. */
  15222. inputTexture: InternalTexture;
  15223. /**
  15224. * Gets the camera which post process is applied to.
  15225. * @returns The camera the post process is applied to.
  15226. */
  15227. getCamera(): Camera;
  15228. /**
  15229. * Gets the texel size of the postprocess.
  15230. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15231. */
  15232. readonly texelSize: Vector2;
  15233. /**
  15234. * Creates a new instance PostProcess
  15235. * @param name The name of the PostProcess.
  15236. * @param fragmentUrl The url of the fragment shader to be used.
  15237. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15238. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15239. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15240. * @param camera The camera to apply the render pass to.
  15241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15242. * @param engine The engine which the post process will be applied. (default: current engine)
  15243. * @param reusable If the post process can be reused on the same frame. (default: false)
  15244. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15245. * @param textureType Type of textures used when performing the post process. (default: 0)
  15246. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15247. * @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
  15248. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15249. */
  15250. constructor(
  15251. /** Name of the PostProcess. */
  15252. 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);
  15253. /**
  15254. * Gets a string idenfifying the name of the class
  15255. * @returns "PostProcess" string
  15256. */
  15257. getClassName(): string;
  15258. /**
  15259. * Gets the engine which this post process belongs to.
  15260. * @returns The engine the post process was enabled with.
  15261. */
  15262. getEngine(): Engine;
  15263. /**
  15264. * The effect that is created when initializing the post process.
  15265. * @returns The created effect corresponding the the postprocess.
  15266. */
  15267. getEffect(): Effect;
  15268. /**
  15269. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15270. * @param postProcess The post process to share the output with.
  15271. * @returns This post process.
  15272. */
  15273. shareOutputWith(postProcess: PostProcess): PostProcess;
  15274. /**
  15275. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15276. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15277. */
  15278. useOwnOutput(): void;
  15279. /**
  15280. * Updates the effect with the current post process compile time values and recompiles the shader.
  15281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15284. * @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
  15285. * @param onCompiled Called when the shader has been compiled.
  15286. * @param onError Called if there is an error when compiling a shader.
  15287. */
  15288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15289. /**
  15290. * The post process is reusable if it can be used multiple times within one frame.
  15291. * @returns If the post process is reusable
  15292. */
  15293. isReusable(): boolean;
  15294. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15295. markTextureDirty(): void;
  15296. /**
  15297. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15298. * 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.
  15299. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15300. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15301. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15302. * @returns The target texture that was bound to be written to.
  15303. */
  15304. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15305. /**
  15306. * If the post process is supported.
  15307. */
  15308. readonly isSupported: boolean;
  15309. /**
  15310. * The aspect ratio of the output texture.
  15311. */
  15312. readonly aspectRatio: number;
  15313. /**
  15314. * Get a value indicating if the post-process is ready to be used
  15315. * @returns true if the post-process is ready (shader is compiled)
  15316. */
  15317. isReady(): boolean;
  15318. /**
  15319. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15320. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15321. */
  15322. apply(): Nullable<Effect>;
  15323. private _disposeTextures;
  15324. /**
  15325. * Disposes the post process.
  15326. * @param camera The camera to dispose the post process on.
  15327. */
  15328. dispose(camera?: Camera): void;
  15329. }
  15330. }
  15331. declare module BABYLON {
  15332. /** @hidden */
  15333. export var kernelBlurVaryingDeclaration: {
  15334. name: string;
  15335. shader: string;
  15336. };
  15337. }
  15338. declare module BABYLON {
  15339. /** @hidden */
  15340. export var kernelBlurFragment: {
  15341. name: string;
  15342. shader: string;
  15343. };
  15344. }
  15345. declare module BABYLON {
  15346. /** @hidden */
  15347. export var kernelBlurFragment2: {
  15348. name: string;
  15349. shader: string;
  15350. };
  15351. }
  15352. declare module BABYLON {
  15353. /** @hidden */
  15354. export var kernelBlurPixelShader: {
  15355. name: string;
  15356. shader: string;
  15357. };
  15358. }
  15359. declare module BABYLON {
  15360. /** @hidden */
  15361. export var kernelBlurVertex: {
  15362. name: string;
  15363. shader: string;
  15364. };
  15365. }
  15366. declare module BABYLON {
  15367. /** @hidden */
  15368. export var kernelBlurVertexShader: {
  15369. name: string;
  15370. shader: string;
  15371. };
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * The Blur Post Process which blurs an image based on a kernel and direction.
  15376. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15377. */
  15378. export class BlurPostProcess extends PostProcess {
  15379. /** The direction in which to blur the image. */
  15380. direction: Vector2;
  15381. private blockCompilation;
  15382. protected _kernel: number;
  15383. protected _idealKernel: number;
  15384. protected _packedFloat: boolean;
  15385. private _staticDefines;
  15386. /**
  15387. * Sets the length in pixels of the blur sample region
  15388. */
  15389. /**
  15390. * Gets the length in pixels of the blur sample region
  15391. */
  15392. kernel: number;
  15393. /**
  15394. * Sets wether or not the blur needs to unpack/repack floats
  15395. */
  15396. /**
  15397. * Gets wether or not the blur is unpacking/repacking floats
  15398. */
  15399. packedFloat: boolean;
  15400. /**
  15401. * Creates a new instance BlurPostProcess
  15402. * @param name The name of the effect.
  15403. * @param direction The direction in which to blur the image.
  15404. * @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.
  15405. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15406. * @param camera The camera to apply the render pass to.
  15407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15408. * @param engine The engine which the post process will be applied. (default: current engine)
  15409. * @param reusable If the post process can be reused on the same frame. (default: false)
  15410. * @param textureType Type of textures used when performing the post process. (default: 0)
  15411. * @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)
  15412. */
  15413. constructor(name: string,
  15414. /** The direction in which to blur the image. */
  15415. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15416. /**
  15417. * Updates the effect with the current post process compile time values and recompiles the shader.
  15418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15421. * @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
  15422. * @param onCompiled Called when the shader has been compiled.
  15423. * @param onError Called if there is an error when compiling a shader.
  15424. */
  15425. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15426. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15427. /**
  15428. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15429. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15430. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15431. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15432. * The gaps between physical kernels are compensated for in the weighting of the samples
  15433. * @param idealKernel Ideal blur kernel.
  15434. * @return Nearest best kernel.
  15435. */
  15436. protected _nearestBestKernel(idealKernel: number): number;
  15437. /**
  15438. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15439. * @param x The point on the Gaussian distribution to sample.
  15440. * @return the value of the Gaussian function at x.
  15441. */
  15442. protected _gaussianWeight(x: number): number;
  15443. /**
  15444. * Generates a string that can be used as a floating point number in GLSL.
  15445. * @param x Value to print.
  15446. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15447. * @return GLSL float string.
  15448. */
  15449. protected _glslFloat(x: number, decimalFigures?: number): string;
  15450. }
  15451. }
  15452. declare module BABYLON {
  15453. /**
  15454. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15455. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15456. * You can then easily use it as a reflectionTexture on a flat surface.
  15457. * In case the surface is not a plane, please consider relying on reflection probes.
  15458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15459. */
  15460. export class MirrorTexture extends RenderTargetTexture {
  15461. private scene;
  15462. /**
  15463. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15464. * 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.
  15465. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15466. */
  15467. mirrorPlane: Plane;
  15468. /**
  15469. * Define the blur ratio used to blur the reflection if needed.
  15470. */
  15471. blurRatio: number;
  15472. /**
  15473. * Define the adaptive blur kernel used to blur the reflection if needed.
  15474. * This will autocompute the closest best match for the `blurKernel`
  15475. */
  15476. adaptiveBlurKernel: number;
  15477. /**
  15478. * Define the blur kernel used to blur the reflection if needed.
  15479. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15480. */
  15481. blurKernel: number;
  15482. /**
  15483. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernelX: number;
  15487. /**
  15488. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelY: number;
  15492. private _autoComputeBlurKernel;
  15493. protected _onRatioRescale(): void;
  15494. private _updateGammaSpace;
  15495. private _imageProcessingConfigChangeObserver;
  15496. private _transformMatrix;
  15497. private _mirrorMatrix;
  15498. private _savedViewMatrix;
  15499. private _blurX;
  15500. private _blurY;
  15501. private _adaptiveBlurKernel;
  15502. private _blurKernelX;
  15503. private _blurKernelY;
  15504. private _blurRatio;
  15505. /**
  15506. * Instantiates a Mirror Texture.
  15507. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15508. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15509. * You can then easily use it as a reflectionTexture on a flat surface.
  15510. * In case the surface is not a plane, please consider relying on reflection probes.
  15511. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15512. * @param name
  15513. * @param size
  15514. * @param scene
  15515. * @param generateMipMaps
  15516. * @param type
  15517. * @param samplingMode
  15518. * @param generateDepthBuffer
  15519. */
  15520. constructor(name: string, size: number | {
  15521. width: number;
  15522. height: number;
  15523. } | {
  15524. ratio: number;
  15525. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15526. private _preparePostProcesses;
  15527. /**
  15528. * Clone the mirror texture.
  15529. * @returns the cloned texture
  15530. */
  15531. clone(): MirrorTexture;
  15532. /**
  15533. * Serialize the texture to a JSON representation you could use in Parse later on
  15534. * @returns the serialized JSON representation
  15535. */
  15536. serialize(): any;
  15537. /**
  15538. * Dispose the texture and release its associated resources.
  15539. */
  15540. dispose(): void;
  15541. }
  15542. }
  15543. declare module BABYLON {
  15544. /**
  15545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15547. */
  15548. export class Texture extends BaseTexture {
  15549. /** @hidden */
  15550. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15551. /** @hidden */
  15552. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15553. /** @hidden */
  15554. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15555. /** nearest is mag = nearest and min = nearest and mip = linear */
  15556. static readonly NEAREST_SAMPLINGMODE: number;
  15557. /** nearest is mag = nearest and min = nearest and mip = linear */
  15558. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15560. static readonly BILINEAR_SAMPLINGMODE: number;
  15561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15562. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15563. /** Trilinear is mag = linear and min = linear and mip = linear */
  15564. static readonly TRILINEAR_SAMPLINGMODE: number;
  15565. /** Trilinear is mag = linear and min = linear and mip = linear */
  15566. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15567. /** mag = nearest and min = nearest and mip = nearest */
  15568. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15569. /** mag = nearest and min = linear and mip = nearest */
  15570. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15571. /** mag = nearest and min = linear and mip = linear */
  15572. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15573. /** mag = nearest and min = linear and mip = none */
  15574. static readonly NEAREST_LINEAR: number;
  15575. /** mag = nearest and min = nearest and mip = none */
  15576. static readonly NEAREST_NEAREST: number;
  15577. /** mag = linear and min = nearest and mip = nearest */
  15578. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15579. /** mag = linear and min = nearest and mip = linear */
  15580. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15581. /** mag = linear and min = linear and mip = none */
  15582. static readonly LINEAR_LINEAR: number;
  15583. /** mag = linear and min = nearest and mip = none */
  15584. static readonly LINEAR_NEAREST: number;
  15585. /** Explicit coordinates mode */
  15586. static readonly EXPLICIT_MODE: number;
  15587. /** Spherical coordinates mode */
  15588. static readonly SPHERICAL_MODE: number;
  15589. /** Planar coordinates mode */
  15590. static readonly PLANAR_MODE: number;
  15591. /** Cubic coordinates mode */
  15592. static readonly CUBIC_MODE: number;
  15593. /** Projection coordinates mode */
  15594. static readonly PROJECTION_MODE: number;
  15595. /** Inverse Cubic coordinates mode */
  15596. static readonly SKYBOX_MODE: number;
  15597. /** Inverse Cubic coordinates mode */
  15598. static readonly INVCUBIC_MODE: number;
  15599. /** Equirectangular coordinates mode */
  15600. static readonly EQUIRECTANGULAR_MODE: number;
  15601. /** Equirectangular Fixed coordinates mode */
  15602. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15603. /** Equirectangular Fixed Mirrored coordinates mode */
  15604. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15605. /** Texture is not repeating outside of 0..1 UVs */
  15606. static readonly CLAMP_ADDRESSMODE: number;
  15607. /** Texture is repeating outside of 0..1 UVs */
  15608. static readonly WRAP_ADDRESSMODE: number;
  15609. /** Texture is repeating and mirrored */
  15610. static readonly MIRROR_ADDRESSMODE: number;
  15611. /**
  15612. * 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
  15613. */
  15614. static UseSerializedUrlIfAny: boolean;
  15615. /**
  15616. * Define the url of the texture.
  15617. */
  15618. url: Nullable<string>;
  15619. /**
  15620. * Define an offset on the texture to offset the u coordinates of the UVs
  15621. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15622. */
  15623. uOffset: number;
  15624. /**
  15625. * Define an offset on the texture to offset the v coordinates of the UVs
  15626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15627. */
  15628. vOffset: number;
  15629. /**
  15630. * Define an offset on the texture to scale the u coordinates of the UVs
  15631. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15632. */
  15633. uScale: number;
  15634. /**
  15635. * Define an offset on the texture to scale the v coordinates of the UVs
  15636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15637. */
  15638. vScale: number;
  15639. /**
  15640. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15641. * @see http://doc.babylonjs.com/how_to/more_materials
  15642. */
  15643. uAng: number;
  15644. /**
  15645. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15646. * @see http://doc.babylonjs.com/how_to/more_materials
  15647. */
  15648. vAng: number;
  15649. /**
  15650. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15651. * @see http://doc.babylonjs.com/how_to/more_materials
  15652. */
  15653. wAng: number;
  15654. /**
  15655. * Defines the center of rotation (U)
  15656. */
  15657. uRotationCenter: number;
  15658. /**
  15659. * Defines the center of rotation (V)
  15660. */
  15661. vRotationCenter: number;
  15662. /**
  15663. * Defines the center of rotation (W)
  15664. */
  15665. wRotationCenter: number;
  15666. /**
  15667. * Are mip maps generated for this texture or not.
  15668. */
  15669. readonly noMipmap: boolean;
  15670. /**
  15671. * List of inspectable custom properties (used by the Inspector)
  15672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15673. */
  15674. inspectableCustomProperties: Nullable<IInspectable[]>;
  15675. private _noMipmap;
  15676. /** @hidden */
  15677. _invertY: boolean;
  15678. private _rowGenerationMatrix;
  15679. private _cachedTextureMatrix;
  15680. private _projectionModeMatrix;
  15681. private _t0;
  15682. private _t1;
  15683. private _t2;
  15684. private _cachedUOffset;
  15685. private _cachedVOffset;
  15686. private _cachedUScale;
  15687. private _cachedVScale;
  15688. private _cachedUAng;
  15689. private _cachedVAng;
  15690. private _cachedWAng;
  15691. private _cachedProjectionMatrixId;
  15692. private _cachedCoordinatesMode;
  15693. /** @hidden */
  15694. protected _initialSamplingMode: number;
  15695. /** @hidden */
  15696. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15697. private _deleteBuffer;
  15698. protected _format: Nullable<number>;
  15699. private _delayedOnLoad;
  15700. private _delayedOnError;
  15701. /**
  15702. * Observable triggered once the texture has been loaded.
  15703. */
  15704. onLoadObservable: Observable<Texture>;
  15705. protected _isBlocking: boolean;
  15706. /**
  15707. * Is the texture preventing material to render while loading.
  15708. * If false, a default texture will be used instead of the loading one during the preparation step.
  15709. */
  15710. isBlocking: boolean;
  15711. /**
  15712. * Get the current sampling mode associated with the texture.
  15713. */
  15714. readonly samplingMode: number;
  15715. /**
  15716. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15717. */
  15718. readonly invertY: boolean;
  15719. /**
  15720. * Instantiates a new texture.
  15721. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15722. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15723. * @param url define the url of the picture to load as a texture
  15724. * @param scene define the scene or engine the texture will belong to
  15725. * @param noMipmap define if the texture will require mip maps or not
  15726. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15727. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15728. * @param onLoad define a callback triggered when the texture has been loaded
  15729. * @param onError define a callback triggered when an error occurred during the loading session
  15730. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15731. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15732. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15733. */
  15734. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15735. /**
  15736. * Update the url (and optional buffer) of this texture if url was null during construction.
  15737. * @param url the url of the texture
  15738. * @param buffer the buffer of the texture (defaults to null)
  15739. * @param onLoad callback called when the texture is loaded (defaults to null)
  15740. */
  15741. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15742. /**
  15743. * Finish the loading sequence of a texture flagged as delayed load.
  15744. * @hidden
  15745. */
  15746. delayLoad(): void;
  15747. private _prepareRowForTextureGeneration;
  15748. /**
  15749. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15750. * @returns the transform matrix of the texture.
  15751. */
  15752. getTextureMatrix(): Matrix;
  15753. /**
  15754. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15755. * @returns The reflection texture transform
  15756. */
  15757. getReflectionTextureMatrix(): Matrix;
  15758. /**
  15759. * Clones the texture.
  15760. * @returns the cloned texture
  15761. */
  15762. clone(): Texture;
  15763. /**
  15764. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15765. * @returns The JSON representation of the texture
  15766. */
  15767. serialize(): any;
  15768. /**
  15769. * Get the current class name of the texture useful for serialization or dynamic coding.
  15770. * @returns "Texture"
  15771. */
  15772. getClassName(): string;
  15773. /**
  15774. * Dispose the texture and release its associated resources.
  15775. */
  15776. dispose(): void;
  15777. /**
  15778. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15779. * @param parsedTexture Define the JSON representation of the texture
  15780. * @param scene Define the scene the parsed texture should be instantiated in
  15781. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15782. * @returns The parsed texture if successful
  15783. */
  15784. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15785. /**
  15786. * Creates a texture from its base 64 representation.
  15787. * @param data Define the base64 payload without the data: prefix
  15788. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15789. * @param scene Define the scene the texture should belong to
  15790. * @param noMipmap Forces the texture to not create mip map information if true
  15791. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15792. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15793. * @param onLoad define a callback triggered when the texture has been loaded
  15794. * @param onError define a callback triggered when an error occurred during the loading session
  15795. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15796. * @returns the created texture
  15797. */
  15798. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15799. /**
  15800. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15801. * @param data Define the base64 payload without the data: prefix
  15802. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15803. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15804. * @param scene Define the scene the texture should belong to
  15805. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15806. * @param noMipmap Forces the texture to not create mip map information if true
  15807. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15808. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15809. * @param onLoad define a callback triggered when the texture has been loaded
  15810. * @param onError define a callback triggered when an error occurred during the loading session
  15811. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15812. * @returns the created texture
  15813. */
  15814. 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;
  15815. }
  15816. }
  15817. declare module BABYLON {
  15818. /**
  15819. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15820. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15821. */
  15822. export class PostProcessManager {
  15823. private _scene;
  15824. private _indexBuffer;
  15825. private _vertexBuffers;
  15826. /**
  15827. * Creates a new instance PostProcess
  15828. * @param scene The scene that the post process is associated with.
  15829. */
  15830. constructor(scene: Scene);
  15831. private _prepareBuffers;
  15832. private _buildIndexBuffer;
  15833. /**
  15834. * Rebuilds the vertex buffers of the manager.
  15835. * @hidden
  15836. */
  15837. _rebuild(): void;
  15838. /**
  15839. * Prepares a frame to be run through a post process.
  15840. * @param sourceTexture The input texture to the post procesess. (default: null)
  15841. * @param postProcesses An array of post processes to be run. (default: null)
  15842. * @returns True if the post processes were able to be run.
  15843. * @hidden
  15844. */
  15845. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15846. /**
  15847. * Manually render a set of post processes to a texture.
  15848. * @param postProcesses An array of post processes to be run.
  15849. * @param targetTexture The target texture to render to.
  15850. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15851. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15852. * @param lodLevel defines which lod of the texture to render to
  15853. */
  15854. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15855. /**
  15856. * Finalize the result of the output of the postprocesses.
  15857. * @param doNotPresent If true the result will not be displayed to the screen.
  15858. * @param targetTexture The target texture to render to.
  15859. * @param faceIndex The index of the face to bind the target texture to.
  15860. * @param postProcesses The array of post processes to render.
  15861. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15862. * @hidden
  15863. */
  15864. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15865. /**
  15866. * Disposes of the post process manager.
  15867. */
  15868. dispose(): void;
  15869. }
  15870. }
  15871. declare module BABYLON {
  15872. /** Interface used by value gradients (color, factor, ...) */
  15873. export interface IValueGradient {
  15874. /**
  15875. * Gets or sets the gradient value (between 0 and 1)
  15876. */
  15877. gradient: number;
  15878. }
  15879. /** Class used to store color4 gradient */
  15880. export class ColorGradient implements IValueGradient {
  15881. /**
  15882. * Gets or sets the gradient value (between 0 and 1)
  15883. */
  15884. gradient: number;
  15885. /**
  15886. * Gets or sets first associated color
  15887. */
  15888. color1: Color4;
  15889. /**
  15890. * Gets or sets second associated color
  15891. */
  15892. color2?: Color4;
  15893. /**
  15894. * Will get a color picked randomly between color1 and color2.
  15895. * If color2 is undefined then color1 will be used
  15896. * @param result defines the target Color4 to store the result in
  15897. */
  15898. getColorToRef(result: Color4): void;
  15899. }
  15900. /** Class used to store color 3 gradient */
  15901. export class Color3Gradient implements IValueGradient {
  15902. /**
  15903. * Gets or sets the gradient value (between 0 and 1)
  15904. */
  15905. gradient: number;
  15906. /**
  15907. * Gets or sets the associated color
  15908. */
  15909. color: Color3;
  15910. }
  15911. /** Class used to store factor gradient */
  15912. export class FactorGradient implements IValueGradient {
  15913. /**
  15914. * Gets or sets the gradient value (between 0 and 1)
  15915. */
  15916. gradient: number;
  15917. /**
  15918. * Gets or sets first associated factor
  15919. */
  15920. factor1: number;
  15921. /**
  15922. * Gets or sets second associated factor
  15923. */
  15924. factor2?: number;
  15925. /**
  15926. * Will get a number picked randomly between factor1 and factor2.
  15927. * If factor2 is undefined then factor1 will be used
  15928. * @returns the picked number
  15929. */
  15930. getFactor(): number;
  15931. }
  15932. /**
  15933. * Helper used to simplify some generic gradient tasks
  15934. */
  15935. export class GradientHelper {
  15936. /**
  15937. * Gets the current gradient from an array of IValueGradient
  15938. * @param ratio defines the current ratio to get
  15939. * @param gradients defines the array of IValueGradient
  15940. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15941. */
  15942. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15943. }
  15944. }
  15945. declare module BABYLON {
  15946. interface AbstractScene {
  15947. /**
  15948. * The list of procedural textures added to the scene
  15949. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15950. */
  15951. proceduralTextures: Array<ProceduralTexture>;
  15952. }
  15953. /**
  15954. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15955. * in a given scene.
  15956. */
  15957. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15958. /**
  15959. * The component name helpfull to identify the component in the list of scene components.
  15960. */
  15961. readonly name: string;
  15962. /**
  15963. * The scene the component belongs to.
  15964. */
  15965. scene: Scene;
  15966. /**
  15967. * Creates a new instance of the component for the given scene
  15968. * @param scene Defines the scene to register the component in
  15969. */
  15970. constructor(scene: Scene);
  15971. /**
  15972. * Registers the component in a given scene
  15973. */
  15974. register(): void;
  15975. /**
  15976. * Rebuilds the elements related to this component in case of
  15977. * context lost for instance.
  15978. */
  15979. rebuild(): void;
  15980. /**
  15981. * Disposes the component and the associated ressources.
  15982. */
  15983. dispose(): void;
  15984. private _beforeClear;
  15985. }
  15986. }
  15987. declare module BABYLON {
  15988. interface Engine {
  15989. /**
  15990. * Creates a new render target cube texture
  15991. * @param size defines the size of the texture
  15992. * @param options defines the options used to create the texture
  15993. * @returns a new render target cube texture stored in an InternalTexture
  15994. */
  15995. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15996. }
  15997. }
  15998. declare module BABYLON {
  15999. /** @hidden */
  16000. export var proceduralVertexShader: {
  16001. name: string;
  16002. shader: string;
  16003. };
  16004. }
  16005. declare module BABYLON {
  16006. /**
  16007. * 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.
  16008. * This is the base class of any Procedural texture and contains most of the shareable code.
  16009. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16010. */
  16011. export class ProceduralTexture extends Texture {
  16012. isCube: boolean;
  16013. /**
  16014. * Define if the texture is enabled or not (disabled texture will not render)
  16015. */
  16016. isEnabled: boolean;
  16017. /**
  16018. * Define if the texture must be cleared before rendering (default is true)
  16019. */
  16020. autoClear: boolean;
  16021. /**
  16022. * Callback called when the texture is generated
  16023. */
  16024. onGenerated: () => void;
  16025. /**
  16026. * Event raised when the texture is generated
  16027. */
  16028. onGeneratedObservable: Observable<ProceduralTexture>;
  16029. /** @hidden */
  16030. _generateMipMaps: boolean;
  16031. /** @hidden **/
  16032. _effect: Effect;
  16033. /** @hidden */
  16034. _textures: {
  16035. [key: string]: Texture;
  16036. };
  16037. private _size;
  16038. private _currentRefreshId;
  16039. private _refreshRate;
  16040. private _vertexBuffers;
  16041. private _indexBuffer;
  16042. private _uniforms;
  16043. private _samplers;
  16044. private _fragment;
  16045. private _floats;
  16046. private _ints;
  16047. private _floatsArrays;
  16048. private _colors3;
  16049. private _colors4;
  16050. private _vectors2;
  16051. private _vectors3;
  16052. private _matrices;
  16053. private _fallbackTexture;
  16054. private _fallbackTextureUsed;
  16055. private _engine;
  16056. private _cachedDefines;
  16057. private _contentUpdateId;
  16058. private _contentData;
  16059. /**
  16060. * Instantiates a new procedural texture.
  16061. * 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.
  16062. * This is the base class of any Procedural texture and contains most of the shareable code.
  16063. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16064. * @param name Define the name of the texture
  16065. * @param size Define the size of the texture to create
  16066. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16067. * @param scene Define the scene the texture belongs to
  16068. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16069. * @param generateMipMaps Define if the texture should creates mip maps or not
  16070. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16071. */
  16072. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16073. /**
  16074. * The effect that is created when initializing the post process.
  16075. * @returns The created effect corresponding the the postprocess.
  16076. */
  16077. getEffect(): Effect;
  16078. /**
  16079. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16080. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16081. */
  16082. getContent(): Nullable<ArrayBufferView>;
  16083. private _createIndexBuffer;
  16084. /** @hidden */
  16085. _rebuild(): void;
  16086. /**
  16087. * Resets the texture in order to recreate its associated resources.
  16088. * This can be called in case of context loss
  16089. */
  16090. reset(): void;
  16091. protected _getDefines(): string;
  16092. /**
  16093. * Is the texture ready to be used ? (rendered at least once)
  16094. * @returns true if ready, otherwise, false.
  16095. */
  16096. isReady(): boolean;
  16097. /**
  16098. * Resets the refresh counter of the texture and start bak from scratch.
  16099. * Could be useful to regenerate the texture if it is setup to render only once.
  16100. */
  16101. resetRefreshCounter(): void;
  16102. /**
  16103. * Set the fragment shader to use in order to render the texture.
  16104. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16105. */
  16106. setFragment(fragment: any): void;
  16107. /**
  16108. * Define the refresh rate of the texture or the rendering frequency.
  16109. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16110. */
  16111. refreshRate: number;
  16112. /** @hidden */
  16113. _shouldRender(): boolean;
  16114. /**
  16115. * Get the size the texture is rendering at.
  16116. * @returns the size (texture is always squared)
  16117. */
  16118. getRenderSize(): number;
  16119. /**
  16120. * Resize the texture to new value.
  16121. * @param size Define the new size the texture should have
  16122. * @param generateMipMaps Define whether the new texture should create mip maps
  16123. */
  16124. resize(size: number, generateMipMaps: boolean): void;
  16125. private _checkUniform;
  16126. /**
  16127. * Set a texture in the shader program used to render.
  16128. * @param name Define the name of the uniform samplers as defined in the shader
  16129. * @param texture Define the texture to bind to this sampler
  16130. * @return the texture itself allowing "fluent" like uniform updates
  16131. */
  16132. setTexture(name: string, texture: Texture): ProceduralTexture;
  16133. /**
  16134. * Set a float in the shader.
  16135. * @param name Define the name of the uniform as defined in the shader
  16136. * @param value Define the value to give to the uniform
  16137. * @return the texture itself allowing "fluent" like uniform updates
  16138. */
  16139. setFloat(name: string, value: number): ProceduralTexture;
  16140. /**
  16141. * Set a int in the shader.
  16142. * @param name Define the name of the uniform as defined in the shader
  16143. * @param value Define the value to give to the uniform
  16144. * @return the texture itself allowing "fluent" like uniform updates
  16145. */
  16146. setInt(name: string, value: number): ProceduralTexture;
  16147. /**
  16148. * Set an array of floats in the shader.
  16149. * @param name Define the name of the uniform as defined in the shader
  16150. * @param value Define the value to give to the uniform
  16151. * @return the texture itself allowing "fluent" like uniform updates
  16152. */
  16153. setFloats(name: string, value: number[]): ProceduralTexture;
  16154. /**
  16155. * Set a vec3 in the shader from a Color3.
  16156. * @param name Define the name of the uniform as defined in the shader
  16157. * @param value Define the value to give to the uniform
  16158. * @return the texture itself allowing "fluent" like uniform updates
  16159. */
  16160. setColor3(name: string, value: Color3): ProceduralTexture;
  16161. /**
  16162. * Set a vec4 in the shader from a Color4.
  16163. * @param name Define the name of the uniform as defined in the shader
  16164. * @param value Define the value to give to the uniform
  16165. * @return the texture itself allowing "fluent" like uniform updates
  16166. */
  16167. setColor4(name: string, value: Color4): ProceduralTexture;
  16168. /**
  16169. * Set a vec2 in the shader from a Vector2.
  16170. * @param name Define the name of the uniform as defined in the shader
  16171. * @param value Define the value to give to the uniform
  16172. * @return the texture itself allowing "fluent" like uniform updates
  16173. */
  16174. setVector2(name: string, value: Vector2): ProceduralTexture;
  16175. /**
  16176. * Set a vec3 in the shader from a Vector3.
  16177. * @param name Define the name of the uniform as defined in the shader
  16178. * @param value Define the value to give to the uniform
  16179. * @return the texture itself allowing "fluent" like uniform updates
  16180. */
  16181. setVector3(name: string, value: Vector3): ProceduralTexture;
  16182. /**
  16183. * Set a mat4 in the shader from a MAtrix.
  16184. * @param name Define the name of the uniform as defined in the shader
  16185. * @param value Define the value to give to the uniform
  16186. * @return the texture itself allowing "fluent" like uniform updates
  16187. */
  16188. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16189. /**
  16190. * Render the texture to its associated render target.
  16191. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16192. */
  16193. render(useCameraPostProcess?: boolean): void;
  16194. /**
  16195. * Clone the texture.
  16196. * @returns the cloned texture
  16197. */
  16198. clone(): ProceduralTexture;
  16199. /**
  16200. * Dispose the texture and release its asoociated resources.
  16201. */
  16202. dispose(): void;
  16203. }
  16204. }
  16205. declare module BABYLON {
  16206. /**
  16207. * This represents the base class for particle system in Babylon.
  16208. * 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.
  16209. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16210. * @example https://doc.babylonjs.com/babylon101/particles
  16211. */
  16212. export class BaseParticleSystem {
  16213. /**
  16214. * Source color is added to the destination color without alpha affecting the result
  16215. */
  16216. static BLENDMODE_ONEONE: number;
  16217. /**
  16218. * Blend current color and particle color using particle’s alpha
  16219. */
  16220. static BLENDMODE_STANDARD: number;
  16221. /**
  16222. * Add current color and particle color multiplied by particle’s alpha
  16223. */
  16224. static BLENDMODE_ADD: number;
  16225. /**
  16226. * Multiply current color with particle color
  16227. */
  16228. static BLENDMODE_MULTIPLY: number;
  16229. /**
  16230. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16231. */
  16232. static BLENDMODE_MULTIPLYADD: number;
  16233. /**
  16234. * List of animations used by the particle system.
  16235. */
  16236. animations: Animation[];
  16237. /**
  16238. * The id of the Particle system.
  16239. */
  16240. id: string;
  16241. /**
  16242. * The friendly name of the Particle system.
  16243. */
  16244. name: string;
  16245. /**
  16246. * The rendering group used by the Particle system to chose when to render.
  16247. */
  16248. renderingGroupId: number;
  16249. /**
  16250. * The emitter represents the Mesh or position we are attaching the particle system to.
  16251. */
  16252. emitter: Nullable<AbstractMesh | Vector3>;
  16253. /**
  16254. * The maximum number of particles to emit per frame
  16255. */
  16256. emitRate: number;
  16257. /**
  16258. * If you want to launch only a few particles at once, that can be done, as well.
  16259. */
  16260. manualEmitCount: number;
  16261. /**
  16262. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16263. */
  16264. updateSpeed: number;
  16265. /**
  16266. * The amount of time the particle system is running (depends of the overall update speed).
  16267. */
  16268. targetStopDuration: number;
  16269. /**
  16270. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16271. */
  16272. disposeOnStop: boolean;
  16273. /**
  16274. * Minimum power of emitting particles.
  16275. */
  16276. minEmitPower: number;
  16277. /**
  16278. * Maximum power of emitting particles.
  16279. */
  16280. maxEmitPower: number;
  16281. /**
  16282. * Minimum life time of emitting particles.
  16283. */
  16284. minLifeTime: number;
  16285. /**
  16286. * Maximum life time of emitting particles.
  16287. */
  16288. maxLifeTime: number;
  16289. /**
  16290. * Minimum Size of emitting particles.
  16291. */
  16292. minSize: number;
  16293. /**
  16294. * Maximum Size of emitting particles.
  16295. */
  16296. maxSize: number;
  16297. /**
  16298. * Minimum scale of emitting particles on X axis.
  16299. */
  16300. minScaleX: number;
  16301. /**
  16302. * Maximum scale of emitting particles on X axis.
  16303. */
  16304. maxScaleX: number;
  16305. /**
  16306. * Minimum scale of emitting particles on Y axis.
  16307. */
  16308. minScaleY: number;
  16309. /**
  16310. * Maximum scale of emitting particles on Y axis.
  16311. */
  16312. maxScaleY: number;
  16313. /**
  16314. * Gets or sets the minimal initial rotation in radians.
  16315. */
  16316. minInitialRotation: number;
  16317. /**
  16318. * Gets or sets the maximal initial rotation in radians.
  16319. */
  16320. maxInitialRotation: number;
  16321. /**
  16322. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16323. */
  16324. minAngularSpeed: number;
  16325. /**
  16326. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16327. */
  16328. maxAngularSpeed: number;
  16329. /**
  16330. * The texture used to render each particle. (this can be a spritesheet)
  16331. */
  16332. particleTexture: Nullable<Texture>;
  16333. /**
  16334. * The layer mask we are rendering the particles through.
  16335. */
  16336. layerMask: number;
  16337. /**
  16338. * This can help using your own shader to render the particle system.
  16339. * The according effect will be created
  16340. */
  16341. customShader: any;
  16342. /**
  16343. * By default particle system starts as soon as they are created. This prevents the
  16344. * automatic start to happen and let you decide when to start emitting particles.
  16345. */
  16346. preventAutoStart: boolean;
  16347. private _noiseTexture;
  16348. /**
  16349. * Gets or sets a texture used to add random noise to particle positions
  16350. */
  16351. noiseTexture: Nullable<ProceduralTexture>;
  16352. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16353. noiseStrength: Vector3;
  16354. /**
  16355. * Callback triggered when the particle animation is ending.
  16356. */
  16357. onAnimationEnd: Nullable<() => void>;
  16358. /**
  16359. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16360. */
  16361. blendMode: number;
  16362. /**
  16363. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16364. * to override the particles.
  16365. */
  16366. forceDepthWrite: boolean;
  16367. /** 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 */
  16368. preWarmCycles: number;
  16369. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16370. preWarmStepOffset: number;
  16371. /**
  16372. * 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)
  16373. */
  16374. spriteCellChangeSpeed: number;
  16375. /**
  16376. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16377. */
  16378. startSpriteCellID: number;
  16379. /**
  16380. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16381. */
  16382. endSpriteCellID: number;
  16383. /**
  16384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16385. */
  16386. spriteCellWidth: number;
  16387. /**
  16388. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16389. */
  16390. spriteCellHeight: number;
  16391. /**
  16392. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16393. */
  16394. spriteRandomStartCell: boolean;
  16395. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16396. translationPivot: Vector2;
  16397. /** @hidden */
  16398. protected _isAnimationSheetEnabled: boolean;
  16399. /**
  16400. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16401. */
  16402. beginAnimationOnStart: boolean;
  16403. /**
  16404. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16405. */
  16406. beginAnimationFrom: number;
  16407. /**
  16408. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16409. */
  16410. beginAnimationTo: number;
  16411. /**
  16412. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16413. */
  16414. beginAnimationLoop: boolean;
  16415. /**
  16416. * Gets or sets a world offset applied to all particles
  16417. */
  16418. worldOffset: Vector3;
  16419. /**
  16420. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16421. */
  16422. isAnimationSheetEnabled: boolean;
  16423. /**
  16424. * Get hosting scene
  16425. * @returns the scene
  16426. */
  16427. getScene(): Scene;
  16428. /**
  16429. * You can use gravity if you want to give an orientation to your particles.
  16430. */
  16431. gravity: Vector3;
  16432. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16433. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16434. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16435. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16436. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16437. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16438. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16439. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16440. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16441. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16442. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16443. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16444. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16445. /**
  16446. * Defines the delay in milliseconds before starting the system (0 by default)
  16447. */
  16448. startDelay: number;
  16449. /**
  16450. * Gets the current list of drag gradients.
  16451. * You must use addDragGradient and removeDragGradient to udpate this list
  16452. * @returns the list of drag gradients
  16453. */
  16454. getDragGradients(): Nullable<Array<FactorGradient>>;
  16455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16456. limitVelocityDamping: number;
  16457. /**
  16458. * Gets the current list of limit velocity gradients.
  16459. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16460. * @returns the list of limit velocity gradients
  16461. */
  16462. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16463. /**
  16464. * Gets the current list of color gradients.
  16465. * You must use addColorGradient and removeColorGradient to udpate this list
  16466. * @returns the list of color gradients
  16467. */
  16468. getColorGradients(): Nullable<Array<ColorGradient>>;
  16469. /**
  16470. * Gets the current list of size gradients.
  16471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16472. * @returns the list of size gradients
  16473. */
  16474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16475. /**
  16476. * Gets the current list of color remap gradients.
  16477. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16478. * @returns the list of color remap gradients
  16479. */
  16480. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16481. /**
  16482. * Gets the current list of alpha remap gradients.
  16483. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16484. * @returns the list of alpha remap gradients
  16485. */
  16486. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16487. /**
  16488. * Gets the current list of life time gradients.
  16489. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16490. * @returns the list of life time gradients
  16491. */
  16492. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16493. /**
  16494. * Gets the current list of angular speed gradients.
  16495. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16496. * @returns the list of angular speed gradients
  16497. */
  16498. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16499. /**
  16500. * Gets the current list of velocity gradients.
  16501. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16502. * @returns the list of velocity gradients
  16503. */
  16504. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16505. /**
  16506. * Gets the current list of start size gradients.
  16507. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16508. * @returns the list of start size gradients
  16509. */
  16510. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16511. /**
  16512. * Gets the current list of emit rate gradients.
  16513. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16514. * @returns the list of emit rate gradients
  16515. */
  16516. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16517. /**
  16518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16520. */
  16521. direction1: Vector3;
  16522. /**
  16523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16525. */
  16526. direction2: Vector3;
  16527. /**
  16528. * 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.
  16529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16530. */
  16531. minEmitBox: Vector3;
  16532. /**
  16533. * 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.
  16534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16535. */
  16536. maxEmitBox: Vector3;
  16537. /**
  16538. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16539. */
  16540. color1: Color4;
  16541. /**
  16542. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16543. */
  16544. color2: Color4;
  16545. /**
  16546. * Color the particle will have at the end of its lifetime
  16547. */
  16548. colorDead: Color4;
  16549. /**
  16550. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16551. */
  16552. textureMask: Color4;
  16553. /**
  16554. * The particle emitter type defines the emitter used by the particle system.
  16555. * It can be for example box, sphere, or cone...
  16556. */
  16557. particleEmitterType: IParticleEmitterType;
  16558. /** @hidden */
  16559. _isSubEmitter: boolean;
  16560. /**
  16561. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16562. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16563. */
  16564. billboardMode: number;
  16565. protected _isBillboardBased: boolean;
  16566. /**
  16567. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16568. */
  16569. isBillboardBased: boolean;
  16570. /**
  16571. * The scene the particle system belongs to.
  16572. */
  16573. protected _scene: Scene;
  16574. /**
  16575. * Local cache of defines for image processing.
  16576. */
  16577. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16578. /**
  16579. * Default configuration related to image processing available in the standard Material.
  16580. */
  16581. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16582. /**
  16583. * Gets the image processing configuration used either in this material.
  16584. */
  16585. /**
  16586. * Sets the Default image processing configuration used either in the this material.
  16587. *
  16588. * If sets to null, the scene one is in use.
  16589. */
  16590. imageProcessingConfiguration: ImageProcessingConfiguration;
  16591. /**
  16592. * Attaches a new image processing configuration to the Standard Material.
  16593. * @param configuration
  16594. */
  16595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16596. /** @hidden */
  16597. protected _reset(): void;
  16598. /** @hidden */
  16599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16600. /**
  16601. * Instantiates a particle system.
  16602. * 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.
  16603. * @param name The name of the particle system
  16604. */
  16605. constructor(name: string);
  16606. /**
  16607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16610. * @returns the emitter
  16611. */
  16612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16613. /**
  16614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16615. * @param radius The radius of the hemisphere to emit from
  16616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16617. * @returns the emitter
  16618. */
  16619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16620. /**
  16621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16622. * @param radius The radius of the sphere to emit from
  16623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16624. * @returns the emitter
  16625. */
  16626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16627. /**
  16628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16629. * @param radius The radius of the sphere to emit from
  16630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16632. * @returns the emitter
  16633. */
  16634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16635. /**
  16636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16637. * @param radius The radius of the emission cylinder
  16638. * @param height The height of the emission cylinder
  16639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16641. * @returns the emitter
  16642. */
  16643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16644. /**
  16645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16646. * @param radius The radius of the cylinder to emit from
  16647. * @param height The height of the emission cylinder
  16648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16651. * @returns the emitter
  16652. */
  16653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16654. /**
  16655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16656. * @param radius The radius of the cone to emit from
  16657. * @param angle The base angle of the cone
  16658. * @returns the emitter
  16659. */
  16660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16661. /**
  16662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16667. * @returns the emitter
  16668. */
  16669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16670. }
  16671. }
  16672. declare module BABYLON {
  16673. /**
  16674. * Type of sub emitter
  16675. */
  16676. export enum SubEmitterType {
  16677. /**
  16678. * Attached to the particle over it's lifetime
  16679. */
  16680. ATTACHED = 0,
  16681. /**
  16682. * Created when the particle dies
  16683. */
  16684. END = 1
  16685. }
  16686. /**
  16687. * Sub emitter class used to emit particles from an existing particle
  16688. */
  16689. export class SubEmitter {
  16690. /**
  16691. * the particle system to be used by the sub emitter
  16692. */
  16693. particleSystem: ParticleSystem;
  16694. /**
  16695. * Type of the submitter (Default: END)
  16696. */
  16697. type: SubEmitterType;
  16698. /**
  16699. * 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)
  16700. * Note: This only is supported when using an emitter of type Mesh
  16701. */
  16702. inheritDirection: boolean;
  16703. /**
  16704. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16705. */
  16706. inheritedVelocityAmount: number;
  16707. /**
  16708. * Creates a sub emitter
  16709. * @param particleSystem the particle system to be used by the sub emitter
  16710. */
  16711. constructor(
  16712. /**
  16713. * the particle system to be used by the sub emitter
  16714. */
  16715. particleSystem: ParticleSystem);
  16716. /**
  16717. * Clones the sub emitter
  16718. * @returns the cloned sub emitter
  16719. */
  16720. clone(): SubEmitter;
  16721. /**
  16722. * Serialize current object to a JSON object
  16723. * @returns the serialized object
  16724. */
  16725. serialize(): any;
  16726. /** @hidden */
  16727. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16728. /**
  16729. * Creates a new SubEmitter from a serialized JSON version
  16730. * @param serializationObject defines the JSON object to read from
  16731. * @param scene defines the hosting scene
  16732. * @param rootUrl defines the rootUrl for data loading
  16733. * @returns a new SubEmitter
  16734. */
  16735. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16736. /** Release associated resources */
  16737. dispose(): void;
  16738. }
  16739. }
  16740. declare module BABYLON {
  16741. /** @hidden */
  16742. export var clipPlaneFragmentDeclaration: {
  16743. name: string;
  16744. shader: string;
  16745. };
  16746. }
  16747. declare module BABYLON {
  16748. /** @hidden */
  16749. export var imageProcessingDeclaration: {
  16750. name: string;
  16751. shader: string;
  16752. };
  16753. }
  16754. declare module BABYLON {
  16755. /** @hidden */
  16756. export var imageProcessingFunctions: {
  16757. name: string;
  16758. shader: string;
  16759. };
  16760. }
  16761. declare module BABYLON {
  16762. /** @hidden */
  16763. export var clipPlaneFragment: {
  16764. name: string;
  16765. shader: string;
  16766. };
  16767. }
  16768. declare module BABYLON {
  16769. /** @hidden */
  16770. export var particlesPixelShader: {
  16771. name: string;
  16772. shader: string;
  16773. };
  16774. }
  16775. declare module BABYLON {
  16776. /** @hidden */
  16777. export var clipPlaneVertexDeclaration: {
  16778. name: string;
  16779. shader: string;
  16780. };
  16781. }
  16782. declare module BABYLON {
  16783. /** @hidden */
  16784. export var clipPlaneVertex: {
  16785. name: string;
  16786. shader: string;
  16787. };
  16788. }
  16789. declare module BABYLON {
  16790. /** @hidden */
  16791. export var particlesVertexShader: {
  16792. name: string;
  16793. shader: string;
  16794. };
  16795. }
  16796. declare module BABYLON {
  16797. /**
  16798. * This represents a particle system in Babylon.
  16799. * 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.
  16800. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16801. * @example https://doc.babylonjs.com/babylon101/particles
  16802. */
  16803. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16804. /**
  16805. * Billboard mode will only apply to Y axis
  16806. */
  16807. static readonly BILLBOARDMODE_Y: number;
  16808. /**
  16809. * Billboard mode will apply to all axes
  16810. */
  16811. static readonly BILLBOARDMODE_ALL: number;
  16812. /**
  16813. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16814. */
  16815. static readonly BILLBOARDMODE_STRETCHED: number;
  16816. /**
  16817. * This function can be defined to provide custom update for active particles.
  16818. * This function will be called instead of regular update (age, position, color, etc.).
  16819. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16820. */
  16821. updateFunction: (particles: Particle[]) => void;
  16822. private _emitterWorldMatrix;
  16823. /**
  16824. * This function can be defined to specify initial direction for every new particle.
  16825. * It by default use the emitterType defined function
  16826. */
  16827. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16828. /**
  16829. * This function can be defined to specify initial position for every new particle.
  16830. * It by default use the emitterType defined function
  16831. */
  16832. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16833. /**
  16834. * @hidden
  16835. */
  16836. _inheritedVelocityOffset: Vector3;
  16837. /**
  16838. * An event triggered when the system is disposed
  16839. */
  16840. onDisposeObservable: Observable<ParticleSystem>;
  16841. private _onDisposeObserver;
  16842. /**
  16843. * Sets a callback that will be triggered when the system is disposed
  16844. */
  16845. onDispose: () => void;
  16846. private _particles;
  16847. private _epsilon;
  16848. private _capacity;
  16849. private _stockParticles;
  16850. private _newPartsExcess;
  16851. private _vertexData;
  16852. private _vertexBuffer;
  16853. private _vertexBuffers;
  16854. private _spriteBuffer;
  16855. private _indexBuffer;
  16856. private _effect;
  16857. private _customEffect;
  16858. private _cachedDefines;
  16859. private _scaledColorStep;
  16860. private _colorDiff;
  16861. private _scaledDirection;
  16862. private _scaledGravity;
  16863. private _currentRenderId;
  16864. private _alive;
  16865. private _useInstancing;
  16866. private _started;
  16867. private _stopped;
  16868. private _actualFrame;
  16869. private _scaledUpdateSpeed;
  16870. private _vertexBufferSize;
  16871. /** @hidden */
  16872. _currentEmitRateGradient: Nullable<FactorGradient>;
  16873. /** @hidden */
  16874. _currentEmitRate1: number;
  16875. /** @hidden */
  16876. _currentEmitRate2: number;
  16877. /** @hidden */
  16878. _currentStartSizeGradient: Nullable<FactorGradient>;
  16879. /** @hidden */
  16880. _currentStartSize1: number;
  16881. /** @hidden */
  16882. _currentStartSize2: number;
  16883. private readonly _rawTextureWidth;
  16884. private _rampGradientsTexture;
  16885. private _useRampGradients;
  16886. /** Gets or sets a boolean indicating that ramp gradients must be used
  16887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16888. */
  16889. useRampGradients: boolean;
  16890. /**
  16891. * 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.
  16892. * 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: [])
  16893. */
  16894. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16895. private _subEmitters;
  16896. /**
  16897. * @hidden
  16898. * If the particle systems emitter should be disposed when the particle system is disposed
  16899. */
  16900. _disposeEmitterOnDispose: boolean;
  16901. /**
  16902. * The current active Sub-systems, this property is used by the root particle system only.
  16903. */
  16904. activeSubSystems: Array<ParticleSystem>;
  16905. private _rootParticleSystem;
  16906. /**
  16907. * Gets the current list of active particles
  16908. */
  16909. readonly particles: Particle[];
  16910. /**
  16911. * Returns the string "ParticleSystem"
  16912. * @returns a string containing the class name
  16913. */
  16914. getClassName(): string;
  16915. /**
  16916. * Instantiates a particle system.
  16917. * 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.
  16918. * @param name The name of the particle system
  16919. * @param capacity The max number of particles alive at the same time
  16920. * @param scene The scene the particle system belongs to
  16921. * @param customEffect a custom effect used to change the way particles are rendered by default
  16922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16923. * @param epsilon Offset used to render the particles
  16924. */
  16925. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16926. private _addFactorGradient;
  16927. private _removeFactorGradient;
  16928. /**
  16929. * Adds a new life time gradient
  16930. * @param gradient defines the gradient to use (between 0 and 1)
  16931. * @param factor defines the life time factor to affect to the specified gradient
  16932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16933. * @returns the current particle system
  16934. */
  16935. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16936. /**
  16937. * Remove a specific life time gradient
  16938. * @param gradient defines the gradient to remove
  16939. * @returns the current particle system
  16940. */
  16941. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16942. /**
  16943. * Adds a new size gradient
  16944. * @param gradient defines the gradient to use (between 0 and 1)
  16945. * @param factor defines the size factor to affect to the specified gradient
  16946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16947. * @returns the current particle system
  16948. */
  16949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16950. /**
  16951. * Remove a specific size gradient
  16952. * @param gradient defines the gradient to remove
  16953. * @returns the current particle system
  16954. */
  16955. removeSizeGradient(gradient: number): IParticleSystem;
  16956. /**
  16957. * Adds a new color remap gradient
  16958. * @param gradient defines the gradient to use (between 0 and 1)
  16959. * @param min defines the color remap minimal range
  16960. * @param max defines the color remap maximal range
  16961. * @returns the current particle system
  16962. */
  16963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16964. /**
  16965. * Remove a specific color remap gradient
  16966. * @param gradient defines the gradient to remove
  16967. * @returns the current particle system
  16968. */
  16969. removeColorRemapGradient(gradient: number): IParticleSystem;
  16970. /**
  16971. * Adds a new alpha remap gradient
  16972. * @param gradient defines the gradient to use (between 0 and 1)
  16973. * @param min defines the alpha remap minimal range
  16974. * @param max defines the alpha remap maximal range
  16975. * @returns the current particle system
  16976. */
  16977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16978. /**
  16979. * Remove a specific alpha remap gradient
  16980. * @param gradient defines the gradient to remove
  16981. * @returns the current particle system
  16982. */
  16983. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16984. /**
  16985. * Adds a new angular speed gradient
  16986. * @param gradient defines the gradient to use (between 0 and 1)
  16987. * @param factor defines the angular speed to affect to the specified gradient
  16988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16989. * @returns the current particle system
  16990. */
  16991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16992. /**
  16993. * Remove a specific angular speed gradient
  16994. * @param gradient defines the gradient to remove
  16995. * @returns the current particle system
  16996. */
  16997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16998. /**
  16999. * Adds a new velocity gradient
  17000. * @param gradient defines the gradient to use (between 0 and 1)
  17001. * @param factor defines the velocity to affect to the specified gradient
  17002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17003. * @returns the current particle system
  17004. */
  17005. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17006. /**
  17007. * Remove a specific velocity gradient
  17008. * @param gradient defines the gradient to remove
  17009. * @returns the current particle system
  17010. */
  17011. removeVelocityGradient(gradient: number): IParticleSystem;
  17012. /**
  17013. * Adds a new limit velocity gradient
  17014. * @param gradient defines the gradient to use (between 0 and 1)
  17015. * @param factor defines the limit velocity value to affect to the specified gradient
  17016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17017. * @returns the current particle system
  17018. */
  17019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17020. /**
  17021. * Remove a specific limit velocity gradient
  17022. * @param gradient defines the gradient to remove
  17023. * @returns the current particle system
  17024. */
  17025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17026. /**
  17027. * Adds a new drag gradient
  17028. * @param gradient defines the gradient to use (between 0 and 1)
  17029. * @param factor defines the drag value to affect to the specified gradient
  17030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17031. * @returns the current particle system
  17032. */
  17033. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17034. /**
  17035. * Remove a specific drag gradient
  17036. * @param gradient defines the gradient to remove
  17037. * @returns the current particle system
  17038. */
  17039. removeDragGradient(gradient: number): IParticleSystem;
  17040. /**
  17041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17042. * @param gradient defines the gradient to use (between 0 and 1)
  17043. * @param factor defines the emit rate value to affect to the specified gradient
  17044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17045. * @returns the current particle system
  17046. */
  17047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17048. /**
  17049. * Remove a specific emit rate gradient
  17050. * @param gradient defines the gradient to remove
  17051. * @returns the current particle system
  17052. */
  17053. removeEmitRateGradient(gradient: number): IParticleSystem;
  17054. /**
  17055. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17056. * @param gradient defines the gradient to use (between 0 and 1)
  17057. * @param factor defines the start size value to affect to the specified gradient
  17058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17059. * @returns the current particle system
  17060. */
  17061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17062. /**
  17063. * Remove a specific start size gradient
  17064. * @param gradient defines the gradient to remove
  17065. * @returns the current particle system
  17066. */
  17067. removeStartSizeGradient(gradient: number): IParticleSystem;
  17068. private _createRampGradientTexture;
  17069. /**
  17070. * Gets the current list of ramp gradients.
  17071. * You must use addRampGradient and removeRampGradient to udpate this list
  17072. * @returns the list of ramp gradients
  17073. */
  17074. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17075. /**
  17076. * Adds a new ramp gradient used to remap particle colors
  17077. * @param gradient defines the gradient to use (between 0 and 1)
  17078. * @param color defines the color to affect to the specified gradient
  17079. * @returns the current particle system
  17080. */
  17081. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17082. /**
  17083. * Remove a specific ramp gradient
  17084. * @param gradient defines the gradient to remove
  17085. * @returns the current particle system
  17086. */
  17087. removeRampGradient(gradient: number): ParticleSystem;
  17088. /**
  17089. * Adds a new color gradient
  17090. * @param gradient defines the gradient to use (between 0 and 1)
  17091. * @param color1 defines the color to affect to the specified gradient
  17092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17093. * @returns this particle system
  17094. */
  17095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17096. /**
  17097. * Remove a specific color gradient
  17098. * @param gradient defines the gradient to remove
  17099. * @returns this particle system
  17100. */
  17101. removeColorGradient(gradient: number): IParticleSystem;
  17102. private _fetchR;
  17103. protected _reset(): void;
  17104. private _resetEffect;
  17105. private _createVertexBuffers;
  17106. private _createIndexBuffer;
  17107. /**
  17108. * Gets the maximum number of particles active at the same time.
  17109. * @returns The max number of active particles.
  17110. */
  17111. getCapacity(): number;
  17112. /**
  17113. * Gets whether there are still active particles in the system.
  17114. * @returns True if it is alive, otherwise false.
  17115. */
  17116. isAlive(): boolean;
  17117. /**
  17118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17119. * @returns True if it has been started, otherwise false.
  17120. */
  17121. isStarted(): boolean;
  17122. private _prepareSubEmitterInternalArray;
  17123. /**
  17124. * Starts the particle system and begins to emit
  17125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17126. */
  17127. start(delay?: number): void;
  17128. /**
  17129. * Stops the particle system.
  17130. * @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.
  17131. */
  17132. stop(stopSubEmitters?: boolean): void;
  17133. /**
  17134. * Remove all active particles
  17135. */
  17136. reset(): void;
  17137. /**
  17138. * @hidden (for internal use only)
  17139. */
  17140. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17141. /**
  17142. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17143. * Its lifetime will start back at 0.
  17144. */
  17145. recycleParticle: (particle: Particle) => void;
  17146. private _stopSubEmitters;
  17147. private _createParticle;
  17148. private _removeFromRoot;
  17149. private _emitFromParticle;
  17150. private _update;
  17151. /** @hidden */
  17152. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17153. /** @hidden */
  17154. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17155. /** @hidden */
  17156. private _getEffect;
  17157. /**
  17158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17159. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17160. */
  17161. animate(preWarmOnly?: boolean): void;
  17162. private _appendParticleVertices;
  17163. /**
  17164. * Rebuilds the particle system.
  17165. */
  17166. rebuild(): void;
  17167. /**
  17168. * Is this system ready to be used/rendered
  17169. * @return true if the system is ready
  17170. */
  17171. isReady(): boolean;
  17172. private _render;
  17173. /**
  17174. * Renders the particle system in its current state.
  17175. * @returns the current number of particles
  17176. */
  17177. render(): number;
  17178. /**
  17179. * Disposes the particle system and free the associated resources
  17180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17181. */
  17182. dispose(disposeTexture?: boolean): void;
  17183. /**
  17184. * Clones the particle system.
  17185. * @param name The name of the cloned object
  17186. * @param newEmitter The new emitter to use
  17187. * @returns the cloned particle system
  17188. */
  17189. clone(name: string, newEmitter: any): ParticleSystem;
  17190. /**
  17191. * Serializes the particle system to a JSON object.
  17192. * @returns the JSON object
  17193. */
  17194. serialize(): any;
  17195. /** @hidden */
  17196. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17197. /** @hidden */
  17198. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17199. /**
  17200. * Parses a JSON object to create a particle system.
  17201. * @param parsedParticleSystem The JSON object to parse
  17202. * @param scene The scene to create the particle system in
  17203. * @param rootUrl The root url to use to load external dependencies like texture
  17204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17205. * @returns the Parsed particle system
  17206. */
  17207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17208. }
  17209. }
  17210. declare module BABYLON {
  17211. /**
  17212. * A particle represents one of the element emitted by a particle system.
  17213. * This is mainly define by its coordinates, direction, velocity and age.
  17214. */
  17215. export class Particle {
  17216. /**
  17217. * The particle system the particle belongs to.
  17218. */
  17219. particleSystem: ParticleSystem;
  17220. private static _Count;
  17221. /**
  17222. * Unique ID of the particle
  17223. */
  17224. id: number;
  17225. /**
  17226. * The world position of the particle in the scene.
  17227. */
  17228. position: Vector3;
  17229. /**
  17230. * The world direction of the particle in the scene.
  17231. */
  17232. direction: Vector3;
  17233. /**
  17234. * The color of the particle.
  17235. */
  17236. color: Color4;
  17237. /**
  17238. * The color change of the particle per step.
  17239. */
  17240. colorStep: Color4;
  17241. /**
  17242. * Defines how long will the life of the particle be.
  17243. */
  17244. lifeTime: number;
  17245. /**
  17246. * The current age of the particle.
  17247. */
  17248. age: number;
  17249. /**
  17250. * The current size of the particle.
  17251. */
  17252. size: number;
  17253. /**
  17254. * The current scale of the particle.
  17255. */
  17256. scale: Vector2;
  17257. /**
  17258. * The current angle of the particle.
  17259. */
  17260. angle: number;
  17261. /**
  17262. * Defines how fast is the angle changing.
  17263. */
  17264. angularSpeed: number;
  17265. /**
  17266. * Defines the cell index used by the particle to be rendered from a sprite.
  17267. */
  17268. cellIndex: number;
  17269. /**
  17270. * The information required to support color remapping
  17271. */
  17272. remapData: Vector4;
  17273. /** @hidden */
  17274. _randomCellOffset?: number;
  17275. /** @hidden */
  17276. _initialDirection: Nullable<Vector3>;
  17277. /** @hidden */
  17278. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17279. /** @hidden */
  17280. _initialStartSpriteCellID: number;
  17281. /** @hidden */
  17282. _initialEndSpriteCellID: number;
  17283. /** @hidden */
  17284. _currentColorGradient: Nullable<ColorGradient>;
  17285. /** @hidden */
  17286. _currentColor1: Color4;
  17287. /** @hidden */
  17288. _currentColor2: Color4;
  17289. /** @hidden */
  17290. _currentSizeGradient: Nullable<FactorGradient>;
  17291. /** @hidden */
  17292. _currentSize1: number;
  17293. /** @hidden */
  17294. _currentSize2: number;
  17295. /** @hidden */
  17296. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17297. /** @hidden */
  17298. _currentAngularSpeed1: number;
  17299. /** @hidden */
  17300. _currentAngularSpeed2: number;
  17301. /** @hidden */
  17302. _currentVelocityGradient: Nullable<FactorGradient>;
  17303. /** @hidden */
  17304. _currentVelocity1: number;
  17305. /** @hidden */
  17306. _currentVelocity2: number;
  17307. /** @hidden */
  17308. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17309. /** @hidden */
  17310. _currentLimitVelocity1: number;
  17311. /** @hidden */
  17312. _currentLimitVelocity2: number;
  17313. /** @hidden */
  17314. _currentDragGradient: Nullable<FactorGradient>;
  17315. /** @hidden */
  17316. _currentDrag1: number;
  17317. /** @hidden */
  17318. _currentDrag2: number;
  17319. /** @hidden */
  17320. _randomNoiseCoordinates1: Vector3;
  17321. /** @hidden */
  17322. _randomNoiseCoordinates2: Vector3;
  17323. /**
  17324. * Creates a new instance Particle
  17325. * @param particleSystem the particle system the particle belongs to
  17326. */
  17327. constructor(
  17328. /**
  17329. * The particle system the particle belongs to.
  17330. */
  17331. particleSystem: ParticleSystem);
  17332. private updateCellInfoFromSystem;
  17333. /**
  17334. * Defines how the sprite cell index is updated for the particle
  17335. */
  17336. updateCellIndex(): void;
  17337. /** @hidden */
  17338. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17339. /** @hidden */
  17340. _inheritParticleInfoToSubEmitters(): void;
  17341. /** @hidden */
  17342. _reset(): void;
  17343. /**
  17344. * Copy the properties of particle to another one.
  17345. * @param other the particle to copy the information to.
  17346. */
  17347. copyTo(other: Particle): void;
  17348. }
  17349. }
  17350. declare module BABYLON {
  17351. /**
  17352. * Particle emitter represents a volume emitting particles.
  17353. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17354. */
  17355. export interface IParticleEmitterType {
  17356. /**
  17357. * Called by the particle System when the direction is computed for the created particle.
  17358. * @param worldMatrix is the world matrix of the particle system
  17359. * @param directionToUpdate is the direction vector to update with the result
  17360. * @param particle is the particle we are computed the direction for
  17361. */
  17362. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17363. /**
  17364. * Called by the particle System when the position is computed for the created particle.
  17365. * @param worldMatrix is the world matrix of the particle system
  17366. * @param positionToUpdate is the position vector to update with the result
  17367. * @param particle is the particle we are computed the position for
  17368. */
  17369. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17370. /**
  17371. * Clones the current emitter and returns a copy of it
  17372. * @returns the new emitter
  17373. */
  17374. clone(): IParticleEmitterType;
  17375. /**
  17376. * Called by the GPUParticleSystem to setup the update shader
  17377. * @param effect defines the update shader
  17378. */
  17379. applyToShader(effect: Effect): void;
  17380. /**
  17381. * Returns a string to use to update the GPU particles update shader
  17382. * @returns the effect defines string
  17383. */
  17384. getEffectDefines(): string;
  17385. /**
  17386. * Returns a string representing the class name
  17387. * @returns a string containing the class name
  17388. */
  17389. getClassName(): string;
  17390. /**
  17391. * Serializes the particle system to a JSON object.
  17392. * @returns the JSON object
  17393. */
  17394. serialize(): any;
  17395. /**
  17396. * Parse properties from a JSON object
  17397. * @param serializationObject defines the JSON object
  17398. */
  17399. parse(serializationObject: any): void;
  17400. }
  17401. }
  17402. declare module BABYLON {
  17403. /**
  17404. * Particle emitter emitting particles from the inside of a box.
  17405. * It emits the particles randomly between 2 given directions.
  17406. */
  17407. export class BoxParticleEmitter implements IParticleEmitterType {
  17408. /**
  17409. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17410. */
  17411. direction1: Vector3;
  17412. /**
  17413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17414. */
  17415. direction2: Vector3;
  17416. /**
  17417. * 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.
  17418. */
  17419. minEmitBox: Vector3;
  17420. /**
  17421. * 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.
  17422. */
  17423. maxEmitBox: Vector3;
  17424. /**
  17425. * Creates a new instance BoxParticleEmitter
  17426. */
  17427. constructor();
  17428. /**
  17429. * Called by the particle System when the direction is computed for the created particle.
  17430. * @param worldMatrix is the world matrix of the particle system
  17431. * @param directionToUpdate is the direction vector to update with the result
  17432. * @param particle is the particle we are computed the direction for
  17433. */
  17434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17435. /**
  17436. * Called by the particle System when the position is computed for the created particle.
  17437. * @param worldMatrix is the world matrix of the particle system
  17438. * @param positionToUpdate is the position vector to update with the result
  17439. * @param particle is the particle we are computed the position for
  17440. */
  17441. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17442. /**
  17443. * Clones the current emitter and returns a copy of it
  17444. * @returns the new emitter
  17445. */
  17446. clone(): BoxParticleEmitter;
  17447. /**
  17448. * Called by the GPUParticleSystem to setup the update shader
  17449. * @param effect defines the update shader
  17450. */
  17451. applyToShader(effect: Effect): void;
  17452. /**
  17453. * Returns a string to use to update the GPU particles update shader
  17454. * @returns a string containng the defines string
  17455. */
  17456. getEffectDefines(): string;
  17457. /**
  17458. * Returns the string "BoxParticleEmitter"
  17459. * @returns a string containing the class name
  17460. */
  17461. getClassName(): string;
  17462. /**
  17463. * Serializes the particle system to a JSON object.
  17464. * @returns the JSON object
  17465. */
  17466. serialize(): any;
  17467. /**
  17468. * Parse properties from a JSON object
  17469. * @param serializationObject defines the JSON object
  17470. */
  17471. parse(serializationObject: any): void;
  17472. }
  17473. }
  17474. declare module BABYLON {
  17475. /**
  17476. * Particle emitter emitting particles from the inside of a cone.
  17477. * It emits the particles alongside the cone volume from the base to the particle.
  17478. * The emission direction might be randomized.
  17479. */
  17480. export class ConeParticleEmitter implements IParticleEmitterType {
  17481. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17482. directionRandomizer: number;
  17483. private _radius;
  17484. private _angle;
  17485. private _height;
  17486. /**
  17487. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17488. */
  17489. radiusRange: number;
  17490. /**
  17491. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17492. */
  17493. heightRange: number;
  17494. /**
  17495. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17496. */
  17497. emitFromSpawnPointOnly: boolean;
  17498. /**
  17499. * Gets or sets the radius of the emission cone
  17500. */
  17501. radius: number;
  17502. /**
  17503. * Gets or sets the angle of the emission cone
  17504. */
  17505. angle: number;
  17506. private _buildHeight;
  17507. /**
  17508. * Creates a new instance ConeParticleEmitter
  17509. * @param radius the radius of the emission cone (1 by default)
  17510. * @param angle the cone base angle (PI by default)
  17511. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17512. */
  17513. constructor(radius?: number, angle?: number,
  17514. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17515. directionRandomizer?: number);
  17516. /**
  17517. * Called by the particle System when the direction is computed for the created particle.
  17518. * @param worldMatrix is the world matrix of the particle system
  17519. * @param directionToUpdate is the direction vector to update with the result
  17520. * @param particle is the particle we are computed the direction for
  17521. */
  17522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17523. /**
  17524. * Called by the particle System when the position is computed for the created particle.
  17525. * @param worldMatrix is the world matrix of the particle system
  17526. * @param positionToUpdate is the position vector to update with the result
  17527. * @param particle is the particle we are computed the position for
  17528. */
  17529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17530. /**
  17531. * Clones the current emitter and returns a copy of it
  17532. * @returns the new emitter
  17533. */
  17534. clone(): ConeParticleEmitter;
  17535. /**
  17536. * Called by the GPUParticleSystem to setup the update shader
  17537. * @param effect defines the update shader
  17538. */
  17539. applyToShader(effect: Effect): void;
  17540. /**
  17541. * Returns a string to use to update the GPU particles update shader
  17542. * @returns a string containng the defines string
  17543. */
  17544. getEffectDefines(): string;
  17545. /**
  17546. * Returns the string "ConeParticleEmitter"
  17547. * @returns a string containing the class name
  17548. */
  17549. getClassName(): string;
  17550. /**
  17551. * Serializes the particle system to a JSON object.
  17552. * @returns the JSON object
  17553. */
  17554. serialize(): any;
  17555. /**
  17556. * Parse properties from a JSON object
  17557. * @param serializationObject defines the JSON object
  17558. */
  17559. parse(serializationObject: any): void;
  17560. }
  17561. }
  17562. declare module BABYLON {
  17563. /**
  17564. * Particle emitter emitting particles from the inside of a cylinder.
  17565. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17566. */
  17567. export class CylinderParticleEmitter implements IParticleEmitterType {
  17568. /**
  17569. * The radius of the emission cylinder.
  17570. */
  17571. radius: number;
  17572. /**
  17573. * The height of the emission cylinder.
  17574. */
  17575. height: number;
  17576. /**
  17577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17578. */
  17579. radiusRange: number;
  17580. /**
  17581. * How much to randomize the particle direction [0-1].
  17582. */
  17583. directionRandomizer: number;
  17584. /**
  17585. * Creates a new instance CylinderParticleEmitter
  17586. * @param radius the radius of the emission cylinder (1 by default)
  17587. * @param height the height of the emission cylinder (1 by default)
  17588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17589. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17590. */
  17591. constructor(
  17592. /**
  17593. * The radius of the emission cylinder.
  17594. */
  17595. radius?: number,
  17596. /**
  17597. * The height of the emission cylinder.
  17598. */
  17599. height?: number,
  17600. /**
  17601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17602. */
  17603. radiusRange?: number,
  17604. /**
  17605. * How much to randomize the particle direction [0-1].
  17606. */
  17607. directionRandomizer?: number);
  17608. /**
  17609. * Called by the particle System when the direction is computed for the created particle.
  17610. * @param worldMatrix is the world matrix of the particle system
  17611. * @param directionToUpdate is the direction vector to update with the result
  17612. * @param particle is the particle we are computed the direction for
  17613. */
  17614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17615. /**
  17616. * Called by the particle System when the position is computed for the created particle.
  17617. * @param worldMatrix is the world matrix of the particle system
  17618. * @param positionToUpdate is the position vector to update with the result
  17619. * @param particle is the particle we are computed the position for
  17620. */
  17621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17622. /**
  17623. * Clones the current emitter and returns a copy of it
  17624. * @returns the new emitter
  17625. */
  17626. clone(): CylinderParticleEmitter;
  17627. /**
  17628. * Called by the GPUParticleSystem to setup the update shader
  17629. * @param effect defines the update shader
  17630. */
  17631. applyToShader(effect: Effect): void;
  17632. /**
  17633. * Returns a string to use to update the GPU particles update shader
  17634. * @returns a string containng the defines string
  17635. */
  17636. getEffectDefines(): string;
  17637. /**
  17638. * Returns the string "CylinderParticleEmitter"
  17639. * @returns a string containing the class name
  17640. */
  17641. getClassName(): string;
  17642. /**
  17643. * Serializes the particle system to a JSON object.
  17644. * @returns the JSON object
  17645. */
  17646. serialize(): any;
  17647. /**
  17648. * Parse properties from a JSON object
  17649. * @param serializationObject defines the JSON object
  17650. */
  17651. parse(serializationObject: any): void;
  17652. }
  17653. /**
  17654. * Particle emitter emitting particles from the inside of a cylinder.
  17655. * It emits the particles randomly between two vectors.
  17656. */
  17657. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17658. /**
  17659. * The min limit of the emission direction.
  17660. */
  17661. direction1: Vector3;
  17662. /**
  17663. * The max limit of the emission direction.
  17664. */
  17665. direction2: Vector3;
  17666. /**
  17667. * Creates a new instance CylinderDirectedParticleEmitter
  17668. * @param radius the radius of the emission cylinder (1 by default)
  17669. * @param height the height of the emission cylinder (1 by default)
  17670. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17671. * @param direction1 the min limit of the emission direction (up vector by default)
  17672. * @param direction2 the max limit of the emission direction (up vector by default)
  17673. */
  17674. constructor(radius?: number, height?: number, radiusRange?: number,
  17675. /**
  17676. * The min limit of the emission direction.
  17677. */
  17678. direction1?: Vector3,
  17679. /**
  17680. * The max limit of the emission direction.
  17681. */
  17682. direction2?: Vector3);
  17683. /**
  17684. * Called by the particle System when the direction is computed for the created particle.
  17685. * @param worldMatrix is the world matrix of the particle system
  17686. * @param directionToUpdate is the direction vector to update with the result
  17687. * @param particle is the particle we are computed the direction for
  17688. */
  17689. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17690. /**
  17691. * Clones the current emitter and returns a copy of it
  17692. * @returns the new emitter
  17693. */
  17694. clone(): CylinderDirectedParticleEmitter;
  17695. /**
  17696. * Called by the GPUParticleSystem to setup the update shader
  17697. * @param effect defines the update shader
  17698. */
  17699. applyToShader(effect: Effect): void;
  17700. /**
  17701. * Returns a string to use to update the GPU particles update shader
  17702. * @returns a string containng the defines string
  17703. */
  17704. getEffectDefines(): string;
  17705. /**
  17706. * Returns the string "CylinderDirectedParticleEmitter"
  17707. * @returns a string containing the class name
  17708. */
  17709. getClassName(): string;
  17710. /**
  17711. * Serializes the particle system to a JSON object.
  17712. * @returns the JSON object
  17713. */
  17714. serialize(): any;
  17715. /**
  17716. * Parse properties from a JSON object
  17717. * @param serializationObject defines the JSON object
  17718. */
  17719. parse(serializationObject: any): void;
  17720. }
  17721. }
  17722. declare module BABYLON {
  17723. /**
  17724. * Particle emitter emitting particles from the inside of a hemisphere.
  17725. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17726. */
  17727. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17728. /**
  17729. * The radius of the emission hemisphere.
  17730. */
  17731. radius: number;
  17732. /**
  17733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17734. */
  17735. radiusRange: number;
  17736. /**
  17737. * How much to randomize the particle direction [0-1].
  17738. */
  17739. directionRandomizer: number;
  17740. /**
  17741. * Creates a new instance HemisphericParticleEmitter
  17742. * @param radius the radius of the emission hemisphere (1 by default)
  17743. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17745. */
  17746. constructor(
  17747. /**
  17748. * The radius of the emission hemisphere.
  17749. */
  17750. radius?: number,
  17751. /**
  17752. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17753. */
  17754. radiusRange?: number,
  17755. /**
  17756. * How much to randomize the particle direction [0-1].
  17757. */
  17758. directionRandomizer?: number);
  17759. /**
  17760. * Called by the particle System when the direction is computed for the created particle.
  17761. * @param worldMatrix is the world matrix of the particle system
  17762. * @param directionToUpdate is the direction vector to update with the result
  17763. * @param particle is the particle we are computed the direction for
  17764. */
  17765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17766. /**
  17767. * Called by the particle System when the position is computed for the created particle.
  17768. * @param worldMatrix is the world matrix of the particle system
  17769. * @param positionToUpdate is the position vector to update with the result
  17770. * @param particle is the particle we are computed the position for
  17771. */
  17772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17773. /**
  17774. * Clones the current emitter and returns a copy of it
  17775. * @returns the new emitter
  17776. */
  17777. clone(): HemisphericParticleEmitter;
  17778. /**
  17779. * Called by the GPUParticleSystem to setup the update shader
  17780. * @param effect defines the update shader
  17781. */
  17782. applyToShader(effect: Effect): void;
  17783. /**
  17784. * Returns a string to use to update the GPU particles update shader
  17785. * @returns a string containng the defines string
  17786. */
  17787. getEffectDefines(): string;
  17788. /**
  17789. * Returns the string "HemisphericParticleEmitter"
  17790. * @returns a string containing the class name
  17791. */
  17792. getClassName(): string;
  17793. /**
  17794. * Serializes the particle system to a JSON object.
  17795. * @returns the JSON object
  17796. */
  17797. serialize(): any;
  17798. /**
  17799. * Parse properties from a JSON object
  17800. * @param serializationObject defines the JSON object
  17801. */
  17802. parse(serializationObject: any): void;
  17803. }
  17804. }
  17805. declare module BABYLON {
  17806. /**
  17807. * Particle emitter emitting particles from a point.
  17808. * It emits the particles randomly between 2 given directions.
  17809. */
  17810. export class PointParticleEmitter implements IParticleEmitterType {
  17811. /**
  17812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17813. */
  17814. direction1: Vector3;
  17815. /**
  17816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17817. */
  17818. direction2: Vector3;
  17819. /**
  17820. * Creates a new instance PointParticleEmitter
  17821. */
  17822. constructor();
  17823. /**
  17824. * Called by the particle System when the direction is computed for the created particle.
  17825. * @param worldMatrix is the world matrix of the particle system
  17826. * @param directionToUpdate is the direction vector to update with the result
  17827. * @param particle is the particle we are computed the direction for
  17828. */
  17829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17830. /**
  17831. * Called by the particle System when the position is computed for the created particle.
  17832. * @param worldMatrix is the world matrix of the particle system
  17833. * @param positionToUpdate is the position vector to update with the result
  17834. * @param particle is the particle we are computed the position for
  17835. */
  17836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17837. /**
  17838. * Clones the current emitter and returns a copy of it
  17839. * @returns the new emitter
  17840. */
  17841. clone(): PointParticleEmitter;
  17842. /**
  17843. * Called by the GPUParticleSystem to setup the update shader
  17844. * @param effect defines the update shader
  17845. */
  17846. applyToShader(effect: Effect): void;
  17847. /**
  17848. * Returns a string to use to update the GPU particles update shader
  17849. * @returns a string containng the defines string
  17850. */
  17851. getEffectDefines(): string;
  17852. /**
  17853. * Returns the string "PointParticleEmitter"
  17854. * @returns a string containing the class name
  17855. */
  17856. getClassName(): string;
  17857. /**
  17858. * Serializes the particle system to a JSON object.
  17859. * @returns the JSON object
  17860. */
  17861. serialize(): any;
  17862. /**
  17863. * Parse properties from a JSON object
  17864. * @param serializationObject defines the JSON object
  17865. */
  17866. parse(serializationObject: any): void;
  17867. }
  17868. }
  17869. declare module BABYLON {
  17870. /**
  17871. * Particle emitter emitting particles from the inside of a sphere.
  17872. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17873. */
  17874. export class SphereParticleEmitter implements IParticleEmitterType {
  17875. /**
  17876. * The radius of the emission sphere.
  17877. */
  17878. radius: number;
  17879. /**
  17880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17881. */
  17882. radiusRange: number;
  17883. /**
  17884. * How much to randomize the particle direction [0-1].
  17885. */
  17886. directionRandomizer: number;
  17887. /**
  17888. * Creates a new instance SphereParticleEmitter
  17889. * @param radius the radius of the emission sphere (1 by default)
  17890. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17891. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17892. */
  17893. constructor(
  17894. /**
  17895. * The radius of the emission sphere.
  17896. */
  17897. radius?: number,
  17898. /**
  17899. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17900. */
  17901. radiusRange?: number,
  17902. /**
  17903. * How much to randomize the particle direction [0-1].
  17904. */
  17905. directionRandomizer?: number);
  17906. /**
  17907. * Called by the particle System when the direction is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param directionToUpdate is the direction vector to update with the result
  17910. * @param particle is the particle we are computed the direction for
  17911. */
  17912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Called by the particle System when the position is computed for the created particle.
  17915. * @param worldMatrix is the world matrix of the particle system
  17916. * @param positionToUpdate is the position vector to update with the result
  17917. * @param particle is the particle we are computed the position for
  17918. */
  17919. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17920. /**
  17921. * Clones the current emitter and returns a copy of it
  17922. * @returns the new emitter
  17923. */
  17924. clone(): SphereParticleEmitter;
  17925. /**
  17926. * Called by the GPUParticleSystem to setup the update shader
  17927. * @param effect defines the update shader
  17928. */
  17929. applyToShader(effect: Effect): void;
  17930. /**
  17931. * Returns a string to use to update the GPU particles update shader
  17932. * @returns a string containng the defines string
  17933. */
  17934. getEffectDefines(): string;
  17935. /**
  17936. * Returns the string "SphereParticleEmitter"
  17937. * @returns a string containing the class name
  17938. */
  17939. getClassName(): string;
  17940. /**
  17941. * Serializes the particle system to a JSON object.
  17942. * @returns the JSON object
  17943. */
  17944. serialize(): any;
  17945. /**
  17946. * Parse properties from a JSON object
  17947. * @param serializationObject defines the JSON object
  17948. */
  17949. parse(serializationObject: any): void;
  17950. }
  17951. /**
  17952. * Particle emitter emitting particles from the inside of a sphere.
  17953. * It emits the particles randomly between two vectors.
  17954. */
  17955. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17956. /**
  17957. * The min limit of the emission direction.
  17958. */
  17959. direction1: Vector3;
  17960. /**
  17961. * The max limit of the emission direction.
  17962. */
  17963. direction2: Vector3;
  17964. /**
  17965. * Creates a new instance SphereDirectedParticleEmitter
  17966. * @param radius the radius of the emission sphere (1 by default)
  17967. * @param direction1 the min limit of the emission direction (up vector by default)
  17968. * @param direction2 the max limit of the emission direction (up vector by default)
  17969. */
  17970. constructor(radius?: number,
  17971. /**
  17972. * The min limit of the emission direction.
  17973. */
  17974. direction1?: Vector3,
  17975. /**
  17976. * The max limit of the emission direction.
  17977. */
  17978. direction2?: Vector3);
  17979. /**
  17980. * Called by the particle System when the direction is computed for the created particle.
  17981. * @param worldMatrix is the world matrix of the particle system
  17982. * @param directionToUpdate is the direction vector to update with the result
  17983. * @param particle is the particle we are computed the direction for
  17984. */
  17985. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17986. /**
  17987. * Clones the current emitter and returns a copy of it
  17988. * @returns the new emitter
  17989. */
  17990. clone(): SphereDirectedParticleEmitter;
  17991. /**
  17992. * Called by the GPUParticleSystem to setup the update shader
  17993. * @param effect defines the update shader
  17994. */
  17995. applyToShader(effect: Effect): void;
  17996. /**
  17997. * Returns a string to use to update the GPU particles update shader
  17998. * @returns a string containng the defines string
  17999. */
  18000. getEffectDefines(): string;
  18001. /**
  18002. * Returns the string "SphereDirectedParticleEmitter"
  18003. * @returns a string containing the class name
  18004. */
  18005. getClassName(): string;
  18006. /**
  18007. * Serializes the particle system to a JSON object.
  18008. * @returns the JSON object
  18009. */
  18010. serialize(): any;
  18011. /**
  18012. * Parse properties from a JSON object
  18013. * @param serializationObject defines the JSON object
  18014. */
  18015. parse(serializationObject: any): void;
  18016. }
  18017. }
  18018. declare module BABYLON {
  18019. /**
  18020. * Interface representing a particle system in Babylon.js.
  18021. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18022. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18023. */
  18024. export interface IParticleSystem {
  18025. /**
  18026. * List of animations used by the particle system.
  18027. */
  18028. animations: Animation[];
  18029. /**
  18030. * The id of the Particle system.
  18031. */
  18032. id: string;
  18033. /**
  18034. * The name of the Particle system.
  18035. */
  18036. name: string;
  18037. /**
  18038. * The emitter represents the Mesh or position we are attaching the particle system to.
  18039. */
  18040. emitter: Nullable<AbstractMesh | Vector3>;
  18041. /**
  18042. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18043. */
  18044. isBillboardBased: boolean;
  18045. /**
  18046. * The rendering group used by the Particle system to chose when to render.
  18047. */
  18048. renderingGroupId: number;
  18049. /**
  18050. * The layer mask we are rendering the particles through.
  18051. */
  18052. layerMask: number;
  18053. /**
  18054. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18055. */
  18056. updateSpeed: number;
  18057. /**
  18058. * The amount of time the particle system is running (depends of the overall update speed).
  18059. */
  18060. targetStopDuration: number;
  18061. /**
  18062. * The texture used to render each particle. (this can be a spritesheet)
  18063. */
  18064. particleTexture: Nullable<Texture>;
  18065. /**
  18066. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18067. */
  18068. blendMode: number;
  18069. /**
  18070. * Minimum life time of emitting particles.
  18071. */
  18072. minLifeTime: number;
  18073. /**
  18074. * Maximum life time of emitting particles.
  18075. */
  18076. maxLifeTime: number;
  18077. /**
  18078. * Minimum Size of emitting particles.
  18079. */
  18080. minSize: number;
  18081. /**
  18082. * Maximum Size of emitting particles.
  18083. */
  18084. maxSize: number;
  18085. /**
  18086. * Minimum scale of emitting particles on X axis.
  18087. */
  18088. minScaleX: number;
  18089. /**
  18090. * Maximum scale of emitting particles on X axis.
  18091. */
  18092. maxScaleX: number;
  18093. /**
  18094. * Minimum scale of emitting particles on Y axis.
  18095. */
  18096. minScaleY: number;
  18097. /**
  18098. * Maximum scale of emitting particles on Y axis.
  18099. */
  18100. maxScaleY: number;
  18101. /**
  18102. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18103. */
  18104. color1: Color4;
  18105. /**
  18106. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18107. */
  18108. color2: Color4;
  18109. /**
  18110. * Color the particle will have at the end of its lifetime.
  18111. */
  18112. colorDead: Color4;
  18113. /**
  18114. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18115. */
  18116. emitRate: number;
  18117. /**
  18118. * You can use gravity if you want to give an orientation to your particles.
  18119. */
  18120. gravity: Vector3;
  18121. /**
  18122. * Minimum power of emitting particles.
  18123. */
  18124. minEmitPower: number;
  18125. /**
  18126. * Maximum power of emitting particles.
  18127. */
  18128. maxEmitPower: number;
  18129. /**
  18130. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18131. */
  18132. minAngularSpeed: number;
  18133. /**
  18134. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18135. */
  18136. maxAngularSpeed: number;
  18137. /**
  18138. * Gets or sets the minimal initial rotation in radians.
  18139. */
  18140. minInitialRotation: number;
  18141. /**
  18142. * Gets or sets the maximal initial rotation in radians.
  18143. */
  18144. maxInitialRotation: number;
  18145. /**
  18146. * The particle emitter type defines the emitter used by the particle system.
  18147. * It can be for example box, sphere, or cone...
  18148. */
  18149. particleEmitterType: Nullable<IParticleEmitterType>;
  18150. /**
  18151. * Defines the delay in milliseconds before starting the system (0 by default)
  18152. */
  18153. startDelay: number;
  18154. /**
  18155. * 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
  18156. */
  18157. preWarmCycles: number;
  18158. /**
  18159. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18160. */
  18161. preWarmStepOffset: number;
  18162. /**
  18163. * 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)
  18164. */
  18165. spriteCellChangeSpeed: number;
  18166. /**
  18167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18168. */
  18169. startSpriteCellID: number;
  18170. /**
  18171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18172. */
  18173. endSpriteCellID: number;
  18174. /**
  18175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18176. */
  18177. spriteCellWidth: number;
  18178. /**
  18179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18180. */
  18181. spriteCellHeight: number;
  18182. /**
  18183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18184. */
  18185. spriteRandomStartCell: boolean;
  18186. /**
  18187. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18188. */
  18189. isAnimationSheetEnabled: boolean;
  18190. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18191. translationPivot: Vector2;
  18192. /**
  18193. * Gets or sets a texture used to add random noise to particle positions
  18194. */
  18195. noiseTexture: Nullable<BaseTexture>;
  18196. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18197. noiseStrength: Vector3;
  18198. /**
  18199. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18200. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18201. */
  18202. billboardMode: number;
  18203. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18204. limitVelocityDamping: number;
  18205. /**
  18206. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18207. */
  18208. beginAnimationOnStart: boolean;
  18209. /**
  18210. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18211. */
  18212. beginAnimationFrom: number;
  18213. /**
  18214. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18215. */
  18216. beginAnimationTo: number;
  18217. /**
  18218. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18219. */
  18220. beginAnimationLoop: boolean;
  18221. /**
  18222. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18223. */
  18224. disposeOnStop: boolean;
  18225. /**
  18226. * Gets the maximum number of particles active at the same time.
  18227. * @returns The max number of active particles.
  18228. */
  18229. getCapacity(): number;
  18230. /**
  18231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18232. * @returns True if it has been started, otherwise false.
  18233. */
  18234. isStarted(): boolean;
  18235. /**
  18236. * Animates the particle system for this frame.
  18237. */
  18238. animate(): void;
  18239. /**
  18240. * Renders the particle system in its current state.
  18241. * @returns the current number of particles
  18242. */
  18243. render(): number;
  18244. /**
  18245. * Dispose the particle system and frees its associated resources.
  18246. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18247. */
  18248. dispose(disposeTexture?: boolean): void;
  18249. /**
  18250. * Clones the particle system.
  18251. * @param name The name of the cloned object
  18252. * @param newEmitter The new emitter to use
  18253. * @returns the cloned particle system
  18254. */
  18255. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18256. /**
  18257. * Serializes the particle system to a JSON object.
  18258. * @returns the JSON object
  18259. */
  18260. serialize(): any;
  18261. /**
  18262. * Rebuild the particle system
  18263. */
  18264. rebuild(): void;
  18265. /**
  18266. * Starts the particle system and begins to emit
  18267. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18268. */
  18269. start(delay?: number): void;
  18270. /**
  18271. * Stops the particle system.
  18272. */
  18273. stop(): void;
  18274. /**
  18275. * Remove all active particles
  18276. */
  18277. reset(): void;
  18278. /**
  18279. * Is this system ready to be used/rendered
  18280. * @return true if the system is ready
  18281. */
  18282. isReady(): boolean;
  18283. /**
  18284. * Adds a new color gradient
  18285. * @param gradient defines the gradient to use (between 0 and 1)
  18286. * @param color1 defines the color to affect to the specified gradient
  18287. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18288. * @returns the current particle system
  18289. */
  18290. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18291. /**
  18292. * Remove a specific color gradient
  18293. * @param gradient defines the gradient to remove
  18294. * @returns the current particle system
  18295. */
  18296. removeColorGradient(gradient: number): IParticleSystem;
  18297. /**
  18298. * Adds a new size gradient
  18299. * @param gradient defines the gradient to use (between 0 and 1)
  18300. * @param factor defines the size factor to affect to the specified gradient
  18301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18302. * @returns the current particle system
  18303. */
  18304. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18305. /**
  18306. * Remove a specific size gradient
  18307. * @param gradient defines the gradient to remove
  18308. * @returns the current particle system
  18309. */
  18310. removeSizeGradient(gradient: number): IParticleSystem;
  18311. /**
  18312. * Gets the current list of color gradients.
  18313. * You must use addColorGradient and removeColorGradient to udpate this list
  18314. * @returns the list of color gradients
  18315. */
  18316. getColorGradients(): Nullable<Array<ColorGradient>>;
  18317. /**
  18318. * Gets the current list of size gradients.
  18319. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18320. * @returns the list of size gradients
  18321. */
  18322. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18323. /**
  18324. * Gets the current list of angular speed gradients.
  18325. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18326. * @returns the list of angular speed gradients
  18327. */
  18328. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18329. /**
  18330. * Adds a new angular speed gradient
  18331. * @param gradient defines the gradient to use (between 0 and 1)
  18332. * @param factor defines the angular speed to affect to the specified gradient
  18333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18334. * @returns the current particle system
  18335. */
  18336. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18337. /**
  18338. * Remove a specific angular speed gradient
  18339. * @param gradient defines the gradient to remove
  18340. * @returns the current particle system
  18341. */
  18342. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18343. /**
  18344. * Gets the current list of velocity gradients.
  18345. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18346. * @returns the list of velocity gradients
  18347. */
  18348. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18349. /**
  18350. * Adds a new velocity gradient
  18351. * @param gradient defines the gradient to use (between 0 and 1)
  18352. * @param factor defines the velocity to affect to the specified gradient
  18353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18354. * @returns the current particle system
  18355. */
  18356. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18357. /**
  18358. * Remove a specific velocity gradient
  18359. * @param gradient defines the gradient to remove
  18360. * @returns the current particle system
  18361. */
  18362. removeVelocityGradient(gradient: number): IParticleSystem;
  18363. /**
  18364. * Gets the current list of limit velocity gradients.
  18365. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18366. * @returns the list of limit velocity gradients
  18367. */
  18368. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18369. /**
  18370. * Adds a new limit velocity gradient
  18371. * @param gradient defines the gradient to use (between 0 and 1)
  18372. * @param factor defines the limit velocity to affect to the specified gradient
  18373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18374. * @returns the current particle system
  18375. */
  18376. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18377. /**
  18378. * Remove a specific limit velocity gradient
  18379. * @param gradient defines the gradient to remove
  18380. * @returns the current particle system
  18381. */
  18382. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18383. /**
  18384. * Adds a new drag gradient
  18385. * @param gradient defines the gradient to use (between 0 and 1)
  18386. * @param factor defines the drag to affect to the specified gradient
  18387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18388. * @returns the current particle system
  18389. */
  18390. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18391. /**
  18392. * Remove a specific drag gradient
  18393. * @param gradient defines the gradient to remove
  18394. * @returns the current particle system
  18395. */
  18396. removeDragGradient(gradient: number): IParticleSystem;
  18397. /**
  18398. * Gets the current list of drag gradients.
  18399. * You must use addDragGradient and removeDragGradient to udpate this list
  18400. * @returns the list of drag gradients
  18401. */
  18402. getDragGradients(): Nullable<Array<FactorGradient>>;
  18403. /**
  18404. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18405. * @param gradient defines the gradient to use (between 0 and 1)
  18406. * @param factor defines the emit rate to affect to the specified gradient
  18407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18408. * @returns the current particle system
  18409. */
  18410. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18411. /**
  18412. * Remove a specific emit rate gradient
  18413. * @param gradient defines the gradient to remove
  18414. * @returns the current particle system
  18415. */
  18416. removeEmitRateGradient(gradient: number): IParticleSystem;
  18417. /**
  18418. * Gets the current list of emit rate gradients.
  18419. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18420. * @returns the list of emit rate gradients
  18421. */
  18422. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18423. /**
  18424. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18425. * @param gradient defines the gradient to use (between 0 and 1)
  18426. * @param factor defines the start size to affect to the specified gradient
  18427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18428. * @returns the current particle system
  18429. */
  18430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18431. /**
  18432. * Remove a specific start size gradient
  18433. * @param gradient defines the gradient to remove
  18434. * @returns the current particle system
  18435. */
  18436. removeStartSizeGradient(gradient: number): IParticleSystem;
  18437. /**
  18438. * Gets the current list of start size gradients.
  18439. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18440. * @returns the list of start size gradients
  18441. */
  18442. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18443. /**
  18444. * Adds a new life time gradient
  18445. * @param gradient defines the gradient to use (between 0 and 1)
  18446. * @param factor defines the life time factor to affect to the specified gradient
  18447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18448. * @returns the current particle system
  18449. */
  18450. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18451. /**
  18452. * Remove a specific life time gradient
  18453. * @param gradient defines the gradient to remove
  18454. * @returns the current particle system
  18455. */
  18456. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18457. /**
  18458. * Gets the current list of life time gradients.
  18459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18460. * @returns the list of life time gradients
  18461. */
  18462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18463. /**
  18464. * Gets the current list of color gradients.
  18465. * You must use addColorGradient and removeColorGradient to udpate this list
  18466. * @returns the list of color gradients
  18467. */
  18468. getColorGradients(): Nullable<Array<ColorGradient>>;
  18469. /**
  18470. * Adds a new ramp gradient used to remap particle colors
  18471. * @param gradient defines the gradient to use (between 0 and 1)
  18472. * @param color defines the color to affect to the specified gradient
  18473. * @returns the current particle system
  18474. */
  18475. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18476. /**
  18477. * Gets the current list of ramp gradients.
  18478. * You must use addRampGradient and removeRampGradient to udpate this list
  18479. * @returns the list of ramp gradients
  18480. */
  18481. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18482. /** Gets or sets a boolean indicating that ramp gradients must be used
  18483. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18484. */
  18485. useRampGradients: boolean;
  18486. /**
  18487. * Adds a new color remap gradient
  18488. * @param gradient defines the gradient to use (between 0 and 1)
  18489. * @param min defines the color remap minimal range
  18490. * @param max defines the color remap maximal range
  18491. * @returns the current particle system
  18492. */
  18493. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18494. /**
  18495. * Gets the current list of color remap gradients.
  18496. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18497. * @returns the list of color remap gradients
  18498. */
  18499. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18500. /**
  18501. * Adds a new alpha remap gradient
  18502. * @param gradient defines the gradient to use (between 0 and 1)
  18503. * @param min defines the alpha remap minimal range
  18504. * @param max defines the alpha remap maximal range
  18505. * @returns the current particle system
  18506. */
  18507. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18508. /**
  18509. * Gets the current list of alpha remap gradients.
  18510. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18511. * @returns the list of alpha remap gradients
  18512. */
  18513. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18514. /**
  18515. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18518. * @returns the emitter
  18519. */
  18520. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18521. /**
  18522. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18523. * @param radius The radius of the hemisphere to emit from
  18524. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18525. * @returns the emitter
  18526. */
  18527. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18528. /**
  18529. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18530. * @param radius The radius of the sphere to emit from
  18531. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18532. * @returns the emitter
  18533. */
  18534. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18535. /**
  18536. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18537. * @param radius The radius of the sphere to emit from
  18538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18540. * @returns the emitter
  18541. */
  18542. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18543. /**
  18544. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18545. * @param radius The radius of the emission cylinder
  18546. * @param height The height of the emission cylinder
  18547. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18548. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18549. * @returns the emitter
  18550. */
  18551. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18552. /**
  18553. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18554. * @param radius The radius of the cylinder to emit from
  18555. * @param height The height of the emission cylinder
  18556. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18559. * @returns the emitter
  18560. */
  18561. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18562. /**
  18563. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18564. * @param radius The radius of the cone to emit from
  18565. * @param angle The base angle of the cone
  18566. * @returns the emitter
  18567. */
  18568. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18569. /**
  18570. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18573. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18574. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18575. * @returns the emitter
  18576. */
  18577. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18578. /**
  18579. * Get hosting scene
  18580. * @returns the scene
  18581. */
  18582. getScene(): Scene;
  18583. }
  18584. }
  18585. declare module BABYLON {
  18586. /**
  18587. * Creates an instance based on a source mesh.
  18588. */
  18589. export class InstancedMesh extends AbstractMesh {
  18590. private _sourceMesh;
  18591. private _currentLOD;
  18592. /** @hidden */
  18593. _indexInSourceMeshInstanceArray: number;
  18594. constructor(name: string, source: Mesh);
  18595. /**
  18596. * Returns the string "InstancedMesh".
  18597. */
  18598. getClassName(): string;
  18599. /** Gets the list of lights affecting that mesh */
  18600. readonly lightSources: Light[];
  18601. _resyncLightSources(): void;
  18602. _resyncLighSource(light: Light): void;
  18603. _removeLightSource(light: Light, dispose: boolean): void;
  18604. /**
  18605. * If the source mesh receives shadows
  18606. */
  18607. readonly receiveShadows: boolean;
  18608. /**
  18609. * The material of the source mesh
  18610. */
  18611. readonly material: Nullable<Material>;
  18612. /**
  18613. * Visibility of the source mesh
  18614. */
  18615. readonly visibility: number;
  18616. /**
  18617. * Skeleton of the source mesh
  18618. */
  18619. readonly skeleton: Nullable<Skeleton>;
  18620. /**
  18621. * Rendering ground id of the source mesh
  18622. */
  18623. renderingGroupId: number;
  18624. /**
  18625. * Returns the total number of vertices (integer).
  18626. */
  18627. getTotalVertices(): number;
  18628. /**
  18629. * Returns a positive integer : the total number of indices in this mesh geometry.
  18630. * @returns the numner of indices or zero if the mesh has no geometry.
  18631. */
  18632. getTotalIndices(): number;
  18633. /**
  18634. * The source mesh of the instance
  18635. */
  18636. readonly sourceMesh: Mesh;
  18637. /**
  18638. * Is this node ready to be used/rendered
  18639. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18640. * @return {boolean} is it ready
  18641. */
  18642. isReady(completeCheck?: boolean): boolean;
  18643. /**
  18644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18645. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18646. * @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.
  18647. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18648. */
  18649. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18650. /**
  18651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18653. * The `data` are either a numeric array either a Float32Array.
  18654. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18655. * 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).
  18656. * Note that a new underlying VertexBuffer object is created each call.
  18657. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18658. *
  18659. * Possible `kind` values :
  18660. * - VertexBuffer.PositionKind
  18661. * - VertexBuffer.UVKind
  18662. * - VertexBuffer.UV2Kind
  18663. * - VertexBuffer.UV3Kind
  18664. * - VertexBuffer.UV4Kind
  18665. * - VertexBuffer.UV5Kind
  18666. * - VertexBuffer.UV6Kind
  18667. * - VertexBuffer.ColorKind
  18668. * - VertexBuffer.MatricesIndicesKind
  18669. * - VertexBuffer.MatricesIndicesExtraKind
  18670. * - VertexBuffer.MatricesWeightsKind
  18671. * - VertexBuffer.MatricesWeightsExtraKind
  18672. *
  18673. * Returns the Mesh.
  18674. */
  18675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18676. /**
  18677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18678. * If the mesh has no geometry, it is simply returned as it is.
  18679. * The `data` are either a numeric array either a Float32Array.
  18680. * No new underlying VertexBuffer object is created.
  18681. * 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.
  18682. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18683. *
  18684. * Possible `kind` values :
  18685. * - VertexBuffer.PositionKind
  18686. * - VertexBuffer.UVKind
  18687. * - VertexBuffer.UV2Kind
  18688. * - VertexBuffer.UV3Kind
  18689. * - VertexBuffer.UV4Kind
  18690. * - VertexBuffer.UV5Kind
  18691. * - VertexBuffer.UV6Kind
  18692. * - VertexBuffer.ColorKind
  18693. * - VertexBuffer.MatricesIndicesKind
  18694. * - VertexBuffer.MatricesIndicesExtraKind
  18695. * - VertexBuffer.MatricesWeightsKind
  18696. * - VertexBuffer.MatricesWeightsExtraKind
  18697. *
  18698. * Returns the Mesh.
  18699. */
  18700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18701. /**
  18702. * Sets the mesh indices.
  18703. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18704. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18705. * This method creates a new index buffer each call.
  18706. * Returns the Mesh.
  18707. */
  18708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18709. /**
  18710. * Boolean : True if the mesh owns the requested kind of data.
  18711. */
  18712. isVerticesDataPresent(kind: string): boolean;
  18713. /**
  18714. * Returns an array of indices (IndicesArray).
  18715. */
  18716. getIndices(): Nullable<IndicesArray>;
  18717. readonly _positions: Nullable<Vector3[]>;
  18718. /**
  18719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18720. * This means the mesh underlying bounding box and sphere are recomputed.
  18721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18722. * @returns the current mesh
  18723. */
  18724. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18725. /** @hidden */
  18726. _preActivate(): InstancedMesh;
  18727. /** @hidden */
  18728. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18729. /** @hidden */
  18730. _postActivate(): void;
  18731. getWorldMatrix(): Matrix;
  18732. readonly isAnInstance: boolean;
  18733. /**
  18734. * Returns the current associated LOD AbstractMesh.
  18735. */
  18736. getLOD(camera: Camera): AbstractMesh;
  18737. /** @hidden */
  18738. _syncSubMeshes(): InstancedMesh;
  18739. /** @hidden */
  18740. _generatePointsArray(): boolean;
  18741. /**
  18742. * Creates a new InstancedMesh from the current mesh.
  18743. * - name (string) : the cloned mesh name
  18744. * - newParent (optional Node) : the optional Node to parent the clone to.
  18745. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18746. *
  18747. * Returns the clone.
  18748. */
  18749. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18750. /**
  18751. * Disposes the InstancedMesh.
  18752. * Returns nothing.
  18753. */
  18754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18755. }
  18756. }
  18757. declare module BABYLON {
  18758. /**
  18759. * Defines the options associated with the creation of a shader material.
  18760. */
  18761. export interface IShaderMaterialOptions {
  18762. /**
  18763. * Does the material work in alpha blend mode
  18764. */
  18765. needAlphaBlending: boolean;
  18766. /**
  18767. * Does the material work in alpha test mode
  18768. */
  18769. needAlphaTesting: boolean;
  18770. /**
  18771. * The list of attribute names used in the shader
  18772. */
  18773. attributes: string[];
  18774. /**
  18775. * The list of unifrom names used in the shader
  18776. */
  18777. uniforms: string[];
  18778. /**
  18779. * The list of UBO names used in the shader
  18780. */
  18781. uniformBuffers: string[];
  18782. /**
  18783. * The list of sampler names used in the shader
  18784. */
  18785. samplers: string[];
  18786. /**
  18787. * The list of defines used in the shader
  18788. */
  18789. defines: string[];
  18790. }
  18791. /**
  18792. * 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.
  18793. *
  18794. * This returned material effects how the mesh will look based on the code in the shaders.
  18795. *
  18796. * @see http://doc.babylonjs.com/how_to/shader_material
  18797. */
  18798. export class ShaderMaterial extends Material {
  18799. private _shaderPath;
  18800. private _options;
  18801. private _textures;
  18802. private _textureArrays;
  18803. private _floats;
  18804. private _ints;
  18805. private _floatsArrays;
  18806. private _colors3;
  18807. private _colors3Arrays;
  18808. private _colors4;
  18809. private _colors4Arrays;
  18810. private _vectors2;
  18811. private _vectors3;
  18812. private _vectors4;
  18813. private _matrices;
  18814. private _matrices3x3;
  18815. private _matrices2x2;
  18816. private _vectors2Arrays;
  18817. private _vectors3Arrays;
  18818. private _vectors4Arrays;
  18819. private _cachedWorldViewMatrix;
  18820. private _cachedWorldViewProjectionMatrix;
  18821. private _renderId;
  18822. /**
  18823. * Instantiate a new shader material.
  18824. * 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.
  18825. * This returned material effects how the mesh will look based on the code in the shaders.
  18826. * @see http://doc.babylonjs.com/how_to/shader_material
  18827. * @param name Define the name of the material in the scene
  18828. * @param scene Define the scene the material belongs to
  18829. * @param shaderPath Defines the route to the shader code in one of three ways:
  18830. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18831. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18832. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18833. * @param options Define the options used to create the shader
  18834. */
  18835. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18836. /**
  18837. * Gets the options used to compile the shader.
  18838. * They can be modified to trigger a new compilation
  18839. */
  18840. readonly options: IShaderMaterialOptions;
  18841. /**
  18842. * Gets the current class name of the material e.g. "ShaderMaterial"
  18843. * Mainly use in serialization.
  18844. * @returns the class name
  18845. */
  18846. getClassName(): string;
  18847. /**
  18848. * Specifies if the material will require alpha blending
  18849. * @returns a boolean specifying if alpha blending is needed
  18850. */
  18851. needAlphaBlending(): boolean;
  18852. /**
  18853. * Specifies if this material should be rendered in alpha test mode
  18854. * @returns a boolean specifying if an alpha test is needed.
  18855. */
  18856. needAlphaTesting(): boolean;
  18857. private _checkUniform;
  18858. /**
  18859. * Set a texture in the shader.
  18860. * @param name Define the name of the uniform samplers as defined in the shader
  18861. * @param texture Define the texture to bind to this sampler
  18862. * @return the material itself allowing "fluent" like uniform updates
  18863. */
  18864. setTexture(name: string, texture: Texture): ShaderMaterial;
  18865. /**
  18866. * Set a texture array in the shader.
  18867. * @param name Define the name of the uniform sampler array as defined in the shader
  18868. * @param textures Define the list of textures to bind to this sampler
  18869. * @return the material itself allowing "fluent" like uniform updates
  18870. */
  18871. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18872. /**
  18873. * Set a float in the shader.
  18874. * @param name Define the name of the uniform as defined in the shader
  18875. * @param value Define the value to give to the uniform
  18876. * @return the material itself allowing "fluent" like uniform updates
  18877. */
  18878. setFloat(name: string, value: number): ShaderMaterial;
  18879. /**
  18880. * Set a int in the shader.
  18881. * @param name Define the name of the uniform as defined in the shader
  18882. * @param value Define the value to give to the uniform
  18883. * @return the material itself allowing "fluent" like uniform updates
  18884. */
  18885. setInt(name: string, value: number): ShaderMaterial;
  18886. /**
  18887. * Set an array of floats in the shader.
  18888. * @param name Define the name of the uniform as defined in the shader
  18889. * @param value Define the value to give to the uniform
  18890. * @return the material itself allowing "fluent" like uniform updates
  18891. */
  18892. setFloats(name: string, value: number[]): ShaderMaterial;
  18893. /**
  18894. * Set a vec3 in the shader from a Color3.
  18895. * @param name Define the name of the uniform as defined in the shader
  18896. * @param value Define the value to give to the uniform
  18897. * @return the material itself allowing "fluent" like uniform updates
  18898. */
  18899. setColor3(name: string, value: Color3): ShaderMaterial;
  18900. /**
  18901. * Set a vec3 array in the shader from a Color3 array.
  18902. * @param name Define the name of the uniform as defined in the shader
  18903. * @param value Define the value to give to the uniform
  18904. * @return the material itself allowing "fluent" like uniform updates
  18905. */
  18906. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18907. /**
  18908. * Set a vec4 in the shader from a Color4.
  18909. * @param name Define the name of the uniform as defined in the shader
  18910. * @param value Define the value to give to the uniform
  18911. * @return the material itself allowing "fluent" like uniform updates
  18912. */
  18913. setColor4(name: string, value: Color4): ShaderMaterial;
  18914. /**
  18915. * Set a vec4 array in the shader from a Color4 array.
  18916. * @param name Define the name of the uniform as defined in the shader
  18917. * @param value Define the value to give to the uniform
  18918. * @return the material itself allowing "fluent" like uniform updates
  18919. */
  18920. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18921. /**
  18922. * Set a vec2 in the shader from a Vector2.
  18923. * @param name Define the name of the uniform as defined in the shader
  18924. * @param value Define the value to give to the uniform
  18925. * @return the material itself allowing "fluent" like uniform updates
  18926. */
  18927. setVector2(name: string, value: Vector2): ShaderMaterial;
  18928. /**
  18929. * Set a vec3 in the shader from a Vector3.
  18930. * @param name Define the name of the uniform as defined in the shader
  18931. * @param value Define the value to give to the uniform
  18932. * @return the material itself allowing "fluent" like uniform updates
  18933. */
  18934. setVector3(name: string, value: Vector3): ShaderMaterial;
  18935. /**
  18936. * Set a vec4 in the shader from a Vector4.
  18937. * @param name Define the name of the uniform as defined in the shader
  18938. * @param value Define the value to give to the uniform
  18939. * @return the material itself allowing "fluent" like uniform updates
  18940. */
  18941. setVector4(name: string, value: Vector4): ShaderMaterial;
  18942. /**
  18943. * Set a mat4 in the shader from a Matrix.
  18944. * @param name Define the name of the uniform as defined in the shader
  18945. * @param value Define the value to give to the uniform
  18946. * @return the material itself allowing "fluent" like uniform updates
  18947. */
  18948. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18949. /**
  18950. * Set a mat3 in the shader from a Float32Array.
  18951. * @param name Define the name of the uniform as defined in the shader
  18952. * @param value Define the value to give to the uniform
  18953. * @return the material itself allowing "fluent" like uniform updates
  18954. */
  18955. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18956. /**
  18957. * Set a mat2 in the shader from a Float32Array.
  18958. * @param name Define the name of the uniform as defined in the shader
  18959. * @param value Define the value to give to the uniform
  18960. * @return the material itself allowing "fluent" like uniform updates
  18961. */
  18962. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18963. /**
  18964. * Set a vec2 array in the shader from a number array.
  18965. * @param name Define the name of the uniform as defined in the shader
  18966. * @param value Define the value to give to the uniform
  18967. * @return the material itself allowing "fluent" like uniform updates
  18968. */
  18969. setArray2(name: string, value: number[]): ShaderMaterial;
  18970. /**
  18971. * Set a vec3 array in the shader from a number array.
  18972. * @param name Define the name of the uniform as defined in the shader
  18973. * @param value Define the value to give to the uniform
  18974. * @return the material itself allowing "fluent" like uniform updates
  18975. */
  18976. setArray3(name: string, value: number[]): ShaderMaterial;
  18977. /**
  18978. * Set a vec4 array in the shader from a number array.
  18979. * @param name Define the name of the uniform as defined in the shader
  18980. * @param value Define the value to give to the uniform
  18981. * @return the material itself allowing "fluent" like uniform updates
  18982. */
  18983. setArray4(name: string, value: number[]): ShaderMaterial;
  18984. private _checkCache;
  18985. /**
  18986. * Specifies that the submesh is ready to be used
  18987. * @param mesh defines the mesh to check
  18988. * @param subMesh defines which submesh to check
  18989. * @param useInstances specifies that instances should be used
  18990. * @returns a boolean indicating that the submesh is ready or not
  18991. */
  18992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18993. /**
  18994. * Checks if the material is ready to render the requested mesh
  18995. * @param mesh Define the mesh to render
  18996. * @param useInstances Define whether or not the material is used with instances
  18997. * @returns true if ready, otherwise false
  18998. */
  18999. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19000. /**
  19001. * Binds the world matrix to the material
  19002. * @param world defines the world transformation matrix
  19003. */
  19004. bindOnlyWorldMatrix(world: Matrix): void;
  19005. /**
  19006. * Binds the material to the mesh
  19007. * @param world defines the world transformation matrix
  19008. * @param mesh defines the mesh to bind the material to
  19009. */
  19010. bind(world: Matrix, mesh?: Mesh): void;
  19011. /**
  19012. * Gets the active textures from the material
  19013. * @returns an array of textures
  19014. */
  19015. getActiveTextures(): BaseTexture[];
  19016. /**
  19017. * Specifies if the material uses a texture
  19018. * @param texture defines the texture to check against the material
  19019. * @returns a boolean specifying if the material uses the texture
  19020. */
  19021. hasTexture(texture: BaseTexture): boolean;
  19022. /**
  19023. * Makes a duplicate of the material, and gives it a new name
  19024. * @param name defines the new name for the duplicated material
  19025. * @returns the cloned material
  19026. */
  19027. clone(name: string): ShaderMaterial;
  19028. /**
  19029. * Disposes the material
  19030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19032. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19033. */
  19034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19035. /**
  19036. * Serializes this material in a JSON representation
  19037. * @returns the serialized material object
  19038. */
  19039. serialize(): any;
  19040. /**
  19041. * Creates a shader material from parsed shader material data
  19042. * @param source defines the JSON represnetation of the material
  19043. * @param scene defines the hosting scene
  19044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19045. * @returns a new material
  19046. */
  19047. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19048. }
  19049. }
  19050. declare module BABYLON {
  19051. /** @hidden */
  19052. export var colorPixelShader: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module BABYLON {
  19058. /** @hidden */
  19059. export var colorVertexShader: {
  19060. name: string;
  19061. shader: string;
  19062. };
  19063. }
  19064. declare module BABYLON {
  19065. /**
  19066. * Line mesh
  19067. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19068. */
  19069. export class LinesMesh extends Mesh {
  19070. /**
  19071. * If vertex color should be applied to the mesh
  19072. */
  19073. readonly useVertexColor?: boolean | undefined;
  19074. /**
  19075. * If vertex alpha should be applied to the mesh
  19076. */
  19077. readonly useVertexAlpha?: boolean | undefined;
  19078. /**
  19079. * Color of the line (Default: White)
  19080. */
  19081. color: Color3;
  19082. /**
  19083. * Alpha of the line (Default: 1)
  19084. */
  19085. alpha: number;
  19086. /**
  19087. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19088. * This margin is expressed in world space coordinates, so its value may vary.
  19089. * Default value is 0.1
  19090. */
  19091. intersectionThreshold: number;
  19092. private _colorShader;
  19093. private color4;
  19094. /**
  19095. * Creates a new LinesMesh
  19096. * @param name defines the name
  19097. * @param scene defines the hosting scene
  19098. * @param parent defines the parent mesh if any
  19099. * @param source defines the optional source LinesMesh used to clone data from
  19100. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19101. * When false, achieved by calling a clone(), also passing False.
  19102. * This will make creation of children, recursive.
  19103. * @param useVertexColor defines if this LinesMesh supports vertex color
  19104. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19105. */
  19106. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19107. /**
  19108. * If vertex color should be applied to the mesh
  19109. */
  19110. useVertexColor?: boolean | undefined,
  19111. /**
  19112. * If vertex alpha should be applied to the mesh
  19113. */
  19114. useVertexAlpha?: boolean | undefined);
  19115. private _addClipPlaneDefine;
  19116. private _removeClipPlaneDefine;
  19117. isReady(): boolean;
  19118. /**
  19119. * Returns the string "LineMesh"
  19120. */
  19121. getClassName(): string;
  19122. /**
  19123. * @hidden
  19124. */
  19125. /**
  19126. * @hidden
  19127. */
  19128. material: Material;
  19129. /**
  19130. * @hidden
  19131. */
  19132. readonly checkCollisions: boolean;
  19133. /** @hidden */
  19134. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19135. /** @hidden */
  19136. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19137. /**
  19138. * Disposes of the line mesh
  19139. * @param doNotRecurse If children should be disposed
  19140. */
  19141. dispose(doNotRecurse?: boolean): void;
  19142. /**
  19143. * Returns a new LineMesh object cloned from the current one.
  19144. */
  19145. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19146. /**
  19147. * Creates a new InstancedLinesMesh object from the mesh model.
  19148. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19149. * @param name defines the name of the new instance
  19150. * @returns a new InstancedLinesMesh
  19151. */
  19152. createInstance(name: string): InstancedLinesMesh;
  19153. }
  19154. /**
  19155. * Creates an instance based on a source LinesMesh
  19156. */
  19157. export class InstancedLinesMesh extends InstancedMesh {
  19158. /**
  19159. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19160. * This margin is expressed in world space coordinates, so its value may vary.
  19161. * Initilized with the intersectionThreshold value of the source LinesMesh
  19162. */
  19163. intersectionThreshold: number;
  19164. constructor(name: string, source: LinesMesh);
  19165. /**
  19166. * Returns the string "InstancedLinesMesh".
  19167. */
  19168. getClassName(): string;
  19169. }
  19170. }
  19171. declare module BABYLON {
  19172. /** @hidden */
  19173. export var linePixelShader: {
  19174. name: string;
  19175. shader: string;
  19176. };
  19177. }
  19178. declare module BABYLON {
  19179. /** @hidden */
  19180. export var lineVertexShader: {
  19181. name: string;
  19182. shader: string;
  19183. };
  19184. }
  19185. declare module BABYLON {
  19186. interface AbstractMesh {
  19187. /**
  19188. * Gets the edgesRenderer associated with the mesh
  19189. */
  19190. edgesRenderer: Nullable<EdgesRenderer>;
  19191. }
  19192. interface LinesMesh {
  19193. /**
  19194. * Enables the edge rendering mode on the mesh.
  19195. * This mode makes the mesh edges visible
  19196. * @param epsilon defines the maximal distance between two angles to detect a face
  19197. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19198. * @returns the currentAbstractMesh
  19199. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19200. */
  19201. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19202. }
  19203. interface InstancedLinesMesh {
  19204. /**
  19205. * Enables the edge rendering mode on the mesh.
  19206. * This mode makes the mesh edges visible
  19207. * @param epsilon defines the maximal distance between two angles to detect a face
  19208. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19209. * @returns the current InstancedLinesMesh
  19210. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19211. */
  19212. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19213. }
  19214. /**
  19215. * Defines the minimum contract an Edges renderer should follow.
  19216. */
  19217. export interface IEdgesRenderer extends IDisposable {
  19218. /**
  19219. * Gets or sets a boolean indicating if the edgesRenderer is active
  19220. */
  19221. isEnabled: boolean;
  19222. /**
  19223. * Renders the edges of the attached mesh,
  19224. */
  19225. render(): void;
  19226. /**
  19227. * Checks wether or not the edges renderer is ready to render.
  19228. * @return true if ready, otherwise false.
  19229. */
  19230. isReady(): boolean;
  19231. }
  19232. /**
  19233. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19234. */
  19235. export class EdgesRenderer implements IEdgesRenderer {
  19236. /**
  19237. * Define the size of the edges with an orthographic camera
  19238. */
  19239. edgesWidthScalerForOrthographic: number;
  19240. /**
  19241. * Define the size of the edges with a perspective camera
  19242. */
  19243. edgesWidthScalerForPerspective: number;
  19244. protected _source: AbstractMesh;
  19245. protected _linesPositions: number[];
  19246. protected _linesNormals: number[];
  19247. protected _linesIndices: number[];
  19248. protected _epsilon: number;
  19249. protected _indicesCount: number;
  19250. protected _lineShader: ShaderMaterial;
  19251. protected _ib: DataBuffer;
  19252. protected _buffers: {
  19253. [key: string]: Nullable<VertexBuffer>;
  19254. };
  19255. protected _checkVerticesInsteadOfIndices: boolean;
  19256. private _meshRebuildObserver;
  19257. private _meshDisposeObserver;
  19258. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19259. isEnabled: boolean;
  19260. /**
  19261. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19262. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19263. * @param source Mesh used to create edges
  19264. * @param epsilon sum of angles in adjacency to check for edge
  19265. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19266. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19267. */
  19268. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19269. protected _prepareRessources(): void;
  19270. /** @hidden */
  19271. _rebuild(): void;
  19272. /**
  19273. * Releases the required resources for the edges renderer
  19274. */
  19275. dispose(): void;
  19276. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19277. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19278. /**
  19279. * Checks if the pair of p0 and p1 is en edge
  19280. * @param faceIndex
  19281. * @param edge
  19282. * @param faceNormals
  19283. * @param p0
  19284. * @param p1
  19285. * @private
  19286. */
  19287. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19288. /**
  19289. * push line into the position, normal and index buffer
  19290. * @protected
  19291. */
  19292. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19293. /**
  19294. * Generates lines edges from adjacencjes
  19295. * @private
  19296. */
  19297. _generateEdgesLines(): void;
  19298. /**
  19299. * Checks wether or not the edges renderer is ready to render.
  19300. * @return true if ready, otherwise false.
  19301. */
  19302. isReady(): boolean;
  19303. /**
  19304. * Renders the edges of the attached mesh,
  19305. */
  19306. render(): void;
  19307. }
  19308. /**
  19309. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19310. */
  19311. export class LineEdgesRenderer extends EdgesRenderer {
  19312. /**
  19313. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19314. * @param source LineMesh used to generate edges
  19315. * @param epsilon not important (specified angle for edge detection)
  19316. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19317. */
  19318. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19319. /**
  19320. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19321. */
  19322. _generateEdgesLines(): void;
  19323. }
  19324. }
  19325. declare module BABYLON {
  19326. /**
  19327. * This represents the object necessary to create a rendering group.
  19328. * This is exclusively used and created by the rendering manager.
  19329. * To modify the behavior, you use the available helpers in your scene or meshes.
  19330. * @hidden
  19331. */
  19332. export class RenderingGroup {
  19333. index: number;
  19334. private static _zeroVector;
  19335. private _scene;
  19336. private _opaqueSubMeshes;
  19337. private _transparentSubMeshes;
  19338. private _alphaTestSubMeshes;
  19339. private _depthOnlySubMeshes;
  19340. private _particleSystems;
  19341. private _spriteManagers;
  19342. private _opaqueSortCompareFn;
  19343. private _alphaTestSortCompareFn;
  19344. private _transparentSortCompareFn;
  19345. private _renderOpaque;
  19346. private _renderAlphaTest;
  19347. private _renderTransparent;
  19348. /** @hidden */
  19349. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19350. onBeforeTransparentRendering: () => void;
  19351. /**
  19352. * Set the opaque sort comparison function.
  19353. * If null the sub meshes will be render in the order they were created
  19354. */
  19355. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19356. /**
  19357. * Set the alpha test sort comparison function.
  19358. * If null the sub meshes will be render in the order they were created
  19359. */
  19360. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19361. /**
  19362. * Set the transparent sort comparison function.
  19363. * If null the sub meshes will be render in the order they were created
  19364. */
  19365. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19366. /**
  19367. * Creates a new rendering group.
  19368. * @param index The rendering group index
  19369. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19370. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19371. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19372. */
  19373. 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>);
  19374. /**
  19375. * Render all the sub meshes contained in the group.
  19376. * @param customRenderFunction Used to override the default render behaviour of the group.
  19377. * @returns true if rendered some submeshes.
  19378. */
  19379. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19380. /**
  19381. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19382. * @param subMeshes The submeshes to render
  19383. */
  19384. private renderOpaqueSorted;
  19385. /**
  19386. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19387. * @param subMeshes The submeshes to render
  19388. */
  19389. private renderAlphaTestSorted;
  19390. /**
  19391. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19392. * @param subMeshes The submeshes to render
  19393. */
  19394. private renderTransparentSorted;
  19395. /**
  19396. * Renders the submeshes in a specified order.
  19397. * @param subMeshes The submeshes to sort before render
  19398. * @param sortCompareFn The comparison function use to sort
  19399. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19400. * @param transparent Specifies to activate blending if true
  19401. */
  19402. private static renderSorted;
  19403. /**
  19404. * Renders the submeshes in the order they were dispatched (no sort applied).
  19405. * @param subMeshes The submeshes to render
  19406. */
  19407. private static renderUnsorted;
  19408. /**
  19409. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19410. * are rendered back to front if in the same alpha index.
  19411. *
  19412. * @param a The first submesh
  19413. * @param b The second submesh
  19414. * @returns The result of the comparison
  19415. */
  19416. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19417. /**
  19418. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19419. * are rendered back to front.
  19420. *
  19421. * @param a The first submesh
  19422. * @param b The second submesh
  19423. * @returns The result of the comparison
  19424. */
  19425. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19426. /**
  19427. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19428. * are rendered front to back (prevent overdraw).
  19429. *
  19430. * @param a The first submesh
  19431. * @param b The second submesh
  19432. * @returns The result of the comparison
  19433. */
  19434. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19435. /**
  19436. * Resets the different lists of submeshes to prepare a new frame.
  19437. */
  19438. prepare(): void;
  19439. dispose(): void;
  19440. /**
  19441. * Inserts the submesh in its correct queue depending on its material.
  19442. * @param subMesh The submesh to dispatch
  19443. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19444. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19445. */
  19446. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19447. dispatchSprites(spriteManager: ISpriteManager): void;
  19448. dispatchParticles(particleSystem: IParticleSystem): void;
  19449. private _renderParticles;
  19450. private _renderSprites;
  19451. }
  19452. }
  19453. declare module BABYLON {
  19454. /**
  19455. * Interface describing the different options available in the rendering manager
  19456. * regarding Auto Clear between groups.
  19457. */
  19458. export interface IRenderingManagerAutoClearSetup {
  19459. /**
  19460. * Defines whether or not autoclear is enable.
  19461. */
  19462. autoClear: boolean;
  19463. /**
  19464. * Defines whether or not to autoclear the depth buffer.
  19465. */
  19466. depth: boolean;
  19467. /**
  19468. * Defines whether or not to autoclear the stencil buffer.
  19469. */
  19470. stencil: boolean;
  19471. }
  19472. /**
  19473. * This class is used by the onRenderingGroupObservable
  19474. */
  19475. export class RenderingGroupInfo {
  19476. /**
  19477. * The Scene that being rendered
  19478. */
  19479. scene: Scene;
  19480. /**
  19481. * The camera currently used for the rendering pass
  19482. */
  19483. camera: Nullable<Camera>;
  19484. /**
  19485. * The ID of the renderingGroup being processed
  19486. */
  19487. renderingGroupId: number;
  19488. }
  19489. /**
  19490. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19491. * It is enable to manage the different groups as well as the different necessary sort functions.
  19492. * This should not be used directly aside of the few static configurations
  19493. */
  19494. export class RenderingManager {
  19495. /**
  19496. * The max id used for rendering groups (not included)
  19497. */
  19498. static MAX_RENDERINGGROUPS: number;
  19499. /**
  19500. * The min id used for rendering groups (included)
  19501. */
  19502. static MIN_RENDERINGGROUPS: number;
  19503. /**
  19504. * Used to globally prevent autoclearing scenes.
  19505. */
  19506. static AUTOCLEAR: boolean;
  19507. /**
  19508. * @hidden
  19509. */
  19510. _useSceneAutoClearSetup: boolean;
  19511. private _scene;
  19512. private _renderingGroups;
  19513. private _depthStencilBufferAlreadyCleaned;
  19514. private _autoClearDepthStencil;
  19515. private _customOpaqueSortCompareFn;
  19516. private _customAlphaTestSortCompareFn;
  19517. private _customTransparentSortCompareFn;
  19518. private _renderingGroupInfo;
  19519. /**
  19520. * Instantiates a new rendering group for a particular scene
  19521. * @param scene Defines the scene the groups belongs to
  19522. */
  19523. constructor(scene: Scene);
  19524. private _clearDepthStencilBuffer;
  19525. /**
  19526. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19527. * @hidden
  19528. */
  19529. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19530. /**
  19531. * Resets the different information of the group to prepare a new frame
  19532. * @hidden
  19533. */
  19534. reset(): void;
  19535. /**
  19536. * Dispose and release the group and its associated resources.
  19537. * @hidden
  19538. */
  19539. dispose(): void;
  19540. /**
  19541. * Clear the info related to rendering groups preventing retention points during dispose.
  19542. */
  19543. freeRenderingGroups(): void;
  19544. private _prepareRenderingGroup;
  19545. /**
  19546. * Add a sprite manager to the rendering manager in order to render it this frame.
  19547. * @param spriteManager Define the sprite manager to render
  19548. */
  19549. dispatchSprites(spriteManager: ISpriteManager): void;
  19550. /**
  19551. * Add a particle system to the rendering manager in order to render it this frame.
  19552. * @param particleSystem Define the particle system to render
  19553. */
  19554. dispatchParticles(particleSystem: IParticleSystem): void;
  19555. /**
  19556. * Add a submesh to the manager in order to render it this frame
  19557. * @param subMesh The submesh to dispatch
  19558. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19559. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19560. */
  19561. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19562. /**
  19563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19564. * This allowed control for front to back rendering or reversly depending of the special needs.
  19565. *
  19566. * @param renderingGroupId The rendering group id corresponding to its index
  19567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19570. */
  19571. 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;
  19572. /**
  19573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19574. *
  19575. * @param renderingGroupId The rendering group id corresponding to its index
  19576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19577. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19578. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19579. */
  19580. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19581. /**
  19582. * Gets the current auto clear configuration for one rendering group of the rendering
  19583. * manager.
  19584. * @param index the rendering group index to get the information for
  19585. * @returns The auto clear setup for the requested rendering group
  19586. */
  19587. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19588. }
  19589. }
  19590. declare module BABYLON {
  19591. /**
  19592. * This Helps creating a texture that will be created from a camera in your scene.
  19593. * It is basically a dynamic texture that could be used to create special effects for instance.
  19594. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19595. */
  19596. export class RenderTargetTexture extends Texture {
  19597. isCube: boolean;
  19598. /**
  19599. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19600. */
  19601. static readonly REFRESHRATE_RENDER_ONCE: number;
  19602. /**
  19603. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19604. */
  19605. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19606. /**
  19607. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19608. * the central point of your effect and can save a lot of performances.
  19609. */
  19610. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19611. /**
  19612. * Use this predicate to dynamically define the list of mesh you want to render.
  19613. * If set, the renderList property will be overwritten.
  19614. */
  19615. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19616. private _renderList;
  19617. /**
  19618. * Use this list to define the list of mesh you want to render.
  19619. */
  19620. renderList: Nullable<Array<AbstractMesh>>;
  19621. private _hookArray;
  19622. /**
  19623. * Define if particles should be rendered in your texture.
  19624. */
  19625. renderParticles: boolean;
  19626. /**
  19627. * Define if sprites should be rendered in your texture.
  19628. */
  19629. renderSprites: boolean;
  19630. /**
  19631. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19632. */
  19633. coordinatesMode: number;
  19634. /**
  19635. * Define the camera used to render the texture.
  19636. */
  19637. activeCamera: Nullable<Camera>;
  19638. /**
  19639. * Override the render function of the texture with your own one.
  19640. */
  19641. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19642. /**
  19643. * Define if camera post processes should be use while rendering the texture.
  19644. */
  19645. useCameraPostProcesses: boolean;
  19646. /**
  19647. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19648. */
  19649. ignoreCameraViewport: boolean;
  19650. private _postProcessManager;
  19651. private _postProcesses;
  19652. private _resizeObserver;
  19653. /**
  19654. * An event triggered when the texture is unbind.
  19655. */
  19656. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19657. /**
  19658. * An event triggered when the texture is unbind.
  19659. */
  19660. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19661. private _onAfterUnbindObserver;
  19662. /**
  19663. * Set a after unbind callback in the texture.
  19664. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19665. */
  19666. onAfterUnbind: () => void;
  19667. /**
  19668. * An event triggered before rendering the texture
  19669. */
  19670. onBeforeRenderObservable: Observable<number>;
  19671. private _onBeforeRenderObserver;
  19672. /**
  19673. * Set a before render callback in the texture.
  19674. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19675. */
  19676. onBeforeRender: (faceIndex: number) => void;
  19677. /**
  19678. * An event triggered after rendering the texture
  19679. */
  19680. onAfterRenderObservable: Observable<number>;
  19681. private _onAfterRenderObserver;
  19682. /**
  19683. * Set a after render callback in the texture.
  19684. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19685. */
  19686. onAfterRender: (faceIndex: number) => void;
  19687. /**
  19688. * An event triggered after the texture clear
  19689. */
  19690. onClearObservable: Observable<Engine>;
  19691. private _onClearObserver;
  19692. /**
  19693. * Set a clear callback in the texture.
  19694. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19695. */
  19696. onClear: (Engine: Engine) => void;
  19697. /**
  19698. * An event triggered when the texture is resized.
  19699. */
  19700. onResizeObservable: Observable<RenderTargetTexture>;
  19701. /**
  19702. * Define the clear color of the Render Target if it should be different from the scene.
  19703. */
  19704. clearColor: Color4;
  19705. protected _size: number | {
  19706. width: number;
  19707. height: number;
  19708. };
  19709. protected _initialSizeParameter: number | {
  19710. width: number;
  19711. height: number;
  19712. } | {
  19713. ratio: number;
  19714. };
  19715. protected _sizeRatio: Nullable<number>;
  19716. /** @hidden */
  19717. _generateMipMaps: boolean;
  19718. protected _renderingManager: RenderingManager;
  19719. /** @hidden */
  19720. _waitingRenderList: string[];
  19721. protected _doNotChangeAspectRatio: boolean;
  19722. protected _currentRefreshId: number;
  19723. protected _refreshRate: number;
  19724. protected _textureMatrix: Matrix;
  19725. protected _samples: number;
  19726. protected _renderTargetOptions: RenderTargetCreationOptions;
  19727. /**
  19728. * Gets render target creation options that were used.
  19729. */
  19730. readonly renderTargetOptions: RenderTargetCreationOptions;
  19731. protected _engine: Engine;
  19732. protected _onRatioRescale(): void;
  19733. /**
  19734. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19735. * It must define where the camera used to render the texture is set
  19736. */
  19737. boundingBoxPosition: Vector3;
  19738. private _boundingBoxSize;
  19739. /**
  19740. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19741. * When defined, the cubemap will switch to local mode
  19742. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19743. * @example https://www.babylonjs-playground.com/#RNASML
  19744. */
  19745. boundingBoxSize: Vector3;
  19746. /**
  19747. * In case the RTT has been created with a depth texture, get the associated
  19748. * depth texture.
  19749. * Otherwise, return null.
  19750. */
  19751. depthStencilTexture: Nullable<InternalTexture>;
  19752. /**
  19753. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19754. * or used a shadow, depth texture...
  19755. * @param name The friendly name of the texture
  19756. * @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)
  19757. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19758. * @param generateMipMaps True if mip maps need to be generated after render.
  19759. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19760. * @param type The type of the buffer in the RTT (int, half float, float...)
  19761. * @param isCube True if a cube texture needs to be created
  19762. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19763. * @param generateDepthBuffer True to generate a depth buffer
  19764. * @param generateStencilBuffer True to generate a stencil buffer
  19765. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19766. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19767. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19768. */
  19769. constructor(name: string, size: number | {
  19770. width: number;
  19771. height: number;
  19772. } | {
  19773. ratio: number;
  19774. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19775. /**
  19776. * Creates a depth stencil texture.
  19777. * This is only available in WebGL 2 or with the depth texture extension available.
  19778. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19779. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19780. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19781. */
  19782. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19783. private _processSizeParameter;
  19784. /**
  19785. * Define the number of samples to use in case of MSAA.
  19786. * It defaults to one meaning no MSAA has been enabled.
  19787. */
  19788. samples: number;
  19789. /**
  19790. * Resets the refresh counter of the texture and start bak from scratch.
  19791. * Could be useful to regenerate the texture if it is setup to render only once.
  19792. */
  19793. resetRefreshCounter(): void;
  19794. /**
  19795. * Define the refresh rate of the texture or the rendering frequency.
  19796. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19797. */
  19798. refreshRate: number;
  19799. /**
  19800. * Adds a post process to the render target rendering passes.
  19801. * @param postProcess define the post process to add
  19802. */
  19803. addPostProcess(postProcess: PostProcess): void;
  19804. /**
  19805. * Clear all the post processes attached to the render target
  19806. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19807. */
  19808. clearPostProcesses(dispose?: boolean): void;
  19809. /**
  19810. * Remove one of the post process from the list of attached post processes to the texture
  19811. * @param postProcess define the post process to remove from the list
  19812. */
  19813. removePostProcess(postProcess: PostProcess): void;
  19814. /** @hidden */
  19815. _shouldRender(): boolean;
  19816. /**
  19817. * Gets the actual render size of the texture.
  19818. * @returns the width of the render size
  19819. */
  19820. getRenderSize(): number;
  19821. /**
  19822. * Gets the actual render width of the texture.
  19823. * @returns the width of the render size
  19824. */
  19825. getRenderWidth(): number;
  19826. /**
  19827. * Gets the actual render height of the texture.
  19828. * @returns the height of the render size
  19829. */
  19830. getRenderHeight(): number;
  19831. /**
  19832. * Get if the texture can be rescaled or not.
  19833. */
  19834. readonly canRescale: boolean;
  19835. /**
  19836. * Resize the texture using a ratio.
  19837. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19838. */
  19839. scale(ratio: number): void;
  19840. /**
  19841. * Get the texture reflection matrix used to rotate/transform the reflection.
  19842. * @returns the reflection matrix
  19843. */
  19844. getReflectionTextureMatrix(): Matrix;
  19845. /**
  19846. * Resize the texture to a new desired size.
  19847. * Be carrefull as it will recreate all the data in the new texture.
  19848. * @param size Define the new size. It can be:
  19849. * - a number for squared texture,
  19850. * - an object containing { width: number, height: number }
  19851. * - or an object containing a ratio { ratio: number }
  19852. */
  19853. resize(size: number | {
  19854. width: number;
  19855. height: number;
  19856. } | {
  19857. ratio: number;
  19858. }): void;
  19859. /**
  19860. * Renders all the objects from the render list into the texture.
  19861. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19862. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19863. */
  19864. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19865. private _bestReflectionRenderTargetDimension;
  19866. /**
  19867. * @hidden
  19868. * @param faceIndex face index to bind to if this is a cubetexture
  19869. */
  19870. _bindFrameBuffer(faceIndex?: number): void;
  19871. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19872. private renderToTarget;
  19873. /**
  19874. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19875. * This allowed control for front to back rendering or reversly depending of the special needs.
  19876. *
  19877. * @param renderingGroupId The rendering group id corresponding to its index
  19878. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19879. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19880. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19881. */
  19882. 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;
  19883. /**
  19884. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19885. *
  19886. * @param renderingGroupId The rendering group id corresponding to its index
  19887. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19888. */
  19889. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19890. /**
  19891. * Clones the texture.
  19892. * @returns the cloned texture
  19893. */
  19894. clone(): RenderTargetTexture;
  19895. /**
  19896. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19897. * @returns The JSON representation of the texture
  19898. */
  19899. serialize(): any;
  19900. /**
  19901. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19902. */
  19903. disposeFramebufferObjects(): void;
  19904. /**
  19905. * Dispose the texture and release its associated resources.
  19906. */
  19907. dispose(): void;
  19908. /** @hidden */
  19909. _rebuild(): void;
  19910. /**
  19911. * Clear the info related to rendering groups preventing retention point in material dispose.
  19912. */
  19913. freeRenderingGroups(): void;
  19914. /**
  19915. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19916. * @returns the view count
  19917. */
  19918. getViewCount(): number;
  19919. }
  19920. }
  19921. declare module BABYLON {
  19922. /**
  19923. * Base class for the main features of a material in Babylon.js
  19924. */
  19925. export class Material implements IAnimatable {
  19926. /**
  19927. * Returns the triangle fill mode
  19928. */
  19929. static readonly TriangleFillMode: number;
  19930. /**
  19931. * Returns the wireframe mode
  19932. */
  19933. static readonly WireFrameFillMode: number;
  19934. /**
  19935. * Returns the point fill mode
  19936. */
  19937. static readonly PointFillMode: number;
  19938. /**
  19939. * Returns the point list draw mode
  19940. */
  19941. static readonly PointListDrawMode: number;
  19942. /**
  19943. * Returns the line list draw mode
  19944. */
  19945. static readonly LineListDrawMode: number;
  19946. /**
  19947. * Returns the line loop draw mode
  19948. */
  19949. static readonly LineLoopDrawMode: number;
  19950. /**
  19951. * Returns the line strip draw mode
  19952. */
  19953. static readonly LineStripDrawMode: number;
  19954. /**
  19955. * Returns the triangle strip draw mode
  19956. */
  19957. static readonly TriangleStripDrawMode: number;
  19958. /**
  19959. * Returns the triangle fan draw mode
  19960. */
  19961. static readonly TriangleFanDrawMode: number;
  19962. /**
  19963. * Stores the clock-wise side orientation
  19964. */
  19965. static readonly ClockWiseSideOrientation: number;
  19966. /**
  19967. * Stores the counter clock-wise side orientation
  19968. */
  19969. static readonly CounterClockWiseSideOrientation: number;
  19970. /**
  19971. * The dirty texture flag value
  19972. */
  19973. static readonly TextureDirtyFlag: number;
  19974. /**
  19975. * The dirty light flag value
  19976. */
  19977. static readonly LightDirtyFlag: number;
  19978. /**
  19979. * The dirty fresnel flag value
  19980. */
  19981. static readonly FresnelDirtyFlag: number;
  19982. /**
  19983. * The dirty attribute flag value
  19984. */
  19985. static readonly AttributesDirtyFlag: number;
  19986. /**
  19987. * The dirty misc flag value
  19988. */
  19989. static readonly MiscDirtyFlag: number;
  19990. /**
  19991. * The all dirty flag value
  19992. */
  19993. static readonly AllDirtyFlag: number;
  19994. /**
  19995. * The ID of the material
  19996. */
  19997. id: string;
  19998. /**
  19999. * Gets or sets the unique id of the material
  20000. */
  20001. uniqueId: number;
  20002. /**
  20003. * The name of the material
  20004. */
  20005. name: string;
  20006. /**
  20007. * Gets or sets user defined metadata
  20008. */
  20009. metadata: any;
  20010. /**
  20011. * For internal use only. Please do not use.
  20012. */
  20013. reservedDataStore: any;
  20014. /**
  20015. * Specifies if the ready state should be checked on each call
  20016. */
  20017. checkReadyOnEveryCall: boolean;
  20018. /**
  20019. * Specifies if the ready state should be checked once
  20020. */
  20021. checkReadyOnlyOnce: boolean;
  20022. /**
  20023. * The state of the material
  20024. */
  20025. state: string;
  20026. /**
  20027. * The alpha value of the material
  20028. */
  20029. protected _alpha: number;
  20030. /**
  20031. * List of inspectable custom properties (used by the Inspector)
  20032. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20033. */
  20034. inspectableCustomProperties: IInspectable[];
  20035. /**
  20036. * Sets the alpha value of the material
  20037. */
  20038. /**
  20039. * Gets the alpha value of the material
  20040. */
  20041. alpha: number;
  20042. /**
  20043. * Specifies if back face culling is enabled
  20044. */
  20045. protected _backFaceCulling: boolean;
  20046. /**
  20047. * Sets the back-face culling state
  20048. */
  20049. /**
  20050. * Gets the back-face culling state
  20051. */
  20052. backFaceCulling: boolean;
  20053. /**
  20054. * Stores the value for side orientation
  20055. */
  20056. sideOrientation: number;
  20057. /**
  20058. * Callback triggered when the material is compiled
  20059. */
  20060. onCompiled: Nullable<(effect: Effect) => void>;
  20061. /**
  20062. * Callback triggered when an error occurs
  20063. */
  20064. onError: Nullable<(effect: Effect, errors: string) => void>;
  20065. /**
  20066. * Callback triggered to get the render target textures
  20067. */
  20068. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20069. /**
  20070. * Gets a boolean indicating that current material needs to register RTT
  20071. */
  20072. readonly hasRenderTargetTextures: boolean;
  20073. /**
  20074. * Specifies if the material should be serialized
  20075. */
  20076. doNotSerialize: boolean;
  20077. /**
  20078. * @hidden
  20079. */
  20080. _storeEffectOnSubMeshes: boolean;
  20081. /**
  20082. * Stores the animations for the material
  20083. */
  20084. animations: Nullable<Array<Animation>>;
  20085. /**
  20086. * An event triggered when the material is disposed
  20087. */
  20088. onDisposeObservable: Observable<Material>;
  20089. /**
  20090. * An observer which watches for dispose events
  20091. */
  20092. private _onDisposeObserver;
  20093. private _onUnBindObservable;
  20094. /**
  20095. * Called during a dispose event
  20096. */
  20097. onDispose: () => void;
  20098. private _onBindObservable;
  20099. /**
  20100. * An event triggered when the material is bound
  20101. */
  20102. readonly onBindObservable: Observable<AbstractMesh>;
  20103. /**
  20104. * An observer which watches for bind events
  20105. */
  20106. private _onBindObserver;
  20107. /**
  20108. * Called during a bind event
  20109. */
  20110. onBind: (Mesh: AbstractMesh) => void;
  20111. /**
  20112. * An event triggered when the material is unbound
  20113. */
  20114. readonly onUnBindObservable: Observable<Material>;
  20115. /**
  20116. * Stores the value of the alpha mode
  20117. */
  20118. private _alphaMode;
  20119. /**
  20120. * Sets the value of the alpha mode.
  20121. *
  20122. * | Value | Type | Description |
  20123. * | --- | --- | --- |
  20124. * | 0 | ALPHA_DISABLE | |
  20125. * | 1 | ALPHA_ADD | |
  20126. * | 2 | ALPHA_COMBINE | |
  20127. * | 3 | ALPHA_SUBTRACT | |
  20128. * | 4 | ALPHA_MULTIPLY | |
  20129. * | 5 | ALPHA_MAXIMIZED | |
  20130. * | 6 | ALPHA_ONEONE | |
  20131. * | 7 | ALPHA_PREMULTIPLIED | |
  20132. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20133. * | 9 | ALPHA_INTERPOLATE | |
  20134. * | 10 | ALPHA_SCREENMODE | |
  20135. *
  20136. */
  20137. /**
  20138. * Gets the value of the alpha mode
  20139. */
  20140. alphaMode: number;
  20141. /**
  20142. * Stores the state of the need depth pre-pass value
  20143. */
  20144. private _needDepthPrePass;
  20145. /**
  20146. * Sets the need depth pre-pass value
  20147. */
  20148. /**
  20149. * Gets the depth pre-pass value
  20150. */
  20151. needDepthPrePass: boolean;
  20152. /**
  20153. * Specifies if depth writing should be disabled
  20154. */
  20155. disableDepthWrite: boolean;
  20156. /**
  20157. * Specifies if depth writing should be forced
  20158. */
  20159. forceDepthWrite: boolean;
  20160. /**
  20161. * Specifies if there should be a separate pass for culling
  20162. */
  20163. separateCullingPass: boolean;
  20164. /**
  20165. * Stores the state specifing if fog should be enabled
  20166. */
  20167. private _fogEnabled;
  20168. /**
  20169. * Sets the state for enabling fog
  20170. */
  20171. /**
  20172. * Gets the value of the fog enabled state
  20173. */
  20174. fogEnabled: boolean;
  20175. /**
  20176. * Stores the size of points
  20177. */
  20178. pointSize: number;
  20179. /**
  20180. * Stores the z offset value
  20181. */
  20182. zOffset: number;
  20183. /**
  20184. * Gets a value specifying if wireframe mode is enabled
  20185. */
  20186. /**
  20187. * Sets the state of wireframe mode
  20188. */
  20189. wireframe: boolean;
  20190. /**
  20191. * Gets the value specifying if point clouds are enabled
  20192. */
  20193. /**
  20194. * Sets the state of point cloud mode
  20195. */
  20196. pointsCloud: boolean;
  20197. /**
  20198. * Gets the material fill mode
  20199. */
  20200. /**
  20201. * Sets the material fill mode
  20202. */
  20203. fillMode: number;
  20204. /**
  20205. * @hidden
  20206. * Stores the effects for the material
  20207. */
  20208. _effect: Nullable<Effect>;
  20209. /**
  20210. * @hidden
  20211. * Specifies if the material was previously ready
  20212. */
  20213. _wasPreviouslyReady: boolean;
  20214. /**
  20215. * Specifies if uniform buffers should be used
  20216. */
  20217. private _useUBO;
  20218. /**
  20219. * Stores a reference to the scene
  20220. */
  20221. private _scene;
  20222. /**
  20223. * Stores the fill mode state
  20224. */
  20225. private _fillMode;
  20226. /**
  20227. * Specifies if the depth write state should be cached
  20228. */
  20229. private _cachedDepthWriteState;
  20230. /**
  20231. * Stores the uniform buffer
  20232. */
  20233. protected _uniformBuffer: UniformBuffer;
  20234. /** @hidden */
  20235. _indexInSceneMaterialArray: number;
  20236. /** @hidden */
  20237. meshMap: Nullable<{
  20238. [id: string]: AbstractMesh | undefined;
  20239. }>;
  20240. /**
  20241. * Creates a material instance
  20242. * @param name defines the name of the material
  20243. * @param scene defines the scene to reference
  20244. * @param doNotAdd specifies if the material should be added to the scene
  20245. */
  20246. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20247. /**
  20248. * Returns a string representation of the current material
  20249. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20250. * @returns a string with material information
  20251. */
  20252. toString(fullDetails?: boolean): string;
  20253. /**
  20254. * Gets the class name of the material
  20255. * @returns a string with the class name of the material
  20256. */
  20257. getClassName(): string;
  20258. /**
  20259. * Specifies if updates for the material been locked
  20260. */
  20261. readonly isFrozen: boolean;
  20262. /**
  20263. * Locks updates for the material
  20264. */
  20265. freeze(): void;
  20266. /**
  20267. * Unlocks updates for the material
  20268. */
  20269. unfreeze(): void;
  20270. /**
  20271. * Specifies if the material is ready to be used
  20272. * @param mesh defines the mesh to check
  20273. * @param useInstances specifies if instances should be used
  20274. * @returns a boolean indicating if the material is ready to be used
  20275. */
  20276. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20277. /**
  20278. * Specifies that the submesh is ready to be used
  20279. * @param mesh defines the mesh to check
  20280. * @param subMesh defines which submesh to check
  20281. * @param useInstances specifies that instances should be used
  20282. * @returns a boolean indicating that the submesh is ready or not
  20283. */
  20284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20285. /**
  20286. * Returns the material effect
  20287. * @returns the effect associated with the material
  20288. */
  20289. getEffect(): Nullable<Effect>;
  20290. /**
  20291. * Returns the current scene
  20292. * @returns a Scene
  20293. */
  20294. getScene(): Scene;
  20295. /**
  20296. * Specifies if the material will require alpha blending
  20297. * @returns a boolean specifying if alpha blending is needed
  20298. */
  20299. needAlphaBlending(): boolean;
  20300. /**
  20301. * Specifies if the mesh will require alpha blending
  20302. * @param mesh defines the mesh to check
  20303. * @returns a boolean specifying if alpha blending is needed for the mesh
  20304. */
  20305. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20306. /**
  20307. * Specifies if this material should be rendered in alpha test mode
  20308. * @returns a boolean specifying if an alpha test is needed.
  20309. */
  20310. needAlphaTesting(): boolean;
  20311. /**
  20312. * Gets the texture used for the alpha test
  20313. * @returns the texture to use for alpha testing
  20314. */
  20315. getAlphaTestTexture(): Nullable<BaseTexture>;
  20316. /**
  20317. * Marks the material to indicate that it needs to be re-calculated
  20318. */
  20319. markDirty(): void;
  20320. /** @hidden */
  20321. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20322. /**
  20323. * Binds the material to the mesh
  20324. * @param world defines the world transformation matrix
  20325. * @param mesh defines the mesh to bind the material to
  20326. */
  20327. bind(world: Matrix, mesh?: Mesh): void;
  20328. /**
  20329. * Binds the submesh to the material
  20330. * @param world defines the world transformation matrix
  20331. * @param mesh defines the mesh containing the submesh
  20332. * @param subMesh defines the submesh to bind the material to
  20333. */
  20334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20335. /**
  20336. * Binds the world matrix to the material
  20337. * @param world defines the world transformation matrix
  20338. */
  20339. bindOnlyWorldMatrix(world: Matrix): void;
  20340. /**
  20341. * Binds the scene's uniform buffer to the effect.
  20342. * @param effect defines the effect to bind to the scene uniform buffer
  20343. * @param sceneUbo defines the uniform buffer storing scene data
  20344. */
  20345. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20346. /**
  20347. * Binds the view matrix to the effect
  20348. * @param effect defines the effect to bind the view matrix to
  20349. */
  20350. bindView(effect: Effect): void;
  20351. /**
  20352. * Binds the view projection matrix to the effect
  20353. * @param effect defines the effect to bind the view projection matrix to
  20354. */
  20355. bindViewProjection(effect: Effect): void;
  20356. /**
  20357. * Specifies if material alpha testing should be turned on for the mesh
  20358. * @param mesh defines the mesh to check
  20359. */
  20360. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20361. /**
  20362. * Processes to execute after binding the material to a mesh
  20363. * @param mesh defines the rendered mesh
  20364. */
  20365. protected _afterBind(mesh?: Mesh): void;
  20366. /**
  20367. * Unbinds the material from the mesh
  20368. */
  20369. unbind(): void;
  20370. /**
  20371. * Gets the active textures from the material
  20372. * @returns an array of textures
  20373. */
  20374. getActiveTextures(): BaseTexture[];
  20375. /**
  20376. * Specifies if the material uses a texture
  20377. * @param texture defines the texture to check against the material
  20378. * @returns a boolean specifying if the material uses the texture
  20379. */
  20380. hasTexture(texture: BaseTexture): boolean;
  20381. /**
  20382. * Makes a duplicate of the material, and gives it a new name
  20383. * @param name defines the new name for the duplicated material
  20384. * @returns the cloned material
  20385. */
  20386. clone(name: string): Nullable<Material>;
  20387. /**
  20388. * Gets the meshes bound to the material
  20389. * @returns an array of meshes bound to the material
  20390. */
  20391. getBindedMeshes(): AbstractMesh[];
  20392. /**
  20393. * Force shader compilation
  20394. * @param mesh defines the mesh associated with this material
  20395. * @param onCompiled defines a function to execute once the material is compiled
  20396. * @param options defines the options to configure the compilation
  20397. */
  20398. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20399. clipPlane: boolean;
  20400. }>): void;
  20401. /**
  20402. * Force shader compilation
  20403. * @param mesh defines the mesh that will use this material
  20404. * @param options defines additional options for compiling the shaders
  20405. * @returns a promise that resolves when the compilation completes
  20406. */
  20407. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20408. clipPlane: boolean;
  20409. }>): Promise<void>;
  20410. private static readonly _AllDirtyCallBack;
  20411. private static readonly _ImageProcessingDirtyCallBack;
  20412. private static readonly _TextureDirtyCallBack;
  20413. private static readonly _FresnelDirtyCallBack;
  20414. private static readonly _MiscDirtyCallBack;
  20415. private static readonly _LightsDirtyCallBack;
  20416. private static readonly _AttributeDirtyCallBack;
  20417. private static _FresnelAndMiscDirtyCallBack;
  20418. private static _TextureAndMiscDirtyCallBack;
  20419. private static readonly _DirtyCallbackArray;
  20420. private static readonly _RunDirtyCallBacks;
  20421. /**
  20422. * Marks a define in the material to indicate that it needs to be re-computed
  20423. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20424. */
  20425. markAsDirty(flag: number): void;
  20426. /**
  20427. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20428. * @param func defines a function which checks material defines against the submeshes
  20429. */
  20430. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20431. /**
  20432. * Indicates that we need to re-calculated for all submeshes
  20433. */
  20434. protected _markAllSubMeshesAsAllDirty(): void;
  20435. /**
  20436. * Indicates that image processing needs to be re-calculated for all submeshes
  20437. */
  20438. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20439. /**
  20440. * Indicates that textures need to be re-calculated for all submeshes
  20441. */
  20442. protected _markAllSubMeshesAsTexturesDirty(): void;
  20443. /**
  20444. * Indicates that fresnel needs to be re-calculated for all submeshes
  20445. */
  20446. protected _markAllSubMeshesAsFresnelDirty(): void;
  20447. /**
  20448. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20449. */
  20450. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20451. /**
  20452. * Indicates that lights need to be re-calculated for all submeshes
  20453. */
  20454. protected _markAllSubMeshesAsLightsDirty(): void;
  20455. /**
  20456. * Indicates that attributes need to be re-calculated for all submeshes
  20457. */
  20458. protected _markAllSubMeshesAsAttributesDirty(): void;
  20459. /**
  20460. * Indicates that misc needs to be re-calculated for all submeshes
  20461. */
  20462. protected _markAllSubMeshesAsMiscDirty(): void;
  20463. /**
  20464. * Indicates that textures and misc need to be re-calculated for all submeshes
  20465. */
  20466. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20467. /**
  20468. * Disposes the material
  20469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20472. */
  20473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20474. /** @hidden */
  20475. private releaseVertexArrayObject;
  20476. /**
  20477. * Serializes this material
  20478. * @returns the serialized material object
  20479. */
  20480. serialize(): any;
  20481. /**
  20482. * Creates a material from parsed material data
  20483. * @param parsedMaterial defines parsed material data
  20484. * @param scene defines the hosting scene
  20485. * @param rootUrl defines the root URL to use to load textures
  20486. * @returns a new material
  20487. */
  20488. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20489. }
  20490. }
  20491. declare module BABYLON {
  20492. /**
  20493. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20494. * separate meshes. This can be use to improve performances.
  20495. * @see http://doc.babylonjs.com/how_to/multi_materials
  20496. */
  20497. export class MultiMaterial extends Material {
  20498. private _subMaterials;
  20499. /**
  20500. * Gets or Sets the list of Materials used within the multi material.
  20501. * They need to be ordered according to the submeshes order in the associated mesh
  20502. */
  20503. subMaterials: Nullable<Material>[];
  20504. /**
  20505. * Function used to align with Node.getChildren()
  20506. * @returns the list of Materials used within the multi material
  20507. */
  20508. getChildren(): Nullable<Material>[];
  20509. /**
  20510. * Instantiates a new Multi Material
  20511. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20512. * separate meshes. This can be use to improve performances.
  20513. * @see http://doc.babylonjs.com/how_to/multi_materials
  20514. * @param name Define the name in the scene
  20515. * @param scene Define the scene the material belongs to
  20516. */
  20517. constructor(name: string, scene: Scene);
  20518. private _hookArray;
  20519. /**
  20520. * Get one of the submaterial by its index in the submaterials array
  20521. * @param index The index to look the sub material at
  20522. * @returns The Material if the index has been defined
  20523. */
  20524. getSubMaterial(index: number): Nullable<Material>;
  20525. /**
  20526. * Get the list of active textures for the whole sub materials list.
  20527. * @returns All the textures that will be used during the rendering
  20528. */
  20529. getActiveTextures(): BaseTexture[];
  20530. /**
  20531. * Gets the current class name of the material e.g. "MultiMaterial"
  20532. * Mainly use in serialization.
  20533. * @returns the class name
  20534. */
  20535. getClassName(): string;
  20536. /**
  20537. * Checks if the material is ready to render the requested sub mesh
  20538. * @param mesh Define the mesh the submesh belongs to
  20539. * @param subMesh Define the sub mesh to look readyness for
  20540. * @param useInstances Define whether or not the material is used with instances
  20541. * @returns true if ready, otherwise false
  20542. */
  20543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20544. /**
  20545. * Clones the current material and its related sub materials
  20546. * @param name Define the name of the newly cloned material
  20547. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20548. * @returns the cloned material
  20549. */
  20550. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20551. /**
  20552. * Serializes the materials into a JSON representation.
  20553. * @returns the JSON representation
  20554. */
  20555. serialize(): any;
  20556. /**
  20557. * Dispose the material and release its associated resources
  20558. * @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)
  20559. * @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)
  20560. * @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)
  20561. */
  20562. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20563. /**
  20564. * Creates a MultiMaterial from parsed MultiMaterial data.
  20565. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20566. * @param scene defines the hosting scene
  20567. * @returns a new MultiMaterial
  20568. */
  20569. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20570. }
  20571. }
  20572. declare module BABYLON {
  20573. /**
  20574. * Base class for submeshes
  20575. */
  20576. export class BaseSubMesh {
  20577. /** @hidden */
  20578. _materialDefines: Nullable<MaterialDefines>;
  20579. /** @hidden */
  20580. _materialEffect: Nullable<Effect>;
  20581. /**
  20582. * Gets associated effect
  20583. */
  20584. readonly effect: Nullable<Effect>;
  20585. /**
  20586. * Sets associated effect (effect used to render this submesh)
  20587. * @param effect defines the effect to associate with
  20588. * @param defines defines the set of defines used to compile this effect
  20589. */
  20590. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20591. }
  20592. /**
  20593. * Defines a subdivision inside a mesh
  20594. */
  20595. export class SubMesh extends BaseSubMesh implements ICullable {
  20596. /** the material index to use */
  20597. materialIndex: number;
  20598. /** vertex index start */
  20599. verticesStart: number;
  20600. /** vertices count */
  20601. verticesCount: number;
  20602. /** index start */
  20603. indexStart: number;
  20604. /** indices count */
  20605. indexCount: number;
  20606. /** @hidden */
  20607. _linesIndexCount: number;
  20608. private _mesh;
  20609. private _renderingMesh;
  20610. private _boundingInfo;
  20611. private _linesIndexBuffer;
  20612. /** @hidden */
  20613. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20614. /** @hidden */
  20615. _trianglePlanes: Plane[];
  20616. /** @hidden */
  20617. _lastColliderTransformMatrix: Nullable<Matrix>;
  20618. /** @hidden */
  20619. _renderId: number;
  20620. /** @hidden */
  20621. _alphaIndex: number;
  20622. /** @hidden */
  20623. _distanceToCamera: number;
  20624. /** @hidden */
  20625. _id: number;
  20626. private _currentMaterial;
  20627. /**
  20628. * Add a new submesh to a mesh
  20629. * @param materialIndex defines the material index to use
  20630. * @param verticesStart defines vertex index start
  20631. * @param verticesCount defines vertices count
  20632. * @param indexStart defines index start
  20633. * @param indexCount defines indices count
  20634. * @param mesh defines the parent mesh
  20635. * @param renderingMesh defines an optional rendering mesh
  20636. * @param createBoundingBox defines if bounding box should be created for this submesh
  20637. * @returns the new submesh
  20638. */
  20639. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20640. /**
  20641. * Creates a new submesh
  20642. * @param materialIndex defines the material index to use
  20643. * @param verticesStart defines vertex index start
  20644. * @param verticesCount defines vertices count
  20645. * @param indexStart defines index start
  20646. * @param indexCount defines indices count
  20647. * @param mesh defines the parent mesh
  20648. * @param renderingMesh defines an optional rendering mesh
  20649. * @param createBoundingBox defines if bounding box should be created for this submesh
  20650. */
  20651. constructor(
  20652. /** the material index to use */
  20653. materialIndex: number,
  20654. /** vertex index start */
  20655. verticesStart: number,
  20656. /** vertices count */
  20657. verticesCount: number,
  20658. /** index start */
  20659. indexStart: number,
  20660. /** indices count */
  20661. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20662. /**
  20663. * Returns true if this submesh covers the entire parent mesh
  20664. * @ignorenaming
  20665. */
  20666. readonly IsGlobal: boolean;
  20667. /**
  20668. * Returns the submesh BoudingInfo object
  20669. * @returns current bounding info (or mesh's one if the submesh is global)
  20670. */
  20671. getBoundingInfo(): BoundingInfo;
  20672. /**
  20673. * Sets the submesh BoundingInfo
  20674. * @param boundingInfo defines the new bounding info to use
  20675. * @returns the SubMesh
  20676. */
  20677. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20678. /**
  20679. * Returns the mesh of the current submesh
  20680. * @return the parent mesh
  20681. */
  20682. getMesh(): AbstractMesh;
  20683. /**
  20684. * Returns the rendering mesh of the submesh
  20685. * @returns the rendering mesh (could be different from parent mesh)
  20686. */
  20687. getRenderingMesh(): Mesh;
  20688. /**
  20689. * Returns the submesh material
  20690. * @returns null or the current material
  20691. */
  20692. getMaterial(): Nullable<Material>;
  20693. /**
  20694. * Sets a new updated BoundingInfo object to the submesh
  20695. * @param data defines an optional position array to use to determine the bounding info
  20696. * @returns the SubMesh
  20697. */
  20698. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20699. /** @hidden */
  20700. _checkCollision(collider: Collider): boolean;
  20701. /**
  20702. * Updates the submesh BoundingInfo
  20703. * @param world defines the world matrix to use to update the bounding info
  20704. * @returns the submesh
  20705. */
  20706. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20707. /**
  20708. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20709. * @param frustumPlanes defines the frustum planes
  20710. * @returns true if the submesh is intersecting with the frustum
  20711. */
  20712. isInFrustum(frustumPlanes: Plane[]): boolean;
  20713. /**
  20714. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20715. * @param frustumPlanes defines the frustum planes
  20716. * @returns true if the submesh is inside the frustum
  20717. */
  20718. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20719. /**
  20720. * Renders the submesh
  20721. * @param enableAlphaMode defines if alpha needs to be used
  20722. * @returns the submesh
  20723. */
  20724. render(enableAlphaMode: boolean): SubMesh;
  20725. /**
  20726. * @hidden
  20727. */
  20728. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20729. /**
  20730. * Checks if the submesh intersects with a ray
  20731. * @param ray defines the ray to test
  20732. * @returns true is the passed ray intersects the submesh bounding box
  20733. */
  20734. canIntersects(ray: Ray): boolean;
  20735. /**
  20736. * Intersects current submesh with a ray
  20737. * @param ray defines the ray to test
  20738. * @param positions defines mesh's positions array
  20739. * @param indices defines mesh's indices array
  20740. * @param fastCheck defines if only bounding info should be used
  20741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20742. * @returns intersection info or null if no intersection
  20743. */
  20744. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20745. /** @hidden */
  20746. private _intersectLines;
  20747. /** @hidden */
  20748. private _intersectUnIndexedLines;
  20749. /** @hidden */
  20750. private _intersectTriangles;
  20751. /** @hidden */
  20752. private _intersectUnIndexedTriangles;
  20753. /** @hidden */
  20754. _rebuild(): void;
  20755. /**
  20756. * Creates a new submesh from the passed mesh
  20757. * @param newMesh defines the new hosting mesh
  20758. * @param newRenderingMesh defines an optional rendering mesh
  20759. * @returns the new submesh
  20760. */
  20761. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20762. /**
  20763. * Release associated resources
  20764. */
  20765. dispose(): void;
  20766. /**
  20767. * Gets the class name
  20768. * @returns the string "SubMesh".
  20769. */
  20770. getClassName(): string;
  20771. /**
  20772. * Creates a new submesh from indices data
  20773. * @param materialIndex the index of the main mesh material
  20774. * @param startIndex the index where to start the copy in the mesh indices array
  20775. * @param indexCount the number of indices to copy then from the startIndex
  20776. * @param mesh the main mesh to create the submesh from
  20777. * @param renderingMesh the optional rendering mesh
  20778. * @returns a new submesh
  20779. */
  20780. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20781. }
  20782. }
  20783. declare module BABYLON {
  20784. /**
  20785. * Class used to represent data loading progression
  20786. */
  20787. export class SceneLoaderFlags {
  20788. private static _ForceFullSceneLoadingForIncremental;
  20789. private static _ShowLoadingScreen;
  20790. private static _CleanBoneMatrixWeights;
  20791. private static _loggingLevel;
  20792. /**
  20793. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20794. */
  20795. static ForceFullSceneLoadingForIncremental: boolean;
  20796. /**
  20797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20798. */
  20799. static ShowLoadingScreen: boolean;
  20800. /**
  20801. * Defines the current logging level (while loading the scene)
  20802. * @ignorenaming
  20803. */
  20804. static loggingLevel: number;
  20805. /**
  20806. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20807. */
  20808. static CleanBoneMatrixWeights: boolean;
  20809. }
  20810. }
  20811. declare module BABYLON {
  20812. /**
  20813. * Class used to store geometry data (vertex buffers + index buffer)
  20814. */
  20815. export class Geometry implements IGetSetVerticesData {
  20816. /**
  20817. * Gets or sets the ID of the geometry
  20818. */
  20819. id: string;
  20820. /**
  20821. * Gets or sets the unique ID of the geometry
  20822. */
  20823. uniqueId: number;
  20824. /**
  20825. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20826. */
  20827. delayLoadState: number;
  20828. /**
  20829. * Gets the file containing the data to load when running in delay load state
  20830. */
  20831. delayLoadingFile: Nullable<string>;
  20832. /**
  20833. * Callback called when the geometry is updated
  20834. */
  20835. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20836. private _scene;
  20837. private _engine;
  20838. private _meshes;
  20839. private _totalVertices;
  20840. /** @hidden */
  20841. _indices: IndicesArray;
  20842. /** @hidden */
  20843. _vertexBuffers: {
  20844. [key: string]: VertexBuffer;
  20845. };
  20846. private _isDisposed;
  20847. private _extend;
  20848. private _boundingBias;
  20849. /** @hidden */
  20850. _delayInfo: Array<string>;
  20851. private _indexBuffer;
  20852. private _indexBufferIsUpdatable;
  20853. /** @hidden */
  20854. _boundingInfo: Nullable<BoundingInfo>;
  20855. /** @hidden */
  20856. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20857. /** @hidden */
  20858. _softwareSkinningFrameId: number;
  20859. private _vertexArrayObjects;
  20860. private _updatable;
  20861. /** @hidden */
  20862. _positions: Nullable<Vector3[]>;
  20863. /**
  20864. * 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
  20865. */
  20866. /**
  20867. * 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
  20868. */
  20869. boundingBias: Vector2;
  20870. /**
  20871. * Static function used to attach a new empty geometry to a mesh
  20872. * @param mesh defines the mesh to attach the geometry to
  20873. * @returns the new Geometry
  20874. */
  20875. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20876. /**
  20877. * Creates a new geometry
  20878. * @param id defines the unique ID
  20879. * @param scene defines the hosting scene
  20880. * @param vertexData defines the VertexData used to get geometry data
  20881. * @param updatable defines if geometry must be updatable (false by default)
  20882. * @param mesh defines the mesh that will be associated with the geometry
  20883. */
  20884. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20885. /**
  20886. * Gets the current extend of the geometry
  20887. */
  20888. readonly extend: {
  20889. minimum: Vector3;
  20890. maximum: Vector3;
  20891. };
  20892. /**
  20893. * Gets the hosting scene
  20894. * @returns the hosting Scene
  20895. */
  20896. getScene(): Scene;
  20897. /**
  20898. * Gets the hosting engine
  20899. * @returns the hosting Engine
  20900. */
  20901. getEngine(): Engine;
  20902. /**
  20903. * Defines if the geometry is ready to use
  20904. * @returns true if the geometry is ready to be used
  20905. */
  20906. isReady(): boolean;
  20907. /**
  20908. * Gets a value indicating that the geometry should not be serialized
  20909. */
  20910. readonly doNotSerialize: boolean;
  20911. /** @hidden */
  20912. _rebuild(): void;
  20913. /**
  20914. * Affects all geometry data in one call
  20915. * @param vertexData defines the geometry data
  20916. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20917. */
  20918. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20919. /**
  20920. * Set specific vertex data
  20921. * @param kind defines the data kind (Position, normal, etc...)
  20922. * @param data defines the vertex data to use
  20923. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20924. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20925. */
  20926. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20927. /**
  20928. * Removes a specific vertex data
  20929. * @param kind defines the data kind (Position, normal, etc...)
  20930. */
  20931. removeVerticesData(kind: string): void;
  20932. /**
  20933. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20934. * @param buffer defines the vertex buffer to use
  20935. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20936. */
  20937. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20938. /**
  20939. * Update a specific vertex buffer
  20940. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20941. * It will do nothing if the buffer is not updatable
  20942. * @param kind defines the data kind (Position, normal, etc...)
  20943. * @param data defines the data to use
  20944. * @param offset defines the offset in the target buffer where to store the data
  20945. * @param useBytes set to true if the offset is in bytes
  20946. */
  20947. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20948. /**
  20949. * Update a specific vertex buffer
  20950. * This function will create a new buffer if the current one is not updatable
  20951. * @param kind defines the data kind (Position, normal, etc...)
  20952. * @param data defines the data to use
  20953. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20954. */
  20955. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20956. private _updateBoundingInfo;
  20957. /** @hidden */
  20958. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20959. /**
  20960. * Gets total number of vertices
  20961. * @returns the total number of vertices
  20962. */
  20963. getTotalVertices(): number;
  20964. /**
  20965. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20966. * @param kind defines the data kind (Position, normal, etc...)
  20967. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20968. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20969. * @returns a float array containing vertex data
  20970. */
  20971. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20972. /**
  20973. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20974. * @param kind defines the data kind (Position, normal, etc...)
  20975. * @returns true if the vertex buffer with the specified kind is updatable
  20976. */
  20977. isVertexBufferUpdatable(kind: string): boolean;
  20978. /**
  20979. * Gets a specific vertex buffer
  20980. * @param kind defines the data kind (Position, normal, etc...)
  20981. * @returns a VertexBuffer
  20982. */
  20983. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20984. /**
  20985. * Returns all vertex buffers
  20986. * @return an object holding all vertex buffers indexed by kind
  20987. */
  20988. getVertexBuffers(): Nullable<{
  20989. [key: string]: VertexBuffer;
  20990. }>;
  20991. /**
  20992. * Gets a boolean indicating if specific vertex buffer is present
  20993. * @param kind defines the data kind (Position, normal, etc...)
  20994. * @returns true if data is present
  20995. */
  20996. isVerticesDataPresent(kind: string): boolean;
  20997. /**
  20998. * Gets a list of all attached data kinds (Position, normal, etc...)
  20999. * @returns a list of string containing all kinds
  21000. */
  21001. getVerticesDataKinds(): string[];
  21002. /**
  21003. * Update index buffer
  21004. * @param indices defines the indices to store in the index buffer
  21005. * @param offset defines the offset in the target buffer where to store the data
  21006. * @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)
  21007. */
  21008. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21009. /**
  21010. * Creates a new index buffer
  21011. * @param indices defines the indices to store in the index buffer
  21012. * @param totalVertices defines the total number of vertices (could be null)
  21013. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21014. */
  21015. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21016. /**
  21017. * Return the total number of indices
  21018. * @returns the total number of indices
  21019. */
  21020. getTotalIndices(): number;
  21021. /**
  21022. * Gets the index buffer array
  21023. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21025. * @returns the index buffer array
  21026. */
  21027. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21028. /**
  21029. * Gets the index buffer
  21030. * @return the index buffer
  21031. */
  21032. getIndexBuffer(): Nullable<DataBuffer>;
  21033. /** @hidden */
  21034. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21035. /**
  21036. * Release the associated resources for a specific mesh
  21037. * @param mesh defines the source mesh
  21038. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21039. */
  21040. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21041. /**
  21042. * Apply current geometry to a given mesh
  21043. * @param mesh defines the mesh to apply geometry to
  21044. */
  21045. applyToMesh(mesh: Mesh): void;
  21046. private _updateExtend;
  21047. private _applyToMesh;
  21048. private notifyUpdate;
  21049. /**
  21050. * Load the geometry if it was flagged as delay loaded
  21051. * @param scene defines the hosting scene
  21052. * @param onLoaded defines a callback called when the geometry is loaded
  21053. */
  21054. load(scene: Scene, onLoaded?: () => void): void;
  21055. private _queueLoad;
  21056. /**
  21057. * Invert the geometry to move from a right handed system to a left handed one.
  21058. */
  21059. toLeftHanded(): void;
  21060. /** @hidden */
  21061. _resetPointsArrayCache(): void;
  21062. /** @hidden */
  21063. _generatePointsArray(): boolean;
  21064. /**
  21065. * Gets a value indicating if the geometry is disposed
  21066. * @returns true if the geometry was disposed
  21067. */
  21068. isDisposed(): boolean;
  21069. private _disposeVertexArrayObjects;
  21070. /**
  21071. * Free all associated resources
  21072. */
  21073. dispose(): void;
  21074. /**
  21075. * Clone the current geometry into a new geometry
  21076. * @param id defines the unique ID of the new geometry
  21077. * @returns a new geometry object
  21078. */
  21079. copy(id: string): Geometry;
  21080. /**
  21081. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21082. * @return a JSON representation of the current geometry data (without the vertices data)
  21083. */
  21084. serialize(): any;
  21085. private toNumberArray;
  21086. /**
  21087. * Serialize all vertices data into a JSON oject
  21088. * @returns a JSON representation of the current geometry data
  21089. */
  21090. serializeVerticeData(): any;
  21091. /**
  21092. * Extracts a clone of a mesh geometry
  21093. * @param mesh defines the source mesh
  21094. * @param id defines the unique ID of the new geometry object
  21095. * @returns the new geometry object
  21096. */
  21097. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21098. /**
  21099. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21100. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21101. * Be aware Math.random() could cause collisions, but:
  21102. * "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"
  21103. * @returns a string containing a new GUID
  21104. */
  21105. static RandomId(): string;
  21106. /** @hidden */
  21107. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21108. private static _CleanMatricesWeights;
  21109. /**
  21110. * Create a new geometry from persisted data (Using .babylon file format)
  21111. * @param parsedVertexData defines the persisted data
  21112. * @param scene defines the hosting scene
  21113. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21114. * @returns the new geometry object
  21115. */
  21116. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21117. }
  21118. }
  21119. declare module BABYLON {
  21120. /**
  21121. * Define an interface for all classes that will get and set the data on vertices
  21122. */
  21123. export interface IGetSetVerticesData {
  21124. /**
  21125. * Gets a boolean indicating if specific vertex data is present
  21126. * @param kind defines the vertex data kind to use
  21127. * @returns true is data kind is present
  21128. */
  21129. isVerticesDataPresent(kind: string): boolean;
  21130. /**
  21131. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21132. * @param kind defines the data kind (Position, normal, etc...)
  21133. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21135. * @returns a float array containing vertex data
  21136. */
  21137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21138. /**
  21139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21140. * @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.
  21141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21142. * @returns the indices array or an empty array if the mesh has no geometry
  21143. */
  21144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21145. /**
  21146. * Set specific vertex data
  21147. * @param kind defines the data kind (Position, normal, etc...)
  21148. * @param data defines the vertex data to use
  21149. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21150. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21151. */
  21152. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21153. /**
  21154. * Update a specific associated vertex buffer
  21155. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21156. * - VertexBuffer.PositionKind
  21157. * - VertexBuffer.UVKind
  21158. * - VertexBuffer.UV2Kind
  21159. * - VertexBuffer.UV3Kind
  21160. * - VertexBuffer.UV4Kind
  21161. * - VertexBuffer.UV5Kind
  21162. * - VertexBuffer.UV6Kind
  21163. * - VertexBuffer.ColorKind
  21164. * - VertexBuffer.MatricesIndicesKind
  21165. * - VertexBuffer.MatricesIndicesExtraKind
  21166. * - VertexBuffer.MatricesWeightsKind
  21167. * - VertexBuffer.MatricesWeightsExtraKind
  21168. * @param data defines the data source
  21169. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21170. * @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)
  21171. */
  21172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21173. /**
  21174. * Creates a new index buffer
  21175. * @param indices defines the indices to store in the index buffer
  21176. * @param totalVertices defines the total number of vertices (could be null)
  21177. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21178. */
  21179. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21180. }
  21181. /**
  21182. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21183. */
  21184. export class VertexData {
  21185. /**
  21186. * Mesh side orientation : usually the external or front surface
  21187. */
  21188. static readonly FRONTSIDE: number;
  21189. /**
  21190. * Mesh side orientation : usually the internal or back surface
  21191. */
  21192. static readonly BACKSIDE: number;
  21193. /**
  21194. * Mesh side orientation : both internal and external or front and back surfaces
  21195. */
  21196. static readonly DOUBLESIDE: number;
  21197. /**
  21198. * Mesh side orientation : by default, `FRONTSIDE`
  21199. */
  21200. static readonly DEFAULTSIDE: number;
  21201. /**
  21202. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21203. */
  21204. positions: Nullable<FloatArray>;
  21205. /**
  21206. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21207. */
  21208. normals: Nullable<FloatArray>;
  21209. /**
  21210. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21211. */
  21212. tangents: Nullable<FloatArray>;
  21213. /**
  21214. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21215. */
  21216. uvs: Nullable<FloatArray>;
  21217. /**
  21218. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21219. */
  21220. uvs2: Nullable<FloatArray>;
  21221. /**
  21222. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21223. */
  21224. uvs3: Nullable<FloatArray>;
  21225. /**
  21226. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21227. */
  21228. uvs4: Nullable<FloatArray>;
  21229. /**
  21230. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21231. */
  21232. uvs5: Nullable<FloatArray>;
  21233. /**
  21234. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21235. */
  21236. uvs6: Nullable<FloatArray>;
  21237. /**
  21238. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21239. */
  21240. colors: Nullable<FloatArray>;
  21241. /**
  21242. * 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).
  21243. */
  21244. matricesIndices: Nullable<FloatArray>;
  21245. /**
  21246. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21247. */
  21248. matricesWeights: Nullable<FloatArray>;
  21249. /**
  21250. * An array extending the number of possible indices
  21251. */
  21252. matricesIndicesExtra: Nullable<FloatArray>;
  21253. /**
  21254. * An array extending the number of possible weights when the number of indices is extended
  21255. */
  21256. matricesWeightsExtra: Nullable<FloatArray>;
  21257. /**
  21258. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21259. */
  21260. indices: Nullable<IndicesArray>;
  21261. /**
  21262. * Uses the passed data array to set the set the values for the specified kind of data
  21263. * @param data a linear array of floating numbers
  21264. * @param kind the type of data that is being set, eg positions, colors etc
  21265. */
  21266. set(data: FloatArray, kind: string): void;
  21267. /**
  21268. * Associates the vertexData to the passed Mesh.
  21269. * Sets it as updatable or not (default `false`)
  21270. * @param mesh the mesh the vertexData is applied to
  21271. * @param updatable when used and having the value true allows new data to update the vertexData
  21272. * @returns the VertexData
  21273. */
  21274. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21275. /**
  21276. * Associates the vertexData to the passed Geometry.
  21277. * Sets it as updatable or not (default `false`)
  21278. * @param geometry the geometry the vertexData is applied to
  21279. * @param updatable when used and having the value true allows new data to update the vertexData
  21280. * @returns VertexData
  21281. */
  21282. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21283. /**
  21284. * Updates the associated mesh
  21285. * @param mesh the mesh to be updated
  21286. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21287. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21288. * @returns VertexData
  21289. */
  21290. updateMesh(mesh: Mesh): VertexData;
  21291. /**
  21292. * Updates the associated geometry
  21293. * @param geometry the geometry to be updated
  21294. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21295. * @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
  21296. * @returns VertexData.
  21297. */
  21298. updateGeometry(geometry: Geometry): VertexData;
  21299. private _applyTo;
  21300. private _update;
  21301. /**
  21302. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21303. * @param matrix the transforming matrix
  21304. * @returns the VertexData
  21305. */
  21306. transform(matrix: Matrix): VertexData;
  21307. /**
  21308. * Merges the passed VertexData into the current one
  21309. * @param other the VertexData to be merged into the current one
  21310. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21311. * @returns the modified VertexData
  21312. */
  21313. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21314. private _mergeElement;
  21315. private _validate;
  21316. /**
  21317. * Serializes the VertexData
  21318. * @returns a serialized object
  21319. */
  21320. serialize(): any;
  21321. /**
  21322. * Extracts the vertexData from a mesh
  21323. * @param mesh the mesh from which to extract the VertexData
  21324. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21326. * @returns the object VertexData associated to the passed mesh
  21327. */
  21328. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21329. /**
  21330. * Extracts the vertexData from the geometry
  21331. * @param geometry the geometry from which to extract the VertexData
  21332. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21333. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21334. * @returns the object VertexData associated to the passed mesh
  21335. */
  21336. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21337. private static _ExtractFrom;
  21338. /**
  21339. * Creates the VertexData for a Ribbon
  21340. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21341. * * pathArray array of paths, each of which an array of successive Vector3
  21342. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21343. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21344. * * 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
  21345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21346. * * 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)
  21347. * * 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)
  21348. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21349. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21350. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21351. * @returns the VertexData of the ribbon
  21352. */
  21353. static CreateRibbon(options: {
  21354. pathArray: Vector3[][];
  21355. closeArray?: boolean;
  21356. closePath?: boolean;
  21357. offset?: number;
  21358. sideOrientation?: number;
  21359. frontUVs?: Vector4;
  21360. backUVs?: Vector4;
  21361. invertUV?: boolean;
  21362. uvs?: Vector2[];
  21363. colors?: Color4[];
  21364. }): VertexData;
  21365. /**
  21366. * Creates the VertexData for a box
  21367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21368. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21369. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21370. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21371. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21372. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21373. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21375. * * 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)
  21376. * * 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)
  21377. * @returns the VertexData of the box
  21378. */
  21379. static CreateBox(options: {
  21380. size?: number;
  21381. width?: number;
  21382. height?: number;
  21383. depth?: number;
  21384. faceUV?: Vector4[];
  21385. faceColors?: Color4[];
  21386. sideOrientation?: number;
  21387. frontUVs?: Vector4;
  21388. backUVs?: Vector4;
  21389. }): VertexData;
  21390. /**
  21391. * Creates the VertexData for a tiled box
  21392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21393. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21394. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21395. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21397. * @returns the VertexData of the box
  21398. */
  21399. static CreateTiledBox(options: {
  21400. pattern?: number;
  21401. width?: number;
  21402. height?: number;
  21403. depth?: number;
  21404. tileSize?: number;
  21405. tileWidth?: number;
  21406. tileHeight?: number;
  21407. alignHorizontal?: number;
  21408. alignVertical?: number;
  21409. faceUV?: Vector4[];
  21410. faceColors?: Color4[];
  21411. sideOrientation?: number;
  21412. }): VertexData;
  21413. /**
  21414. * Creates the VertexData for a tiled plane
  21415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21416. * * pattern a limited pattern arrangement depending on the number
  21417. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21418. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21419. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21421. * * 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)
  21422. * * 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)
  21423. * @returns the VertexData of the tiled plane
  21424. */
  21425. static CreateTiledPlane(options: {
  21426. pattern?: number;
  21427. tileSize?: number;
  21428. tileWidth?: number;
  21429. tileHeight?: number;
  21430. size?: number;
  21431. width?: number;
  21432. height?: number;
  21433. alignHorizontal?: number;
  21434. alignVertical?: number;
  21435. sideOrientation?: number;
  21436. frontUVs?: Vector4;
  21437. backUVs?: Vector4;
  21438. }): VertexData;
  21439. /**
  21440. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21442. * * segments sets the number of horizontal strips optional, default 32
  21443. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21444. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21445. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21446. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21447. * * 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
  21448. * * 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
  21449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21450. * * 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)
  21451. * * 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)
  21452. * @returns the VertexData of the ellipsoid
  21453. */
  21454. static CreateSphere(options: {
  21455. segments?: number;
  21456. diameter?: number;
  21457. diameterX?: number;
  21458. diameterY?: number;
  21459. diameterZ?: number;
  21460. arc?: number;
  21461. slice?: number;
  21462. sideOrientation?: number;
  21463. frontUVs?: Vector4;
  21464. backUVs?: Vector4;
  21465. }): VertexData;
  21466. /**
  21467. * Creates the VertexData for a cylinder, cone or prism
  21468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21469. * * height sets the height (y direction) of the cylinder, optional, default 2
  21470. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21471. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21472. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21473. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21474. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21475. * * 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
  21476. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21477. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21478. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21479. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21481. * * 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)
  21482. * * 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)
  21483. * @returns the VertexData of the cylinder, cone or prism
  21484. */
  21485. static CreateCylinder(options: {
  21486. height?: number;
  21487. diameterTop?: number;
  21488. diameterBottom?: number;
  21489. diameter?: number;
  21490. tessellation?: number;
  21491. subdivisions?: number;
  21492. arc?: number;
  21493. faceColors?: Color4[];
  21494. faceUV?: Vector4[];
  21495. hasRings?: boolean;
  21496. enclose?: boolean;
  21497. sideOrientation?: number;
  21498. frontUVs?: Vector4;
  21499. backUVs?: Vector4;
  21500. }): VertexData;
  21501. /**
  21502. * Creates the VertexData for a torus
  21503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21504. * * diameter the diameter of the torus, optional default 1
  21505. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21506. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21508. * * 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)
  21509. * * 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)
  21510. * @returns the VertexData of the torus
  21511. */
  21512. static CreateTorus(options: {
  21513. diameter?: number;
  21514. thickness?: number;
  21515. tessellation?: number;
  21516. sideOrientation?: number;
  21517. frontUVs?: Vector4;
  21518. backUVs?: Vector4;
  21519. }): VertexData;
  21520. /**
  21521. * Creates the VertexData of the LineSystem
  21522. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21523. * - lines an array of lines, each line being an array of successive Vector3
  21524. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21525. * @returns the VertexData of the LineSystem
  21526. */
  21527. static CreateLineSystem(options: {
  21528. lines: Vector3[][];
  21529. colors?: Nullable<Color4[][]>;
  21530. }): VertexData;
  21531. /**
  21532. * Create the VertexData for a DashedLines
  21533. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21534. * - points an array successive Vector3
  21535. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21536. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21537. * - dashNb the intended total number of dashes, optional, default 200
  21538. * @returns the VertexData for the DashedLines
  21539. */
  21540. static CreateDashedLines(options: {
  21541. points: Vector3[];
  21542. dashSize?: number;
  21543. gapSize?: number;
  21544. dashNb?: number;
  21545. }): VertexData;
  21546. /**
  21547. * Creates the VertexData for a Ground
  21548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21549. * - width the width (x direction) of the ground, optional, default 1
  21550. * - height the height (z direction) of the ground, optional, default 1
  21551. * - subdivisions the number of subdivisions per side, optional, default 1
  21552. * @returns the VertexData of the Ground
  21553. */
  21554. static CreateGround(options: {
  21555. width?: number;
  21556. height?: number;
  21557. subdivisions?: number;
  21558. subdivisionsX?: number;
  21559. subdivisionsY?: number;
  21560. }): VertexData;
  21561. /**
  21562. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21563. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21564. * * xmin the ground minimum X coordinate, optional, default -1
  21565. * * zmin the ground minimum Z coordinate, optional, default -1
  21566. * * xmax the ground maximum X coordinate, optional, default 1
  21567. * * zmax the ground maximum Z coordinate, optional, default 1
  21568. * * 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}
  21569. * * 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}
  21570. * @returns the VertexData of the TiledGround
  21571. */
  21572. static CreateTiledGround(options: {
  21573. xmin: number;
  21574. zmin: number;
  21575. xmax: number;
  21576. zmax: number;
  21577. subdivisions?: {
  21578. w: number;
  21579. h: number;
  21580. };
  21581. precision?: {
  21582. w: number;
  21583. h: number;
  21584. };
  21585. }): VertexData;
  21586. /**
  21587. * Creates the VertexData of the Ground designed from a heightmap
  21588. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21589. * * width the width (x direction) of the ground
  21590. * * height the height (z direction) of the ground
  21591. * * subdivisions the number of subdivisions per side
  21592. * * minHeight the minimum altitude on the ground, optional, default 0
  21593. * * maxHeight the maximum altitude on the ground, optional default 1
  21594. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21595. * * buffer the array holding the image color data
  21596. * * bufferWidth the width of image
  21597. * * bufferHeight the height of image
  21598. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21599. * @returns the VertexData of the Ground designed from a heightmap
  21600. */
  21601. static CreateGroundFromHeightMap(options: {
  21602. width: number;
  21603. height: number;
  21604. subdivisions: number;
  21605. minHeight: number;
  21606. maxHeight: number;
  21607. colorFilter: Color3;
  21608. buffer: Uint8Array;
  21609. bufferWidth: number;
  21610. bufferHeight: number;
  21611. alphaFilter: number;
  21612. }): VertexData;
  21613. /**
  21614. * Creates the VertexData for a Plane
  21615. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21616. * * size sets the width and height of the plane to the value of size, optional default 1
  21617. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21618. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21620. * * 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)
  21621. * * 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)
  21622. * @returns the VertexData of the box
  21623. */
  21624. static CreatePlane(options: {
  21625. size?: number;
  21626. width?: number;
  21627. height?: number;
  21628. sideOrientation?: number;
  21629. frontUVs?: Vector4;
  21630. backUVs?: Vector4;
  21631. }): VertexData;
  21632. /**
  21633. * Creates the VertexData of the Disc or regular Polygon
  21634. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21635. * * radius the radius of the disc, optional default 0.5
  21636. * * tessellation the number of polygon sides, optional, default 64
  21637. * * 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
  21638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21639. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21640. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21641. * @returns the VertexData of the box
  21642. */
  21643. static CreateDisc(options: {
  21644. radius?: number;
  21645. tessellation?: number;
  21646. arc?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21653. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21654. * @param polygon a mesh built from polygonTriangulation.build()
  21655. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21656. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21657. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21658. * @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)
  21659. * @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)
  21660. * @returns the VertexData of the Polygon
  21661. */
  21662. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21663. /**
  21664. * Creates the VertexData of the IcoSphere
  21665. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21666. * * radius the radius of the IcoSphere, optional default 1
  21667. * * radiusX allows stretching in the x direction, optional, default radius
  21668. * * radiusY allows stretching in the y direction, optional, default radius
  21669. * * radiusZ allows stretching in the z direction, optional, default radius
  21670. * * flat when true creates a flat shaded mesh, optional, default true
  21671. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21673. * * 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)
  21674. * * 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)
  21675. * @returns the VertexData of the IcoSphere
  21676. */
  21677. static CreateIcoSphere(options: {
  21678. radius?: number;
  21679. radiusX?: number;
  21680. radiusY?: number;
  21681. radiusZ?: number;
  21682. flat?: boolean;
  21683. subdivisions?: number;
  21684. sideOrientation?: number;
  21685. frontUVs?: Vector4;
  21686. backUVs?: Vector4;
  21687. }): VertexData;
  21688. /**
  21689. * Creates the VertexData for a Polyhedron
  21690. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21691. * * type provided types are:
  21692. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21693. * * 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)
  21694. * * size the size of the IcoSphere, optional default 1
  21695. * * sizeX allows stretching in the x direction, optional, default size
  21696. * * sizeY allows stretching in the y direction, optional, default size
  21697. * * sizeZ allows stretching in the z direction, optional, default size
  21698. * * 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
  21699. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21701. * * flat when true creates a flat shaded mesh, optional, default true
  21702. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21704. * * 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)
  21705. * * 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)
  21706. * @returns the VertexData of the Polyhedron
  21707. */
  21708. static CreatePolyhedron(options: {
  21709. type?: number;
  21710. size?: number;
  21711. sizeX?: number;
  21712. sizeY?: number;
  21713. sizeZ?: number;
  21714. custom?: any;
  21715. faceUV?: Vector4[];
  21716. faceColors?: Color4[];
  21717. flat?: boolean;
  21718. sideOrientation?: number;
  21719. frontUVs?: Vector4;
  21720. backUVs?: Vector4;
  21721. }): VertexData;
  21722. /**
  21723. * Creates the VertexData for a TorusKnot
  21724. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21725. * * radius the radius of the torus knot, optional, default 2
  21726. * * tube the thickness of the tube, optional, default 0.5
  21727. * * radialSegments the number of sides on each tube segments, optional, default 32
  21728. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21729. * * p the number of windings around the z axis, optional, default 2
  21730. * * q the number of windings around the x axis, optional, default 3
  21731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21732. * * 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)
  21733. * * 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)
  21734. * @returns the VertexData of the Torus Knot
  21735. */
  21736. static CreateTorusKnot(options: {
  21737. radius?: number;
  21738. tube?: number;
  21739. radialSegments?: number;
  21740. tubularSegments?: number;
  21741. p?: number;
  21742. q?: number;
  21743. sideOrientation?: number;
  21744. frontUVs?: Vector4;
  21745. backUVs?: Vector4;
  21746. }): VertexData;
  21747. /**
  21748. * Compute normals for given positions and indices
  21749. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21750. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21751. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21752. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21753. * * facetNormals : optional array of facet normals (vector3)
  21754. * * facetPositions : optional array of facet positions (vector3)
  21755. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21756. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21757. * * bInfo : optional bounding info, required for facetPartitioning computation
  21758. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21759. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21760. * * useRightHandedSystem: optional boolean to for right handed system computation
  21761. * * depthSort : optional boolean to enable the facet depth sort computation
  21762. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21763. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21764. */
  21765. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21766. facetNormals?: any;
  21767. facetPositions?: any;
  21768. facetPartitioning?: any;
  21769. ratio?: number;
  21770. bInfo?: any;
  21771. bbSize?: Vector3;
  21772. subDiv?: any;
  21773. useRightHandedSystem?: boolean;
  21774. depthSort?: boolean;
  21775. distanceTo?: Vector3;
  21776. depthSortedFacets?: any;
  21777. }): void;
  21778. /** @hidden */
  21779. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21780. /**
  21781. * Applies VertexData created from the imported parameters to the geometry
  21782. * @param parsedVertexData the parsed data from an imported file
  21783. * @param geometry the geometry to apply the VertexData to
  21784. */
  21785. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21786. }
  21787. }
  21788. declare module BABYLON {
  21789. /**
  21790. * Defines a target to use with MorphTargetManager
  21791. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21792. */
  21793. export class MorphTarget implements IAnimatable {
  21794. /** defines the name of the target */
  21795. name: string;
  21796. /**
  21797. * Gets or sets the list of animations
  21798. */
  21799. animations: Animation[];
  21800. private _scene;
  21801. private _positions;
  21802. private _normals;
  21803. private _tangents;
  21804. private _uvs;
  21805. private _influence;
  21806. /**
  21807. * Observable raised when the influence changes
  21808. */
  21809. onInfluenceChanged: Observable<boolean>;
  21810. /** @hidden */
  21811. _onDataLayoutChanged: Observable<void>;
  21812. /**
  21813. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21814. */
  21815. influence: number;
  21816. /**
  21817. * Gets or sets the id of the morph Target
  21818. */
  21819. id: string;
  21820. private _animationPropertiesOverride;
  21821. /**
  21822. * Gets or sets the animation properties override
  21823. */
  21824. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21825. /**
  21826. * Creates a new MorphTarget
  21827. * @param name defines the name of the target
  21828. * @param influence defines the influence to use
  21829. * @param scene defines the scene the morphtarget belongs to
  21830. */
  21831. constructor(
  21832. /** defines the name of the target */
  21833. name: string, influence?: number, scene?: Nullable<Scene>);
  21834. /**
  21835. * Gets a boolean defining if the target contains position data
  21836. */
  21837. readonly hasPositions: boolean;
  21838. /**
  21839. * Gets a boolean defining if the target contains normal data
  21840. */
  21841. readonly hasNormals: boolean;
  21842. /**
  21843. * Gets a boolean defining if the target contains tangent data
  21844. */
  21845. readonly hasTangents: boolean;
  21846. /**
  21847. * Gets a boolean defining if the target contains texture coordinates data
  21848. */
  21849. readonly hasUVs: boolean;
  21850. /**
  21851. * Affects position data to this target
  21852. * @param data defines the position data to use
  21853. */
  21854. setPositions(data: Nullable<FloatArray>): void;
  21855. /**
  21856. * Gets the position data stored in this target
  21857. * @returns a FloatArray containing the position data (or null if not present)
  21858. */
  21859. getPositions(): Nullable<FloatArray>;
  21860. /**
  21861. * Affects normal data to this target
  21862. * @param data defines the normal data to use
  21863. */
  21864. setNormals(data: Nullable<FloatArray>): void;
  21865. /**
  21866. * Gets the normal data stored in this target
  21867. * @returns a FloatArray containing the normal data (or null if not present)
  21868. */
  21869. getNormals(): Nullable<FloatArray>;
  21870. /**
  21871. * Affects tangent data to this target
  21872. * @param data defines the tangent data to use
  21873. */
  21874. setTangents(data: Nullable<FloatArray>): void;
  21875. /**
  21876. * Gets the tangent data stored in this target
  21877. * @returns a FloatArray containing the tangent data (or null if not present)
  21878. */
  21879. getTangents(): Nullable<FloatArray>;
  21880. /**
  21881. * Affects texture coordinates data to this target
  21882. * @param data defines the texture coordinates data to use
  21883. */
  21884. setUVs(data: Nullable<FloatArray>): void;
  21885. /**
  21886. * Gets the texture coordinates data stored in this target
  21887. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21888. */
  21889. getUVs(): Nullable<FloatArray>;
  21890. /**
  21891. * Serializes the current target into a Serialization object
  21892. * @returns the serialized object
  21893. */
  21894. serialize(): any;
  21895. /**
  21896. * Returns the string "MorphTarget"
  21897. * @returns "MorphTarget"
  21898. */
  21899. getClassName(): string;
  21900. /**
  21901. * Creates a new target from serialized data
  21902. * @param serializationObject defines the serialized data to use
  21903. * @returns a new MorphTarget
  21904. */
  21905. static Parse(serializationObject: any): MorphTarget;
  21906. /**
  21907. * Creates a MorphTarget from mesh data
  21908. * @param mesh defines the source mesh
  21909. * @param name defines the name to use for the new target
  21910. * @param influence defines the influence to attach to the target
  21911. * @returns a new MorphTarget
  21912. */
  21913. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21914. }
  21915. }
  21916. declare module BABYLON {
  21917. /**
  21918. * This class is used to deform meshes using morphing between different targets
  21919. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21920. */
  21921. export class MorphTargetManager {
  21922. private _targets;
  21923. private _targetInfluenceChangedObservers;
  21924. private _targetDataLayoutChangedObservers;
  21925. private _activeTargets;
  21926. private _scene;
  21927. private _influences;
  21928. private _supportsNormals;
  21929. private _supportsTangents;
  21930. private _supportsUVs;
  21931. private _vertexCount;
  21932. private _uniqueId;
  21933. private _tempInfluences;
  21934. /**
  21935. * Gets or sets a boolean indicating if normals must be morphed
  21936. */
  21937. enableNormalMorphing: boolean;
  21938. /**
  21939. * Gets or sets a boolean indicating if tangents must be morphed
  21940. */
  21941. enableTangentMorphing: boolean;
  21942. /**
  21943. * Gets or sets a boolean indicating if UV must be morphed
  21944. */
  21945. enableUVMorphing: boolean;
  21946. /**
  21947. * Creates a new MorphTargetManager
  21948. * @param scene defines the current scene
  21949. */
  21950. constructor(scene?: Nullable<Scene>);
  21951. /**
  21952. * Gets the unique ID of this manager
  21953. */
  21954. readonly uniqueId: number;
  21955. /**
  21956. * Gets the number of vertices handled by this manager
  21957. */
  21958. readonly vertexCount: number;
  21959. /**
  21960. * Gets a boolean indicating if this manager supports morphing of normals
  21961. */
  21962. readonly supportsNormals: boolean;
  21963. /**
  21964. * Gets a boolean indicating if this manager supports morphing of tangents
  21965. */
  21966. readonly supportsTangents: boolean;
  21967. /**
  21968. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21969. */
  21970. readonly supportsUVs: boolean;
  21971. /**
  21972. * Gets the number of targets stored in this manager
  21973. */
  21974. readonly numTargets: number;
  21975. /**
  21976. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21977. */
  21978. readonly numInfluencers: number;
  21979. /**
  21980. * Gets the list of influences (one per target)
  21981. */
  21982. readonly influences: Float32Array;
  21983. /**
  21984. * Gets the active target at specified index. An active target is a target with an influence > 0
  21985. * @param index defines the index to check
  21986. * @returns the requested target
  21987. */
  21988. getActiveTarget(index: number): MorphTarget;
  21989. /**
  21990. * Gets the target at specified index
  21991. * @param index defines the index to check
  21992. * @returns the requested target
  21993. */
  21994. getTarget(index: number): MorphTarget;
  21995. /**
  21996. * Add a new target to this manager
  21997. * @param target defines the target to add
  21998. */
  21999. addTarget(target: MorphTarget): void;
  22000. /**
  22001. * Removes a target from the manager
  22002. * @param target defines the target to remove
  22003. */
  22004. removeTarget(target: MorphTarget): void;
  22005. /**
  22006. * Serializes the current manager into a Serialization object
  22007. * @returns the serialized object
  22008. */
  22009. serialize(): any;
  22010. private _syncActiveTargets;
  22011. /**
  22012. * Syncrhonize the targets with all the meshes using this morph target manager
  22013. */
  22014. synchronize(): void;
  22015. /**
  22016. * Creates a new MorphTargetManager from serialized data
  22017. * @param serializationObject defines the serialized data
  22018. * @param scene defines the hosting scene
  22019. * @returns the new MorphTargetManager
  22020. */
  22021. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22022. }
  22023. }
  22024. declare module BABYLON {
  22025. /**
  22026. * Class used to represent a specific level of detail of a mesh
  22027. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22028. */
  22029. export class MeshLODLevel {
  22030. /** Defines the distance where this level should star being displayed */
  22031. distance: number;
  22032. /** Defines the mesh to use to render this level */
  22033. mesh: Nullable<Mesh>;
  22034. /**
  22035. * Creates a new LOD level
  22036. * @param distance defines the distance where this level should star being displayed
  22037. * @param mesh defines the mesh to use to render this level
  22038. */
  22039. constructor(
  22040. /** Defines the distance where this level should star being displayed */
  22041. distance: number,
  22042. /** Defines the mesh to use to render this level */
  22043. mesh: Nullable<Mesh>);
  22044. }
  22045. }
  22046. declare module BABYLON {
  22047. /**
  22048. * Mesh representing the gorund
  22049. */
  22050. export class GroundMesh extends Mesh {
  22051. /** If octree should be generated */
  22052. generateOctree: boolean;
  22053. private _heightQuads;
  22054. /** @hidden */
  22055. _subdivisionsX: number;
  22056. /** @hidden */
  22057. _subdivisionsY: number;
  22058. /** @hidden */
  22059. _width: number;
  22060. /** @hidden */
  22061. _height: number;
  22062. /** @hidden */
  22063. _minX: number;
  22064. /** @hidden */
  22065. _maxX: number;
  22066. /** @hidden */
  22067. _minZ: number;
  22068. /** @hidden */
  22069. _maxZ: number;
  22070. constructor(name: string, scene: Scene);
  22071. /**
  22072. * "GroundMesh"
  22073. * @returns "GroundMesh"
  22074. */
  22075. getClassName(): string;
  22076. /**
  22077. * The minimum of x and y subdivisions
  22078. */
  22079. readonly subdivisions: number;
  22080. /**
  22081. * X subdivisions
  22082. */
  22083. readonly subdivisionsX: number;
  22084. /**
  22085. * Y subdivisions
  22086. */
  22087. readonly subdivisionsY: number;
  22088. /**
  22089. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22090. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22091. * @param chunksCount the number of subdivisions for x and y
  22092. * @param octreeBlocksSize (Default: 32)
  22093. */
  22094. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22095. /**
  22096. * Returns a height (y) value in the Worl system :
  22097. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22098. * @param x x coordinate
  22099. * @param z z coordinate
  22100. * @returns the ground y position if (x, z) are outside the ground surface.
  22101. */
  22102. getHeightAtCoordinates(x: number, z: number): number;
  22103. /**
  22104. * Returns a normalized vector (Vector3) orthogonal to the ground
  22105. * at the ground coordinates (x, z) expressed in the World system.
  22106. * @param x x coordinate
  22107. * @param z z coordinate
  22108. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22109. */
  22110. getNormalAtCoordinates(x: number, z: number): Vector3;
  22111. /**
  22112. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22113. * at the ground coordinates (x, z) expressed in the World system.
  22114. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22115. * @param x x coordinate
  22116. * @param z z coordinate
  22117. * @param ref vector to store the result
  22118. * @returns the GroundMesh.
  22119. */
  22120. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22121. /**
  22122. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22123. * if the ground has been updated.
  22124. * This can be used in the render loop.
  22125. * @returns the GroundMesh.
  22126. */
  22127. updateCoordinateHeights(): GroundMesh;
  22128. private _getFacetAt;
  22129. private _initHeightQuads;
  22130. private _computeHeightQuads;
  22131. /**
  22132. * Serializes this ground mesh
  22133. * @param serializationObject object to write serialization to
  22134. */
  22135. serialize(serializationObject: any): void;
  22136. /**
  22137. * Parses a serialized ground mesh
  22138. * @param parsedMesh the serialized mesh
  22139. * @param scene the scene to create the ground mesh in
  22140. * @returns the created ground mesh
  22141. */
  22142. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22143. }
  22144. }
  22145. declare module BABYLON {
  22146. /**
  22147. * Interface for Physics-Joint data
  22148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22149. */
  22150. export interface PhysicsJointData {
  22151. /**
  22152. * The main pivot of the joint
  22153. */
  22154. mainPivot?: Vector3;
  22155. /**
  22156. * The connected pivot of the joint
  22157. */
  22158. connectedPivot?: Vector3;
  22159. /**
  22160. * The main axis of the joint
  22161. */
  22162. mainAxis?: Vector3;
  22163. /**
  22164. * The connected axis of the joint
  22165. */
  22166. connectedAxis?: Vector3;
  22167. /**
  22168. * The collision of the joint
  22169. */
  22170. collision?: boolean;
  22171. /**
  22172. * Native Oimo/Cannon/Energy data
  22173. */
  22174. nativeParams?: any;
  22175. }
  22176. /**
  22177. * This is a holder class for the physics joint created by the physics plugin
  22178. * It holds a set of functions to control the underlying joint
  22179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22180. */
  22181. export class PhysicsJoint {
  22182. /**
  22183. * The type of the physics joint
  22184. */
  22185. type: number;
  22186. /**
  22187. * The data for the physics joint
  22188. */
  22189. jointData: PhysicsJointData;
  22190. private _physicsJoint;
  22191. protected _physicsPlugin: IPhysicsEnginePlugin;
  22192. /**
  22193. * Initializes the physics joint
  22194. * @param type The type of the physics joint
  22195. * @param jointData The data for the physics joint
  22196. */
  22197. constructor(
  22198. /**
  22199. * The type of the physics joint
  22200. */
  22201. type: number,
  22202. /**
  22203. * The data for the physics joint
  22204. */
  22205. jointData: PhysicsJointData);
  22206. /**
  22207. * Gets the physics joint
  22208. */
  22209. /**
  22210. * Sets the physics joint
  22211. */
  22212. physicsJoint: any;
  22213. /**
  22214. * Sets the physics plugin
  22215. */
  22216. physicsPlugin: IPhysicsEnginePlugin;
  22217. /**
  22218. * Execute a function that is physics-plugin specific.
  22219. * @param {Function} func the function that will be executed.
  22220. * It accepts two parameters: the physics world and the physics joint
  22221. */
  22222. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22223. /**
  22224. * Distance-Joint type
  22225. */
  22226. static DistanceJoint: number;
  22227. /**
  22228. * Hinge-Joint type
  22229. */
  22230. static HingeJoint: number;
  22231. /**
  22232. * Ball-and-Socket joint type
  22233. */
  22234. static BallAndSocketJoint: number;
  22235. /**
  22236. * Wheel-Joint type
  22237. */
  22238. static WheelJoint: number;
  22239. /**
  22240. * Slider-Joint type
  22241. */
  22242. static SliderJoint: number;
  22243. /**
  22244. * Prismatic-Joint type
  22245. */
  22246. static PrismaticJoint: number;
  22247. /**
  22248. * Universal-Joint type
  22249. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22250. */
  22251. static UniversalJoint: number;
  22252. /**
  22253. * Hinge-Joint 2 type
  22254. */
  22255. static Hinge2Joint: number;
  22256. /**
  22257. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22258. */
  22259. static PointToPointJoint: number;
  22260. /**
  22261. * Spring-Joint type
  22262. */
  22263. static SpringJoint: number;
  22264. /**
  22265. * Lock-Joint type
  22266. */
  22267. static LockJoint: number;
  22268. }
  22269. /**
  22270. * A class representing a physics distance joint
  22271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22272. */
  22273. export class DistanceJoint extends PhysicsJoint {
  22274. /**
  22275. *
  22276. * @param jointData The data for the Distance-Joint
  22277. */
  22278. constructor(jointData: DistanceJointData);
  22279. /**
  22280. * Update the predefined distance.
  22281. * @param maxDistance The maximum preferred distance
  22282. * @param minDistance The minimum preferred distance
  22283. */
  22284. updateDistance(maxDistance: number, minDistance?: number): void;
  22285. }
  22286. /**
  22287. * Represents a Motor-Enabled Joint
  22288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22289. */
  22290. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22291. /**
  22292. * Initializes the Motor-Enabled Joint
  22293. * @param type The type of the joint
  22294. * @param jointData The physica joint data for the joint
  22295. */
  22296. constructor(type: number, jointData: PhysicsJointData);
  22297. /**
  22298. * Set the motor values.
  22299. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22300. * @param force the force to apply
  22301. * @param maxForce max force for this motor.
  22302. */
  22303. setMotor(force?: number, maxForce?: number): void;
  22304. /**
  22305. * Set the motor's limits.
  22306. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22307. * @param upperLimit The upper limit of the motor
  22308. * @param lowerLimit The lower limit of the motor
  22309. */
  22310. setLimit(upperLimit: number, lowerLimit?: number): void;
  22311. }
  22312. /**
  22313. * This class represents a single physics Hinge-Joint
  22314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22315. */
  22316. export class HingeJoint extends MotorEnabledJoint {
  22317. /**
  22318. * Initializes the Hinge-Joint
  22319. * @param jointData The joint data for the Hinge-Joint
  22320. */
  22321. constructor(jointData: PhysicsJointData);
  22322. /**
  22323. * Set the motor values.
  22324. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22325. * @param {number} force the force to apply
  22326. * @param {number} maxForce max force for this motor.
  22327. */
  22328. setMotor(force?: number, maxForce?: number): void;
  22329. /**
  22330. * Set the motor's limits.
  22331. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22332. * @param upperLimit The upper limit of the motor
  22333. * @param lowerLimit The lower limit of the motor
  22334. */
  22335. setLimit(upperLimit: number, lowerLimit?: number): void;
  22336. }
  22337. /**
  22338. * This class represents a dual hinge physics joint (same as wheel joint)
  22339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22340. */
  22341. export class Hinge2Joint extends MotorEnabledJoint {
  22342. /**
  22343. * Initializes the Hinge2-Joint
  22344. * @param jointData The joint data for the Hinge2-Joint
  22345. */
  22346. constructor(jointData: PhysicsJointData);
  22347. /**
  22348. * Set the motor values.
  22349. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22350. * @param {number} targetSpeed the speed the motor is to reach
  22351. * @param {number} maxForce max force for this motor.
  22352. * @param {motorIndex} the motor's index, 0 or 1.
  22353. */
  22354. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22355. /**
  22356. * Set the motor limits.
  22357. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22358. * @param {number} upperLimit the upper limit
  22359. * @param {number} lowerLimit lower limit
  22360. * @param {motorIndex} the motor's index, 0 or 1.
  22361. */
  22362. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22363. }
  22364. /**
  22365. * Interface for a motor enabled joint
  22366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22367. */
  22368. export interface IMotorEnabledJoint {
  22369. /**
  22370. * Physics joint
  22371. */
  22372. physicsJoint: any;
  22373. /**
  22374. * Sets the motor of the motor-enabled joint
  22375. * @param force The force of the motor
  22376. * @param maxForce The maximum force of the motor
  22377. * @param motorIndex The index of the motor
  22378. */
  22379. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22380. /**
  22381. * Sets the limit of the motor
  22382. * @param upperLimit The upper limit of the motor
  22383. * @param lowerLimit The lower limit of the motor
  22384. * @param motorIndex The index of the motor
  22385. */
  22386. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22387. }
  22388. /**
  22389. * Joint data for a Distance-Joint
  22390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22391. */
  22392. export interface DistanceJointData extends PhysicsJointData {
  22393. /**
  22394. * Max distance the 2 joint objects can be apart
  22395. */
  22396. maxDistance: number;
  22397. }
  22398. /**
  22399. * Joint data from a spring joint
  22400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22401. */
  22402. export interface SpringJointData extends PhysicsJointData {
  22403. /**
  22404. * Length of the spring
  22405. */
  22406. length: number;
  22407. /**
  22408. * Stiffness of the spring
  22409. */
  22410. stiffness: number;
  22411. /**
  22412. * Damping of the spring
  22413. */
  22414. damping: number;
  22415. /** this callback will be called when applying the force to the impostors. */
  22416. forceApplicationCallback: () => void;
  22417. }
  22418. }
  22419. declare module BABYLON {
  22420. /**
  22421. * Holds the data for the raycast result
  22422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22423. */
  22424. export class PhysicsRaycastResult {
  22425. private _hasHit;
  22426. private _hitDistance;
  22427. private _hitNormalWorld;
  22428. private _hitPointWorld;
  22429. private _rayFromWorld;
  22430. private _rayToWorld;
  22431. /**
  22432. * Gets if there was a hit
  22433. */
  22434. readonly hasHit: boolean;
  22435. /**
  22436. * Gets the distance from the hit
  22437. */
  22438. readonly hitDistance: number;
  22439. /**
  22440. * Gets the hit normal/direction in the world
  22441. */
  22442. readonly hitNormalWorld: Vector3;
  22443. /**
  22444. * Gets the hit point in the world
  22445. */
  22446. readonly hitPointWorld: Vector3;
  22447. /**
  22448. * Gets the ray "start point" of the ray in the world
  22449. */
  22450. readonly rayFromWorld: Vector3;
  22451. /**
  22452. * Gets the ray "end point" of the ray in the world
  22453. */
  22454. readonly rayToWorld: Vector3;
  22455. /**
  22456. * Sets the hit data (normal & point in world space)
  22457. * @param hitNormalWorld defines the normal in world space
  22458. * @param hitPointWorld defines the point in world space
  22459. */
  22460. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22461. /**
  22462. * Sets the distance from the start point to the hit point
  22463. * @param distance
  22464. */
  22465. setHitDistance(distance: number): void;
  22466. /**
  22467. * Calculates the distance manually
  22468. */
  22469. calculateHitDistance(): void;
  22470. /**
  22471. * Resets all the values to default
  22472. * @param from The from point on world space
  22473. * @param to The to point on world space
  22474. */
  22475. reset(from?: Vector3, to?: Vector3): void;
  22476. }
  22477. /**
  22478. * Interface for the size containing width and height
  22479. */
  22480. interface IXYZ {
  22481. /**
  22482. * X
  22483. */
  22484. x: number;
  22485. /**
  22486. * Y
  22487. */
  22488. y: number;
  22489. /**
  22490. * Z
  22491. */
  22492. z: number;
  22493. }
  22494. }
  22495. declare module BABYLON {
  22496. /**
  22497. * Interface used to describe a physics joint
  22498. */
  22499. export interface PhysicsImpostorJoint {
  22500. /** Defines the main impostor to which the joint is linked */
  22501. mainImpostor: PhysicsImpostor;
  22502. /** Defines the impostor that is connected to the main impostor using this joint */
  22503. connectedImpostor: PhysicsImpostor;
  22504. /** Defines the joint itself */
  22505. joint: PhysicsJoint;
  22506. }
  22507. /** @hidden */
  22508. export interface IPhysicsEnginePlugin {
  22509. world: any;
  22510. name: string;
  22511. setGravity(gravity: Vector3): void;
  22512. setTimeStep(timeStep: number): void;
  22513. getTimeStep(): number;
  22514. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22515. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22516. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22517. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22518. removePhysicsBody(impostor: PhysicsImpostor): void;
  22519. generateJoint(joint: PhysicsImpostorJoint): void;
  22520. removeJoint(joint: PhysicsImpostorJoint): void;
  22521. isSupported(): boolean;
  22522. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22523. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22524. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22525. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22526. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22527. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22528. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22529. getBodyMass(impostor: PhysicsImpostor): number;
  22530. getBodyFriction(impostor: PhysicsImpostor): number;
  22531. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22532. getBodyRestitution(impostor: PhysicsImpostor): number;
  22533. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22534. getBodyPressure?(impostor: PhysicsImpostor): number;
  22535. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22536. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22537. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22538. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22539. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22540. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22541. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22542. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22543. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22544. sleepBody(impostor: PhysicsImpostor): void;
  22545. wakeUpBody(impostor: PhysicsImpostor): void;
  22546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22547. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22548. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22549. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22550. getRadius(impostor: PhysicsImpostor): number;
  22551. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22553. dispose(): void;
  22554. }
  22555. /**
  22556. * Interface used to define a physics engine
  22557. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22558. */
  22559. export interface IPhysicsEngine {
  22560. /**
  22561. * Gets the gravity vector used by the simulation
  22562. */
  22563. gravity: Vector3;
  22564. /**
  22565. * Sets the gravity vector used by the simulation
  22566. * @param gravity defines the gravity vector to use
  22567. */
  22568. setGravity(gravity: Vector3): void;
  22569. /**
  22570. * Set the time step of the physics engine.
  22571. * Default is 1/60.
  22572. * To slow it down, enter 1/600 for example.
  22573. * To speed it up, 1/30
  22574. * @param newTimeStep the new timestep to apply to this world.
  22575. */
  22576. setTimeStep(newTimeStep: number): void;
  22577. /**
  22578. * Get the time step of the physics engine.
  22579. * @returns the current time step
  22580. */
  22581. getTimeStep(): number;
  22582. /**
  22583. * Release all resources
  22584. */
  22585. dispose(): void;
  22586. /**
  22587. * Gets the name of the current physics plugin
  22588. * @returns the name of the plugin
  22589. */
  22590. getPhysicsPluginName(): string;
  22591. /**
  22592. * Adding a new impostor for the impostor tracking.
  22593. * This will be done by the impostor itself.
  22594. * @param impostor the impostor to add
  22595. */
  22596. addImpostor(impostor: PhysicsImpostor): void;
  22597. /**
  22598. * Remove an impostor from the engine.
  22599. * This impostor and its mesh will not longer be updated by the physics engine.
  22600. * @param impostor the impostor to remove
  22601. */
  22602. removeImpostor(impostor: PhysicsImpostor): void;
  22603. /**
  22604. * Add a joint to the physics engine
  22605. * @param mainImpostor defines the main impostor to which the joint is added.
  22606. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22607. * @param joint defines the joint that will connect both impostors.
  22608. */
  22609. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22610. /**
  22611. * Removes a joint from the simulation
  22612. * @param mainImpostor defines the impostor used with the joint
  22613. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22614. * @param joint defines the joint to remove
  22615. */
  22616. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22617. /**
  22618. * Gets the current plugin used to run the simulation
  22619. * @returns current plugin
  22620. */
  22621. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22622. /**
  22623. * Gets the list of physic impostors
  22624. * @returns an array of PhysicsImpostor
  22625. */
  22626. getImpostors(): Array<PhysicsImpostor>;
  22627. /**
  22628. * Gets the impostor for a physics enabled object
  22629. * @param object defines the object impersonated by the impostor
  22630. * @returns the PhysicsImpostor or null if not found
  22631. */
  22632. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22633. /**
  22634. * Gets the impostor for a physics body object
  22635. * @param body defines physics body used by the impostor
  22636. * @returns the PhysicsImpostor or null if not found
  22637. */
  22638. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22639. /**
  22640. * Does a raycast in the physics world
  22641. * @param from when should the ray start?
  22642. * @param to when should the ray end?
  22643. * @returns PhysicsRaycastResult
  22644. */
  22645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22646. /**
  22647. * Called by the scene. No need to call it.
  22648. * @param delta defines the timespam between frames
  22649. */
  22650. _step(delta: number): void;
  22651. }
  22652. }
  22653. declare module BABYLON {
  22654. /**
  22655. * The interface for the physics imposter parameters
  22656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22657. */
  22658. export interface PhysicsImpostorParameters {
  22659. /**
  22660. * The mass of the physics imposter
  22661. */
  22662. mass: number;
  22663. /**
  22664. * The friction of the physics imposter
  22665. */
  22666. friction?: number;
  22667. /**
  22668. * The coefficient of restitution of the physics imposter
  22669. */
  22670. restitution?: number;
  22671. /**
  22672. * The native options of the physics imposter
  22673. */
  22674. nativeOptions?: any;
  22675. /**
  22676. * Specifies if the parent should be ignored
  22677. */
  22678. ignoreParent?: boolean;
  22679. /**
  22680. * Specifies if bi-directional transformations should be disabled
  22681. */
  22682. disableBidirectionalTransformation?: boolean;
  22683. /**
  22684. * The pressure inside the physics imposter, soft object only
  22685. */
  22686. pressure?: number;
  22687. /**
  22688. * The stiffness the physics imposter, soft object only
  22689. */
  22690. stiffness?: number;
  22691. /**
  22692. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22693. */
  22694. velocityIterations?: number;
  22695. /**
  22696. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22697. */
  22698. positionIterations?: number;
  22699. /**
  22700. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22701. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22702. * Add to fix multiple points
  22703. */
  22704. fixedPoints?: number;
  22705. /**
  22706. * The collision margin around a soft object
  22707. */
  22708. margin?: number;
  22709. /**
  22710. * The collision margin around a soft object
  22711. */
  22712. damping?: number;
  22713. /**
  22714. * The path for a rope based on an extrusion
  22715. */
  22716. path?: any;
  22717. /**
  22718. * The shape of an extrusion used for a rope based on an extrusion
  22719. */
  22720. shape?: any;
  22721. }
  22722. /**
  22723. * Interface for a physics-enabled object
  22724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22725. */
  22726. export interface IPhysicsEnabledObject {
  22727. /**
  22728. * The position of the physics-enabled object
  22729. */
  22730. position: Vector3;
  22731. /**
  22732. * The rotation of the physics-enabled object
  22733. */
  22734. rotationQuaternion: Nullable<Quaternion>;
  22735. /**
  22736. * The scale of the physics-enabled object
  22737. */
  22738. scaling: Vector3;
  22739. /**
  22740. * The rotation of the physics-enabled object
  22741. */
  22742. rotation?: Vector3;
  22743. /**
  22744. * The parent of the physics-enabled object
  22745. */
  22746. parent?: any;
  22747. /**
  22748. * The bounding info of the physics-enabled object
  22749. * @returns The bounding info of the physics-enabled object
  22750. */
  22751. getBoundingInfo(): BoundingInfo;
  22752. /**
  22753. * Computes the world matrix
  22754. * @param force Specifies if the world matrix should be computed by force
  22755. * @returns A world matrix
  22756. */
  22757. computeWorldMatrix(force: boolean): Matrix;
  22758. /**
  22759. * Gets the world matrix
  22760. * @returns A world matrix
  22761. */
  22762. getWorldMatrix?(): Matrix;
  22763. /**
  22764. * Gets the child meshes
  22765. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22766. * @returns An array of abstract meshes
  22767. */
  22768. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22769. /**
  22770. * Gets the vertex data
  22771. * @param kind The type of vertex data
  22772. * @returns A nullable array of numbers, or a float32 array
  22773. */
  22774. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22775. /**
  22776. * Gets the indices from the mesh
  22777. * @returns A nullable array of index arrays
  22778. */
  22779. getIndices?(): Nullable<IndicesArray>;
  22780. /**
  22781. * Gets the scene from the mesh
  22782. * @returns the indices array or null
  22783. */
  22784. getScene?(): Scene;
  22785. /**
  22786. * Gets the absolute position from the mesh
  22787. * @returns the absolute position
  22788. */
  22789. getAbsolutePosition(): Vector3;
  22790. /**
  22791. * Gets the absolute pivot point from the mesh
  22792. * @returns the absolute pivot point
  22793. */
  22794. getAbsolutePivotPoint(): Vector3;
  22795. /**
  22796. * Rotates the mesh
  22797. * @param axis The axis of rotation
  22798. * @param amount The amount of rotation
  22799. * @param space The space of the rotation
  22800. * @returns The rotation transform node
  22801. */
  22802. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22803. /**
  22804. * Translates the mesh
  22805. * @param axis The axis of translation
  22806. * @param distance The distance of translation
  22807. * @param space The space of the translation
  22808. * @returns The transform node
  22809. */
  22810. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22811. /**
  22812. * Sets the absolute position of the mesh
  22813. * @param absolutePosition The absolute position of the mesh
  22814. * @returns The transform node
  22815. */
  22816. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22817. /**
  22818. * Gets the class name of the mesh
  22819. * @returns The class name
  22820. */
  22821. getClassName(): string;
  22822. }
  22823. /**
  22824. * Represents a physics imposter
  22825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22826. */
  22827. export class PhysicsImpostor {
  22828. /**
  22829. * The physics-enabled object used as the physics imposter
  22830. */
  22831. object: IPhysicsEnabledObject;
  22832. /**
  22833. * The type of the physics imposter
  22834. */
  22835. type: number;
  22836. private _options;
  22837. private _scene?;
  22838. /**
  22839. * The default object size of the imposter
  22840. */
  22841. static DEFAULT_OBJECT_SIZE: Vector3;
  22842. /**
  22843. * The identity quaternion of the imposter
  22844. */
  22845. static IDENTITY_QUATERNION: Quaternion;
  22846. /** @hidden */
  22847. _pluginData: any;
  22848. private _physicsEngine;
  22849. private _physicsBody;
  22850. private _bodyUpdateRequired;
  22851. private _onBeforePhysicsStepCallbacks;
  22852. private _onAfterPhysicsStepCallbacks;
  22853. /** @hidden */
  22854. _onPhysicsCollideCallbacks: Array<{
  22855. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22856. otherImpostors: Array<PhysicsImpostor>;
  22857. }>;
  22858. private _deltaPosition;
  22859. private _deltaRotation;
  22860. private _deltaRotationConjugated;
  22861. /** @hidden */
  22862. _isFromLine: boolean;
  22863. private _parent;
  22864. private _isDisposed;
  22865. private static _tmpVecs;
  22866. private static _tmpQuat;
  22867. /**
  22868. * Specifies if the physics imposter is disposed
  22869. */
  22870. readonly isDisposed: boolean;
  22871. /**
  22872. * Gets the mass of the physics imposter
  22873. */
  22874. mass: number;
  22875. /**
  22876. * Gets the coefficient of friction
  22877. */
  22878. /**
  22879. * Sets the coefficient of friction
  22880. */
  22881. friction: number;
  22882. /**
  22883. * Gets the coefficient of restitution
  22884. */
  22885. /**
  22886. * Sets the coefficient of restitution
  22887. */
  22888. restitution: number;
  22889. /**
  22890. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22891. */
  22892. /**
  22893. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22894. */
  22895. pressure: number;
  22896. /**
  22897. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22898. */
  22899. /**
  22900. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22901. */
  22902. stiffness: number;
  22903. /**
  22904. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22905. */
  22906. /**
  22907. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22908. */
  22909. velocityIterations: number;
  22910. /**
  22911. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22912. */
  22913. /**
  22914. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22915. */
  22916. positionIterations: number;
  22917. /**
  22918. * The unique id of the physics imposter
  22919. * set by the physics engine when adding this impostor to the array
  22920. */
  22921. uniqueId: number;
  22922. /**
  22923. * @hidden
  22924. */
  22925. soft: boolean;
  22926. /**
  22927. * @hidden
  22928. */
  22929. segments: number;
  22930. private _joints;
  22931. /**
  22932. * Initializes the physics imposter
  22933. * @param object The physics-enabled object used as the physics imposter
  22934. * @param type The type of the physics imposter
  22935. * @param _options The options for the physics imposter
  22936. * @param _scene The Babylon scene
  22937. */
  22938. constructor(
  22939. /**
  22940. * The physics-enabled object used as the physics imposter
  22941. */
  22942. object: IPhysicsEnabledObject,
  22943. /**
  22944. * The type of the physics imposter
  22945. */
  22946. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22947. /**
  22948. * This function will completly initialize this impostor.
  22949. * It will create a new body - but only if this mesh has no parent.
  22950. * If it has, this impostor will not be used other than to define the impostor
  22951. * of the child mesh.
  22952. * @hidden
  22953. */
  22954. _init(): void;
  22955. private _getPhysicsParent;
  22956. /**
  22957. * Should a new body be generated.
  22958. * @returns boolean specifying if body initialization is required
  22959. */
  22960. isBodyInitRequired(): boolean;
  22961. /**
  22962. * Sets the updated scaling
  22963. * @param updated Specifies if the scaling is updated
  22964. */
  22965. setScalingUpdated(): void;
  22966. /**
  22967. * Force a regeneration of this or the parent's impostor's body.
  22968. * Use under cautious - This will remove all joints already implemented.
  22969. */
  22970. forceUpdate(): void;
  22971. /**
  22972. * Gets the body that holds this impostor. Either its own, or its parent.
  22973. */
  22974. /**
  22975. * Set the physics body. Used mainly by the physics engine/plugin
  22976. */
  22977. physicsBody: any;
  22978. /**
  22979. * Get the parent of the physics imposter
  22980. * @returns Physics imposter or null
  22981. */
  22982. /**
  22983. * Sets the parent of the physics imposter
  22984. */
  22985. parent: Nullable<PhysicsImpostor>;
  22986. /**
  22987. * Resets the update flags
  22988. */
  22989. resetUpdateFlags(): void;
  22990. /**
  22991. * Gets the object extend size
  22992. * @returns the object extend size
  22993. */
  22994. getObjectExtendSize(): Vector3;
  22995. /**
  22996. * Gets the object center
  22997. * @returns The object center
  22998. */
  22999. getObjectCenter(): Vector3;
  23000. /**
  23001. * Get a specific parametes from the options parameter
  23002. * @param paramName The object parameter name
  23003. * @returns The object parameter
  23004. */
  23005. getParam(paramName: string): any;
  23006. /**
  23007. * Sets a specific parameter in the options given to the physics plugin
  23008. * @param paramName The parameter name
  23009. * @param value The value of the parameter
  23010. */
  23011. setParam(paramName: string, value: number): void;
  23012. /**
  23013. * Specifically change the body's mass option. Won't recreate the physics body object
  23014. * @param mass The mass of the physics imposter
  23015. */
  23016. setMass(mass: number): void;
  23017. /**
  23018. * Gets the linear velocity
  23019. * @returns linear velocity or null
  23020. */
  23021. getLinearVelocity(): Nullable<Vector3>;
  23022. /**
  23023. * Sets the linear velocity
  23024. * @param velocity linear velocity or null
  23025. */
  23026. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23027. /**
  23028. * Gets the angular velocity
  23029. * @returns angular velocity or null
  23030. */
  23031. getAngularVelocity(): Nullable<Vector3>;
  23032. /**
  23033. * Sets the angular velocity
  23034. * @param velocity The velocity or null
  23035. */
  23036. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23037. /**
  23038. * Execute a function with the physics plugin native code
  23039. * Provide a function the will have two variables - the world object and the physics body object
  23040. * @param func The function to execute with the physics plugin native code
  23041. */
  23042. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23043. /**
  23044. * Register a function that will be executed before the physics world is stepping forward
  23045. * @param func The function to execute before the physics world is stepped forward
  23046. */
  23047. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23048. /**
  23049. * Unregister a function that will be executed before the physics world is stepping forward
  23050. * @param func The function to execute before the physics world is stepped forward
  23051. */
  23052. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23053. /**
  23054. * Register a function that will be executed after the physics step
  23055. * @param func The function to execute after physics step
  23056. */
  23057. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23058. /**
  23059. * Unregisters a function that will be executed after the physics step
  23060. * @param func The function to execute after physics step
  23061. */
  23062. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23063. /**
  23064. * register a function that will be executed when this impostor collides against a different body
  23065. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23066. * @param func Callback that is executed on collision
  23067. */
  23068. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23069. /**
  23070. * Unregisters the physics imposter on contact
  23071. * @param collideAgainst The physics object to collide against
  23072. * @param func Callback to execute on collision
  23073. */
  23074. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23075. private _tmpQuat;
  23076. private _tmpQuat2;
  23077. /**
  23078. * Get the parent rotation
  23079. * @returns The parent rotation
  23080. */
  23081. getParentsRotation(): Quaternion;
  23082. /**
  23083. * this function is executed by the physics engine.
  23084. */
  23085. beforeStep: () => void;
  23086. /**
  23087. * this function is executed by the physics engine
  23088. */
  23089. afterStep: () => void;
  23090. /**
  23091. * Legacy collision detection event support
  23092. */
  23093. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23094. /**
  23095. * event and body object due to cannon's event-based architecture.
  23096. */
  23097. onCollide: (e: {
  23098. body: any;
  23099. }) => void;
  23100. /**
  23101. * Apply a force
  23102. * @param force The force to apply
  23103. * @param contactPoint The contact point for the force
  23104. * @returns The physics imposter
  23105. */
  23106. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23107. /**
  23108. * Apply an impulse
  23109. * @param force The impulse force
  23110. * @param contactPoint The contact point for the impulse force
  23111. * @returns The physics imposter
  23112. */
  23113. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23114. /**
  23115. * A help function to create a joint
  23116. * @param otherImpostor A physics imposter used to create a joint
  23117. * @param jointType The type of joint
  23118. * @param jointData The data for the joint
  23119. * @returns The physics imposter
  23120. */
  23121. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23122. /**
  23123. * Add a joint to this impostor with a different impostor
  23124. * @param otherImpostor A physics imposter used to add a joint
  23125. * @param joint The joint to add
  23126. * @returns The physics imposter
  23127. */
  23128. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23129. /**
  23130. * Add an anchor to a cloth impostor
  23131. * @param otherImpostor rigid impostor to anchor to
  23132. * @param width ratio across width from 0 to 1
  23133. * @param height ratio up height from 0 to 1
  23134. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23135. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23136. * @returns impostor the soft imposter
  23137. */
  23138. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23139. /**
  23140. * Add a hook to a rope impostor
  23141. * @param otherImpostor rigid impostor to anchor to
  23142. * @param length ratio across rope from 0 to 1
  23143. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23144. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23145. * @returns impostor the rope imposter
  23146. */
  23147. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23148. /**
  23149. * Will keep this body still, in a sleep mode.
  23150. * @returns the physics imposter
  23151. */
  23152. sleep(): PhysicsImpostor;
  23153. /**
  23154. * Wake the body up.
  23155. * @returns The physics imposter
  23156. */
  23157. wakeUp(): PhysicsImpostor;
  23158. /**
  23159. * Clones the physics imposter
  23160. * @param newObject The physics imposter clones to this physics-enabled object
  23161. * @returns A nullable physics imposter
  23162. */
  23163. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23164. /**
  23165. * Disposes the physics imposter
  23166. */
  23167. dispose(): void;
  23168. /**
  23169. * Sets the delta position
  23170. * @param position The delta position amount
  23171. */
  23172. setDeltaPosition(position: Vector3): void;
  23173. /**
  23174. * Sets the delta rotation
  23175. * @param rotation The delta rotation amount
  23176. */
  23177. setDeltaRotation(rotation: Quaternion): void;
  23178. /**
  23179. * Gets the box size of the physics imposter and stores the result in the input parameter
  23180. * @param result Stores the box size
  23181. * @returns The physics imposter
  23182. */
  23183. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23184. /**
  23185. * Gets the radius of the physics imposter
  23186. * @returns Radius of the physics imposter
  23187. */
  23188. getRadius(): number;
  23189. /**
  23190. * Sync a bone with this impostor
  23191. * @param bone The bone to sync to the impostor.
  23192. * @param boneMesh The mesh that the bone is influencing.
  23193. * @param jointPivot The pivot of the joint / bone in local space.
  23194. * @param distToJoint Optional distance from the impostor to the joint.
  23195. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23196. */
  23197. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23198. /**
  23199. * Sync impostor to a bone
  23200. * @param bone The bone that the impostor will be synced to.
  23201. * @param boneMesh The mesh that the bone is influencing.
  23202. * @param jointPivot The pivot of the joint / bone in local space.
  23203. * @param distToJoint Optional distance from the impostor to the joint.
  23204. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23205. * @param boneAxis Optional vector3 axis the bone is aligned with
  23206. */
  23207. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23208. /**
  23209. * No-Imposter type
  23210. */
  23211. static NoImpostor: number;
  23212. /**
  23213. * Sphere-Imposter type
  23214. */
  23215. static SphereImpostor: number;
  23216. /**
  23217. * Box-Imposter type
  23218. */
  23219. static BoxImpostor: number;
  23220. /**
  23221. * Plane-Imposter type
  23222. */
  23223. static PlaneImpostor: number;
  23224. /**
  23225. * Mesh-imposter type
  23226. */
  23227. static MeshImpostor: number;
  23228. /**
  23229. * Capsule-Impostor type (Ammo.js plugin only)
  23230. */
  23231. static CapsuleImpostor: number;
  23232. /**
  23233. * Cylinder-Imposter type
  23234. */
  23235. static CylinderImpostor: number;
  23236. /**
  23237. * Particle-Imposter type
  23238. */
  23239. static ParticleImpostor: number;
  23240. /**
  23241. * Heightmap-Imposter type
  23242. */
  23243. static HeightmapImpostor: number;
  23244. /**
  23245. * ConvexHull-Impostor type (Ammo.js plugin only)
  23246. */
  23247. static ConvexHullImpostor: number;
  23248. /**
  23249. * Rope-Imposter type
  23250. */
  23251. static RopeImpostor: number;
  23252. /**
  23253. * Cloth-Imposter type
  23254. */
  23255. static ClothImpostor: number;
  23256. /**
  23257. * Softbody-Imposter type
  23258. */
  23259. static SoftbodyImpostor: number;
  23260. }
  23261. }
  23262. declare module BABYLON {
  23263. /**
  23264. * @hidden
  23265. **/
  23266. export class _CreationDataStorage {
  23267. closePath?: boolean;
  23268. closeArray?: boolean;
  23269. idx: number[];
  23270. dashSize: number;
  23271. gapSize: number;
  23272. path3D: Path3D;
  23273. pathArray: Vector3[][];
  23274. arc: number;
  23275. radius: number;
  23276. cap: number;
  23277. tessellation: number;
  23278. }
  23279. /**
  23280. * @hidden
  23281. **/
  23282. class _InstanceDataStorage {
  23283. visibleInstances: any;
  23284. batchCache: _InstancesBatch;
  23285. instancesBufferSize: number;
  23286. instancesBuffer: Nullable<Buffer>;
  23287. instancesData: Float32Array;
  23288. overridenInstanceCount: number;
  23289. isFrozen: boolean;
  23290. previousBatch: Nullable<_InstancesBatch>;
  23291. hardwareInstancedRendering: boolean;
  23292. sideOrientation: number;
  23293. }
  23294. /**
  23295. * @hidden
  23296. **/
  23297. export class _InstancesBatch {
  23298. mustReturn: boolean;
  23299. visibleInstances: Nullable<InstancedMesh[]>[];
  23300. renderSelf: boolean[];
  23301. hardwareInstancedRendering: boolean[];
  23302. }
  23303. /**
  23304. * Class used to represent renderable models
  23305. */
  23306. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23307. /**
  23308. * Mesh side orientation : usually the external or front surface
  23309. */
  23310. static readonly FRONTSIDE: number;
  23311. /**
  23312. * Mesh side orientation : usually the internal or back surface
  23313. */
  23314. static readonly BACKSIDE: number;
  23315. /**
  23316. * Mesh side orientation : both internal and external or front and back surfaces
  23317. */
  23318. static readonly DOUBLESIDE: number;
  23319. /**
  23320. * Mesh side orientation : by default, `FRONTSIDE`
  23321. */
  23322. static readonly DEFAULTSIDE: number;
  23323. /**
  23324. * Mesh cap setting : no cap
  23325. */
  23326. static readonly NO_CAP: number;
  23327. /**
  23328. * Mesh cap setting : one cap at the beginning of the mesh
  23329. */
  23330. static readonly CAP_START: number;
  23331. /**
  23332. * Mesh cap setting : one cap at the end of the mesh
  23333. */
  23334. static readonly CAP_END: number;
  23335. /**
  23336. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23337. */
  23338. static readonly CAP_ALL: number;
  23339. /**
  23340. * Mesh pattern setting : no flip or rotate
  23341. */
  23342. static readonly NO_FLIP: number;
  23343. /**
  23344. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23345. */
  23346. static readonly FLIP_TILE: number;
  23347. /**
  23348. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23349. */
  23350. static readonly ROTATE_TILE: number;
  23351. /**
  23352. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23353. */
  23354. static readonly FLIP_ROW: number;
  23355. /**
  23356. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23357. */
  23358. static readonly ROTATE_ROW: number;
  23359. /**
  23360. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23361. */
  23362. static readonly FLIP_N_ROTATE_TILE: number;
  23363. /**
  23364. * Mesh pattern setting : rotate pattern and rotate
  23365. */
  23366. static readonly FLIP_N_ROTATE_ROW: number;
  23367. /**
  23368. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23369. */
  23370. static readonly CENTER: number;
  23371. /**
  23372. * Mesh tile positioning : part tiles on left
  23373. */
  23374. static readonly LEFT: number;
  23375. /**
  23376. * Mesh tile positioning : part tiles on right
  23377. */
  23378. static readonly RIGHT: number;
  23379. /**
  23380. * Mesh tile positioning : part tiles on top
  23381. */
  23382. static readonly TOP: number;
  23383. /**
  23384. * Mesh tile positioning : part tiles on bottom
  23385. */
  23386. static readonly BOTTOM: number;
  23387. /**
  23388. * Gets the default side orientation.
  23389. * @param orientation the orientation to value to attempt to get
  23390. * @returns the default orientation
  23391. * @hidden
  23392. */
  23393. static _GetDefaultSideOrientation(orientation?: number): number;
  23394. private _internalMeshDataInfo;
  23395. /**
  23396. * An event triggered before rendering the mesh
  23397. */
  23398. readonly onBeforeRenderObservable: Observable<Mesh>;
  23399. /**
  23400. * An event triggered before binding the mesh
  23401. */
  23402. readonly onBeforeBindObservable: Observable<Mesh>;
  23403. /**
  23404. * An event triggered after rendering the mesh
  23405. */
  23406. readonly onAfterRenderObservable: Observable<Mesh>;
  23407. /**
  23408. * An event triggered before drawing the mesh
  23409. */
  23410. readonly onBeforeDrawObservable: Observable<Mesh>;
  23411. private _onBeforeDrawObserver;
  23412. /**
  23413. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23414. */
  23415. onBeforeDraw: () => void;
  23416. readonly hasInstances: boolean;
  23417. /**
  23418. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23419. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23420. */
  23421. delayLoadState: number;
  23422. /**
  23423. * Gets the list of instances created from this mesh
  23424. * it is not supposed to be modified manually.
  23425. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23426. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23427. */
  23428. instances: InstancedMesh[];
  23429. /**
  23430. * Gets the file containing delay loading data for this mesh
  23431. */
  23432. delayLoadingFile: string;
  23433. /** @hidden */
  23434. _binaryInfo: any;
  23435. /**
  23436. * User defined function used to change how LOD level selection is done
  23437. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23438. */
  23439. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23440. /**
  23441. * Gets or sets the morph target manager
  23442. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23443. */
  23444. morphTargetManager: Nullable<MorphTargetManager>;
  23445. /** @hidden */
  23446. _creationDataStorage: Nullable<_CreationDataStorage>;
  23447. /** @hidden */
  23448. _geometry: Nullable<Geometry>;
  23449. /** @hidden */
  23450. _delayInfo: Array<string>;
  23451. /** @hidden */
  23452. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23453. /** @hidden */
  23454. _instanceDataStorage: _InstanceDataStorage;
  23455. private _effectiveMaterial;
  23456. /** @hidden */
  23457. _shouldGenerateFlatShading: boolean;
  23458. /** @hidden */
  23459. _originalBuilderSideOrientation: number;
  23460. /**
  23461. * Use this property to change the original side orientation defined at construction time
  23462. */
  23463. overrideMaterialSideOrientation: Nullable<number>;
  23464. /**
  23465. * Gets the source mesh (the one used to clone this one from)
  23466. */
  23467. readonly source: Nullable<Mesh>;
  23468. /**
  23469. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23470. */
  23471. isUnIndexed: boolean;
  23472. /**
  23473. * @constructor
  23474. * @param name The value used by scene.getMeshByName() to do a lookup.
  23475. * @param scene The scene to add this mesh to.
  23476. * @param parent The parent of this mesh, if it has one
  23477. * @param source An optional Mesh from which geometry is shared, cloned.
  23478. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23479. * When false, achieved by calling a clone(), also passing False.
  23480. * This will make creation of children, recursive.
  23481. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23482. */
  23483. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23484. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23485. /**
  23486. * Gets the class name
  23487. * @returns the string "Mesh".
  23488. */
  23489. getClassName(): string;
  23490. /** @hidden */
  23491. readonly _isMesh: boolean;
  23492. /**
  23493. * Returns a description of this mesh
  23494. * @param fullDetails define if full details about this mesh must be used
  23495. * @returns a descriptive string representing this mesh
  23496. */
  23497. toString(fullDetails?: boolean): string;
  23498. /** @hidden */
  23499. _unBindEffect(): void;
  23500. /**
  23501. * Gets a boolean indicating if this mesh has LOD
  23502. */
  23503. readonly hasLODLevels: boolean;
  23504. /**
  23505. * Gets the list of MeshLODLevel associated with the current mesh
  23506. * @returns an array of MeshLODLevel
  23507. */
  23508. getLODLevels(): MeshLODLevel[];
  23509. private _sortLODLevels;
  23510. /**
  23511. * Add a mesh as LOD level triggered at the given distance.
  23512. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23513. * @param distance The distance from the center of the object to show this level
  23514. * @param mesh The mesh to be added as LOD level (can be null)
  23515. * @return This mesh (for chaining)
  23516. */
  23517. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23518. /**
  23519. * Returns the LOD level mesh at the passed distance or null if not found.
  23520. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23521. * @param distance The distance from the center of the object to show this level
  23522. * @returns a Mesh or `null`
  23523. */
  23524. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23525. /**
  23526. * Remove a mesh from the LOD array
  23527. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23528. * @param mesh defines the mesh to be removed
  23529. * @return This mesh (for chaining)
  23530. */
  23531. removeLODLevel(mesh: Mesh): Mesh;
  23532. /**
  23533. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23534. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23535. * @param camera defines the camera to use to compute distance
  23536. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23537. * @return This mesh (for chaining)
  23538. */
  23539. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23540. /**
  23541. * Gets the mesh internal Geometry object
  23542. */
  23543. readonly geometry: Nullable<Geometry>;
  23544. /**
  23545. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23546. * @returns the total number of vertices
  23547. */
  23548. getTotalVertices(): number;
  23549. /**
  23550. * Returns the content of an associated vertex buffer
  23551. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23552. * - VertexBuffer.PositionKind
  23553. * - VertexBuffer.UVKind
  23554. * - VertexBuffer.UV2Kind
  23555. * - VertexBuffer.UV3Kind
  23556. * - VertexBuffer.UV4Kind
  23557. * - VertexBuffer.UV5Kind
  23558. * - VertexBuffer.UV6Kind
  23559. * - VertexBuffer.ColorKind
  23560. * - VertexBuffer.MatricesIndicesKind
  23561. * - VertexBuffer.MatricesIndicesExtraKind
  23562. * - VertexBuffer.MatricesWeightsKind
  23563. * - VertexBuffer.MatricesWeightsExtraKind
  23564. * @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
  23565. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23566. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23567. */
  23568. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23569. /**
  23570. * Returns the mesh VertexBuffer object from the requested `kind`
  23571. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23572. * - VertexBuffer.PositionKind
  23573. * - VertexBuffer.NormalKind
  23574. * - VertexBuffer.UVKind
  23575. * - VertexBuffer.UV2Kind
  23576. * - VertexBuffer.UV3Kind
  23577. * - VertexBuffer.UV4Kind
  23578. * - VertexBuffer.UV5Kind
  23579. * - VertexBuffer.UV6Kind
  23580. * - VertexBuffer.ColorKind
  23581. * - VertexBuffer.MatricesIndicesKind
  23582. * - VertexBuffer.MatricesIndicesExtraKind
  23583. * - VertexBuffer.MatricesWeightsKind
  23584. * - VertexBuffer.MatricesWeightsExtraKind
  23585. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23586. */
  23587. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23588. /**
  23589. * Tests if a specific vertex buffer is associated with this mesh
  23590. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23591. * - VertexBuffer.PositionKind
  23592. * - VertexBuffer.NormalKind
  23593. * - VertexBuffer.UVKind
  23594. * - VertexBuffer.UV2Kind
  23595. * - VertexBuffer.UV3Kind
  23596. * - VertexBuffer.UV4Kind
  23597. * - VertexBuffer.UV5Kind
  23598. * - VertexBuffer.UV6Kind
  23599. * - VertexBuffer.ColorKind
  23600. * - VertexBuffer.MatricesIndicesKind
  23601. * - VertexBuffer.MatricesIndicesExtraKind
  23602. * - VertexBuffer.MatricesWeightsKind
  23603. * - VertexBuffer.MatricesWeightsExtraKind
  23604. * @returns a boolean
  23605. */
  23606. isVerticesDataPresent(kind: string): boolean;
  23607. /**
  23608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23609. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23610. * - VertexBuffer.PositionKind
  23611. * - VertexBuffer.UVKind
  23612. * - VertexBuffer.UV2Kind
  23613. * - VertexBuffer.UV3Kind
  23614. * - VertexBuffer.UV4Kind
  23615. * - VertexBuffer.UV5Kind
  23616. * - VertexBuffer.UV6Kind
  23617. * - VertexBuffer.ColorKind
  23618. * - VertexBuffer.MatricesIndicesKind
  23619. * - VertexBuffer.MatricesIndicesExtraKind
  23620. * - VertexBuffer.MatricesWeightsKind
  23621. * - VertexBuffer.MatricesWeightsExtraKind
  23622. * @returns a boolean
  23623. */
  23624. isVertexBufferUpdatable(kind: string): boolean;
  23625. /**
  23626. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23627. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23628. * - VertexBuffer.PositionKind
  23629. * - VertexBuffer.NormalKind
  23630. * - VertexBuffer.UVKind
  23631. * - VertexBuffer.UV2Kind
  23632. * - VertexBuffer.UV3Kind
  23633. * - VertexBuffer.UV4Kind
  23634. * - VertexBuffer.UV5Kind
  23635. * - VertexBuffer.UV6Kind
  23636. * - VertexBuffer.ColorKind
  23637. * - VertexBuffer.MatricesIndicesKind
  23638. * - VertexBuffer.MatricesIndicesExtraKind
  23639. * - VertexBuffer.MatricesWeightsKind
  23640. * - VertexBuffer.MatricesWeightsExtraKind
  23641. * @returns an array of strings
  23642. */
  23643. getVerticesDataKinds(): string[];
  23644. /**
  23645. * Returns a positive integer : the total number of indices in this mesh geometry.
  23646. * @returns the numner of indices or zero if the mesh has no geometry.
  23647. */
  23648. getTotalIndices(): number;
  23649. /**
  23650. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23651. * @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.
  23652. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23653. * @returns the indices array or an empty array if the mesh has no geometry
  23654. */
  23655. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23656. readonly isBlocked: boolean;
  23657. /**
  23658. * Determine if the current mesh is ready to be rendered
  23659. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23660. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23661. * @returns true if all associated assets are ready (material, textures, shaders)
  23662. */
  23663. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23664. /**
  23665. * 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.
  23666. */
  23667. readonly areNormalsFrozen: boolean;
  23668. /**
  23669. * 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.
  23670. * @returns the current mesh
  23671. */
  23672. freezeNormals(): Mesh;
  23673. /**
  23674. * 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
  23675. * @returns the current mesh
  23676. */
  23677. unfreezeNormals(): Mesh;
  23678. /**
  23679. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23680. */
  23681. overridenInstanceCount: number;
  23682. /** @hidden */
  23683. _preActivate(): Mesh;
  23684. /** @hidden */
  23685. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23686. /** @hidden */
  23687. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23688. /**
  23689. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23690. * This means the mesh underlying bounding box and sphere are recomputed.
  23691. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23692. * @returns the current mesh
  23693. */
  23694. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23695. /** @hidden */
  23696. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23697. /**
  23698. * This function will subdivide the mesh into multiple submeshes
  23699. * @param count defines the expected number of submeshes
  23700. */
  23701. subdivide(count: number): void;
  23702. /**
  23703. * Copy a FloatArray into a specific associated vertex buffer
  23704. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23705. * - VertexBuffer.PositionKind
  23706. * - VertexBuffer.UVKind
  23707. * - VertexBuffer.UV2Kind
  23708. * - VertexBuffer.UV3Kind
  23709. * - VertexBuffer.UV4Kind
  23710. * - VertexBuffer.UV5Kind
  23711. * - VertexBuffer.UV6Kind
  23712. * - VertexBuffer.ColorKind
  23713. * - VertexBuffer.MatricesIndicesKind
  23714. * - VertexBuffer.MatricesIndicesExtraKind
  23715. * - VertexBuffer.MatricesWeightsKind
  23716. * - VertexBuffer.MatricesWeightsExtraKind
  23717. * @param data defines the data source
  23718. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23719. * @param stride defines the data stride size (can be null)
  23720. * @returns the current mesh
  23721. */
  23722. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23723. /**
  23724. * Flags an associated vertex buffer as updatable
  23725. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23726. * - VertexBuffer.PositionKind
  23727. * - VertexBuffer.UVKind
  23728. * - VertexBuffer.UV2Kind
  23729. * - VertexBuffer.UV3Kind
  23730. * - VertexBuffer.UV4Kind
  23731. * - VertexBuffer.UV5Kind
  23732. * - VertexBuffer.UV6Kind
  23733. * - VertexBuffer.ColorKind
  23734. * - VertexBuffer.MatricesIndicesKind
  23735. * - VertexBuffer.MatricesIndicesExtraKind
  23736. * - VertexBuffer.MatricesWeightsKind
  23737. * - VertexBuffer.MatricesWeightsExtraKind
  23738. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23739. */
  23740. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23741. /**
  23742. * Sets the mesh global Vertex Buffer
  23743. * @param buffer defines the buffer to use
  23744. * @returns the current mesh
  23745. */
  23746. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23747. /**
  23748. * Update a specific associated vertex buffer
  23749. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23750. * - VertexBuffer.PositionKind
  23751. * - VertexBuffer.UVKind
  23752. * - VertexBuffer.UV2Kind
  23753. * - VertexBuffer.UV3Kind
  23754. * - VertexBuffer.UV4Kind
  23755. * - VertexBuffer.UV5Kind
  23756. * - VertexBuffer.UV6Kind
  23757. * - VertexBuffer.ColorKind
  23758. * - VertexBuffer.MatricesIndicesKind
  23759. * - VertexBuffer.MatricesIndicesExtraKind
  23760. * - VertexBuffer.MatricesWeightsKind
  23761. * - VertexBuffer.MatricesWeightsExtraKind
  23762. * @param data defines the data source
  23763. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23764. * @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)
  23765. * @returns the current mesh
  23766. */
  23767. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23768. /**
  23769. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23770. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23771. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23772. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23773. * @returns the current mesh
  23774. */
  23775. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23776. /**
  23777. * Creates a un-shared specific occurence of the geometry for the mesh.
  23778. * @returns the current mesh
  23779. */
  23780. makeGeometryUnique(): Mesh;
  23781. /**
  23782. * Set the index buffer of this mesh
  23783. * @param indices defines the source data
  23784. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23785. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23786. * @returns the current mesh
  23787. */
  23788. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23789. /**
  23790. * Update the current index buffer
  23791. * @param indices defines the source data
  23792. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23793. * @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)
  23794. * @returns the current mesh
  23795. */
  23796. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23797. /**
  23798. * Invert the geometry to move from a right handed system to a left handed one.
  23799. * @returns the current mesh
  23800. */
  23801. toLeftHanded(): Mesh;
  23802. /** @hidden */
  23803. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23804. /** @hidden */
  23805. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23806. /**
  23807. * Registers for this mesh a javascript function called just before the rendering process
  23808. * @param func defines the function to call before rendering this mesh
  23809. * @returns the current mesh
  23810. */
  23811. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23812. /**
  23813. * Disposes a previously registered javascript function called before the rendering
  23814. * @param func defines the function to remove
  23815. * @returns the current mesh
  23816. */
  23817. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23818. /**
  23819. * Registers for this mesh a javascript function called just after the rendering is complete
  23820. * @param func defines the function to call after rendering this mesh
  23821. * @returns the current mesh
  23822. */
  23823. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23824. /**
  23825. * Disposes a previously registered javascript function called after the rendering.
  23826. * @param func defines the function to remove
  23827. * @returns the current mesh
  23828. */
  23829. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23830. /** @hidden */
  23831. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23832. /** @hidden */
  23833. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23834. /** @hidden */
  23835. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23836. /** @hidden */
  23837. _rebuild(): void;
  23838. /** @hidden */
  23839. _freeze(): void;
  23840. /** @hidden */
  23841. _unFreeze(): void;
  23842. /**
  23843. * 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
  23844. * @param subMesh defines the subMesh to render
  23845. * @param enableAlphaMode defines if alpha mode can be changed
  23846. * @returns the current mesh
  23847. */
  23848. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23849. private _onBeforeDraw;
  23850. /**
  23851. * Renormalize the mesh and patch it up if there are no weights
  23852. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23853. * However in the case of zero weights then we set just a single influence to 1.
  23854. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23855. */
  23856. cleanMatrixWeights(): void;
  23857. private normalizeSkinFourWeights;
  23858. private normalizeSkinWeightsAndExtra;
  23859. /**
  23860. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23861. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23862. * the user know there was an issue with importing the mesh
  23863. * @returns a validation object with skinned, valid and report string
  23864. */
  23865. validateSkinning(): {
  23866. skinned: boolean;
  23867. valid: boolean;
  23868. report: string;
  23869. };
  23870. /** @hidden */
  23871. _checkDelayState(): Mesh;
  23872. private _queueLoad;
  23873. /**
  23874. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23875. * A mesh is in the frustum if its bounding box intersects the frustum
  23876. * @param frustumPlanes defines the frustum to test
  23877. * @returns true if the mesh is in the frustum planes
  23878. */
  23879. isInFrustum(frustumPlanes: Plane[]): boolean;
  23880. /**
  23881. * Sets the mesh material by the material or multiMaterial `id` property
  23882. * @param id is a string identifying the material or the multiMaterial
  23883. * @returns the current mesh
  23884. */
  23885. setMaterialByID(id: string): Mesh;
  23886. /**
  23887. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23888. * @returns an array of IAnimatable
  23889. */
  23890. getAnimatables(): IAnimatable[];
  23891. /**
  23892. * Modifies the mesh geometry according to the passed transformation matrix.
  23893. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23894. * The mesh normals are modified using the same transformation.
  23895. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23896. * @param transform defines the transform matrix to use
  23897. * @see http://doc.babylonjs.com/resources/baking_transformations
  23898. * @returns the current mesh
  23899. */
  23900. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23901. /**
  23902. * Modifies the mesh geometry according to its own current World Matrix.
  23903. * The mesh World Matrix is then reset.
  23904. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23905. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23906. * @see http://doc.babylonjs.com/resources/baking_transformations
  23907. * @returns the current mesh
  23908. */
  23909. bakeCurrentTransformIntoVertices(): Mesh;
  23910. /** @hidden */
  23911. readonly _positions: Nullable<Vector3[]>;
  23912. /** @hidden */
  23913. _resetPointsArrayCache(): Mesh;
  23914. /** @hidden */
  23915. _generatePointsArray(): boolean;
  23916. /**
  23917. * Returns a new Mesh object generated from the current mesh properties.
  23918. * This method must not get confused with createInstance()
  23919. * @param name is a string, the name given to the new mesh
  23920. * @param newParent can be any Node object (default `null`)
  23921. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23922. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23923. * @returns a new mesh
  23924. */
  23925. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23926. /**
  23927. * Releases resources associated with this mesh.
  23928. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23929. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23930. */
  23931. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23932. /**
  23933. * Modifies the mesh geometry according to a displacement map.
  23934. * 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.
  23935. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23936. * @param url is a string, the URL from the image file is to be downloaded.
  23937. * @param minHeight is the lower limit of the displacement.
  23938. * @param maxHeight is the upper limit of the displacement.
  23939. * @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.
  23940. * @param uvOffset is an optional vector2 used to offset UV.
  23941. * @param uvScale is an optional vector2 used to scale UV.
  23942. * @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.
  23943. * @returns the Mesh.
  23944. */
  23945. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23946. /**
  23947. * Modifies the mesh geometry according to a displacementMap buffer.
  23948. * 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.
  23949. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23950. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23951. * @param heightMapWidth is the width of the buffer image.
  23952. * @param heightMapHeight is the height of the buffer image.
  23953. * @param minHeight is the lower limit of the displacement.
  23954. * @param maxHeight is the upper limit of the displacement.
  23955. * @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.
  23956. * @param uvOffset is an optional vector2 used to offset UV.
  23957. * @param uvScale is an optional vector2 used to scale UV.
  23958. * @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.
  23959. * @returns the Mesh.
  23960. */
  23961. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23962. /**
  23963. * Modify the mesh to get a flat shading rendering.
  23964. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23965. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23966. * @returns current mesh
  23967. */
  23968. convertToFlatShadedMesh(): Mesh;
  23969. /**
  23970. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23971. * In other words, more vertices, no more indices and a single bigger VBO.
  23972. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23973. * @returns current mesh
  23974. */
  23975. convertToUnIndexedMesh(): Mesh;
  23976. /**
  23977. * Inverses facet orientations.
  23978. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23979. * @param flipNormals will also inverts the normals
  23980. * @returns current mesh
  23981. */
  23982. flipFaces(flipNormals?: boolean): Mesh;
  23983. /**
  23984. * Increase the number of facets and hence vertices in a mesh
  23985. * Vertex normals are interpolated from existing vertex normals
  23986. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23987. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23988. */
  23989. increaseVertices(numberPerEdge: number): void;
  23990. /**
  23991. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23992. * This will undo any application of covertToFlatShadedMesh
  23993. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23994. */
  23995. forceSharedVertices(): void;
  23996. /** @hidden */
  23997. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23998. /** @hidden */
  23999. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24000. /**
  24001. * Creates a new InstancedMesh object from the mesh model.
  24002. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24003. * @param name defines the name of the new instance
  24004. * @returns a new InstancedMesh
  24005. */
  24006. createInstance(name: string): InstancedMesh;
  24007. /**
  24008. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24009. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24010. * @returns the current mesh
  24011. */
  24012. synchronizeInstances(): Mesh;
  24013. /**
  24014. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24015. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24016. * This should be used together with the simplification to avoid disappearing triangles.
  24017. * @param successCallback an optional success callback to be called after the optimization finished.
  24018. * @returns the current mesh
  24019. */
  24020. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24021. /**
  24022. * Serialize current mesh
  24023. * @param serializationObject defines the object which will receive the serialization data
  24024. */
  24025. serialize(serializationObject: any): void;
  24026. /** @hidden */
  24027. _syncGeometryWithMorphTargetManager(): void;
  24028. /** @hidden */
  24029. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24030. /**
  24031. * Returns a new Mesh object parsed from the source provided.
  24032. * @param parsedMesh is the source
  24033. * @param scene defines the hosting scene
  24034. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24035. * @returns a new Mesh
  24036. */
  24037. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24038. /**
  24039. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24040. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24041. * @param name defines the name of the mesh to create
  24042. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24043. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24044. * @param closePath creates a seam between the first and the last points of each path of the path array
  24045. * @param offset is taken in account only if the `pathArray` is containing a single path
  24046. * @param scene defines the hosting scene
  24047. * @param updatable defines if the mesh must be flagged as updatable
  24048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24049. * @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)
  24050. * @returns a new Mesh
  24051. */
  24052. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24053. /**
  24054. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24055. * @param name defines the name of the mesh to create
  24056. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24057. * @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
  24058. * @param scene defines the hosting scene
  24059. * @param updatable defines if the mesh must be flagged as updatable
  24060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24061. * @returns a new Mesh
  24062. */
  24063. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24064. /**
  24065. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24066. * @param name defines the name of the mesh to create
  24067. * @param size sets the size (float) of each box side (default 1)
  24068. * @param scene defines the hosting scene
  24069. * @param updatable defines if the mesh must be flagged as updatable
  24070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24071. * @returns a new Mesh
  24072. */
  24073. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24074. /**
  24075. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24076. * @param name defines the name of the mesh to create
  24077. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24078. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24079. * @param scene defines the hosting scene
  24080. * @param updatable defines if the mesh must be flagged as updatable
  24081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24082. * @returns a new Mesh
  24083. */
  24084. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24085. /**
  24086. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24087. * @param name defines the name of the mesh to create
  24088. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24089. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24090. * @param scene defines the hosting scene
  24091. * @returns a new Mesh
  24092. */
  24093. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24094. /**
  24095. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24096. * @param name defines the name of the mesh to create
  24097. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24098. * @param diameterTop set the top cap diameter (floats, default 1)
  24099. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24100. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24101. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24102. * @param scene defines the hosting scene
  24103. * @param updatable defines if the mesh must be flagged as updatable
  24104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24105. * @returns a new Mesh
  24106. */
  24107. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24108. /**
  24109. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24110. * @param name defines the name of the mesh to create
  24111. * @param diameter sets the diameter size (float) of the torus (default 1)
  24112. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24113. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24114. * @param scene defines the hosting scene
  24115. * @param updatable defines if the mesh must be flagged as updatable
  24116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24117. * @returns a new Mesh
  24118. */
  24119. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24120. /**
  24121. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24122. * @param name defines the name of the mesh to create
  24123. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24124. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24125. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24126. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24127. * @param p the number of windings on X axis (positive integers, default 2)
  24128. * @param q the number of windings on Y axis (positive integers, default 3)
  24129. * @param scene defines the hosting scene
  24130. * @param updatable defines if the mesh must be flagged as updatable
  24131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24132. * @returns a new Mesh
  24133. */
  24134. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24135. /**
  24136. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24137. * @param name defines the name of the mesh to create
  24138. * @param points is an array successive Vector3
  24139. * @param scene defines the hosting scene
  24140. * @param updatable defines if the mesh must be flagged as updatable
  24141. * @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).
  24142. * @returns a new Mesh
  24143. */
  24144. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24145. /**
  24146. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24147. * @param name defines the name of the mesh to create
  24148. * @param points is an array successive Vector3
  24149. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24150. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24151. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24152. * @param scene defines the hosting scene
  24153. * @param updatable defines if the mesh must be flagged as updatable
  24154. * @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)
  24155. * @returns a new Mesh
  24156. */
  24157. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24158. /**
  24159. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24160. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24161. * 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.
  24162. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24163. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24164. * Remember you can only change the shape positions, not their number when updating a polygon.
  24165. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24166. * @param name defines the name of the mesh to create
  24167. * @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
  24168. * @param scene defines the hosting scene
  24169. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24170. * @param updatable defines if the mesh must be flagged as updatable
  24171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24172. * @param earcutInjection can be used to inject your own earcut reference
  24173. * @returns a new Mesh
  24174. */
  24175. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24176. /**
  24177. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24178. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24179. * @param name defines the name of the mesh to create
  24180. * @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
  24181. * @param depth defines the height of extrusion
  24182. * @param scene defines the hosting scene
  24183. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24184. * @param updatable defines if the mesh must be flagged as updatable
  24185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24186. * @param earcutInjection can be used to inject your own earcut reference
  24187. * @returns a new Mesh
  24188. */
  24189. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24190. /**
  24191. * Creates an extruded shape mesh.
  24192. * 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
  24193. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24195. * @param name defines the name of the mesh to create
  24196. * @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
  24197. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24198. * @param scale is the value to scale the shape
  24199. * @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
  24200. * @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
  24201. * @param scene defines the hosting scene
  24202. * @param updatable defines if the mesh must be flagged as updatable
  24203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24204. * @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)
  24205. * @returns a new Mesh
  24206. */
  24207. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24208. /**
  24209. * Creates an custom extruded shape mesh.
  24210. * The custom extrusion is a parametric shape.
  24211. * It has no predefined shape. Its final shape will depend on the input parameters.
  24212. * Please consider using the same method from the MeshBuilder class instead
  24213. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24214. * @param name defines the name of the mesh to create
  24215. * @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
  24216. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24217. * @param scaleFunction is a custom Javascript function called on each path point
  24218. * @param rotationFunction is a custom Javascript function called on each path point
  24219. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24220. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24221. * @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
  24222. * @param scene defines the hosting scene
  24223. * @param updatable defines if the mesh must be flagged as updatable
  24224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24225. * @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)
  24226. * @returns a new Mesh
  24227. */
  24228. 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;
  24229. /**
  24230. * Creates lathe mesh.
  24231. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24232. * Please consider using the same method from the MeshBuilder class instead
  24233. * @param name defines the name of the mesh to create
  24234. * @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
  24235. * @param radius is the radius value of the lathe
  24236. * @param tessellation is the side number of the lathe.
  24237. * @param scene defines the hosting scene
  24238. * @param updatable defines if the mesh must be flagged as updatable
  24239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24240. * @returns a new Mesh
  24241. */
  24242. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24243. /**
  24244. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24245. * @param name defines the name of the mesh to create
  24246. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24247. * @param scene defines the hosting scene
  24248. * @param updatable defines if the mesh must be flagged as updatable
  24249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24250. * @returns a new Mesh
  24251. */
  24252. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24253. /**
  24254. * Creates a ground mesh.
  24255. * Please consider using the same method from the MeshBuilder class instead
  24256. * @param name defines the name of the mesh to create
  24257. * @param width set the width of the ground
  24258. * @param height set the height of the ground
  24259. * @param subdivisions sets the number of subdivisions per side
  24260. * @param scene defines the hosting scene
  24261. * @param updatable defines if the mesh must be flagged as updatable
  24262. * @returns a new Mesh
  24263. */
  24264. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24265. /**
  24266. * Creates a tiled ground mesh.
  24267. * Please consider using the same method from the MeshBuilder class instead
  24268. * @param name defines the name of the mesh to create
  24269. * @param xmin set the ground minimum X coordinate
  24270. * @param zmin set the ground minimum Y coordinate
  24271. * @param xmax set the ground maximum X coordinate
  24272. * @param zmax set the ground maximum Z coordinate
  24273. * @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
  24274. * @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
  24275. * @param scene defines the hosting scene
  24276. * @param updatable defines if the mesh must be flagged as updatable
  24277. * @returns a new Mesh
  24278. */
  24279. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24280. w: number;
  24281. h: number;
  24282. }, precision: {
  24283. w: number;
  24284. h: number;
  24285. }, scene: Scene, updatable?: boolean): Mesh;
  24286. /**
  24287. * Creates a ground mesh from a height map.
  24288. * Please consider using the same method from the MeshBuilder class instead
  24289. * @see http://doc.babylonjs.com/babylon101/height_map
  24290. * @param name defines the name of the mesh to create
  24291. * @param url sets the URL of the height map image resource
  24292. * @param width set the ground width size
  24293. * @param height set the ground height size
  24294. * @param subdivisions sets the number of subdivision per side
  24295. * @param minHeight is the minimum altitude on the ground
  24296. * @param maxHeight is the maximum altitude on the ground
  24297. * @param scene defines the hosting scene
  24298. * @param updatable defines if the mesh must be flagged as updatable
  24299. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24300. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24301. * @returns a new Mesh
  24302. */
  24303. 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;
  24304. /**
  24305. * Creates a tube mesh.
  24306. * The tube is a parametric shape.
  24307. * It has no predefined shape. Its final shape will depend on the input parameters.
  24308. * Please consider using the same method from the MeshBuilder class instead
  24309. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24310. * @param name defines the name of the mesh to create
  24311. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24312. * @param radius sets the tube radius size
  24313. * @param tessellation is the number of sides on the tubular surface
  24314. * @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
  24315. * @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
  24316. * @param scene defines the hosting scene
  24317. * @param updatable defines if the mesh must be flagged as updatable
  24318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24319. * @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)
  24320. * @returns a new Mesh
  24321. */
  24322. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24323. (i: number, distance: number): number;
  24324. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24325. /**
  24326. * Creates a polyhedron mesh.
  24327. * Please consider using the same method from the MeshBuilder class instead.
  24328. * * 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
  24329. * * The parameter `size` (positive float, default 1) sets the polygon size
  24330. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24331. * * 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`
  24332. * * 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
  24333. * * 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)`)
  24334. * * 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
  24335. * * 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
  24336. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24337. * * 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
  24338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24339. * @param name defines the name of the mesh to create
  24340. * @param options defines the options used to create the mesh
  24341. * @param scene defines the hosting scene
  24342. * @returns a new Mesh
  24343. */
  24344. static CreatePolyhedron(name: string, options: {
  24345. type?: number;
  24346. size?: number;
  24347. sizeX?: number;
  24348. sizeY?: number;
  24349. sizeZ?: number;
  24350. custom?: any;
  24351. faceUV?: Vector4[];
  24352. faceColors?: Color4[];
  24353. updatable?: boolean;
  24354. sideOrientation?: number;
  24355. }, scene: Scene): Mesh;
  24356. /**
  24357. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24358. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24359. * * 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`)
  24360. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24361. * * 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
  24362. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24363. * * 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
  24364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24365. * @param name defines the name of the mesh
  24366. * @param options defines the options used to create the mesh
  24367. * @param scene defines the hosting scene
  24368. * @returns a new Mesh
  24369. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24370. */
  24371. static CreateIcoSphere(name: string, options: {
  24372. radius?: number;
  24373. flat?: boolean;
  24374. subdivisions?: number;
  24375. sideOrientation?: number;
  24376. updatable?: boolean;
  24377. }, scene: Scene): Mesh;
  24378. /**
  24379. * Creates a decal mesh.
  24380. * Please consider using the same method from the MeshBuilder class instead.
  24381. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24382. * @param name defines the name of the mesh
  24383. * @param sourceMesh defines the mesh receiving the decal
  24384. * @param position sets the position of the decal in world coordinates
  24385. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24386. * @param size sets the decal scaling
  24387. * @param angle sets the angle to rotate the decal
  24388. * @returns a new Mesh
  24389. */
  24390. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24391. /**
  24392. * Prepare internal position array for software CPU skinning
  24393. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24394. */
  24395. setPositionsForCPUSkinning(): Float32Array;
  24396. /**
  24397. * Prepare internal normal array for software CPU skinning
  24398. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24399. */
  24400. setNormalsForCPUSkinning(): Float32Array;
  24401. /**
  24402. * Updates the vertex buffer by applying transformation from the bones
  24403. * @param skeleton defines the skeleton to apply to current mesh
  24404. * @returns the current mesh
  24405. */
  24406. applySkeleton(skeleton: Skeleton): Mesh;
  24407. /**
  24408. * 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
  24409. * @param meshes defines the list of meshes to scan
  24410. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24411. */
  24412. static MinMax(meshes: AbstractMesh[]): {
  24413. min: Vector3;
  24414. max: Vector3;
  24415. };
  24416. /**
  24417. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24418. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24419. * @returns a vector3
  24420. */
  24421. static Center(meshesOrMinMaxVector: {
  24422. min: Vector3;
  24423. max: Vector3;
  24424. } | AbstractMesh[]): Vector3;
  24425. /**
  24426. * Merge the array of meshes into a single mesh for performance reasons.
  24427. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24428. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24429. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24430. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24431. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24432. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24433. * @returns a new mesh
  24434. */
  24435. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24436. /** @hidden */
  24437. addInstance(instance: InstancedMesh): void;
  24438. /** @hidden */
  24439. removeInstance(instance: InstancedMesh): void;
  24440. }
  24441. }
  24442. declare module BABYLON {
  24443. /**
  24444. * This is the base class of all the camera used in the application.
  24445. * @see http://doc.babylonjs.com/features/cameras
  24446. */
  24447. export class Camera extends Node {
  24448. /** @hidden */
  24449. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24450. /**
  24451. * This is the default projection mode used by the cameras.
  24452. * It helps recreating a feeling of perspective and better appreciate depth.
  24453. * This is the best way to simulate real life cameras.
  24454. */
  24455. static readonly PERSPECTIVE_CAMERA: number;
  24456. /**
  24457. * This helps creating camera with an orthographic mode.
  24458. * 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.
  24459. */
  24460. static readonly ORTHOGRAPHIC_CAMERA: number;
  24461. /**
  24462. * This is the default FOV mode for perspective cameras.
  24463. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24464. */
  24465. static readonly FOVMODE_VERTICAL_FIXED: number;
  24466. /**
  24467. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24468. */
  24469. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24470. /**
  24471. * This specifies ther is no need for a camera rig.
  24472. * Basically only one eye is rendered corresponding to the camera.
  24473. */
  24474. static readonly RIG_MODE_NONE: number;
  24475. /**
  24476. * Simulates a camera Rig with one blue eye and one red eye.
  24477. * This can be use with 3d blue and red glasses.
  24478. */
  24479. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24480. /**
  24481. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24482. */
  24483. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24484. /**
  24485. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24486. */
  24487. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24488. /**
  24489. * Defines that both eyes of the camera will be rendered over under each other.
  24490. */
  24491. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24492. /**
  24493. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24494. */
  24495. static readonly RIG_MODE_VR: number;
  24496. /**
  24497. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24498. */
  24499. static readonly RIG_MODE_WEBVR: number;
  24500. /**
  24501. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24502. */
  24503. static readonly RIG_MODE_CUSTOM: number;
  24504. /**
  24505. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24506. */
  24507. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24508. /**
  24509. * Define the input manager associated with the camera.
  24510. */
  24511. inputs: CameraInputsManager<Camera>;
  24512. /** @hidden */
  24513. _position: Vector3;
  24514. /**
  24515. * Define the current local position of the camera in the scene
  24516. */
  24517. position: Vector3;
  24518. /**
  24519. * The vector the camera should consider as up.
  24520. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24521. */
  24522. upVector: Vector3;
  24523. /**
  24524. * Define the current limit on the left side for an orthographic camera
  24525. * In scene unit
  24526. */
  24527. orthoLeft: Nullable<number>;
  24528. /**
  24529. * Define the current limit on the right side for an orthographic camera
  24530. * In scene unit
  24531. */
  24532. orthoRight: Nullable<number>;
  24533. /**
  24534. * Define the current limit on the bottom side for an orthographic camera
  24535. * In scene unit
  24536. */
  24537. orthoBottom: Nullable<number>;
  24538. /**
  24539. * Define the current limit on the top side for an orthographic camera
  24540. * In scene unit
  24541. */
  24542. orthoTop: Nullable<number>;
  24543. /**
  24544. * Field Of View is set in Radians. (default is 0.8)
  24545. */
  24546. fov: number;
  24547. /**
  24548. * Define the minimum distance the camera can see from.
  24549. * This is important to note that the depth buffer are not infinite and the closer it starts
  24550. * the more your scene might encounter depth fighting issue.
  24551. */
  24552. minZ: number;
  24553. /**
  24554. * Define the maximum distance the camera can see to.
  24555. * This is important to note that the depth buffer are not infinite and the further it end
  24556. * the more your scene might encounter depth fighting issue.
  24557. */
  24558. maxZ: number;
  24559. /**
  24560. * Define the default inertia of the camera.
  24561. * This helps giving a smooth feeling to the camera movement.
  24562. */
  24563. inertia: number;
  24564. /**
  24565. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24566. */
  24567. mode: number;
  24568. /**
  24569. * Define wether the camera is intermediate.
  24570. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24571. */
  24572. isIntermediate: boolean;
  24573. /**
  24574. * Define the viewport of the camera.
  24575. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24576. */
  24577. viewport: Viewport;
  24578. /**
  24579. * Restricts the camera to viewing objects with the same layerMask.
  24580. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24581. */
  24582. layerMask: number;
  24583. /**
  24584. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24585. */
  24586. fovMode: number;
  24587. /**
  24588. * Rig mode of the camera.
  24589. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24590. * This is normally controlled byt the camera themselves as internal use.
  24591. */
  24592. cameraRigMode: number;
  24593. /**
  24594. * Defines the distance between both "eyes" in case of a RIG
  24595. */
  24596. interaxialDistance: number;
  24597. /**
  24598. * Defines if stereoscopic rendering is done side by side or over under.
  24599. */
  24600. isStereoscopicSideBySide: boolean;
  24601. /**
  24602. * 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
  24603. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24604. * else in the scene. (Eg. security camera)
  24605. *
  24606. * 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)
  24607. */
  24608. customRenderTargets: RenderTargetTexture[];
  24609. /**
  24610. * When set, the camera will render to this render target instead of the default canvas
  24611. *
  24612. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24613. */
  24614. outputRenderTarget: Nullable<RenderTargetTexture>;
  24615. /**
  24616. * Observable triggered when the camera view matrix has changed.
  24617. */
  24618. onViewMatrixChangedObservable: Observable<Camera>;
  24619. /**
  24620. * Observable triggered when the camera Projection matrix has changed.
  24621. */
  24622. onProjectionMatrixChangedObservable: Observable<Camera>;
  24623. /**
  24624. * Observable triggered when the inputs have been processed.
  24625. */
  24626. onAfterCheckInputsObservable: Observable<Camera>;
  24627. /**
  24628. * Observable triggered when reset has been called and applied to the camera.
  24629. */
  24630. onRestoreStateObservable: Observable<Camera>;
  24631. /** @hidden */
  24632. _cameraRigParams: any;
  24633. /** @hidden */
  24634. _rigCameras: Camera[];
  24635. /** @hidden */
  24636. _rigPostProcess: Nullable<PostProcess>;
  24637. protected _webvrViewMatrix: Matrix;
  24638. /** @hidden */
  24639. _skipRendering: boolean;
  24640. /** @hidden */
  24641. _projectionMatrix: Matrix;
  24642. /** @hidden */
  24643. _postProcesses: Nullable<PostProcess>[];
  24644. /** @hidden */
  24645. _activeMeshes: SmartArray<AbstractMesh>;
  24646. protected _globalPosition: Vector3;
  24647. /** @hidden */
  24648. _computedViewMatrix: Matrix;
  24649. private _doNotComputeProjectionMatrix;
  24650. private _transformMatrix;
  24651. private _frustumPlanes;
  24652. private _refreshFrustumPlanes;
  24653. private _storedFov;
  24654. private _stateStored;
  24655. /**
  24656. * Instantiates a new camera object.
  24657. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24658. * @see http://doc.babylonjs.com/features/cameras
  24659. * @param name Defines the name of the camera in the scene
  24660. * @param position Defines the position of the camera
  24661. * @param scene Defines the scene the camera belongs too
  24662. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24663. */
  24664. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24665. /**
  24666. * Store current camera state (fov, position, etc..)
  24667. * @returns the camera
  24668. */
  24669. storeState(): Camera;
  24670. /**
  24671. * Restores the camera state values if it has been stored. You must call storeState() first
  24672. */
  24673. protected _restoreStateValues(): boolean;
  24674. /**
  24675. * Restored camera state. You must call storeState() first.
  24676. * @returns true if restored and false otherwise
  24677. */
  24678. restoreState(): boolean;
  24679. /**
  24680. * Gets the class name of the camera.
  24681. * @returns the class name
  24682. */
  24683. getClassName(): string;
  24684. /** @hidden */
  24685. readonly _isCamera: boolean;
  24686. /**
  24687. * Gets a string representation of the camera useful for debug purpose.
  24688. * @param fullDetails Defines that a more verboe level of logging is required
  24689. * @returns the string representation
  24690. */
  24691. toString(fullDetails?: boolean): string;
  24692. /**
  24693. * Gets the current world space position of the camera.
  24694. */
  24695. readonly globalPosition: Vector3;
  24696. /**
  24697. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24698. * @returns the active meshe list
  24699. */
  24700. getActiveMeshes(): SmartArray<AbstractMesh>;
  24701. /**
  24702. * Check wether a mesh is part of the current active mesh list of the camera
  24703. * @param mesh Defines the mesh to check
  24704. * @returns true if active, false otherwise
  24705. */
  24706. isActiveMesh(mesh: Mesh): boolean;
  24707. /**
  24708. * Is this camera ready to be used/rendered
  24709. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24710. * @return true if the camera is ready
  24711. */
  24712. isReady(completeCheck?: boolean): boolean;
  24713. /** @hidden */
  24714. _initCache(): void;
  24715. /** @hidden */
  24716. _updateCache(ignoreParentClass?: boolean): void;
  24717. /** @hidden */
  24718. _isSynchronized(): boolean;
  24719. /** @hidden */
  24720. _isSynchronizedViewMatrix(): boolean;
  24721. /** @hidden */
  24722. _isSynchronizedProjectionMatrix(): boolean;
  24723. /**
  24724. * Attach the input controls to a specific dom element to get the input from.
  24725. * @param element Defines the element the controls should be listened from
  24726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24727. */
  24728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24729. /**
  24730. * Detach the current controls from the specified dom element.
  24731. * @param element Defines the element to stop listening the inputs from
  24732. */
  24733. detachControl(element: HTMLElement): void;
  24734. /**
  24735. * Update the camera state according to the different inputs gathered during the frame.
  24736. */
  24737. update(): void;
  24738. /** @hidden */
  24739. _checkInputs(): void;
  24740. /** @hidden */
  24741. readonly rigCameras: Camera[];
  24742. /**
  24743. * Gets the post process used by the rig cameras
  24744. */
  24745. readonly rigPostProcess: Nullable<PostProcess>;
  24746. /**
  24747. * Internal, gets the first post proces.
  24748. * @returns the first post process to be run on this camera.
  24749. */
  24750. _getFirstPostProcess(): Nullable<PostProcess>;
  24751. private _cascadePostProcessesToRigCams;
  24752. /**
  24753. * Attach a post process to the camera.
  24754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24755. * @param postProcess The post process to attach to the camera
  24756. * @param insertAt The position of the post process in case several of them are in use in the scene
  24757. * @returns the position the post process has been inserted at
  24758. */
  24759. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24760. /**
  24761. * Detach a post process to the camera.
  24762. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24763. * @param postProcess The post process to detach from the camera
  24764. */
  24765. detachPostProcess(postProcess: PostProcess): void;
  24766. /**
  24767. * Gets the current world matrix of the camera
  24768. */
  24769. getWorldMatrix(): Matrix;
  24770. /** @hidden */
  24771. _getViewMatrix(): Matrix;
  24772. /**
  24773. * Gets the current view matrix of the camera.
  24774. * @param force forces the camera to recompute the matrix without looking at the cached state
  24775. * @returns the view matrix
  24776. */
  24777. getViewMatrix(force?: boolean): Matrix;
  24778. /**
  24779. * Freeze the projection matrix.
  24780. * It will prevent the cache check of the camera projection compute and can speed up perf
  24781. * if no parameter of the camera are meant to change
  24782. * @param projection Defines manually a projection if necessary
  24783. */
  24784. freezeProjectionMatrix(projection?: Matrix): void;
  24785. /**
  24786. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24787. */
  24788. unfreezeProjectionMatrix(): void;
  24789. /**
  24790. * Gets the current projection matrix of the camera.
  24791. * @param force forces the camera to recompute the matrix without looking at the cached state
  24792. * @returns the projection matrix
  24793. */
  24794. getProjectionMatrix(force?: boolean): Matrix;
  24795. /**
  24796. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24797. * @returns a Matrix
  24798. */
  24799. getTransformationMatrix(): Matrix;
  24800. private _updateFrustumPlanes;
  24801. /**
  24802. * Checks if a cullable object (mesh...) is in the camera frustum
  24803. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24804. * @param target The object to check
  24805. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24806. * @returns true if the object is in frustum otherwise false
  24807. */
  24808. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24809. /**
  24810. * Checks if a cullable object (mesh...) is in the camera frustum
  24811. * Unlike isInFrustum this cheks the full bounding box
  24812. * @param target The object to check
  24813. * @returns true if the object is in frustum otherwise false
  24814. */
  24815. isCompletelyInFrustum(target: ICullable): boolean;
  24816. /**
  24817. * Gets a ray in the forward direction from the camera.
  24818. * @param length Defines the length of the ray to create
  24819. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24820. * @param origin Defines the start point of the ray which defaults to the camera position
  24821. * @returns the forward ray
  24822. */
  24823. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24824. /**
  24825. * Releases resources associated with this node.
  24826. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24827. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24828. */
  24829. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24830. /** @hidden */
  24831. _isLeftCamera: boolean;
  24832. /**
  24833. * Gets the left camera of a rig setup in case of Rigged Camera
  24834. */
  24835. readonly isLeftCamera: boolean;
  24836. /** @hidden */
  24837. _isRightCamera: boolean;
  24838. /**
  24839. * Gets the right camera of a rig setup in case of Rigged Camera
  24840. */
  24841. readonly isRightCamera: boolean;
  24842. /**
  24843. * Gets the left camera of a rig setup in case of Rigged Camera
  24844. */
  24845. readonly leftCamera: Nullable<FreeCamera>;
  24846. /**
  24847. * Gets the right camera of a rig setup in case of Rigged Camera
  24848. */
  24849. readonly rightCamera: Nullable<FreeCamera>;
  24850. /**
  24851. * Gets the left camera target of a rig setup in case of Rigged Camera
  24852. * @returns the target position
  24853. */
  24854. getLeftTarget(): Nullable<Vector3>;
  24855. /**
  24856. * Gets the right camera target of a rig setup in case of Rigged Camera
  24857. * @returns the target position
  24858. */
  24859. getRightTarget(): Nullable<Vector3>;
  24860. /**
  24861. * @hidden
  24862. */
  24863. setCameraRigMode(mode: number, rigParams: any): void;
  24864. /** @hidden */
  24865. static _setStereoscopicRigMode(camera: Camera): void;
  24866. /** @hidden */
  24867. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24868. /** @hidden */
  24869. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24870. /** @hidden */
  24871. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24872. /** @hidden */
  24873. _getVRProjectionMatrix(): Matrix;
  24874. protected _updateCameraRotationMatrix(): void;
  24875. protected _updateWebVRCameraRotationMatrix(): void;
  24876. /**
  24877. * This function MUST be overwritten by the different WebVR cameras available.
  24878. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24879. * @hidden
  24880. */
  24881. _getWebVRProjectionMatrix(): Matrix;
  24882. /**
  24883. * This function MUST be overwritten by the different WebVR cameras available.
  24884. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24885. * @hidden
  24886. */
  24887. _getWebVRViewMatrix(): Matrix;
  24888. /** @hidden */
  24889. setCameraRigParameter(name: string, value: any): void;
  24890. /**
  24891. * needs to be overridden by children so sub has required properties to be copied
  24892. * @hidden
  24893. */
  24894. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24895. /**
  24896. * May need to be overridden by children
  24897. * @hidden
  24898. */
  24899. _updateRigCameras(): void;
  24900. /** @hidden */
  24901. _setupInputs(): void;
  24902. /**
  24903. * Serialiaze the camera setup to a json represention
  24904. * @returns the JSON representation
  24905. */
  24906. serialize(): any;
  24907. /**
  24908. * Clones the current camera.
  24909. * @param name The cloned camera name
  24910. * @returns the cloned camera
  24911. */
  24912. clone(name: string): Camera;
  24913. /**
  24914. * Gets the direction of the camera relative to a given local axis.
  24915. * @param localAxis Defines the reference axis to provide a relative direction.
  24916. * @return the direction
  24917. */
  24918. getDirection(localAxis: Vector3): Vector3;
  24919. /**
  24920. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24921. * @param localAxis Defines the reference axis to provide a relative direction.
  24922. * @param result Defines the vector to store the result in
  24923. */
  24924. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24925. /**
  24926. * Gets a camera constructor for a given camera type
  24927. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24928. * @param name The name of the camera the result will be able to instantiate
  24929. * @param scene The scene the result will construct the camera in
  24930. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24931. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24932. * @returns a factory method to construc the camera
  24933. */
  24934. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24935. /**
  24936. * Compute the world matrix of the camera.
  24937. * @returns the camera workd matrix
  24938. */
  24939. computeWorldMatrix(): Matrix;
  24940. /**
  24941. * Parse a JSON and creates the camera from the parsed information
  24942. * @param parsedCamera The JSON to parse
  24943. * @param scene The scene to instantiate the camera in
  24944. * @returns the newly constructed camera
  24945. */
  24946. static Parse(parsedCamera: any, scene: Scene): Camera;
  24947. }
  24948. }
  24949. declare module BABYLON {
  24950. /**
  24951. * Class containing static functions to help procedurally build meshes
  24952. */
  24953. export class DiscBuilder {
  24954. /**
  24955. * Creates a plane polygonal mesh. By default, this is a disc
  24956. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24957. * * 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
  24958. * * 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
  24959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24960. * * 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
  24961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24962. * @param name defines the name of the mesh
  24963. * @param options defines the options used to create the mesh
  24964. * @param scene defines the hosting scene
  24965. * @returns the plane polygonal mesh
  24966. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24967. */
  24968. static CreateDisc(name: string, options: {
  24969. radius?: number;
  24970. tessellation?: number;
  24971. arc?: number;
  24972. updatable?: boolean;
  24973. sideOrientation?: number;
  24974. frontUVs?: Vector4;
  24975. backUVs?: Vector4;
  24976. }, scene?: Nullable<Scene>): Mesh;
  24977. }
  24978. }
  24979. declare module BABYLON {
  24980. /**
  24981. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24982. *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.
  24983. * The SPS is also a particle system. It provides some methods to manage the particles.
  24984. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24985. *
  24986. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24987. */
  24988. export class SolidParticleSystem implements IDisposable {
  24989. /**
  24990. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24991. * Example : var p = SPS.particles[i];
  24992. */
  24993. particles: SolidParticle[];
  24994. /**
  24995. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24996. */
  24997. nbParticles: number;
  24998. /**
  24999. * If the particles must ever face the camera (default false). Useful for planar particles.
  25000. */
  25001. billboard: boolean;
  25002. /**
  25003. * Recompute normals when adding a shape
  25004. */
  25005. recomputeNormals: boolean;
  25006. /**
  25007. * This a counter ofr your own usage. It's not set by any SPS functions.
  25008. */
  25009. counter: number;
  25010. /**
  25011. * The SPS name. This name is also given to the underlying mesh.
  25012. */
  25013. name: string;
  25014. /**
  25015. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25016. */
  25017. mesh: Mesh;
  25018. /**
  25019. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25020. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25021. */
  25022. vars: any;
  25023. /**
  25024. * This array is populated when the SPS is set as 'pickable'.
  25025. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25026. * Each element of this array is an object `{idx: int, faceId: int}`.
  25027. * `idx` is the picked particle index in the `SPS.particles` array
  25028. * `faceId` is the picked face index counted within this particle.
  25029. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25030. */
  25031. pickedParticles: {
  25032. idx: number;
  25033. faceId: number;
  25034. }[];
  25035. /**
  25036. * This array is populated when `enableDepthSort` is set to true.
  25037. * Each element of this array is an instance of the class DepthSortedParticle.
  25038. */
  25039. depthSortedParticles: DepthSortedParticle[];
  25040. /**
  25041. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25042. * @hidden
  25043. */
  25044. _bSphereOnly: boolean;
  25045. /**
  25046. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25047. * @hidden
  25048. */
  25049. _bSphereRadiusFactor: number;
  25050. private _scene;
  25051. private _positions;
  25052. private _indices;
  25053. private _normals;
  25054. private _colors;
  25055. private _uvs;
  25056. private _indices32;
  25057. private _positions32;
  25058. private _normals32;
  25059. private _fixedNormal32;
  25060. private _colors32;
  25061. private _uvs32;
  25062. private _index;
  25063. private _updatable;
  25064. private _pickable;
  25065. private _isVisibilityBoxLocked;
  25066. private _alwaysVisible;
  25067. private _depthSort;
  25068. private _shapeCounter;
  25069. private _copy;
  25070. private _color;
  25071. private _computeParticleColor;
  25072. private _computeParticleTexture;
  25073. private _computeParticleRotation;
  25074. private _computeParticleVertex;
  25075. private _computeBoundingBox;
  25076. private _depthSortParticles;
  25077. private _camera;
  25078. private _mustUnrotateFixedNormals;
  25079. private _particlesIntersect;
  25080. private _needs32Bits;
  25081. /**
  25082. * Creates a SPS (Solid Particle System) object.
  25083. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25084. * @param scene (Scene) is the scene in which the SPS is added.
  25085. * @param options defines the options of the sps e.g.
  25086. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25087. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25088. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25089. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25090. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25091. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25092. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25093. */
  25094. constructor(name: string, scene: Scene, options?: {
  25095. updatable?: boolean;
  25096. isPickable?: boolean;
  25097. enableDepthSort?: boolean;
  25098. particleIntersection?: boolean;
  25099. boundingSphereOnly?: boolean;
  25100. bSphereRadiusFactor?: number;
  25101. });
  25102. /**
  25103. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25104. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25105. * @returns the created mesh
  25106. */
  25107. buildMesh(): Mesh;
  25108. /**
  25109. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25110. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25111. * Thus the particles generated from `digest()` have their property `position` set yet.
  25112. * @param mesh ( Mesh ) is the mesh to be digested
  25113. * @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
  25114. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25115. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25116. * @returns the current SPS
  25117. */
  25118. digest(mesh: Mesh, options?: {
  25119. facetNb?: number;
  25120. number?: number;
  25121. delta?: number;
  25122. }): SolidParticleSystem;
  25123. private _unrotateFixedNormals;
  25124. private _resetCopy;
  25125. private _meshBuilder;
  25126. private _posToShape;
  25127. private _uvsToShapeUV;
  25128. private _addParticle;
  25129. /**
  25130. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25131. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25132. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25133. * @param nb (positive integer) the number of particles to be created from this model
  25134. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25135. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25136. * @returns the number of shapes in the system
  25137. */
  25138. addShape(mesh: Mesh, nb: number, options?: {
  25139. positionFunction?: any;
  25140. vertexFunction?: any;
  25141. }): number;
  25142. private _rebuildParticle;
  25143. /**
  25144. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25145. * @returns the SPS.
  25146. */
  25147. rebuildMesh(): SolidParticleSystem;
  25148. /**
  25149. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25150. * This method calls `updateParticle()` for each particle of the SPS.
  25151. * For an animated SPS, it is usually called within the render loop.
  25152. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25153. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25154. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25155. * @returns the SPS.
  25156. */
  25157. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25158. /**
  25159. * Disposes the SPS.
  25160. */
  25161. dispose(): void;
  25162. /**
  25163. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25164. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25165. * @returns the SPS.
  25166. */
  25167. refreshVisibleSize(): SolidParticleSystem;
  25168. /**
  25169. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25170. * @param size the size (float) of the visibility box
  25171. * note : this doesn't lock the SPS mesh bounding box.
  25172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25173. */
  25174. setVisibilityBox(size: number): void;
  25175. /**
  25176. * Gets whether the SPS as always visible or not
  25177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25178. */
  25179. /**
  25180. * Sets the SPS as always visible or not
  25181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25182. */
  25183. isAlwaysVisible: boolean;
  25184. /**
  25185. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25187. */
  25188. /**
  25189. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25191. */
  25192. isVisibilityBoxLocked: boolean;
  25193. /**
  25194. * Tells to `setParticles()` to compute the particle rotations or not.
  25195. * Default value : true. The SPS is faster when it's set to false.
  25196. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25197. */
  25198. /**
  25199. * Gets if `setParticles()` computes the particle rotations or not.
  25200. * Default value : true. The SPS is faster when it's set to false.
  25201. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25202. */
  25203. computeParticleRotation: boolean;
  25204. /**
  25205. * Tells to `setParticles()` to compute the particle colors or not.
  25206. * Default value : true. The SPS is faster when it's set to false.
  25207. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25208. */
  25209. /**
  25210. * Gets if `setParticles()` computes the particle colors or not.
  25211. * Default value : true. The SPS is faster when it's set to false.
  25212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25213. */
  25214. computeParticleColor: boolean;
  25215. /**
  25216. * Gets if `setParticles()` computes the particle textures or not.
  25217. * Default value : true. The SPS is faster when it's set to false.
  25218. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25219. */
  25220. computeParticleTexture: boolean;
  25221. /**
  25222. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25223. * Default value : false. The SPS is faster when it's set to false.
  25224. * Note : the particle custom vertex positions aren't stored values.
  25225. */
  25226. /**
  25227. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25228. * Default value : false. The SPS is faster when it's set to false.
  25229. * Note : the particle custom vertex positions aren't stored values.
  25230. */
  25231. computeParticleVertex: boolean;
  25232. /**
  25233. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25234. */
  25235. /**
  25236. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25237. */
  25238. computeBoundingBox: boolean;
  25239. /**
  25240. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25241. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25242. * Default : `true`
  25243. */
  25244. /**
  25245. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25246. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25247. * Default : `true`
  25248. */
  25249. depthSortParticles: boolean;
  25250. /**
  25251. * This function does nothing. It may be overwritten to set all the particle first values.
  25252. * The SPS doesn't call this function, you may have to call it by your own.
  25253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25254. */
  25255. initParticles(): void;
  25256. /**
  25257. * This function does nothing. It may be overwritten to recycle a particle.
  25258. * The SPS doesn't call this function, you may have to call it by your own.
  25259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25260. * @param particle The particle to recycle
  25261. * @returns the recycled particle
  25262. */
  25263. recycleParticle(particle: SolidParticle): SolidParticle;
  25264. /**
  25265. * Updates a particle : this function should be overwritten by the user.
  25266. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25268. * @example : just set a particle position or velocity and recycle conditions
  25269. * @param particle The particle to update
  25270. * @returns the updated particle
  25271. */
  25272. updateParticle(particle: SolidParticle): SolidParticle;
  25273. /**
  25274. * Updates a vertex of a particle : it can be overwritten by the user.
  25275. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25276. * @param particle the current particle
  25277. * @param vertex the current index of the current particle
  25278. * @param pt the index of the current vertex in the particle shape
  25279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25280. * @example : just set a vertex particle position
  25281. * @returns the updated vertex
  25282. */
  25283. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25284. /**
  25285. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25286. * This does nothing and may be overwritten by the user.
  25287. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25288. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25289. * @param update the boolean update value actually passed to setParticles()
  25290. */
  25291. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25292. /**
  25293. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25294. * This will be passed three parameters.
  25295. * This does nothing and may be overwritten by the user.
  25296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25298. * @param update the boolean update value actually passed to setParticles()
  25299. */
  25300. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25301. }
  25302. }
  25303. declare module BABYLON {
  25304. /**
  25305. * Represents one particle of a solid particle system.
  25306. */
  25307. export class SolidParticle {
  25308. /**
  25309. * particle global index
  25310. */
  25311. idx: number;
  25312. /**
  25313. * The color of the particle
  25314. */
  25315. color: Nullable<Color4>;
  25316. /**
  25317. * The world space position of the particle.
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25322. */
  25323. rotation: Vector3;
  25324. /**
  25325. * The world space rotation quaternion of the particle.
  25326. */
  25327. rotationQuaternion: Nullable<Quaternion>;
  25328. /**
  25329. * The scaling of the particle.
  25330. */
  25331. scaling: Vector3;
  25332. /**
  25333. * The uvs of the particle.
  25334. */
  25335. uvs: Vector4;
  25336. /**
  25337. * The current speed of the particle.
  25338. */
  25339. velocity: Vector3;
  25340. /**
  25341. * The pivot point in the particle local space.
  25342. */
  25343. pivot: Vector3;
  25344. /**
  25345. * Must the particle be translated from its pivot point in its local space ?
  25346. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25347. * Default : false
  25348. */
  25349. translateFromPivot: boolean;
  25350. /**
  25351. * Is the particle active or not ?
  25352. */
  25353. alive: boolean;
  25354. /**
  25355. * Is the particle visible or not ?
  25356. */
  25357. isVisible: boolean;
  25358. /**
  25359. * Index of this particle in the global "positions" array (Internal use)
  25360. * @hidden
  25361. */
  25362. _pos: number;
  25363. /**
  25364. * @hidden Index of this particle in the global "indices" array (Internal use)
  25365. */
  25366. _ind: number;
  25367. /**
  25368. * @hidden ModelShape of this particle (Internal use)
  25369. */
  25370. _model: ModelShape;
  25371. /**
  25372. * ModelShape id of this particle
  25373. */
  25374. shapeId: number;
  25375. /**
  25376. * Index of the particle in its shape id
  25377. */
  25378. idxInShape: number;
  25379. /**
  25380. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25381. */
  25382. _modelBoundingInfo: BoundingInfo;
  25383. /**
  25384. * @hidden Particle BoundingInfo object (Internal use)
  25385. */
  25386. _boundingInfo: BoundingInfo;
  25387. /**
  25388. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25389. */
  25390. _sps: SolidParticleSystem;
  25391. /**
  25392. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25393. */
  25394. _stillInvisible: boolean;
  25395. /**
  25396. * @hidden Last computed particle rotation matrix
  25397. */
  25398. _rotationMatrix: number[];
  25399. /**
  25400. * Parent particle Id, if any.
  25401. * Default null.
  25402. */
  25403. parentId: Nullable<number>;
  25404. /**
  25405. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25406. * The possible values are :
  25407. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25408. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25409. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25410. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25411. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25412. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25413. * */
  25414. cullingStrategy: number;
  25415. /**
  25416. * @hidden Internal global position in the SPS.
  25417. */
  25418. _globalPosition: Vector3;
  25419. /**
  25420. * Creates a Solid Particle object.
  25421. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25422. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25423. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25424. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25425. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25426. * @param shapeId (integer) is the model shape identifier in the SPS.
  25427. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25428. * @param sps defines the sps it is associated to
  25429. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25430. */
  25431. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25432. /**
  25433. * Legacy support, changed scale to scaling
  25434. */
  25435. /**
  25436. * Legacy support, changed scale to scaling
  25437. */
  25438. scale: Vector3;
  25439. /**
  25440. * Legacy support, changed quaternion to rotationQuaternion
  25441. */
  25442. /**
  25443. * Legacy support, changed quaternion to rotationQuaternion
  25444. */
  25445. quaternion: Nullable<Quaternion>;
  25446. /**
  25447. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25448. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25449. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25450. * @returns true if it intersects
  25451. */
  25452. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25453. /**
  25454. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25455. * A particle is in the frustum if its bounding box intersects the frustum
  25456. * @param frustumPlanes defines the frustum to test
  25457. * @returns true if the particle is in the frustum planes
  25458. */
  25459. isInFrustum(frustumPlanes: Plane[]): boolean;
  25460. /**
  25461. * get the rotation matrix of the particle
  25462. * @hidden
  25463. */
  25464. getRotationMatrix(m: Matrix): void;
  25465. }
  25466. /**
  25467. * Represents the shape of the model used by one particle of a solid particle system.
  25468. * SPS internal tool, don't use it manually.
  25469. */
  25470. export class ModelShape {
  25471. /**
  25472. * The shape id
  25473. * @hidden
  25474. */
  25475. shapeID: number;
  25476. /**
  25477. * flat array of model positions (internal use)
  25478. * @hidden
  25479. */
  25480. _shape: Vector3[];
  25481. /**
  25482. * flat array of model UVs (internal use)
  25483. * @hidden
  25484. */
  25485. _shapeUV: number[];
  25486. /**
  25487. * length of the shape in the model indices array (internal use)
  25488. * @hidden
  25489. */
  25490. _indicesLength: number;
  25491. /**
  25492. * Custom position function (internal use)
  25493. * @hidden
  25494. */
  25495. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25496. /**
  25497. * Custom vertex function (internal use)
  25498. * @hidden
  25499. */
  25500. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25501. /**
  25502. * 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.
  25503. * SPS internal tool, don't use it manually.
  25504. * @hidden
  25505. */
  25506. 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>);
  25507. }
  25508. /**
  25509. * Represents a Depth Sorted Particle in the solid particle system.
  25510. */
  25511. export class DepthSortedParticle {
  25512. /**
  25513. * Index of the particle in the "indices" array
  25514. */
  25515. ind: number;
  25516. /**
  25517. * Length of the particle shape in the "indices" array
  25518. */
  25519. indicesLength: number;
  25520. /**
  25521. * Squared distance from the particle to the camera
  25522. */
  25523. sqDistance: number;
  25524. }
  25525. }
  25526. declare module BABYLON {
  25527. /**
  25528. * @hidden
  25529. */
  25530. export class _MeshCollisionData {
  25531. _checkCollisions: boolean;
  25532. _collisionMask: number;
  25533. _collisionGroup: number;
  25534. _collider: Nullable<Collider>;
  25535. _oldPositionForCollisions: Vector3;
  25536. _diffPositionForCollisions: Vector3;
  25537. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25538. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25539. }
  25540. }
  25541. declare module BABYLON {
  25542. /** @hidden */
  25543. class _FacetDataStorage {
  25544. facetPositions: Vector3[];
  25545. facetNormals: Vector3[];
  25546. facetPartitioning: number[][];
  25547. facetNb: number;
  25548. partitioningSubdivisions: number;
  25549. partitioningBBoxRatio: number;
  25550. facetDataEnabled: boolean;
  25551. facetParameters: any;
  25552. bbSize: Vector3;
  25553. subDiv: {
  25554. max: number;
  25555. X: number;
  25556. Y: number;
  25557. Z: number;
  25558. };
  25559. facetDepthSort: boolean;
  25560. facetDepthSortEnabled: boolean;
  25561. depthSortedIndices: IndicesArray;
  25562. depthSortedFacets: {
  25563. ind: number;
  25564. sqDistance: number;
  25565. }[];
  25566. facetDepthSortFunction: (f1: {
  25567. ind: number;
  25568. sqDistance: number;
  25569. }, f2: {
  25570. ind: number;
  25571. sqDistance: number;
  25572. }) => number;
  25573. facetDepthSortFrom: Vector3;
  25574. facetDepthSortOrigin: Vector3;
  25575. invertedMatrix: Matrix;
  25576. }
  25577. /**
  25578. * @hidden
  25579. **/
  25580. class _InternalAbstractMeshDataInfo {
  25581. _hasVertexAlpha: boolean;
  25582. _useVertexColors: boolean;
  25583. _numBoneInfluencers: number;
  25584. _applyFog: boolean;
  25585. _receiveShadows: boolean;
  25586. _facetData: _FacetDataStorage;
  25587. _visibility: number;
  25588. _skeleton: Nullable<Skeleton>;
  25589. _layerMask: number;
  25590. _computeBonesUsingShaders: boolean;
  25591. _isActive: boolean;
  25592. _onlyForInstances: boolean;
  25593. _isActiveIntermediate: boolean;
  25594. _onlyForInstancesIntermediate: boolean;
  25595. }
  25596. /**
  25597. * Class used to store all common mesh properties
  25598. */
  25599. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25600. /** No occlusion */
  25601. static OCCLUSION_TYPE_NONE: number;
  25602. /** Occlusion set to optimisitic */
  25603. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25604. /** Occlusion set to strict */
  25605. static OCCLUSION_TYPE_STRICT: number;
  25606. /** Use an accurante occlusion algorithm */
  25607. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25608. /** Use a conservative occlusion algorithm */
  25609. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25610. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25611. * Test order :
  25612. * Is the bounding sphere outside the frustum ?
  25613. * If not, are the bounding box vertices outside the frustum ?
  25614. * It not, then the cullable object is in the frustum.
  25615. */
  25616. static readonly CULLINGSTRATEGY_STANDARD: number;
  25617. /** Culling strategy : Bounding Sphere Only.
  25618. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25619. * It's also less accurate than the standard because some not visible objects can still be selected.
  25620. * Test : is the bounding sphere outside the frustum ?
  25621. * If not, then the cullable object is in the frustum.
  25622. */
  25623. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25624. /** Culling strategy : Optimistic Inclusion.
  25625. * This in an inclusion test first, then the standard exclusion test.
  25626. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25627. * 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.
  25628. * Anyway, it's as accurate as the standard strategy.
  25629. * Test :
  25630. * Is the cullable object bounding sphere center in the frustum ?
  25631. * If not, apply the default culling strategy.
  25632. */
  25633. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25634. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25635. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25636. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25637. * 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.
  25638. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25639. * Test :
  25640. * Is the cullable object bounding sphere center in the frustum ?
  25641. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25642. */
  25643. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25644. /**
  25645. * No billboard
  25646. */
  25647. static readonly BILLBOARDMODE_NONE: number;
  25648. /** Billboard on X axis */
  25649. static readonly BILLBOARDMODE_X: number;
  25650. /** Billboard on Y axis */
  25651. static readonly BILLBOARDMODE_Y: number;
  25652. /** Billboard on Z axis */
  25653. static readonly BILLBOARDMODE_Z: number;
  25654. /** Billboard on all axes */
  25655. static readonly BILLBOARDMODE_ALL: number;
  25656. /** Billboard on using position instead of orientation */
  25657. static readonly BILLBOARDMODE_USE_POSITION: number;
  25658. /** @hidden */
  25659. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25660. /**
  25661. * The culling strategy to use to check whether the mesh must be rendered or not.
  25662. * This value can be changed at any time and will be used on the next render mesh selection.
  25663. * The possible values are :
  25664. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25665. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25666. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25667. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25668. * Please read each static variable documentation to get details about the culling process.
  25669. * */
  25670. cullingStrategy: number;
  25671. /**
  25672. * Gets the number of facets in the mesh
  25673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25674. */
  25675. readonly facetNb: number;
  25676. /**
  25677. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25679. */
  25680. partitioningSubdivisions: number;
  25681. /**
  25682. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25683. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25685. */
  25686. partitioningBBoxRatio: number;
  25687. /**
  25688. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25689. * Works only for updatable meshes.
  25690. * Doesn't work with multi-materials
  25691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25692. */
  25693. mustDepthSortFacets: boolean;
  25694. /**
  25695. * The location (Vector3) where the facet depth sort must be computed from.
  25696. * By default, the active camera position.
  25697. * Used only when facet depth sort is enabled
  25698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25699. */
  25700. facetDepthSortFrom: Vector3;
  25701. /**
  25702. * gets a boolean indicating if facetData is enabled
  25703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25704. */
  25705. readonly isFacetDataEnabled: boolean;
  25706. /** @hidden */
  25707. _updateNonUniformScalingState(value: boolean): boolean;
  25708. /**
  25709. * An event triggered when this mesh collides with another one
  25710. */
  25711. onCollideObservable: Observable<AbstractMesh>;
  25712. /** Set a function to call when this mesh collides with another one */
  25713. onCollide: () => void;
  25714. /**
  25715. * An event triggered when the collision's position changes
  25716. */
  25717. onCollisionPositionChangeObservable: Observable<Vector3>;
  25718. /** Set a function to call when the collision's position changes */
  25719. onCollisionPositionChange: () => void;
  25720. /**
  25721. * An event triggered when material is changed
  25722. */
  25723. onMaterialChangedObservable: Observable<AbstractMesh>;
  25724. /**
  25725. * Gets or sets the orientation for POV movement & rotation
  25726. */
  25727. definedFacingForward: boolean;
  25728. /** @hidden */
  25729. _occlusionQuery: Nullable<WebGLQuery>;
  25730. /** @hidden */
  25731. _renderingGroup: Nullable<RenderingGroup>;
  25732. /**
  25733. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25734. */
  25735. /**
  25736. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25737. */
  25738. visibility: number;
  25739. /** Gets or sets the alpha index used to sort transparent meshes
  25740. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25741. */
  25742. alphaIndex: number;
  25743. /**
  25744. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25745. */
  25746. isVisible: boolean;
  25747. /**
  25748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25749. */
  25750. isPickable: boolean;
  25751. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25752. showSubMeshesBoundingBox: boolean;
  25753. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25755. */
  25756. isBlocker: boolean;
  25757. /**
  25758. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25759. */
  25760. enablePointerMoveEvents: boolean;
  25761. /**
  25762. * Specifies the rendering group id for this mesh (0 by default)
  25763. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25764. */
  25765. renderingGroupId: number;
  25766. private _material;
  25767. /** Gets or sets current material */
  25768. material: Nullable<Material>;
  25769. /**
  25770. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25771. * @see http://doc.babylonjs.com/babylon101/shadows
  25772. */
  25773. receiveShadows: boolean;
  25774. /** Defines color to use when rendering outline */
  25775. outlineColor: Color3;
  25776. /** Define width to use when rendering outline */
  25777. outlineWidth: number;
  25778. /** Defines color to use when rendering overlay */
  25779. overlayColor: Color3;
  25780. /** Defines alpha to use when rendering overlay */
  25781. overlayAlpha: number;
  25782. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25783. hasVertexAlpha: boolean;
  25784. /** 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) */
  25785. useVertexColors: boolean;
  25786. /**
  25787. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25788. */
  25789. computeBonesUsingShaders: boolean;
  25790. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25791. numBoneInfluencers: number;
  25792. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25793. applyFog: boolean;
  25794. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25795. useOctreeForRenderingSelection: boolean;
  25796. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25797. useOctreeForPicking: boolean;
  25798. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25799. useOctreeForCollisions: boolean;
  25800. /**
  25801. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25802. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25803. */
  25804. layerMask: number;
  25805. /**
  25806. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25807. */
  25808. alwaysSelectAsActiveMesh: boolean;
  25809. /**
  25810. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25811. */
  25812. doNotSyncBoundingInfo: boolean;
  25813. /**
  25814. * Gets or sets the current action manager
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25816. */
  25817. actionManager: Nullable<AbstractActionManager>;
  25818. private _meshCollisionData;
  25819. /**
  25820. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25822. */
  25823. ellipsoid: Vector3;
  25824. /**
  25825. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25827. */
  25828. ellipsoidOffset: Vector3;
  25829. /**
  25830. * Gets or sets a collision mask used to mask collisions (default is -1).
  25831. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25832. */
  25833. collisionMask: number;
  25834. /**
  25835. * Gets or sets the current collision group mask (-1 by default).
  25836. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25837. */
  25838. collisionGroup: number;
  25839. /**
  25840. * Defines edge width used when edgesRenderer is enabled
  25841. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25842. */
  25843. edgesWidth: number;
  25844. /**
  25845. * Defines edge color used when edgesRenderer is enabled
  25846. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25847. */
  25848. edgesColor: Color4;
  25849. /** @hidden */
  25850. _edgesRenderer: Nullable<IEdgesRenderer>;
  25851. /** @hidden */
  25852. _masterMesh: Nullable<AbstractMesh>;
  25853. /** @hidden */
  25854. _boundingInfo: Nullable<BoundingInfo>;
  25855. /** @hidden */
  25856. _renderId: number;
  25857. /**
  25858. * Gets or sets the list of subMeshes
  25859. * @see http://doc.babylonjs.com/how_to/multi_materials
  25860. */
  25861. subMeshes: SubMesh[];
  25862. /** @hidden */
  25863. _intersectionsInProgress: AbstractMesh[];
  25864. /** @hidden */
  25865. _unIndexed: boolean;
  25866. /** @hidden */
  25867. _lightSources: Light[];
  25868. /** Gets the list of lights affecting that mesh */
  25869. readonly lightSources: Light[];
  25870. /** @hidden */
  25871. readonly _positions: Nullable<Vector3[]>;
  25872. /** @hidden */
  25873. _waitingData: {
  25874. lods: Nullable<any>;
  25875. actions: Nullable<any>;
  25876. freezeWorldMatrix: Nullable<boolean>;
  25877. };
  25878. /** @hidden */
  25879. _bonesTransformMatrices: Nullable<Float32Array>;
  25880. /** @hidden */
  25881. _transformMatrixTexture: Nullable<RawTexture>;
  25882. /**
  25883. * Gets or sets a skeleton to apply skining transformations
  25884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25885. */
  25886. skeleton: Nullable<Skeleton>;
  25887. /**
  25888. * An event triggered when the mesh is rebuilt.
  25889. */
  25890. onRebuildObservable: Observable<AbstractMesh>;
  25891. /**
  25892. * Creates a new AbstractMesh
  25893. * @param name defines the name of the mesh
  25894. * @param scene defines the hosting scene
  25895. */
  25896. constructor(name: string, scene?: Nullable<Scene>);
  25897. /**
  25898. * Returns the string "AbstractMesh"
  25899. * @returns "AbstractMesh"
  25900. */
  25901. getClassName(): string;
  25902. /**
  25903. * Gets a string representation of the current mesh
  25904. * @param fullDetails defines a boolean indicating if full details must be included
  25905. * @returns a string representation of the current mesh
  25906. */
  25907. toString(fullDetails?: boolean): string;
  25908. /**
  25909. * @hidden
  25910. */
  25911. protected _getEffectiveParent(): Nullable<Node>;
  25912. /** @hidden */
  25913. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25914. /** @hidden */
  25915. _rebuild(): void;
  25916. /** @hidden */
  25917. _resyncLightSources(): void;
  25918. /** @hidden */
  25919. _resyncLighSource(light: Light): void;
  25920. /** @hidden */
  25921. _unBindEffect(): void;
  25922. /** @hidden */
  25923. _removeLightSource(light: Light, dispose: boolean): void;
  25924. private _markSubMeshesAsDirty;
  25925. /** @hidden */
  25926. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25927. /** @hidden */
  25928. _markSubMeshesAsAttributesDirty(): void;
  25929. /** @hidden */
  25930. _markSubMeshesAsMiscDirty(): void;
  25931. /**
  25932. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25933. */
  25934. scaling: Vector3;
  25935. /**
  25936. * Returns true if the mesh is blocked. Implemented by child classes
  25937. */
  25938. readonly isBlocked: boolean;
  25939. /**
  25940. * Returns the mesh itself by default. Implemented by child classes
  25941. * @param camera defines the camera to use to pick the right LOD level
  25942. * @returns the currentAbstractMesh
  25943. */
  25944. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25945. /**
  25946. * Returns 0 by default. Implemented by child classes
  25947. * @returns an integer
  25948. */
  25949. getTotalVertices(): number;
  25950. /**
  25951. * Returns a positive integer : the total number of indices in this mesh geometry.
  25952. * @returns the numner of indices or zero if the mesh has no geometry.
  25953. */
  25954. getTotalIndices(): number;
  25955. /**
  25956. * Returns null by default. Implemented by child classes
  25957. * @returns null
  25958. */
  25959. getIndices(): Nullable<IndicesArray>;
  25960. /**
  25961. * Returns the array of the requested vertex data kind. Implemented by child classes
  25962. * @param kind defines the vertex data kind to use
  25963. * @returns null
  25964. */
  25965. getVerticesData(kind: string): Nullable<FloatArray>;
  25966. /**
  25967. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25968. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25969. * Note that a new underlying VertexBuffer object is created each call.
  25970. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25971. * @param kind defines vertex data kind:
  25972. * * VertexBuffer.PositionKind
  25973. * * VertexBuffer.UVKind
  25974. * * VertexBuffer.UV2Kind
  25975. * * VertexBuffer.UV3Kind
  25976. * * VertexBuffer.UV4Kind
  25977. * * VertexBuffer.UV5Kind
  25978. * * VertexBuffer.UV6Kind
  25979. * * VertexBuffer.ColorKind
  25980. * * VertexBuffer.MatricesIndicesKind
  25981. * * VertexBuffer.MatricesIndicesExtraKind
  25982. * * VertexBuffer.MatricesWeightsKind
  25983. * * VertexBuffer.MatricesWeightsExtraKind
  25984. * @param data defines the data source
  25985. * @param updatable defines if the data must be flagged as updatable (or static)
  25986. * @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
  25987. * @returns the current mesh
  25988. */
  25989. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25990. /**
  25991. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25992. * If the mesh has no geometry, it is simply returned as it is.
  25993. * @param kind defines vertex data kind:
  25994. * * VertexBuffer.PositionKind
  25995. * * VertexBuffer.UVKind
  25996. * * VertexBuffer.UV2Kind
  25997. * * VertexBuffer.UV3Kind
  25998. * * VertexBuffer.UV4Kind
  25999. * * VertexBuffer.UV5Kind
  26000. * * VertexBuffer.UV6Kind
  26001. * * VertexBuffer.ColorKind
  26002. * * VertexBuffer.MatricesIndicesKind
  26003. * * VertexBuffer.MatricesIndicesExtraKind
  26004. * * VertexBuffer.MatricesWeightsKind
  26005. * * VertexBuffer.MatricesWeightsExtraKind
  26006. * @param data defines the data source
  26007. * @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
  26008. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26009. * @returns the current mesh
  26010. */
  26011. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26012. /**
  26013. * Sets the mesh indices,
  26014. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26015. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26016. * @param totalVertices Defines the total number of vertices
  26017. * @returns the current mesh
  26018. */
  26019. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26020. /**
  26021. * Gets a boolean indicating if specific vertex data is present
  26022. * @param kind defines the vertex data kind to use
  26023. * @returns true is data kind is present
  26024. */
  26025. isVerticesDataPresent(kind: string): boolean;
  26026. /**
  26027. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26028. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26029. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26030. * @returns a BoundingInfo
  26031. */
  26032. getBoundingInfo(): BoundingInfo;
  26033. /**
  26034. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26035. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26036. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26037. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26038. * @returns the current mesh
  26039. */
  26040. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26041. /**
  26042. * Overwrite the current bounding info
  26043. * @param boundingInfo defines the new bounding info
  26044. * @returns the current mesh
  26045. */
  26046. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26047. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26048. readonly useBones: boolean;
  26049. /** @hidden */
  26050. _preActivate(): void;
  26051. /** @hidden */
  26052. _preActivateForIntermediateRendering(renderId: number): void;
  26053. /** @hidden */
  26054. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26055. /** @hidden */
  26056. _postActivate(): void;
  26057. /** @hidden */
  26058. _freeze(): void;
  26059. /** @hidden */
  26060. _unFreeze(): void;
  26061. /**
  26062. * Gets the current world matrix
  26063. * @returns a Matrix
  26064. */
  26065. getWorldMatrix(): Matrix;
  26066. /** @hidden */
  26067. _getWorldMatrixDeterminant(): number;
  26068. /**
  26069. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26070. */
  26071. readonly isAnInstance: boolean;
  26072. /**
  26073. * Gets a boolean indicating if this mesh has instances
  26074. */
  26075. readonly hasInstances: boolean;
  26076. /**
  26077. * Perform relative position change from the point of view of behind the front of the mesh.
  26078. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26079. * Supports definition of mesh facing forward or backward
  26080. * @param amountRight defines the distance on the right axis
  26081. * @param amountUp defines the distance on the up axis
  26082. * @param amountForward defines the distance on the forward axis
  26083. * @returns the current mesh
  26084. */
  26085. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26086. /**
  26087. * Calculate relative position change from the point of view of behind the front of the mesh.
  26088. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26089. * Supports definition of mesh facing forward or backward
  26090. * @param amountRight defines the distance on the right axis
  26091. * @param amountUp defines the distance on the up axis
  26092. * @param amountForward defines the distance on the forward axis
  26093. * @returns the new displacement vector
  26094. */
  26095. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26096. /**
  26097. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26098. * Supports definition of mesh facing forward or backward
  26099. * @param flipBack defines the flip
  26100. * @param twirlClockwise defines the twirl
  26101. * @param tiltRight defines the tilt
  26102. * @returns the current mesh
  26103. */
  26104. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26105. /**
  26106. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26107. * Supports definition of mesh facing forward or backward.
  26108. * @param flipBack defines the flip
  26109. * @param twirlClockwise defines the twirl
  26110. * @param tiltRight defines the tilt
  26111. * @returns the new rotation vector
  26112. */
  26113. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26114. /**
  26115. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26116. * This means the mesh underlying bounding box and sphere are recomputed.
  26117. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26118. * @returns the current mesh
  26119. */
  26120. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26121. /** @hidden */
  26122. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26123. /** @hidden */
  26124. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26125. /** @hidden */
  26126. _updateBoundingInfo(): AbstractMesh;
  26127. /** @hidden */
  26128. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26129. /** @hidden */
  26130. protected _afterComputeWorldMatrix(): void;
  26131. /** @hidden */
  26132. readonly _effectiveMesh: AbstractMesh;
  26133. /**
  26134. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26135. * A mesh is in the frustum if its bounding box intersects the frustum
  26136. * @param frustumPlanes defines the frustum to test
  26137. * @returns true if the mesh is in the frustum planes
  26138. */
  26139. isInFrustum(frustumPlanes: Plane[]): boolean;
  26140. /**
  26141. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26142. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26143. * @param frustumPlanes defines the frustum to test
  26144. * @returns true if the mesh is completely in the frustum planes
  26145. */
  26146. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26147. /**
  26148. * True if the mesh intersects another mesh or a SolidParticle object
  26149. * @param mesh defines a target mesh or SolidParticle to test
  26150. * @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)
  26151. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26152. * @returns true if there is an intersection
  26153. */
  26154. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26155. /**
  26156. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26157. * @param point defines the point to test
  26158. * @returns true if there is an intersection
  26159. */
  26160. intersectsPoint(point: Vector3): boolean;
  26161. /**
  26162. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26164. */
  26165. checkCollisions: boolean;
  26166. /**
  26167. * Gets Collider object used to compute collisions (not physics)
  26168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26169. */
  26170. readonly collider: Nullable<Collider>;
  26171. /**
  26172. * Move the mesh using collision engine
  26173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26174. * @param displacement defines the requested displacement vector
  26175. * @returns the current mesh
  26176. */
  26177. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26178. private _onCollisionPositionChange;
  26179. /** @hidden */
  26180. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26181. /** @hidden */
  26182. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26183. /** @hidden */
  26184. _checkCollision(collider: Collider): AbstractMesh;
  26185. /** @hidden */
  26186. _generatePointsArray(): boolean;
  26187. /**
  26188. * Checks if the passed Ray intersects with the mesh
  26189. * @param ray defines the ray to use
  26190. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26191. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26192. * @returns the picking info
  26193. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26194. */
  26195. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26196. /**
  26197. * Clones the current mesh
  26198. * @param name defines the mesh name
  26199. * @param newParent defines the new mesh parent
  26200. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26201. * @returns the new mesh
  26202. */
  26203. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26204. /**
  26205. * Disposes all the submeshes of the current meshnp
  26206. * @returns the current mesh
  26207. */
  26208. releaseSubMeshes(): AbstractMesh;
  26209. /**
  26210. * Releases resources associated with this abstract mesh.
  26211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26213. */
  26214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26215. /**
  26216. * Adds the passed mesh as a child to the current mesh
  26217. * @param mesh defines the child mesh
  26218. * @returns the current mesh
  26219. */
  26220. addChild(mesh: AbstractMesh): AbstractMesh;
  26221. /**
  26222. * Removes the passed mesh from the current mesh children list
  26223. * @param mesh defines the child mesh
  26224. * @returns the current mesh
  26225. */
  26226. removeChild(mesh: AbstractMesh): AbstractMesh;
  26227. /** @hidden */
  26228. private _initFacetData;
  26229. /**
  26230. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26231. * This method can be called within the render loop.
  26232. * 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
  26233. * @returns the current mesh
  26234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26235. */
  26236. updateFacetData(): AbstractMesh;
  26237. /**
  26238. * Returns the facetLocalNormals array.
  26239. * The normals are expressed in the mesh local spac
  26240. * @returns an array of Vector3
  26241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26242. */
  26243. getFacetLocalNormals(): Vector3[];
  26244. /**
  26245. * Returns the facetLocalPositions array.
  26246. * The facet positions are expressed in the mesh local space
  26247. * @returns an array of Vector3
  26248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26249. */
  26250. getFacetLocalPositions(): Vector3[];
  26251. /**
  26252. * Returns the facetLocalPartioning array
  26253. * @returns an array of array of numbers
  26254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26255. */
  26256. getFacetLocalPartitioning(): number[][];
  26257. /**
  26258. * Returns the i-th facet position in the world system.
  26259. * This method allocates a new Vector3 per call
  26260. * @param i defines the facet index
  26261. * @returns a new Vector3
  26262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26263. */
  26264. getFacetPosition(i: number): Vector3;
  26265. /**
  26266. * Sets the reference Vector3 with the i-th facet position in the world system
  26267. * @param i defines the facet index
  26268. * @param ref defines the target vector
  26269. * @returns the current mesh
  26270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26271. */
  26272. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26273. /**
  26274. * Returns the i-th facet normal in the world system.
  26275. * This method allocates a new Vector3 per call
  26276. * @param i defines the facet index
  26277. * @returns a new Vector3
  26278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26279. */
  26280. getFacetNormal(i: number): Vector3;
  26281. /**
  26282. * Sets the reference Vector3 with the i-th facet normal in the world system
  26283. * @param i defines the facet index
  26284. * @param ref defines the target vector
  26285. * @returns the current mesh
  26286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26287. */
  26288. getFacetNormalToRef(i: number, ref: Vector3): this;
  26289. /**
  26290. * 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)
  26291. * @param x defines x coordinate
  26292. * @param y defines y coordinate
  26293. * @param z defines z coordinate
  26294. * @returns the array of facet indexes
  26295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26296. */
  26297. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26298. /**
  26299. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26300. * @param projected sets as the (x,y,z) world projection on the facet
  26301. * @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
  26302. * @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
  26303. * @param x defines x coordinate
  26304. * @param y defines y coordinate
  26305. * @param z defines z coordinate
  26306. * @returns the face index if found (or null instead)
  26307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26308. */
  26309. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26310. /**
  26311. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26312. * @param projected sets as the (x,y,z) local projection on the facet
  26313. * @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
  26314. * @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
  26315. * @param x defines x coordinate
  26316. * @param y defines y coordinate
  26317. * @param z defines z coordinate
  26318. * @returns the face index if found (or null instead)
  26319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26320. */
  26321. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26322. /**
  26323. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26324. * @returns the parameters
  26325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26326. */
  26327. getFacetDataParameters(): any;
  26328. /**
  26329. * Disables the feature FacetData and frees the related memory
  26330. * @returns the current mesh
  26331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26332. */
  26333. disableFacetData(): AbstractMesh;
  26334. /**
  26335. * Updates the AbstractMesh indices array
  26336. * @param indices defines the data source
  26337. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26338. * @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)
  26339. * @returns the current mesh
  26340. */
  26341. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26342. /**
  26343. * Creates new normals data for the mesh
  26344. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26345. * @returns the current mesh
  26346. */
  26347. createNormals(updatable: boolean): AbstractMesh;
  26348. /**
  26349. * Align the mesh with a normal
  26350. * @param normal defines the normal to use
  26351. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26352. * @returns the current mesh
  26353. */
  26354. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26355. /** @hidden */
  26356. _checkOcclusionQuery(): boolean;
  26357. /**
  26358. * Disables the mesh edge rendering mode
  26359. * @returns the currentAbstractMesh
  26360. */
  26361. disableEdgesRendering(): AbstractMesh;
  26362. /**
  26363. * Enables the edge rendering mode on the mesh.
  26364. * This mode makes the mesh edges visible
  26365. * @param epsilon defines the maximal distance between two angles to detect a face
  26366. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26367. * @returns the currentAbstractMesh
  26368. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26369. */
  26370. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26371. }
  26372. }
  26373. declare module BABYLON {
  26374. /**
  26375. * Interface used to define ActionEvent
  26376. */
  26377. export interface IActionEvent {
  26378. /** The mesh or sprite that triggered the action */
  26379. source: any;
  26380. /** The X mouse cursor position at the time of the event */
  26381. pointerX: number;
  26382. /** The Y mouse cursor position at the time of the event */
  26383. pointerY: number;
  26384. /** The mesh that is currently pointed at (can be null) */
  26385. meshUnderPointer: Nullable<AbstractMesh>;
  26386. /** the original (browser) event that triggered the ActionEvent */
  26387. sourceEvent?: any;
  26388. /** additional data for the event */
  26389. additionalData?: any;
  26390. }
  26391. /**
  26392. * ActionEvent is the event being sent when an action is triggered.
  26393. */
  26394. export class ActionEvent implements IActionEvent {
  26395. /** The mesh or sprite that triggered the action */
  26396. source: any;
  26397. /** The X mouse cursor position at the time of the event */
  26398. pointerX: number;
  26399. /** The Y mouse cursor position at the time of the event */
  26400. pointerY: number;
  26401. /** The mesh that is currently pointed at (can be null) */
  26402. meshUnderPointer: Nullable<AbstractMesh>;
  26403. /** the original (browser) event that triggered the ActionEvent */
  26404. sourceEvent?: any;
  26405. /** additional data for the event */
  26406. additionalData?: any;
  26407. /**
  26408. * Creates a new ActionEvent
  26409. * @param source The mesh or sprite that triggered the action
  26410. * @param pointerX The X mouse cursor position at the time of the event
  26411. * @param pointerY The Y mouse cursor position at the time of the event
  26412. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26413. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26414. * @param additionalData additional data for the event
  26415. */
  26416. constructor(
  26417. /** The mesh or sprite that triggered the action */
  26418. source: any,
  26419. /** The X mouse cursor position at the time of the event */
  26420. pointerX: number,
  26421. /** The Y mouse cursor position at the time of the event */
  26422. pointerY: number,
  26423. /** The mesh that is currently pointed at (can be null) */
  26424. meshUnderPointer: Nullable<AbstractMesh>,
  26425. /** the original (browser) event that triggered the ActionEvent */
  26426. sourceEvent?: any,
  26427. /** additional data for the event */
  26428. additionalData?: any);
  26429. /**
  26430. * Helper function to auto-create an ActionEvent from a source mesh.
  26431. * @param source The source mesh that triggered the event
  26432. * @param evt The original (browser) event
  26433. * @param additionalData additional data for the event
  26434. * @returns the new ActionEvent
  26435. */
  26436. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26437. /**
  26438. * Helper function to auto-create an ActionEvent from a source sprite
  26439. * @param source The source sprite that triggered the event
  26440. * @param scene Scene associated with the sprite
  26441. * @param evt The original (browser) event
  26442. * @param additionalData additional data for the event
  26443. * @returns the new ActionEvent
  26444. */
  26445. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26446. /**
  26447. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26448. * @param scene the scene where the event occurred
  26449. * @param evt The original (browser) event
  26450. * @returns the new ActionEvent
  26451. */
  26452. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26453. /**
  26454. * Helper function to auto-create an ActionEvent from a primitive
  26455. * @param prim defines the target primitive
  26456. * @param pointerPos defines the pointer position
  26457. * @param evt The original (browser) event
  26458. * @param additionalData additional data for the event
  26459. * @returns the new ActionEvent
  26460. */
  26461. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26462. }
  26463. }
  26464. declare module BABYLON {
  26465. /**
  26466. * Abstract class used to decouple action Manager from scene and meshes.
  26467. * Do not instantiate.
  26468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26469. */
  26470. export abstract class AbstractActionManager implements IDisposable {
  26471. /** Gets the list of active triggers */
  26472. static Triggers: {
  26473. [key: string]: number;
  26474. };
  26475. /** Gets the cursor to use when hovering items */
  26476. hoverCursor: string;
  26477. /** Gets the list of actions */
  26478. actions: IAction[];
  26479. /**
  26480. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26481. */
  26482. isRecursive: boolean;
  26483. /**
  26484. * Releases all associated resources
  26485. */
  26486. abstract dispose(): void;
  26487. /**
  26488. * Does this action manager has pointer triggers
  26489. */
  26490. abstract readonly hasPointerTriggers: boolean;
  26491. /**
  26492. * Does this action manager has pick triggers
  26493. */
  26494. abstract readonly hasPickTriggers: boolean;
  26495. /**
  26496. * Process a specific trigger
  26497. * @param trigger defines the trigger to process
  26498. * @param evt defines the event details to be processed
  26499. */
  26500. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26501. /**
  26502. * Does this action manager handles actions of any of the given triggers
  26503. * @param triggers defines the triggers to be tested
  26504. * @return a boolean indicating whether one (or more) of the triggers is handled
  26505. */
  26506. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26507. /**
  26508. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26509. * speed.
  26510. * @param triggerA defines the trigger to be tested
  26511. * @param triggerB defines the trigger to be tested
  26512. * @return a boolean indicating whether one (or more) of the triggers is handled
  26513. */
  26514. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26515. /**
  26516. * Does this action manager handles actions of a given trigger
  26517. * @param trigger defines the trigger to be tested
  26518. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26519. * @return whether the trigger is handled
  26520. */
  26521. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26522. /**
  26523. * Serialize this manager to a JSON object
  26524. * @param name defines the property name to store this manager
  26525. * @returns a JSON representation of this manager
  26526. */
  26527. abstract serialize(name: string): any;
  26528. /**
  26529. * Registers an action to this action manager
  26530. * @param action defines the action to be registered
  26531. * @return the action amended (prepared) after registration
  26532. */
  26533. abstract registerAction(action: IAction): Nullable<IAction>;
  26534. /**
  26535. * Unregisters an action to this action manager
  26536. * @param action defines the action to be unregistered
  26537. * @return a boolean indicating whether the action has been unregistered
  26538. */
  26539. abstract unregisterAction(action: IAction): Boolean;
  26540. /**
  26541. * Does exist one action manager with at least one trigger
  26542. **/
  26543. static readonly HasTriggers: boolean;
  26544. /**
  26545. * Does exist one action manager with at least one pick trigger
  26546. **/
  26547. static readonly HasPickTriggers: boolean;
  26548. /**
  26549. * Does exist one action manager that handles actions of a given trigger
  26550. * @param trigger defines the trigger to be tested
  26551. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26552. **/
  26553. static HasSpecificTrigger(trigger: number): boolean;
  26554. }
  26555. }
  26556. declare module BABYLON {
  26557. /**
  26558. * Defines how a node can be built from a string name.
  26559. */
  26560. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26561. /**
  26562. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26563. */
  26564. export class Node implements IBehaviorAware<Node> {
  26565. /** @hidden */
  26566. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26567. private static _NodeConstructors;
  26568. /**
  26569. * Add a new node constructor
  26570. * @param type defines the type name of the node to construct
  26571. * @param constructorFunc defines the constructor function
  26572. */
  26573. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26574. /**
  26575. * Returns a node constructor based on type name
  26576. * @param type defines the type name
  26577. * @param name defines the new node name
  26578. * @param scene defines the hosting scene
  26579. * @param options defines optional options to transmit to constructors
  26580. * @returns the new constructor or null
  26581. */
  26582. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26583. /**
  26584. * Gets or sets the name of the node
  26585. */
  26586. name: string;
  26587. /**
  26588. * Gets or sets the id of the node
  26589. */
  26590. id: string;
  26591. /**
  26592. * Gets or sets the unique id of the node
  26593. */
  26594. uniqueId: number;
  26595. /**
  26596. * Gets or sets a string used to store user defined state for the node
  26597. */
  26598. state: string;
  26599. /**
  26600. * Gets or sets an object used to store user defined information for the node
  26601. */
  26602. metadata: any;
  26603. /**
  26604. * For internal use only. Please do not use.
  26605. */
  26606. reservedDataStore: any;
  26607. /**
  26608. * List of inspectable custom properties (used by the Inspector)
  26609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26610. */
  26611. inspectableCustomProperties: IInspectable[];
  26612. /**
  26613. * Gets or sets a boolean used to define if the node must be serialized
  26614. */
  26615. doNotSerialize: boolean;
  26616. /** @hidden */
  26617. _isDisposed: boolean;
  26618. /**
  26619. * Gets a list of Animations associated with the node
  26620. */
  26621. animations: Animation[];
  26622. protected _ranges: {
  26623. [name: string]: Nullable<AnimationRange>;
  26624. };
  26625. /**
  26626. * Callback raised when the node is ready to be used
  26627. */
  26628. onReady: Nullable<(node: Node) => void>;
  26629. private _isEnabled;
  26630. private _isParentEnabled;
  26631. private _isReady;
  26632. /** @hidden */
  26633. _currentRenderId: number;
  26634. private _parentUpdateId;
  26635. /** @hidden */
  26636. _childUpdateId: number;
  26637. /** @hidden */
  26638. _waitingParentId: Nullable<string>;
  26639. /** @hidden */
  26640. _scene: Scene;
  26641. /** @hidden */
  26642. _cache: any;
  26643. private _parentNode;
  26644. private _children;
  26645. /** @hidden */
  26646. _worldMatrix: Matrix;
  26647. /** @hidden */
  26648. _worldMatrixDeterminant: number;
  26649. /** @hidden */
  26650. _worldMatrixDeterminantIsDirty: boolean;
  26651. /** @hidden */
  26652. private _sceneRootNodesIndex;
  26653. /**
  26654. * Gets a boolean indicating if the node has been disposed
  26655. * @returns true if the node was disposed
  26656. */
  26657. isDisposed(): boolean;
  26658. /**
  26659. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26660. * @see https://doc.babylonjs.com/how_to/parenting
  26661. */
  26662. parent: Nullable<Node>;
  26663. private addToSceneRootNodes;
  26664. private removeFromSceneRootNodes;
  26665. private _animationPropertiesOverride;
  26666. /**
  26667. * Gets or sets the animation properties override
  26668. */
  26669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26670. /**
  26671. * Gets a string idenfifying the name of the class
  26672. * @returns "Node" string
  26673. */
  26674. getClassName(): string;
  26675. /** @hidden */
  26676. readonly _isNode: boolean;
  26677. /**
  26678. * An event triggered when the mesh is disposed
  26679. */
  26680. onDisposeObservable: Observable<Node>;
  26681. private _onDisposeObserver;
  26682. /**
  26683. * Sets a callback that will be raised when the node will be disposed
  26684. */
  26685. onDispose: () => void;
  26686. /**
  26687. * Creates a new Node
  26688. * @param name the name and id to be given to this node
  26689. * @param scene the scene this node will be added to
  26690. * @param addToRootNodes the node will be added to scene.rootNodes
  26691. */
  26692. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26693. /**
  26694. * Gets the scene of the node
  26695. * @returns a scene
  26696. */
  26697. getScene(): Scene;
  26698. /**
  26699. * Gets the engine of the node
  26700. * @returns a Engine
  26701. */
  26702. getEngine(): Engine;
  26703. private _behaviors;
  26704. /**
  26705. * Attach a behavior to the node
  26706. * @see http://doc.babylonjs.com/features/behaviour
  26707. * @param behavior defines the behavior to attach
  26708. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26709. * @returns the current Node
  26710. */
  26711. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26712. /**
  26713. * Remove an attached behavior
  26714. * @see http://doc.babylonjs.com/features/behaviour
  26715. * @param behavior defines the behavior to attach
  26716. * @returns the current Node
  26717. */
  26718. removeBehavior(behavior: Behavior<Node>): Node;
  26719. /**
  26720. * Gets the list of attached behaviors
  26721. * @see http://doc.babylonjs.com/features/behaviour
  26722. */
  26723. readonly behaviors: Behavior<Node>[];
  26724. /**
  26725. * Gets an attached behavior by name
  26726. * @param name defines the name of the behavior to look for
  26727. * @see http://doc.babylonjs.com/features/behaviour
  26728. * @returns null if behavior was not found else the requested behavior
  26729. */
  26730. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26731. /**
  26732. * Returns the latest update of the World matrix
  26733. * @returns a Matrix
  26734. */
  26735. getWorldMatrix(): Matrix;
  26736. /** @hidden */
  26737. _getWorldMatrixDeterminant(): number;
  26738. /**
  26739. * Returns directly the latest state of the mesh World matrix.
  26740. * A Matrix is returned.
  26741. */
  26742. readonly worldMatrixFromCache: Matrix;
  26743. /** @hidden */
  26744. _initCache(): void;
  26745. /** @hidden */
  26746. updateCache(force?: boolean): void;
  26747. /** @hidden */
  26748. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26749. /** @hidden */
  26750. _updateCache(ignoreParentClass?: boolean): void;
  26751. /** @hidden */
  26752. _isSynchronized(): boolean;
  26753. /** @hidden */
  26754. _markSyncedWithParent(): void;
  26755. /** @hidden */
  26756. isSynchronizedWithParent(): boolean;
  26757. /** @hidden */
  26758. isSynchronized(): boolean;
  26759. /**
  26760. * Is this node ready to be used/rendered
  26761. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26762. * @return true if the node is ready
  26763. */
  26764. isReady(completeCheck?: boolean): boolean;
  26765. /**
  26766. * Is this node enabled?
  26767. * 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
  26768. * @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
  26769. * @return whether this node (and its parent) is enabled
  26770. */
  26771. isEnabled(checkAncestors?: boolean): boolean;
  26772. /** @hidden */
  26773. protected _syncParentEnabledState(): void;
  26774. /**
  26775. * Set the enabled state of this node
  26776. * @param value defines the new enabled state
  26777. */
  26778. setEnabled(value: boolean): void;
  26779. /**
  26780. * Is this node a descendant of the given node?
  26781. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26782. * @param ancestor defines the parent node to inspect
  26783. * @returns a boolean indicating if this node is a descendant of the given node
  26784. */
  26785. isDescendantOf(ancestor: Node): boolean;
  26786. /** @hidden */
  26787. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26788. /**
  26789. * Will return all nodes that have this node as ascendant
  26790. * @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
  26791. * @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
  26792. * @return all children nodes of all types
  26793. */
  26794. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26795. /**
  26796. * Get all child-meshes of this node
  26797. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26798. * @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
  26799. * @returns an array of AbstractMesh
  26800. */
  26801. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26802. /**
  26803. * Get all direct children of this node
  26804. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26805. * @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)
  26806. * @returns an array of Node
  26807. */
  26808. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26809. /** @hidden */
  26810. _setReady(state: boolean): void;
  26811. /**
  26812. * Get an animation by name
  26813. * @param name defines the name of the animation to look for
  26814. * @returns null if not found else the requested animation
  26815. */
  26816. getAnimationByName(name: string): Nullable<Animation>;
  26817. /**
  26818. * Creates an animation range for this node
  26819. * @param name defines the name of the range
  26820. * @param from defines the starting key
  26821. * @param to defines the end key
  26822. */
  26823. createAnimationRange(name: string, from: number, to: number): void;
  26824. /**
  26825. * Delete a specific animation range
  26826. * @param name defines the name of the range to delete
  26827. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26828. */
  26829. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26830. /**
  26831. * Get an animation range by name
  26832. * @param name defines the name of the animation range to look for
  26833. * @returns null if not found else the requested animation range
  26834. */
  26835. getAnimationRange(name: string): Nullable<AnimationRange>;
  26836. /**
  26837. * Gets the list of all animation ranges defined on this node
  26838. * @returns an array
  26839. */
  26840. getAnimationRanges(): Nullable<AnimationRange>[];
  26841. /**
  26842. * Will start the animation sequence
  26843. * @param name defines the range frames for animation sequence
  26844. * @param loop defines if the animation should loop (false by default)
  26845. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26846. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26847. * @returns the object created for this animation. If range does not exist, it will return null
  26848. */
  26849. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26850. /**
  26851. * Serialize animation ranges into a JSON compatible object
  26852. * @returns serialization object
  26853. */
  26854. serializeAnimationRanges(): any;
  26855. /**
  26856. * Computes the world matrix of the node
  26857. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26858. * @returns the world matrix
  26859. */
  26860. computeWorldMatrix(force?: boolean): Matrix;
  26861. /**
  26862. * Releases resources associated with this node.
  26863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26865. */
  26866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26867. /**
  26868. * Parse animation range data from a serialization object and store them into a given node
  26869. * @param node defines where to store the animation ranges
  26870. * @param parsedNode defines the serialization object to read data from
  26871. * @param scene defines the hosting scene
  26872. */
  26873. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26874. /**
  26875. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26876. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26877. * @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
  26878. * @returns the new bounding vectors
  26879. */
  26880. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26881. min: Vector3;
  26882. max: Vector3;
  26883. };
  26884. }
  26885. }
  26886. declare module BABYLON {
  26887. /**
  26888. * @hidden
  26889. */
  26890. export class _IAnimationState {
  26891. key: number;
  26892. repeatCount: number;
  26893. workValue?: any;
  26894. loopMode?: number;
  26895. offsetValue?: any;
  26896. highLimitValue?: any;
  26897. }
  26898. /**
  26899. * Class used to store any kind of animation
  26900. */
  26901. export class Animation {
  26902. /**Name of the animation */
  26903. name: string;
  26904. /**Property to animate */
  26905. targetProperty: string;
  26906. /**The frames per second of the animation */
  26907. framePerSecond: number;
  26908. /**The data type of the animation */
  26909. dataType: number;
  26910. /**The loop mode of the animation */
  26911. loopMode?: number | undefined;
  26912. /**Specifies if blending should be enabled */
  26913. enableBlending?: boolean | undefined;
  26914. /**
  26915. * Use matrix interpolation instead of using direct key value when animating matrices
  26916. */
  26917. static AllowMatricesInterpolation: boolean;
  26918. /**
  26919. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26920. */
  26921. static AllowMatrixDecomposeForInterpolation: boolean;
  26922. /**
  26923. * Stores the key frames of the animation
  26924. */
  26925. private _keys;
  26926. /**
  26927. * Stores the easing function of the animation
  26928. */
  26929. private _easingFunction;
  26930. /**
  26931. * @hidden Internal use only
  26932. */
  26933. _runtimeAnimations: RuntimeAnimation[];
  26934. /**
  26935. * The set of event that will be linked to this animation
  26936. */
  26937. private _events;
  26938. /**
  26939. * Stores an array of target property paths
  26940. */
  26941. targetPropertyPath: string[];
  26942. /**
  26943. * Stores the blending speed of the animation
  26944. */
  26945. blendingSpeed: number;
  26946. /**
  26947. * Stores the animation ranges for the animation
  26948. */
  26949. private _ranges;
  26950. /**
  26951. * @hidden Internal use
  26952. */
  26953. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26954. /**
  26955. * Sets up an animation
  26956. * @param property The property to animate
  26957. * @param animationType The animation type to apply
  26958. * @param framePerSecond The frames per second of the animation
  26959. * @param easingFunction The easing function used in the animation
  26960. * @returns The created animation
  26961. */
  26962. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26963. /**
  26964. * Create and start an animation on a node
  26965. * @param name defines the name of the global animation that will be run on all nodes
  26966. * @param node defines the root node where the animation will take place
  26967. * @param targetProperty defines property to animate
  26968. * @param framePerSecond defines the number of frame per second yo use
  26969. * @param totalFrame defines the number of frames in total
  26970. * @param from defines the initial value
  26971. * @param to defines the final value
  26972. * @param loopMode defines which loop mode you want to use (off by default)
  26973. * @param easingFunction defines the easing function to use (linear by default)
  26974. * @param onAnimationEnd defines the callback to call when animation end
  26975. * @returns the animatable created for this animation
  26976. */
  26977. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26978. /**
  26979. * Create and start an animation on a node and its descendants
  26980. * @param name defines the name of the global animation that will be run on all nodes
  26981. * @param node defines the root node where the animation will take place
  26982. * @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
  26983. * @param targetProperty defines property to animate
  26984. * @param framePerSecond defines the number of frame per second to use
  26985. * @param totalFrame defines the number of frames in total
  26986. * @param from defines the initial value
  26987. * @param to defines the final value
  26988. * @param loopMode defines which loop mode you want to use (off by default)
  26989. * @param easingFunction defines the easing function to use (linear by default)
  26990. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26991. * @returns the list of animatables created for all nodes
  26992. * @example https://www.babylonjs-playground.com/#MH0VLI
  26993. */
  26994. 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[]>;
  26995. /**
  26996. * Creates a new animation, merges it with the existing animations and starts it
  26997. * @param name Name of the animation
  26998. * @param node Node which contains the scene that begins the animations
  26999. * @param targetProperty Specifies which property to animate
  27000. * @param framePerSecond The frames per second of the animation
  27001. * @param totalFrame The total number of frames
  27002. * @param from The frame at the beginning of the animation
  27003. * @param to The frame at the end of the animation
  27004. * @param loopMode Specifies the loop mode of the animation
  27005. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27006. * @param onAnimationEnd Callback to run once the animation is complete
  27007. * @returns Nullable animation
  27008. */
  27009. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27010. /**
  27011. * Transition property of an host to the target Value
  27012. * @param property The property to transition
  27013. * @param targetValue The target Value of the property
  27014. * @param host The object where the property to animate belongs
  27015. * @param scene Scene used to run the animation
  27016. * @param frameRate Framerate (in frame/s) to use
  27017. * @param transition The transition type we want to use
  27018. * @param duration The duration of the animation, in milliseconds
  27019. * @param onAnimationEnd Callback trigger at the end of the animation
  27020. * @returns Nullable animation
  27021. */
  27022. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27023. /**
  27024. * Return the array of runtime animations currently using this animation
  27025. */
  27026. readonly runtimeAnimations: RuntimeAnimation[];
  27027. /**
  27028. * Specifies if any of the runtime animations are currently running
  27029. */
  27030. readonly hasRunningRuntimeAnimations: boolean;
  27031. /**
  27032. * Initializes the animation
  27033. * @param name Name of the animation
  27034. * @param targetProperty Property to animate
  27035. * @param framePerSecond The frames per second of the animation
  27036. * @param dataType The data type of the animation
  27037. * @param loopMode The loop mode of the animation
  27038. * @param enableBlending Specifies if blending should be enabled
  27039. */
  27040. constructor(
  27041. /**Name of the animation */
  27042. name: string,
  27043. /**Property to animate */
  27044. targetProperty: string,
  27045. /**The frames per second of the animation */
  27046. framePerSecond: number,
  27047. /**The data type of the animation */
  27048. dataType: number,
  27049. /**The loop mode of the animation */
  27050. loopMode?: number | undefined,
  27051. /**Specifies if blending should be enabled */
  27052. enableBlending?: boolean | undefined);
  27053. /**
  27054. * Converts the animation to a string
  27055. * @param fullDetails support for multiple levels of logging within scene loading
  27056. * @returns String form of the animation
  27057. */
  27058. toString(fullDetails?: boolean): string;
  27059. /**
  27060. * Add an event to this animation
  27061. * @param event Event to add
  27062. */
  27063. addEvent(event: AnimationEvent): void;
  27064. /**
  27065. * Remove all events found at the given frame
  27066. * @param frame The frame to remove events from
  27067. */
  27068. removeEvents(frame: number): void;
  27069. /**
  27070. * Retrieves all the events from the animation
  27071. * @returns Events from the animation
  27072. */
  27073. getEvents(): AnimationEvent[];
  27074. /**
  27075. * Creates an animation range
  27076. * @param name Name of the animation range
  27077. * @param from Starting frame of the animation range
  27078. * @param to Ending frame of the animation
  27079. */
  27080. createRange(name: string, from: number, to: number): void;
  27081. /**
  27082. * Deletes an animation range by name
  27083. * @param name Name of the animation range to delete
  27084. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27085. */
  27086. deleteRange(name: string, deleteFrames?: boolean): void;
  27087. /**
  27088. * Gets the animation range by name, or null if not defined
  27089. * @param name Name of the animation range
  27090. * @returns Nullable animation range
  27091. */
  27092. getRange(name: string): Nullable<AnimationRange>;
  27093. /**
  27094. * Gets the key frames from the animation
  27095. * @returns The key frames of the animation
  27096. */
  27097. getKeys(): Array<IAnimationKey>;
  27098. /**
  27099. * Gets the highest frame rate of the animation
  27100. * @returns Highest frame rate of the animation
  27101. */
  27102. getHighestFrame(): number;
  27103. /**
  27104. * Gets the easing function of the animation
  27105. * @returns Easing function of the animation
  27106. */
  27107. getEasingFunction(): IEasingFunction;
  27108. /**
  27109. * Sets the easing function of the animation
  27110. * @param easingFunction A custom mathematical formula for animation
  27111. */
  27112. setEasingFunction(easingFunction: EasingFunction): void;
  27113. /**
  27114. * Interpolates a scalar linearly
  27115. * @param startValue Start value of the animation curve
  27116. * @param endValue End value of the animation curve
  27117. * @param gradient Scalar amount to interpolate
  27118. * @returns Interpolated scalar value
  27119. */
  27120. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27121. /**
  27122. * Interpolates a scalar cubically
  27123. * @param startValue Start value of the animation curve
  27124. * @param outTangent End tangent of the animation
  27125. * @param endValue End value of the animation curve
  27126. * @param inTangent Start tangent of the animation curve
  27127. * @param gradient Scalar amount to interpolate
  27128. * @returns Interpolated scalar value
  27129. */
  27130. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27131. /**
  27132. * Interpolates a quaternion using a spherical linear interpolation
  27133. * @param startValue Start value of the animation curve
  27134. * @param endValue End value of the animation curve
  27135. * @param gradient Scalar amount to interpolate
  27136. * @returns Interpolated quaternion value
  27137. */
  27138. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27139. /**
  27140. * Interpolates a quaternion cubically
  27141. * @param startValue Start value of the animation curve
  27142. * @param outTangent End tangent of the animation curve
  27143. * @param endValue End value of the animation curve
  27144. * @param inTangent Start tangent of the animation curve
  27145. * @param gradient Scalar amount to interpolate
  27146. * @returns Interpolated quaternion value
  27147. */
  27148. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27149. /**
  27150. * Interpolates a Vector3 linearl
  27151. * @param startValue Start value of the animation curve
  27152. * @param endValue End value of the animation curve
  27153. * @param gradient Scalar amount to interpolate
  27154. * @returns Interpolated scalar value
  27155. */
  27156. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27157. /**
  27158. * Interpolates a Vector3 cubically
  27159. * @param startValue Start value of the animation curve
  27160. * @param outTangent End tangent of the animation
  27161. * @param endValue End value of the animation curve
  27162. * @param inTangent Start tangent of the animation curve
  27163. * @param gradient Scalar amount to interpolate
  27164. * @returns InterpolatedVector3 value
  27165. */
  27166. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27167. /**
  27168. * Interpolates a Vector2 linearly
  27169. * @param startValue Start value of the animation curve
  27170. * @param endValue End value of the animation curve
  27171. * @param gradient Scalar amount to interpolate
  27172. * @returns Interpolated Vector2 value
  27173. */
  27174. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27175. /**
  27176. * Interpolates a Vector2 cubically
  27177. * @param startValue Start value of the animation curve
  27178. * @param outTangent End tangent of the animation
  27179. * @param endValue End value of the animation curve
  27180. * @param inTangent Start tangent of the animation curve
  27181. * @param gradient Scalar amount to interpolate
  27182. * @returns Interpolated Vector2 value
  27183. */
  27184. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27185. /**
  27186. * Interpolates a size linearly
  27187. * @param startValue Start value of the animation curve
  27188. * @param endValue End value of the animation curve
  27189. * @param gradient Scalar amount to interpolate
  27190. * @returns Interpolated Size value
  27191. */
  27192. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27193. /**
  27194. * Interpolates a Color3 linearly
  27195. * @param startValue Start value of the animation curve
  27196. * @param endValue End value of the animation curve
  27197. * @param gradient Scalar amount to interpolate
  27198. * @returns Interpolated Color3 value
  27199. */
  27200. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27201. /**
  27202. * @hidden Internal use only
  27203. */
  27204. _getKeyValue(value: any): any;
  27205. /**
  27206. * @hidden Internal use only
  27207. */
  27208. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27209. /**
  27210. * Defines the function to use to interpolate matrices
  27211. * @param startValue defines the start matrix
  27212. * @param endValue defines the end matrix
  27213. * @param gradient defines the gradient between both matrices
  27214. * @param result defines an optional target matrix where to store the interpolation
  27215. * @returns the interpolated matrix
  27216. */
  27217. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27218. /**
  27219. * Makes a copy of the animation
  27220. * @returns Cloned animation
  27221. */
  27222. clone(): Animation;
  27223. /**
  27224. * Sets the key frames of the animation
  27225. * @param values The animation key frames to set
  27226. */
  27227. setKeys(values: Array<IAnimationKey>): void;
  27228. /**
  27229. * Serializes the animation to an object
  27230. * @returns Serialized object
  27231. */
  27232. serialize(): any;
  27233. /**
  27234. * Float animation type
  27235. */
  27236. private static _ANIMATIONTYPE_FLOAT;
  27237. /**
  27238. * Vector3 animation type
  27239. */
  27240. private static _ANIMATIONTYPE_VECTOR3;
  27241. /**
  27242. * Quaternion animation type
  27243. */
  27244. private static _ANIMATIONTYPE_QUATERNION;
  27245. /**
  27246. * Matrix animation type
  27247. */
  27248. private static _ANIMATIONTYPE_MATRIX;
  27249. /**
  27250. * Color3 animation type
  27251. */
  27252. private static _ANIMATIONTYPE_COLOR3;
  27253. /**
  27254. * Vector2 animation type
  27255. */
  27256. private static _ANIMATIONTYPE_VECTOR2;
  27257. /**
  27258. * Size animation type
  27259. */
  27260. private static _ANIMATIONTYPE_SIZE;
  27261. /**
  27262. * Relative Loop Mode
  27263. */
  27264. private static _ANIMATIONLOOPMODE_RELATIVE;
  27265. /**
  27266. * Cycle Loop Mode
  27267. */
  27268. private static _ANIMATIONLOOPMODE_CYCLE;
  27269. /**
  27270. * Constant Loop Mode
  27271. */
  27272. private static _ANIMATIONLOOPMODE_CONSTANT;
  27273. /**
  27274. * Get the float animation type
  27275. */
  27276. static readonly ANIMATIONTYPE_FLOAT: number;
  27277. /**
  27278. * Get the Vector3 animation type
  27279. */
  27280. static readonly ANIMATIONTYPE_VECTOR3: number;
  27281. /**
  27282. * Get the Vector2 animation type
  27283. */
  27284. static readonly ANIMATIONTYPE_VECTOR2: number;
  27285. /**
  27286. * Get the Size animation type
  27287. */
  27288. static readonly ANIMATIONTYPE_SIZE: number;
  27289. /**
  27290. * Get the Quaternion animation type
  27291. */
  27292. static readonly ANIMATIONTYPE_QUATERNION: number;
  27293. /**
  27294. * Get the Matrix animation type
  27295. */
  27296. static readonly ANIMATIONTYPE_MATRIX: number;
  27297. /**
  27298. * Get the Color3 animation type
  27299. */
  27300. static readonly ANIMATIONTYPE_COLOR3: number;
  27301. /**
  27302. * Get the Relative Loop Mode
  27303. */
  27304. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27305. /**
  27306. * Get the Cycle Loop Mode
  27307. */
  27308. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27309. /**
  27310. * Get the Constant Loop Mode
  27311. */
  27312. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27313. /** @hidden */
  27314. static _UniversalLerp(left: any, right: any, amount: number): any;
  27315. /**
  27316. * Parses an animation object and creates an animation
  27317. * @param parsedAnimation Parsed animation object
  27318. * @returns Animation object
  27319. */
  27320. static Parse(parsedAnimation: any): Animation;
  27321. /**
  27322. * Appends the serialized animations from the source animations
  27323. * @param source Source containing the animations
  27324. * @param destination Target to store the animations
  27325. */
  27326. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27327. }
  27328. }
  27329. declare module BABYLON {
  27330. /**
  27331. * Interface containing an array of animations
  27332. */
  27333. export interface IAnimatable {
  27334. /**
  27335. * Array of animations
  27336. */
  27337. animations: Nullable<Array<Animation>>;
  27338. }
  27339. }
  27340. declare module BABYLON {
  27341. /**
  27342. * This represents all the required information to add a fresnel effect on a material:
  27343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27344. */
  27345. export class FresnelParameters {
  27346. private _isEnabled;
  27347. /**
  27348. * Define if the fresnel effect is enable or not.
  27349. */
  27350. isEnabled: boolean;
  27351. /**
  27352. * Define the color used on edges (grazing angle)
  27353. */
  27354. leftColor: Color3;
  27355. /**
  27356. * Define the color used on center
  27357. */
  27358. rightColor: Color3;
  27359. /**
  27360. * Define bias applied to computed fresnel term
  27361. */
  27362. bias: number;
  27363. /**
  27364. * Defined the power exponent applied to fresnel term
  27365. */
  27366. power: number;
  27367. /**
  27368. * Clones the current fresnel and its valuues
  27369. * @returns a clone fresnel configuration
  27370. */
  27371. clone(): FresnelParameters;
  27372. /**
  27373. * Serializes the current fresnel parameters to a JSON representation.
  27374. * @return the JSON serialization
  27375. */
  27376. serialize(): any;
  27377. /**
  27378. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27379. * @param parsedFresnelParameters Define the JSON representation
  27380. * @returns the parsed parameters
  27381. */
  27382. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27383. }
  27384. }
  27385. declare module BABYLON {
  27386. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27387. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27388. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27389. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27390. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27391. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27392. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27393. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27394. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27395. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27396. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27397. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27398. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27399. /**
  27400. * Decorator used to define property that can be serialized as reference to a camera
  27401. * @param sourceName defines the name of the property to decorate
  27402. */
  27403. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27404. /**
  27405. * Class used to help serialization objects
  27406. */
  27407. export class SerializationHelper {
  27408. /** @hidden */
  27409. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27410. /** @hidden */
  27411. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27412. /** @hidden */
  27413. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27414. /** @hidden */
  27415. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27416. /**
  27417. * Appends the serialized animations from the source animations
  27418. * @param source Source containing the animations
  27419. * @param destination Target to store the animations
  27420. */
  27421. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27422. /**
  27423. * Static function used to serialized a specific entity
  27424. * @param entity defines the entity to serialize
  27425. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27426. * @returns a JSON compatible object representing the serialization of the entity
  27427. */
  27428. static Serialize<T>(entity: T, serializationObject?: any): any;
  27429. /**
  27430. * Creates a new entity from a serialization data object
  27431. * @param creationFunction defines a function used to instanciated the new entity
  27432. * @param source defines the source serialization data
  27433. * @param scene defines the hosting scene
  27434. * @param rootUrl defines the root url for resources
  27435. * @returns a new entity
  27436. */
  27437. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27438. /**
  27439. * Clones an object
  27440. * @param creationFunction defines the function used to instanciate the new object
  27441. * @param source defines the source object
  27442. * @returns the cloned object
  27443. */
  27444. static Clone<T>(creationFunction: () => T, source: T): T;
  27445. /**
  27446. * Instanciates a new object based on a source one (some data will be shared between both object)
  27447. * @param creationFunction defines the function used to instanciate the new object
  27448. * @param source defines the source object
  27449. * @returns the new object
  27450. */
  27451. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27452. }
  27453. }
  27454. declare module BABYLON {
  27455. /**
  27456. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27457. */
  27458. export interface CubeMapInfo {
  27459. /**
  27460. * The pixel array for the front face.
  27461. * This is stored in format, left to right, up to down format.
  27462. */
  27463. front: Nullable<ArrayBufferView>;
  27464. /**
  27465. * The pixel array for the back face.
  27466. * This is stored in format, left to right, up to down format.
  27467. */
  27468. back: Nullable<ArrayBufferView>;
  27469. /**
  27470. * The pixel array for the left face.
  27471. * This is stored in format, left to right, up to down format.
  27472. */
  27473. left: Nullable<ArrayBufferView>;
  27474. /**
  27475. * The pixel array for the right face.
  27476. * This is stored in format, left to right, up to down format.
  27477. */
  27478. right: Nullable<ArrayBufferView>;
  27479. /**
  27480. * The pixel array for the up face.
  27481. * This is stored in format, left to right, up to down format.
  27482. */
  27483. up: Nullable<ArrayBufferView>;
  27484. /**
  27485. * The pixel array for the down face.
  27486. * This is stored in format, left to right, up to down format.
  27487. */
  27488. down: Nullable<ArrayBufferView>;
  27489. /**
  27490. * The size of the cubemap stored.
  27491. *
  27492. * Each faces will be size * size pixels.
  27493. */
  27494. size: number;
  27495. /**
  27496. * The format of the texture.
  27497. *
  27498. * RGBA, RGB.
  27499. */
  27500. format: number;
  27501. /**
  27502. * The type of the texture data.
  27503. *
  27504. * UNSIGNED_INT, FLOAT.
  27505. */
  27506. type: number;
  27507. /**
  27508. * Specifies whether the texture is in gamma space.
  27509. */
  27510. gammaSpace: boolean;
  27511. }
  27512. /**
  27513. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27514. */
  27515. export class PanoramaToCubeMapTools {
  27516. private static FACE_FRONT;
  27517. private static FACE_BACK;
  27518. private static FACE_RIGHT;
  27519. private static FACE_LEFT;
  27520. private static FACE_DOWN;
  27521. private static FACE_UP;
  27522. /**
  27523. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27524. *
  27525. * @param float32Array The source data.
  27526. * @param inputWidth The width of the input panorama.
  27527. * @param inputHeight The height of the input panorama.
  27528. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27529. * @return The cubemap data
  27530. */
  27531. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27532. private static CreateCubemapTexture;
  27533. private static CalcProjectionSpherical;
  27534. }
  27535. }
  27536. declare module BABYLON {
  27537. /**
  27538. * Helper class dealing with the extraction of spherical polynomial dataArray
  27539. * from a cube map.
  27540. */
  27541. export class CubeMapToSphericalPolynomialTools {
  27542. private static FileFaces;
  27543. /**
  27544. * Converts a texture to the according Spherical Polynomial data.
  27545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27546. *
  27547. * @param texture The texture to extract the information from.
  27548. * @return The Spherical Polynomial data.
  27549. */
  27550. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27551. /**
  27552. * Converts a cubemap to the according Spherical Polynomial data.
  27553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27554. *
  27555. * @param cubeInfo The Cube map to extract the information from.
  27556. * @return The Spherical Polynomial data.
  27557. */
  27558. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27559. }
  27560. }
  27561. declare module BABYLON {
  27562. /**
  27563. * Class used to manipulate GUIDs
  27564. */
  27565. export class GUID {
  27566. /**
  27567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27568. * Be aware Math.random() could cause collisions, but:
  27569. * "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"
  27570. * @returns a pseudo random id
  27571. */
  27572. static RandomId(): string;
  27573. }
  27574. }
  27575. declare module BABYLON {
  27576. /**
  27577. * Base class of all the textures in babylon.
  27578. * It groups all the common properties the materials, post process, lights... might need
  27579. * in order to make a correct use of the texture.
  27580. */
  27581. export class BaseTexture implements IAnimatable {
  27582. /**
  27583. * Default anisotropic filtering level for the application.
  27584. * It is set to 4 as a good tradeoff between perf and quality.
  27585. */
  27586. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27587. /**
  27588. * Gets or sets the unique id of the texture
  27589. */
  27590. uniqueId: number;
  27591. /**
  27592. * Define the name of the texture.
  27593. */
  27594. name: string;
  27595. /**
  27596. * Gets or sets an object used to store user defined information.
  27597. */
  27598. metadata: any;
  27599. /**
  27600. * For internal use only. Please do not use.
  27601. */
  27602. reservedDataStore: any;
  27603. private _hasAlpha;
  27604. /**
  27605. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27606. */
  27607. hasAlpha: boolean;
  27608. /**
  27609. * Defines if the alpha value should be determined via the rgb values.
  27610. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27611. */
  27612. getAlphaFromRGB: boolean;
  27613. /**
  27614. * Intensity or strength of the texture.
  27615. * It is commonly used by materials to fine tune the intensity of the texture
  27616. */
  27617. level: number;
  27618. /**
  27619. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27620. * This is part of the texture as textures usually maps to one uv set.
  27621. */
  27622. coordinatesIndex: number;
  27623. private _coordinatesMode;
  27624. /**
  27625. * How a texture is mapped.
  27626. *
  27627. * | Value | Type | Description |
  27628. * | ----- | ----------------------------------- | ----------- |
  27629. * | 0 | EXPLICIT_MODE | |
  27630. * | 1 | SPHERICAL_MODE | |
  27631. * | 2 | PLANAR_MODE | |
  27632. * | 3 | CUBIC_MODE | |
  27633. * | 4 | PROJECTION_MODE | |
  27634. * | 5 | SKYBOX_MODE | |
  27635. * | 6 | INVCUBIC_MODE | |
  27636. * | 7 | EQUIRECTANGULAR_MODE | |
  27637. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27638. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27639. */
  27640. coordinatesMode: number;
  27641. /**
  27642. * | Value | Type | Description |
  27643. * | ----- | ------------------ | ----------- |
  27644. * | 0 | CLAMP_ADDRESSMODE | |
  27645. * | 1 | WRAP_ADDRESSMODE | |
  27646. * | 2 | MIRROR_ADDRESSMODE | |
  27647. */
  27648. wrapU: number;
  27649. /**
  27650. * | Value | Type | Description |
  27651. * | ----- | ------------------ | ----------- |
  27652. * | 0 | CLAMP_ADDRESSMODE | |
  27653. * | 1 | WRAP_ADDRESSMODE | |
  27654. * | 2 | MIRROR_ADDRESSMODE | |
  27655. */
  27656. wrapV: number;
  27657. /**
  27658. * | Value | Type | Description |
  27659. * | ----- | ------------------ | ----------- |
  27660. * | 0 | CLAMP_ADDRESSMODE | |
  27661. * | 1 | WRAP_ADDRESSMODE | |
  27662. * | 2 | MIRROR_ADDRESSMODE | |
  27663. */
  27664. wrapR: number;
  27665. /**
  27666. * With compliant hardware and browser (supporting anisotropic filtering)
  27667. * this defines the level of anisotropic filtering in the texture.
  27668. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27669. */
  27670. anisotropicFilteringLevel: number;
  27671. /**
  27672. * Define if the texture is a cube texture or if false a 2d texture.
  27673. */
  27674. isCube: boolean;
  27675. /**
  27676. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27677. */
  27678. is3D: boolean;
  27679. /**
  27680. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27681. * HDR texture are usually stored in linear space.
  27682. * This only impacts the PBR and Background materials
  27683. */
  27684. gammaSpace: boolean;
  27685. /**
  27686. * Gets whether or not the texture contains RGBD data.
  27687. */
  27688. readonly isRGBD: boolean;
  27689. /**
  27690. * Is Z inverted in the texture (useful in a cube texture).
  27691. */
  27692. invertZ: boolean;
  27693. /**
  27694. * Are mip maps generated for this texture or not.
  27695. */
  27696. readonly noMipmap: boolean;
  27697. /**
  27698. * @hidden
  27699. */
  27700. lodLevelInAlpha: boolean;
  27701. /**
  27702. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27703. */
  27704. lodGenerationOffset: number;
  27705. /**
  27706. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27707. */
  27708. lodGenerationScale: number;
  27709. /**
  27710. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27711. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27712. * average roughness values.
  27713. */
  27714. linearSpecularLOD: boolean;
  27715. /**
  27716. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27717. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27718. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27719. */
  27720. irradianceTexture: Nullable<BaseTexture>;
  27721. /**
  27722. * Define if the texture is a render target.
  27723. */
  27724. isRenderTarget: boolean;
  27725. /**
  27726. * Define the unique id of the texture in the scene.
  27727. */
  27728. readonly uid: string;
  27729. /**
  27730. * Return a string representation of the texture.
  27731. * @returns the texture as a string
  27732. */
  27733. toString(): string;
  27734. /**
  27735. * Get the class name of the texture.
  27736. * @returns "BaseTexture"
  27737. */
  27738. getClassName(): string;
  27739. /**
  27740. * Define the list of animation attached to the texture.
  27741. */
  27742. animations: Animation[];
  27743. /**
  27744. * An event triggered when the texture is disposed.
  27745. */
  27746. onDisposeObservable: Observable<BaseTexture>;
  27747. private _onDisposeObserver;
  27748. /**
  27749. * Callback triggered when the texture has been disposed.
  27750. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27751. */
  27752. onDispose: () => void;
  27753. /**
  27754. * Define the current state of the loading sequence when in delayed load mode.
  27755. */
  27756. delayLoadState: number;
  27757. private _scene;
  27758. /** @hidden */
  27759. _texture: Nullable<InternalTexture>;
  27760. private _uid;
  27761. /**
  27762. * Define if the texture is preventinga material to render or not.
  27763. * If not and the texture is not ready, the engine will use a default black texture instead.
  27764. */
  27765. readonly isBlocking: boolean;
  27766. /**
  27767. * Instantiates a new BaseTexture.
  27768. * Base class of all the textures in babylon.
  27769. * It groups all the common properties the materials, post process, lights... might need
  27770. * in order to make a correct use of the texture.
  27771. * @param scene Define the scene the texture blongs to
  27772. */
  27773. constructor(scene: Nullable<Scene>);
  27774. /**
  27775. * Get the scene the texture belongs to.
  27776. * @returns the scene or null if undefined
  27777. */
  27778. getScene(): Nullable<Scene>;
  27779. /**
  27780. * Get the texture transform matrix used to offset tile the texture for istance.
  27781. * @returns the transformation matrix
  27782. */
  27783. getTextureMatrix(): Matrix;
  27784. /**
  27785. * Get the texture reflection matrix used to rotate/transform the reflection.
  27786. * @returns the reflection matrix
  27787. */
  27788. getReflectionTextureMatrix(): Matrix;
  27789. /**
  27790. * Get the underlying lower level texture from Babylon.
  27791. * @returns the insternal texture
  27792. */
  27793. getInternalTexture(): Nullable<InternalTexture>;
  27794. /**
  27795. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27796. * @returns true if ready or not blocking
  27797. */
  27798. isReadyOrNotBlocking(): boolean;
  27799. /**
  27800. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27801. * @returns true if fully ready
  27802. */
  27803. isReady(): boolean;
  27804. private _cachedSize;
  27805. /**
  27806. * Get the size of the texture.
  27807. * @returns the texture size.
  27808. */
  27809. getSize(): ISize;
  27810. /**
  27811. * Get the base size of the texture.
  27812. * It can be different from the size if the texture has been resized for POT for instance
  27813. * @returns the base size
  27814. */
  27815. getBaseSize(): ISize;
  27816. /**
  27817. * Update the sampling mode of the texture.
  27818. * Default is Trilinear mode.
  27819. *
  27820. * | Value | Type | Description |
  27821. * | ----- | ------------------ | ----------- |
  27822. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27823. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27824. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27825. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27826. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27827. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27828. * | 7 | NEAREST_LINEAR | |
  27829. * | 8 | NEAREST_NEAREST | |
  27830. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27831. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27832. * | 11 | LINEAR_LINEAR | |
  27833. * | 12 | LINEAR_NEAREST | |
  27834. *
  27835. * > _mag_: magnification filter (close to the viewer)
  27836. * > _min_: minification filter (far from the viewer)
  27837. * > _mip_: filter used between mip map levels
  27838. *@param samplingMode Define the new sampling mode of the texture
  27839. */
  27840. updateSamplingMode(samplingMode: number): void;
  27841. /**
  27842. * Scales the texture if is `canRescale()`
  27843. * @param ratio the resize factor we want to use to rescale
  27844. */
  27845. scale(ratio: number): void;
  27846. /**
  27847. * Get if the texture can rescale.
  27848. */
  27849. readonly canRescale: boolean;
  27850. /** @hidden */
  27851. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27852. /** @hidden */
  27853. _rebuild(): void;
  27854. /**
  27855. * Triggers the load sequence in delayed load mode.
  27856. */
  27857. delayLoad(): void;
  27858. /**
  27859. * Clones the texture.
  27860. * @returns the cloned texture
  27861. */
  27862. clone(): Nullable<BaseTexture>;
  27863. /**
  27864. * Get the texture underlying type (INT, FLOAT...)
  27865. */
  27866. readonly textureType: number;
  27867. /**
  27868. * Get the texture underlying format (RGB, RGBA...)
  27869. */
  27870. readonly textureFormat: number;
  27871. /**
  27872. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27873. * This will returns an RGBA array buffer containing either in values (0-255) or
  27874. * float values (0-1) depending of the underlying buffer type.
  27875. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27876. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27877. * @param buffer defines a user defined buffer to fill with data (can be null)
  27878. * @returns The Array buffer containing the pixels data.
  27879. */
  27880. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27881. /**
  27882. * Release and destroy the underlying lower level texture aka internalTexture.
  27883. */
  27884. releaseInternalTexture(): void;
  27885. /**
  27886. * Get the polynomial representation of the texture data.
  27887. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27888. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27889. */
  27890. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27891. /** @hidden */
  27892. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27893. /** @hidden */
  27894. readonly _lodTextureMid: Nullable<BaseTexture>;
  27895. /** @hidden */
  27896. readonly _lodTextureLow: Nullable<BaseTexture>;
  27897. /**
  27898. * Dispose the texture and release its associated resources.
  27899. */
  27900. dispose(): void;
  27901. /**
  27902. * Serialize the texture into a JSON representation that can be parsed later on.
  27903. * @returns the JSON representation of the texture
  27904. */
  27905. serialize(): any;
  27906. /**
  27907. * Helper function to be called back once a list of texture contains only ready textures.
  27908. * @param textures Define the list of textures to wait for
  27909. * @param callback Define the callback triggered once the entire list will be ready
  27910. */
  27911. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27912. }
  27913. }
  27914. declare module BABYLON {
  27915. /**
  27916. * Class used to store data associated with WebGL texture data for the engine
  27917. * This class should not be used directly
  27918. */
  27919. export class InternalTexture {
  27920. /** @hidden */
  27921. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27922. /**
  27923. * The source of the texture data is unknown
  27924. */
  27925. static DATASOURCE_UNKNOWN: number;
  27926. /**
  27927. * Texture data comes from an URL
  27928. */
  27929. static DATASOURCE_URL: number;
  27930. /**
  27931. * Texture data is only used for temporary storage
  27932. */
  27933. static DATASOURCE_TEMP: number;
  27934. /**
  27935. * Texture data comes from raw data (ArrayBuffer)
  27936. */
  27937. static DATASOURCE_RAW: number;
  27938. /**
  27939. * Texture content is dynamic (video or dynamic texture)
  27940. */
  27941. static DATASOURCE_DYNAMIC: number;
  27942. /**
  27943. * Texture content is generated by rendering to it
  27944. */
  27945. static DATASOURCE_RENDERTARGET: number;
  27946. /**
  27947. * Texture content is part of a multi render target process
  27948. */
  27949. static DATASOURCE_MULTIRENDERTARGET: number;
  27950. /**
  27951. * Texture data comes from a cube data file
  27952. */
  27953. static DATASOURCE_CUBE: number;
  27954. /**
  27955. * Texture data comes from a raw cube data
  27956. */
  27957. static DATASOURCE_CUBERAW: number;
  27958. /**
  27959. * Texture data come from a prefiltered cube data file
  27960. */
  27961. static DATASOURCE_CUBEPREFILTERED: number;
  27962. /**
  27963. * Texture content is raw 3D data
  27964. */
  27965. static DATASOURCE_RAW3D: number;
  27966. /**
  27967. * Texture content is a depth texture
  27968. */
  27969. static DATASOURCE_DEPTHTEXTURE: number;
  27970. /**
  27971. * Texture data comes from a raw cube data encoded with RGBD
  27972. */
  27973. static DATASOURCE_CUBERAW_RGBD: number;
  27974. /**
  27975. * Defines if the texture is ready
  27976. */
  27977. isReady: boolean;
  27978. /**
  27979. * Defines if the texture is a cube texture
  27980. */
  27981. isCube: boolean;
  27982. /**
  27983. * Defines if the texture contains 3D data
  27984. */
  27985. is3D: boolean;
  27986. /**
  27987. * Defines if the texture contains multiview data
  27988. */
  27989. isMultiview: boolean;
  27990. /**
  27991. * Gets the URL used to load this texture
  27992. */
  27993. url: string;
  27994. /**
  27995. * Gets the sampling mode of the texture
  27996. */
  27997. samplingMode: number;
  27998. /**
  27999. * Gets a boolean indicating if the texture needs mipmaps generation
  28000. */
  28001. generateMipMaps: boolean;
  28002. /**
  28003. * Gets the number of samples used by the texture (WebGL2+ only)
  28004. */
  28005. samples: number;
  28006. /**
  28007. * Gets the type of the texture (int, float...)
  28008. */
  28009. type: number;
  28010. /**
  28011. * Gets the format of the texture (RGB, RGBA...)
  28012. */
  28013. format: number;
  28014. /**
  28015. * Observable called when the texture is loaded
  28016. */
  28017. onLoadedObservable: Observable<InternalTexture>;
  28018. /**
  28019. * Gets the width of the texture
  28020. */
  28021. width: number;
  28022. /**
  28023. * Gets the height of the texture
  28024. */
  28025. height: number;
  28026. /**
  28027. * Gets the depth of the texture
  28028. */
  28029. depth: number;
  28030. /**
  28031. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28032. */
  28033. baseWidth: number;
  28034. /**
  28035. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28036. */
  28037. baseHeight: number;
  28038. /**
  28039. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28040. */
  28041. baseDepth: number;
  28042. /**
  28043. * Gets a boolean indicating if the texture is inverted on Y axis
  28044. */
  28045. invertY: boolean;
  28046. /** @hidden */
  28047. _invertVScale: boolean;
  28048. /** @hidden */
  28049. _associatedChannel: number;
  28050. /** @hidden */
  28051. _dataSource: number;
  28052. /** @hidden */
  28053. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28054. /** @hidden */
  28055. _bufferView: Nullable<ArrayBufferView>;
  28056. /** @hidden */
  28057. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28058. /** @hidden */
  28059. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28060. /** @hidden */
  28061. _size: number;
  28062. /** @hidden */
  28063. _extension: string;
  28064. /** @hidden */
  28065. _files: Nullable<string[]>;
  28066. /** @hidden */
  28067. _workingCanvas: Nullable<HTMLCanvasElement>;
  28068. /** @hidden */
  28069. _workingContext: Nullable<CanvasRenderingContext2D>;
  28070. /** @hidden */
  28071. _framebuffer: Nullable<WebGLFramebuffer>;
  28072. /** @hidden */
  28073. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28074. /** @hidden */
  28075. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28076. /** @hidden */
  28077. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28078. /** @hidden */
  28079. _attachments: Nullable<number[]>;
  28080. /** @hidden */
  28081. _cachedCoordinatesMode: Nullable<number>;
  28082. /** @hidden */
  28083. _cachedWrapU: Nullable<number>;
  28084. /** @hidden */
  28085. _cachedWrapV: Nullable<number>;
  28086. /** @hidden */
  28087. _cachedWrapR: Nullable<number>;
  28088. /** @hidden */
  28089. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28090. /** @hidden */
  28091. _isDisabled: boolean;
  28092. /** @hidden */
  28093. _compression: Nullable<string>;
  28094. /** @hidden */
  28095. _generateStencilBuffer: boolean;
  28096. /** @hidden */
  28097. _generateDepthBuffer: boolean;
  28098. /** @hidden */
  28099. _comparisonFunction: number;
  28100. /** @hidden */
  28101. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28102. /** @hidden */
  28103. _lodGenerationScale: number;
  28104. /** @hidden */
  28105. _lodGenerationOffset: number;
  28106. /** @hidden */
  28107. _colorTextureArray: Nullable<WebGLTexture>;
  28108. /** @hidden */
  28109. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28110. /** @hidden */
  28111. _lodTextureHigh: Nullable<BaseTexture>;
  28112. /** @hidden */
  28113. _lodTextureMid: Nullable<BaseTexture>;
  28114. /** @hidden */
  28115. _lodTextureLow: Nullable<BaseTexture>;
  28116. /** @hidden */
  28117. _isRGBD: boolean;
  28118. /** @hidden */
  28119. _linearSpecularLOD: boolean;
  28120. /** @hidden */
  28121. _irradianceTexture: Nullable<BaseTexture>;
  28122. /** @hidden */
  28123. _webGLTexture: Nullable<WebGLTexture>;
  28124. /** @hidden */
  28125. _references: number;
  28126. private _engine;
  28127. /**
  28128. * Gets the Engine the texture belongs to.
  28129. * @returns The babylon engine
  28130. */
  28131. getEngine(): Engine;
  28132. /**
  28133. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28134. */
  28135. readonly dataSource: number;
  28136. /**
  28137. * Creates a new InternalTexture
  28138. * @param engine defines the engine to use
  28139. * @param dataSource defines the type of data that will be used
  28140. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28141. */
  28142. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28143. /**
  28144. * Increments the number of references (ie. the number of Texture that point to it)
  28145. */
  28146. incrementReferences(): void;
  28147. /**
  28148. * Change the size of the texture (not the size of the content)
  28149. * @param width defines the new width
  28150. * @param height defines the new height
  28151. * @param depth defines the new depth (1 by default)
  28152. */
  28153. updateSize(width: int, height: int, depth?: int): void;
  28154. /** @hidden */
  28155. _rebuild(): void;
  28156. /** @hidden */
  28157. _swapAndDie(target: InternalTexture): void;
  28158. /**
  28159. * Dispose the current allocated resources
  28160. */
  28161. dispose(): void;
  28162. }
  28163. }
  28164. declare module BABYLON {
  28165. /**
  28166. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28167. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28168. */
  28169. export class EffectFallbacks {
  28170. private _defines;
  28171. private _currentRank;
  28172. private _maxRank;
  28173. private _mesh;
  28174. /**
  28175. * Removes the fallback from the bound mesh.
  28176. */
  28177. unBindMesh(): void;
  28178. /**
  28179. * Adds a fallback on the specified property.
  28180. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28181. * @param define The name of the define in the shader
  28182. */
  28183. addFallback(rank: number, define: string): void;
  28184. /**
  28185. * Sets the mesh to use CPU skinning when needing to fallback.
  28186. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28187. * @param mesh The mesh to use the fallbacks.
  28188. */
  28189. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28190. /**
  28191. * Checks to see if more fallbacks are still availible.
  28192. */
  28193. readonly hasMoreFallbacks: boolean;
  28194. /**
  28195. * Removes the defines that should be removed when falling back.
  28196. * @param currentDefines defines the current define statements for the shader.
  28197. * @param effect defines the current effect we try to compile
  28198. * @returns The resulting defines with defines of the current rank removed.
  28199. */
  28200. reduce(currentDefines: string, effect: Effect): string;
  28201. }
  28202. /**
  28203. * Options to be used when creating an effect.
  28204. */
  28205. export class EffectCreationOptions {
  28206. /**
  28207. * Atrributes that will be used in the shader.
  28208. */
  28209. attributes: string[];
  28210. /**
  28211. * Uniform varible names that will be set in the shader.
  28212. */
  28213. uniformsNames: string[];
  28214. /**
  28215. * Uniform buffer varible names that will be set in the shader.
  28216. */
  28217. uniformBuffersNames: string[];
  28218. /**
  28219. * Sampler texture variable names that will be set in the shader.
  28220. */
  28221. samplers: string[];
  28222. /**
  28223. * Define statements that will be set in the shader.
  28224. */
  28225. defines: any;
  28226. /**
  28227. * Possible fallbacks for this effect to improve performance when needed.
  28228. */
  28229. fallbacks: Nullable<EffectFallbacks>;
  28230. /**
  28231. * Callback that will be called when the shader is compiled.
  28232. */
  28233. onCompiled: Nullable<(effect: Effect) => void>;
  28234. /**
  28235. * Callback that will be called if an error occurs during shader compilation.
  28236. */
  28237. onError: Nullable<(effect: Effect, errors: string) => void>;
  28238. /**
  28239. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28240. */
  28241. indexParameters: any;
  28242. /**
  28243. * Max number of lights that can be used in the shader.
  28244. */
  28245. maxSimultaneousLights: number;
  28246. /**
  28247. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28248. */
  28249. transformFeedbackVaryings: Nullable<string[]>;
  28250. }
  28251. /**
  28252. * Effect containing vertex and fragment shader that can be executed on an object.
  28253. */
  28254. export class Effect implements IDisposable {
  28255. /**
  28256. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28257. */
  28258. static ShadersRepository: string;
  28259. /**
  28260. * Name of the effect.
  28261. */
  28262. name: any;
  28263. /**
  28264. * String container all the define statements that should be set on the shader.
  28265. */
  28266. defines: string;
  28267. /**
  28268. * Callback that will be called when the shader is compiled.
  28269. */
  28270. onCompiled: Nullable<(effect: Effect) => void>;
  28271. /**
  28272. * Callback that will be called if an error occurs during shader compilation.
  28273. */
  28274. onError: Nullable<(effect: Effect, errors: string) => void>;
  28275. /**
  28276. * Callback that will be called when effect is bound.
  28277. */
  28278. onBind: Nullable<(effect: Effect) => void>;
  28279. /**
  28280. * Unique ID of the effect.
  28281. */
  28282. uniqueId: number;
  28283. /**
  28284. * Observable that will be called when the shader is compiled.
  28285. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28286. */
  28287. onCompileObservable: Observable<Effect>;
  28288. /**
  28289. * Observable that will be called if an error occurs during shader compilation.
  28290. */
  28291. onErrorObservable: Observable<Effect>;
  28292. /** @hidden */
  28293. _onBindObservable: Nullable<Observable<Effect>>;
  28294. /**
  28295. * Observable that will be called when effect is bound.
  28296. */
  28297. readonly onBindObservable: Observable<Effect>;
  28298. /** @hidden */
  28299. _bonesComputationForcedToCPU: boolean;
  28300. private static _uniqueIdSeed;
  28301. private _engine;
  28302. private _uniformBuffersNames;
  28303. private _uniformsNames;
  28304. private _samplerList;
  28305. private _samplers;
  28306. private _isReady;
  28307. private _compilationError;
  28308. private _attributesNames;
  28309. private _attributes;
  28310. private _uniforms;
  28311. /**
  28312. * Key for the effect.
  28313. * @hidden
  28314. */
  28315. _key: string;
  28316. private _indexParameters;
  28317. private _fallbacks;
  28318. private _vertexSourceCode;
  28319. private _fragmentSourceCode;
  28320. private _vertexSourceCodeOverride;
  28321. private _fragmentSourceCodeOverride;
  28322. private _transformFeedbackVaryings;
  28323. /**
  28324. * Compiled shader to webGL program.
  28325. * @hidden
  28326. */
  28327. _pipelineContext: Nullable<IPipelineContext>;
  28328. private _valueCache;
  28329. private static _baseCache;
  28330. /**
  28331. * Instantiates an effect.
  28332. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28333. * @param baseName Name of the effect.
  28334. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28335. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28336. * @param samplers List of sampler variables that will be passed to the shader.
  28337. * @param engine Engine to be used to render the effect
  28338. * @param defines Define statements to be added to the shader.
  28339. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28340. * @param onCompiled Callback that will be called when the shader is compiled.
  28341. * @param onError Callback that will be called if an error occurs during shader compilation.
  28342. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28343. */
  28344. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28345. private _useFinalCode;
  28346. /**
  28347. * Unique key for this effect
  28348. */
  28349. readonly key: string;
  28350. /**
  28351. * If the effect has been compiled and prepared.
  28352. * @returns if the effect is compiled and prepared.
  28353. */
  28354. isReady(): boolean;
  28355. private _isReadyInternal;
  28356. /**
  28357. * The engine the effect was initialized with.
  28358. * @returns the engine.
  28359. */
  28360. getEngine(): Engine;
  28361. /**
  28362. * The pipeline context for this effect
  28363. * @returns the associated pipeline context
  28364. */
  28365. getPipelineContext(): Nullable<IPipelineContext>;
  28366. /**
  28367. * The set of names of attribute variables for the shader.
  28368. * @returns An array of attribute names.
  28369. */
  28370. getAttributesNames(): string[];
  28371. /**
  28372. * Returns the attribute at the given index.
  28373. * @param index The index of the attribute.
  28374. * @returns The location of the attribute.
  28375. */
  28376. getAttributeLocation(index: number): number;
  28377. /**
  28378. * Returns the attribute based on the name of the variable.
  28379. * @param name of the attribute to look up.
  28380. * @returns the attribute location.
  28381. */
  28382. getAttributeLocationByName(name: string): number;
  28383. /**
  28384. * The number of attributes.
  28385. * @returns the numnber of attributes.
  28386. */
  28387. getAttributesCount(): number;
  28388. /**
  28389. * Gets the index of a uniform variable.
  28390. * @param uniformName of the uniform to look up.
  28391. * @returns the index.
  28392. */
  28393. getUniformIndex(uniformName: string): number;
  28394. /**
  28395. * Returns the attribute based on the name of the variable.
  28396. * @param uniformName of the uniform to look up.
  28397. * @returns the location of the uniform.
  28398. */
  28399. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28400. /**
  28401. * Returns an array of sampler variable names
  28402. * @returns The array of sampler variable neames.
  28403. */
  28404. getSamplers(): string[];
  28405. /**
  28406. * The error from the last compilation.
  28407. * @returns the error string.
  28408. */
  28409. getCompilationError(): string;
  28410. /**
  28411. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28412. * @param func The callback to be used.
  28413. */
  28414. executeWhenCompiled(func: (effect: Effect) => void): void;
  28415. private _checkIsReady;
  28416. /** @hidden */
  28417. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28418. /** @hidden */
  28419. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28420. /** @hidden */
  28421. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28422. /**
  28423. * Recompiles the webGL program
  28424. * @param vertexSourceCode The source code for the vertex shader.
  28425. * @param fragmentSourceCode The source code for the fragment shader.
  28426. * @param onCompiled Callback called when completed.
  28427. * @param onError Callback called on error.
  28428. * @hidden
  28429. */
  28430. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28431. /**
  28432. * Prepares the effect
  28433. * @hidden
  28434. */
  28435. _prepareEffect(): void;
  28436. private _processCompilationErrors;
  28437. /**
  28438. * Checks if the effect is supported. (Must be called after compilation)
  28439. */
  28440. readonly isSupported: boolean;
  28441. /**
  28442. * Binds a texture to the engine to be used as output of the shader.
  28443. * @param channel Name of the output variable.
  28444. * @param texture Texture to bind.
  28445. * @hidden
  28446. */
  28447. _bindTexture(channel: string, texture: InternalTexture): void;
  28448. /**
  28449. * Sets a texture 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. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28454. /**
  28455. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28456. * @param channel Name of the sampler variable.
  28457. * @param texture Texture to set.
  28458. */
  28459. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28460. /**
  28461. * Sets an array of textures on the engine to be used in the shader.
  28462. * @param channel Name of the variable.
  28463. * @param textures Textures to set.
  28464. */
  28465. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28466. /**
  28467. * 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)
  28468. * @param channel Name of the sampler variable.
  28469. * @param postProcess Post process to get the input texture from.
  28470. */
  28471. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28472. /**
  28473. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28474. * 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)
  28475. * @param channel Name of the sampler variable.
  28476. * @param postProcess Post process to get the output texture from.
  28477. */
  28478. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28479. /** @hidden */
  28480. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28481. /** @hidden */
  28482. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28483. /** @hidden */
  28484. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28485. /** @hidden */
  28486. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28487. /**
  28488. * Binds a buffer to a uniform.
  28489. * @param buffer Buffer to bind.
  28490. * @param name Name of the uniform variable to bind to.
  28491. */
  28492. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28493. /**
  28494. * Binds block to a uniform.
  28495. * @param blockName Name of the block to bind.
  28496. * @param index Index to bind.
  28497. */
  28498. bindUniformBlock(blockName: string, index: number): void;
  28499. /**
  28500. * Sets an interger value on a uniform variable.
  28501. * @param uniformName Name of the variable.
  28502. * @param value Value to be set.
  28503. * @returns this effect.
  28504. */
  28505. setInt(uniformName: string, value: number): Effect;
  28506. /**
  28507. * Sets an int array on a uniform variable.
  28508. * @param uniformName Name of the variable.
  28509. * @param array array to be set.
  28510. * @returns this effect.
  28511. */
  28512. setIntArray(uniformName: string, array: Int32Array): Effect;
  28513. /**
  28514. * 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)
  28515. * @param uniformName Name of the variable.
  28516. * @param array array to be set.
  28517. * @returns this effect.
  28518. */
  28519. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28520. /**
  28521. * 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)
  28522. * @param uniformName Name of the variable.
  28523. * @param array array to be set.
  28524. * @returns this effect.
  28525. */
  28526. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28527. /**
  28528. * 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)
  28529. * @param uniformName Name of the variable.
  28530. * @param array array to be set.
  28531. * @returns this effect.
  28532. */
  28533. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28534. /**
  28535. * Sets an float array on a uniform variable.
  28536. * @param uniformName Name of the variable.
  28537. * @param array array to be set.
  28538. * @returns this effect.
  28539. */
  28540. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28541. /**
  28542. * 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)
  28543. * @param uniformName Name of the variable.
  28544. * @param array array to be set.
  28545. * @returns this effect.
  28546. */
  28547. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28548. /**
  28549. * 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)
  28550. * @param uniformName Name of the variable.
  28551. * @param array array to be set.
  28552. * @returns this effect.
  28553. */
  28554. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28555. /**
  28556. * 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)
  28557. * @param uniformName Name of the variable.
  28558. * @param array array to be set.
  28559. * @returns this effect.
  28560. */
  28561. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28562. /**
  28563. * Sets an array on a uniform variable.
  28564. * @param uniformName Name of the variable.
  28565. * @param array array to be set.
  28566. * @returns this effect.
  28567. */
  28568. setArray(uniformName: string, array: number[]): Effect;
  28569. /**
  28570. * 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)
  28571. * @param uniformName Name of the variable.
  28572. * @param array array to be set.
  28573. * @returns this effect.
  28574. */
  28575. setArray2(uniformName: string, array: number[]): Effect;
  28576. /**
  28577. * 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)
  28578. * @param uniformName Name of the variable.
  28579. * @param array array to be set.
  28580. * @returns this effect.
  28581. */
  28582. setArray3(uniformName: string, array: number[]): Effect;
  28583. /**
  28584. * 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)
  28585. * @param uniformName Name of the variable.
  28586. * @param array array to be set.
  28587. * @returns this effect.
  28588. */
  28589. setArray4(uniformName: string, array: number[]): Effect;
  28590. /**
  28591. * Sets matrices on a uniform variable.
  28592. * @param uniformName Name of the variable.
  28593. * @param matrices matrices to be set.
  28594. * @returns this effect.
  28595. */
  28596. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28597. /**
  28598. * Sets matrix on a uniform variable.
  28599. * @param uniformName Name of the variable.
  28600. * @param matrix matrix to be set.
  28601. * @returns this effect.
  28602. */
  28603. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28604. /**
  28605. * 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)
  28606. * @param uniformName Name of the variable.
  28607. * @param matrix matrix to be set.
  28608. * @returns this effect.
  28609. */
  28610. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28611. /**
  28612. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28613. * @param uniformName Name of the variable.
  28614. * @param matrix matrix to be set.
  28615. * @returns this effect.
  28616. */
  28617. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28618. /**
  28619. * Sets a float on a uniform variable.
  28620. * @param uniformName Name of the variable.
  28621. * @param value value to be set.
  28622. * @returns this effect.
  28623. */
  28624. setFloat(uniformName: string, value: number): Effect;
  28625. /**
  28626. * Sets a boolean on a uniform variable.
  28627. * @param uniformName Name of the variable.
  28628. * @param bool value to be set.
  28629. * @returns this effect.
  28630. */
  28631. setBool(uniformName: string, bool: boolean): Effect;
  28632. /**
  28633. * Sets a Vector2 on a uniform variable.
  28634. * @param uniformName Name of the variable.
  28635. * @param vector2 vector2 to be set.
  28636. * @returns this effect.
  28637. */
  28638. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28639. /**
  28640. * Sets a float2 on a uniform variable.
  28641. * @param uniformName Name of the variable.
  28642. * @param x First float in float2.
  28643. * @param y Second float in float2.
  28644. * @returns this effect.
  28645. */
  28646. setFloat2(uniformName: string, x: number, y: number): Effect;
  28647. /**
  28648. * Sets a Vector3 on a uniform variable.
  28649. * @param uniformName Name of the variable.
  28650. * @param vector3 Value to be set.
  28651. * @returns this effect.
  28652. */
  28653. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28654. /**
  28655. * Sets a float3 on a uniform variable.
  28656. * @param uniformName Name of the variable.
  28657. * @param x First float in float3.
  28658. * @param y Second float in float3.
  28659. * @param z Third float in float3.
  28660. * @returns this effect.
  28661. */
  28662. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28663. /**
  28664. * Sets a Vector4 on a uniform variable.
  28665. * @param uniformName Name of the variable.
  28666. * @param vector4 Value to be set.
  28667. * @returns this effect.
  28668. */
  28669. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28670. /**
  28671. * Sets a float4 on a uniform variable.
  28672. * @param uniformName Name of the variable.
  28673. * @param x First float in float4.
  28674. * @param y Second float in float4.
  28675. * @param z Third float in float4.
  28676. * @param w Fourth float in float4.
  28677. * @returns this effect.
  28678. */
  28679. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28680. /**
  28681. * Sets a Color3 on a uniform variable.
  28682. * @param uniformName Name of the variable.
  28683. * @param color3 Value to be set.
  28684. * @returns this effect.
  28685. */
  28686. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28687. /**
  28688. * Sets a Color4 on a uniform variable.
  28689. * @param uniformName Name of the variable.
  28690. * @param color3 Value to be set.
  28691. * @param alpha Alpha value to be set.
  28692. * @returns this effect.
  28693. */
  28694. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28695. /**
  28696. * Sets a Color4 on a uniform variable
  28697. * @param uniformName defines the name of the variable
  28698. * @param color4 defines the value to be set
  28699. * @returns this effect.
  28700. */
  28701. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28702. /** Release all associated resources */
  28703. dispose(): void;
  28704. /**
  28705. * This function will add a new shader to the shader store
  28706. * @param name the name of the shader
  28707. * @param pixelShader optional pixel shader content
  28708. * @param vertexShader optional vertex shader content
  28709. */
  28710. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28711. /**
  28712. * Store of each shader (The can be looked up using effect.key)
  28713. */
  28714. static ShadersStore: {
  28715. [key: string]: string;
  28716. };
  28717. /**
  28718. * Store of each included file for a shader (The can be looked up using effect.key)
  28719. */
  28720. static IncludesShadersStore: {
  28721. [key: string]: string;
  28722. };
  28723. /**
  28724. * Resets the cache of effects.
  28725. */
  28726. static ResetCache(): void;
  28727. }
  28728. }
  28729. declare module BABYLON {
  28730. /**
  28731. * Uniform buffer objects.
  28732. *
  28733. * Handles blocks of uniform on the GPU.
  28734. *
  28735. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28736. *
  28737. * For more information, please refer to :
  28738. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28739. */
  28740. export class UniformBuffer {
  28741. private _engine;
  28742. private _buffer;
  28743. private _data;
  28744. private _bufferData;
  28745. private _dynamic?;
  28746. private _uniformLocations;
  28747. private _uniformSizes;
  28748. private _uniformLocationPointer;
  28749. private _needSync;
  28750. private _noUBO;
  28751. private _currentEffect;
  28752. private static _MAX_UNIFORM_SIZE;
  28753. private static _tempBuffer;
  28754. /**
  28755. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28756. * This is dynamic to allow compat with webgl 1 and 2.
  28757. * You will need to pass the name of the uniform as well as the value.
  28758. */
  28759. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28760. /**
  28761. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28762. * This is dynamic to allow compat with webgl 1 and 2.
  28763. * You will need to pass the name of the uniform as well as the value.
  28764. */
  28765. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28766. /**
  28767. * Lambda to Update a single float in a uniform buffer.
  28768. * This is dynamic to allow compat with webgl 1 and 2.
  28769. * You will need to pass the name of the uniform as well as the value.
  28770. */
  28771. updateFloat: (name: string, x: number) => void;
  28772. /**
  28773. * Lambda to Update a vec2 of float in a uniform buffer.
  28774. * This is dynamic to allow compat with webgl 1 and 2.
  28775. * You will need to pass the name of the uniform as well as the value.
  28776. */
  28777. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28778. /**
  28779. * Lambda to Update a vec3 of float in a uniform buffer.
  28780. * This is dynamic to allow compat with webgl 1 and 2.
  28781. * You will need to pass the name of the uniform as well as the value.
  28782. */
  28783. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28784. /**
  28785. * Lambda to Update a vec4 of float in a uniform buffer.
  28786. * This is dynamic to allow compat with webgl 1 and 2.
  28787. * You will need to pass the name of the uniform as well as the value.
  28788. */
  28789. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28790. /**
  28791. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28792. * This is dynamic to allow compat with webgl 1 and 2.
  28793. * You will need to pass the name of the uniform as well as the value.
  28794. */
  28795. updateMatrix: (name: string, mat: Matrix) => void;
  28796. /**
  28797. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28798. * This is dynamic to allow compat with webgl 1 and 2.
  28799. * You will need to pass the name of the uniform as well as the value.
  28800. */
  28801. updateVector3: (name: string, vector: Vector3) => void;
  28802. /**
  28803. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28804. * This is dynamic to allow compat with webgl 1 and 2.
  28805. * You will need to pass the name of the uniform as well as the value.
  28806. */
  28807. updateVector4: (name: string, vector: Vector4) => void;
  28808. /**
  28809. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28810. * This is dynamic to allow compat with webgl 1 and 2.
  28811. * You will need to pass the name of the uniform as well as the value.
  28812. */
  28813. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28814. /**
  28815. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28816. * This is dynamic to allow compat with webgl 1 and 2.
  28817. * You will need to pass the name of the uniform as well as the value.
  28818. */
  28819. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28820. /**
  28821. * Instantiates a new Uniform buffer objects.
  28822. *
  28823. * Handles blocks of uniform on the GPU.
  28824. *
  28825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28826. *
  28827. * For more information, please refer to :
  28828. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28829. * @param engine Define the engine the buffer is associated with
  28830. * @param data Define the data contained in the buffer
  28831. * @param dynamic Define if the buffer is updatable
  28832. */
  28833. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28834. /**
  28835. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28836. * or just falling back on setUniformXXX calls.
  28837. */
  28838. readonly useUbo: boolean;
  28839. /**
  28840. * Indicates if the WebGL underlying uniform buffer is in sync
  28841. * with the javascript cache data.
  28842. */
  28843. readonly isSync: boolean;
  28844. /**
  28845. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28846. * Also, a dynamic UniformBuffer will disable cache verification and always
  28847. * update the underlying WebGL uniform buffer to the GPU.
  28848. * @returns if Dynamic, otherwise false
  28849. */
  28850. isDynamic(): boolean;
  28851. /**
  28852. * The data cache on JS side.
  28853. * @returns the underlying data as a float array
  28854. */
  28855. getData(): Float32Array;
  28856. /**
  28857. * The underlying WebGL Uniform buffer.
  28858. * @returns the webgl buffer
  28859. */
  28860. getBuffer(): Nullable<DataBuffer>;
  28861. /**
  28862. * std140 layout specifies how to align data within an UBO structure.
  28863. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28864. * for specs.
  28865. */
  28866. private _fillAlignment;
  28867. /**
  28868. * Adds an uniform in the buffer.
  28869. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28870. * for the layout to be correct !
  28871. * @param name Name of the uniform, as used in the uniform block in the shader.
  28872. * @param size Data size, or data directly.
  28873. */
  28874. addUniform(name: string, size: number | number[]): void;
  28875. /**
  28876. * Adds a Matrix 4x4 to the uniform buffer.
  28877. * @param name Name of the uniform, as used in the uniform block in the shader.
  28878. * @param mat A 4x4 matrix.
  28879. */
  28880. addMatrix(name: string, mat: Matrix): void;
  28881. /**
  28882. * Adds a vec2 to the uniform buffer.
  28883. * @param name Name of the uniform, as used in the uniform block in the shader.
  28884. * @param x Define the x component value of the vec2
  28885. * @param y Define the y component value of the vec2
  28886. */
  28887. addFloat2(name: string, x: number, y: number): void;
  28888. /**
  28889. * Adds a vec3 to the uniform buffer.
  28890. * @param name Name of the uniform, as used in the uniform block in the shader.
  28891. * @param x Define the x component value of the vec3
  28892. * @param y Define the y component value of the vec3
  28893. * @param z Define the z component value of the vec3
  28894. */
  28895. addFloat3(name: string, x: number, y: number, z: number): void;
  28896. /**
  28897. * Adds a vec3 to the uniform buffer.
  28898. * @param name Name of the uniform, as used in the uniform block in the shader.
  28899. * @param color Define the vec3 from a Color
  28900. */
  28901. addColor3(name: string, color: Color3): void;
  28902. /**
  28903. * Adds a vec4 to the uniform buffer.
  28904. * @param name Name of the uniform, as used in the uniform block in the shader.
  28905. * @param color Define the rgb components from a Color
  28906. * @param alpha Define the a component of the vec4
  28907. */
  28908. addColor4(name: string, color: Color3, alpha: number): void;
  28909. /**
  28910. * Adds a vec3 to the uniform buffer.
  28911. * @param name Name of the uniform, as used in the uniform block in the shader.
  28912. * @param vector Define the vec3 components from a Vector
  28913. */
  28914. addVector3(name: string, vector: Vector3): void;
  28915. /**
  28916. * Adds a Matrix 3x3 to the uniform buffer.
  28917. * @param name Name of the uniform, as used in the uniform block in the shader.
  28918. */
  28919. addMatrix3x3(name: string): void;
  28920. /**
  28921. * Adds a Matrix 2x2 to the uniform buffer.
  28922. * @param name Name of the uniform, as used in the uniform block in the shader.
  28923. */
  28924. addMatrix2x2(name: string): void;
  28925. /**
  28926. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28927. */
  28928. create(): void;
  28929. /** @hidden */
  28930. _rebuild(): void;
  28931. /**
  28932. * Updates the WebGL Uniform Buffer on the GPU.
  28933. * If the `dynamic` flag is set to true, no cache comparison is done.
  28934. * Otherwise, the buffer will be updated only if the cache differs.
  28935. */
  28936. update(): void;
  28937. /**
  28938. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28939. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28940. * @param data Define the flattened data
  28941. * @param size Define the size of the data.
  28942. */
  28943. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28944. private _valueCache;
  28945. private _cacheMatrix;
  28946. private _updateMatrix3x3ForUniform;
  28947. private _updateMatrix3x3ForEffect;
  28948. private _updateMatrix2x2ForEffect;
  28949. private _updateMatrix2x2ForUniform;
  28950. private _updateFloatForEffect;
  28951. private _updateFloatForUniform;
  28952. private _updateFloat2ForEffect;
  28953. private _updateFloat2ForUniform;
  28954. private _updateFloat3ForEffect;
  28955. private _updateFloat3ForUniform;
  28956. private _updateFloat4ForEffect;
  28957. private _updateFloat4ForUniform;
  28958. private _updateMatrixForEffect;
  28959. private _updateMatrixForUniform;
  28960. private _updateVector3ForEffect;
  28961. private _updateVector3ForUniform;
  28962. private _updateVector4ForEffect;
  28963. private _updateVector4ForUniform;
  28964. private _updateColor3ForEffect;
  28965. private _updateColor3ForUniform;
  28966. private _updateColor4ForEffect;
  28967. private _updateColor4ForUniform;
  28968. /**
  28969. * Sets a sampler uniform on the effect.
  28970. * @param name Define the name of the sampler.
  28971. * @param texture Define the texture to set in the sampler
  28972. */
  28973. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28974. /**
  28975. * Directly updates the value of the uniform in the cache AND on the GPU.
  28976. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28977. * @param data Define the flattened data
  28978. */
  28979. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28980. /**
  28981. * Binds this uniform buffer to an effect.
  28982. * @param effect Define the effect to bind the buffer to
  28983. * @param name Name of the uniform block in the shader.
  28984. */
  28985. bindToEffect(effect: Effect, name: string): void;
  28986. /**
  28987. * Disposes the uniform buffer.
  28988. */
  28989. dispose(): void;
  28990. }
  28991. }
  28992. declare module BABYLON {
  28993. /**
  28994. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28996. */
  28997. export class Analyser {
  28998. /**
  28999. * Gets or sets the smoothing
  29000. * @ignorenaming
  29001. */
  29002. SMOOTHING: number;
  29003. /**
  29004. * Gets or sets the FFT table size
  29005. * @ignorenaming
  29006. */
  29007. FFT_SIZE: number;
  29008. /**
  29009. * Gets or sets the bar graph amplitude
  29010. * @ignorenaming
  29011. */
  29012. BARGRAPHAMPLITUDE: number;
  29013. /**
  29014. * Gets or sets the position of the debug canvas
  29015. * @ignorenaming
  29016. */
  29017. DEBUGCANVASPOS: {
  29018. x: number;
  29019. y: number;
  29020. };
  29021. /**
  29022. * Gets or sets the debug canvas size
  29023. * @ignorenaming
  29024. */
  29025. DEBUGCANVASSIZE: {
  29026. width: number;
  29027. height: number;
  29028. };
  29029. private _byteFreqs;
  29030. private _byteTime;
  29031. private _floatFreqs;
  29032. private _webAudioAnalyser;
  29033. private _debugCanvas;
  29034. private _debugCanvasContext;
  29035. private _scene;
  29036. private _registerFunc;
  29037. private _audioEngine;
  29038. /**
  29039. * Creates a new analyser
  29040. * @param scene defines hosting scene
  29041. */
  29042. constructor(scene: Scene);
  29043. /**
  29044. * Get the number of data values you will have to play with for the visualization
  29045. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29046. * @returns a number
  29047. */
  29048. getFrequencyBinCount(): number;
  29049. /**
  29050. * Gets the current frequency data as a byte array
  29051. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29052. * @returns a Uint8Array
  29053. */
  29054. getByteFrequencyData(): Uint8Array;
  29055. /**
  29056. * Gets the current waveform as a byte array
  29057. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29058. * @returns a Uint8Array
  29059. */
  29060. getByteTimeDomainData(): Uint8Array;
  29061. /**
  29062. * Gets the current frequency data as a float array
  29063. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29064. * @returns a Float32Array
  29065. */
  29066. getFloatFrequencyData(): Float32Array;
  29067. /**
  29068. * Renders the debug canvas
  29069. */
  29070. drawDebugCanvas(): void;
  29071. /**
  29072. * Stops rendering the debug canvas and removes it
  29073. */
  29074. stopDebugCanvas(): void;
  29075. /**
  29076. * Connects two audio nodes
  29077. * @param inputAudioNode defines first node to connect
  29078. * @param outputAudioNode defines second node to connect
  29079. */
  29080. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29081. /**
  29082. * Releases all associated resources
  29083. */
  29084. dispose(): void;
  29085. }
  29086. }
  29087. declare module BABYLON {
  29088. /**
  29089. * This represents an audio engine and it is responsible
  29090. * to play, synchronize and analyse sounds throughout the application.
  29091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29092. */
  29093. export interface IAudioEngine extends IDisposable {
  29094. /**
  29095. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29096. */
  29097. readonly canUseWebAudio: boolean;
  29098. /**
  29099. * Gets the current AudioContext if available.
  29100. */
  29101. readonly audioContext: Nullable<AudioContext>;
  29102. /**
  29103. * The master gain node defines the global audio volume of your audio engine.
  29104. */
  29105. readonly masterGain: GainNode;
  29106. /**
  29107. * Gets whether or not mp3 are supported by your browser.
  29108. */
  29109. readonly isMP3supported: boolean;
  29110. /**
  29111. * Gets whether or not ogg are supported by your browser.
  29112. */
  29113. readonly isOGGsupported: boolean;
  29114. /**
  29115. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29116. * @ignoreNaming
  29117. */
  29118. WarnedWebAudioUnsupported: boolean;
  29119. /**
  29120. * Defines if the audio engine relies on a custom unlocked button.
  29121. * In this case, the embedded button will not be displayed.
  29122. */
  29123. useCustomUnlockedButton: boolean;
  29124. /**
  29125. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29126. */
  29127. readonly unlocked: boolean;
  29128. /**
  29129. * Event raised when audio has been unlocked on the browser.
  29130. */
  29131. onAudioUnlockedObservable: Observable<AudioEngine>;
  29132. /**
  29133. * Event raised when audio has been locked on the browser.
  29134. */
  29135. onAudioLockedObservable: Observable<AudioEngine>;
  29136. /**
  29137. * Flags the audio engine in Locked state.
  29138. * This happens due to new browser policies preventing audio to autoplay.
  29139. */
  29140. lock(): void;
  29141. /**
  29142. * Unlocks the audio engine once a user action has been done on the dom.
  29143. * This is helpful to resume play once browser policies have been satisfied.
  29144. */
  29145. unlock(): void;
  29146. }
  29147. /**
  29148. * This represents the default audio engine used in babylon.
  29149. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29151. */
  29152. export class AudioEngine implements IAudioEngine {
  29153. private _audioContext;
  29154. private _audioContextInitialized;
  29155. private _muteButton;
  29156. private _hostElement;
  29157. /**
  29158. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29159. */
  29160. canUseWebAudio: boolean;
  29161. /**
  29162. * The master gain node defines the global audio volume of your audio engine.
  29163. */
  29164. masterGain: GainNode;
  29165. /**
  29166. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29167. * @ignoreNaming
  29168. */
  29169. WarnedWebAudioUnsupported: boolean;
  29170. /**
  29171. * Gets whether or not mp3 are supported by your browser.
  29172. */
  29173. isMP3supported: boolean;
  29174. /**
  29175. * Gets whether or not ogg are supported by your browser.
  29176. */
  29177. isOGGsupported: boolean;
  29178. /**
  29179. * Gets whether audio has been unlocked on the device.
  29180. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29181. * a user interaction has happened.
  29182. */
  29183. unlocked: boolean;
  29184. /**
  29185. * Defines if the audio engine relies on a custom unlocked button.
  29186. * In this case, the embedded button will not be displayed.
  29187. */
  29188. useCustomUnlockedButton: boolean;
  29189. /**
  29190. * Event raised when audio has been unlocked on the browser.
  29191. */
  29192. onAudioUnlockedObservable: Observable<AudioEngine>;
  29193. /**
  29194. * Event raised when audio has been locked on the browser.
  29195. */
  29196. onAudioLockedObservable: Observable<AudioEngine>;
  29197. /**
  29198. * Gets the current AudioContext if available.
  29199. */
  29200. readonly audioContext: Nullable<AudioContext>;
  29201. private _connectedAnalyser;
  29202. /**
  29203. * Instantiates a new audio engine.
  29204. *
  29205. * There should be only one per page as some browsers restrict the number
  29206. * of audio contexts you can create.
  29207. * @param hostElement defines the host element where to display the mute icon if necessary
  29208. */
  29209. constructor(hostElement?: Nullable<HTMLElement>);
  29210. /**
  29211. * Flags the audio engine in Locked state.
  29212. * This happens due to new browser policies preventing audio to autoplay.
  29213. */
  29214. lock(): void;
  29215. /**
  29216. * Unlocks the audio engine once a user action has been done on the dom.
  29217. * This is helpful to resume play once browser policies have been satisfied.
  29218. */
  29219. unlock(): void;
  29220. private _resumeAudioContext;
  29221. private _initializeAudioContext;
  29222. private _tryToRun;
  29223. private _triggerRunningState;
  29224. private _triggerSuspendedState;
  29225. private _displayMuteButton;
  29226. private _moveButtonToTopLeft;
  29227. private _onResize;
  29228. private _hideMuteButton;
  29229. /**
  29230. * Destroy and release the resources associated with the audio ccontext.
  29231. */
  29232. dispose(): void;
  29233. /**
  29234. * Gets the global volume sets on the master gain.
  29235. * @returns the global volume if set or -1 otherwise
  29236. */
  29237. getGlobalVolume(): number;
  29238. /**
  29239. * Sets the global volume of your experience (sets on the master gain).
  29240. * @param newVolume Defines the new global volume of the application
  29241. */
  29242. setGlobalVolume(newVolume: number): void;
  29243. /**
  29244. * Connect the audio engine to an audio analyser allowing some amazing
  29245. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29247. * @param analyser The analyser to connect to the engine
  29248. */
  29249. connectToAnalyser(analyser: Analyser): void;
  29250. }
  29251. }
  29252. declare module BABYLON {
  29253. /**
  29254. * Interface used to present a loading screen while loading a scene
  29255. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29256. */
  29257. export interface ILoadingScreen {
  29258. /**
  29259. * Function called to display the loading screen
  29260. */
  29261. displayLoadingUI: () => void;
  29262. /**
  29263. * Function called to hide the loading screen
  29264. */
  29265. hideLoadingUI: () => void;
  29266. /**
  29267. * Gets or sets the color to use for the background
  29268. */
  29269. loadingUIBackgroundColor: string;
  29270. /**
  29271. * Gets or sets the text to display while loading
  29272. */
  29273. loadingUIText: string;
  29274. }
  29275. /**
  29276. * Class used for the default loading screen
  29277. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29278. */
  29279. export class DefaultLoadingScreen implements ILoadingScreen {
  29280. private _renderingCanvas;
  29281. private _loadingText;
  29282. private _loadingDivBackgroundColor;
  29283. private _loadingDiv;
  29284. private _loadingTextDiv;
  29285. /** Gets or sets the logo url to use for the default loading screen */
  29286. static DefaultLogoUrl: string;
  29287. /** Gets or sets the spinner url to use for the default loading screen */
  29288. static DefaultSpinnerUrl: string;
  29289. /**
  29290. * Creates a new default loading screen
  29291. * @param _renderingCanvas defines the canvas used to render the scene
  29292. * @param _loadingText defines the default text to display
  29293. * @param _loadingDivBackgroundColor defines the default background color
  29294. */
  29295. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29296. /**
  29297. * Function called to display the loading screen
  29298. */
  29299. displayLoadingUI(): void;
  29300. /**
  29301. * Function called to hide the loading screen
  29302. */
  29303. hideLoadingUI(): void;
  29304. /**
  29305. * Gets or sets the text to display while loading
  29306. */
  29307. loadingUIText: string;
  29308. /**
  29309. * Gets or sets the color to use for the background
  29310. */
  29311. loadingUIBackgroundColor: string;
  29312. private _resizeLoadingUI;
  29313. }
  29314. }
  29315. declare module BABYLON {
  29316. /** @hidden */
  29317. export class WebGLPipelineContext implements IPipelineContext {
  29318. engine: Engine;
  29319. program: Nullable<WebGLProgram>;
  29320. context?: WebGLRenderingContext;
  29321. vertexShader?: WebGLShader;
  29322. fragmentShader?: WebGLShader;
  29323. isParallelCompiled: boolean;
  29324. onCompiled?: () => void;
  29325. transformFeedback?: WebGLTransformFeedback | null;
  29326. readonly isAsync: boolean;
  29327. readonly isReady: boolean;
  29328. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29329. }
  29330. }
  29331. declare module BABYLON {
  29332. /** @hidden */
  29333. export class WebGLDataBuffer extends DataBuffer {
  29334. private _buffer;
  29335. constructor(resource: WebGLBuffer);
  29336. readonly underlyingResource: any;
  29337. }
  29338. }
  29339. declare module BABYLON {
  29340. /** @hidden */
  29341. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29342. attributeProcessor(attribute: string): string;
  29343. varyingProcessor(varying: string, isFragment: boolean): string;
  29344. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29345. }
  29346. }
  29347. declare module BABYLON {
  29348. /**
  29349. * This class is used to track a performance counter which is number based.
  29350. * The user has access to many properties which give statistics of different nature.
  29351. *
  29352. * The implementer can track two kinds of Performance Counter: time and count.
  29353. * 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.
  29354. * 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.
  29355. */
  29356. export class PerfCounter {
  29357. /**
  29358. * Gets or sets a global boolean to turn on and off all the counters
  29359. */
  29360. static Enabled: boolean;
  29361. /**
  29362. * Returns the smallest value ever
  29363. */
  29364. readonly min: number;
  29365. /**
  29366. * Returns the biggest value ever
  29367. */
  29368. readonly max: number;
  29369. /**
  29370. * Returns the average value since the performance counter is running
  29371. */
  29372. readonly average: number;
  29373. /**
  29374. * Returns the average value of the last second the counter was monitored
  29375. */
  29376. readonly lastSecAverage: number;
  29377. /**
  29378. * Returns the current value
  29379. */
  29380. readonly current: number;
  29381. /**
  29382. * Gets the accumulated total
  29383. */
  29384. readonly total: number;
  29385. /**
  29386. * Gets the total value count
  29387. */
  29388. readonly count: number;
  29389. /**
  29390. * Creates a new counter
  29391. */
  29392. constructor();
  29393. /**
  29394. * Call this method to start monitoring a new frame.
  29395. * 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.
  29396. */
  29397. fetchNewFrame(): void;
  29398. /**
  29399. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29400. * @param newCount the count value to add to the monitored count
  29401. * @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.
  29402. */
  29403. addCount(newCount: number, fetchResult: boolean): void;
  29404. /**
  29405. * Start monitoring this performance counter
  29406. */
  29407. beginMonitoring(): void;
  29408. /**
  29409. * Compute the time lapsed since the previous beginMonitoring() call.
  29410. * @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
  29411. */
  29412. endMonitoring(newFrame?: boolean): void;
  29413. private _fetchResult;
  29414. private _startMonitoringTime;
  29415. private _min;
  29416. private _max;
  29417. private _average;
  29418. private _current;
  29419. private _totalValueCount;
  29420. private _totalAccumulated;
  29421. private _lastSecAverage;
  29422. private _lastSecAccumulated;
  29423. private _lastSecTime;
  29424. private _lastSecValueCount;
  29425. }
  29426. }
  29427. declare module BABYLON {
  29428. /**
  29429. * Interface for any object that can request an animation frame
  29430. */
  29431. export interface ICustomAnimationFrameRequester {
  29432. /**
  29433. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29434. */
  29435. renderFunction?: Function;
  29436. /**
  29437. * Called to request the next frame to render to
  29438. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29439. */
  29440. requestAnimationFrame: Function;
  29441. /**
  29442. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29443. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29444. */
  29445. requestID?: number;
  29446. }
  29447. }
  29448. declare module BABYLON {
  29449. /**
  29450. * Settings for finer control over video usage
  29451. */
  29452. export interface VideoTextureSettings {
  29453. /**
  29454. * Applies `autoplay` to video, if specified
  29455. */
  29456. autoPlay?: boolean;
  29457. /**
  29458. * Applies `loop` to video, if specified
  29459. */
  29460. loop?: boolean;
  29461. /**
  29462. * Automatically updates internal texture from video at every frame in the render loop
  29463. */
  29464. autoUpdateTexture: boolean;
  29465. /**
  29466. * Image src displayed during the video loading or until the user interacts with the video.
  29467. */
  29468. poster?: string;
  29469. }
  29470. /**
  29471. * If you want to display a video in your scene, this is the special texture for that.
  29472. * This special texture works similar to other textures, with the exception of a few parameters.
  29473. * @see https://doc.babylonjs.com/how_to/video_texture
  29474. */
  29475. export class VideoTexture extends Texture {
  29476. /**
  29477. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29478. */
  29479. readonly autoUpdateTexture: boolean;
  29480. /**
  29481. * The video instance used by the texture internally
  29482. */
  29483. readonly video: HTMLVideoElement;
  29484. private _onUserActionRequestedObservable;
  29485. /**
  29486. * Event triggerd when a dom action is required by the user to play the video.
  29487. * This happens due to recent changes in browser policies preventing video to auto start.
  29488. */
  29489. readonly onUserActionRequestedObservable: Observable<Texture>;
  29490. private _generateMipMaps;
  29491. private _engine;
  29492. private _stillImageCaptured;
  29493. private _displayingPosterTexture;
  29494. private _settings;
  29495. private _createInternalTextureOnEvent;
  29496. private _frameId;
  29497. /**
  29498. * Creates a video texture.
  29499. * If you want to display a video in your scene, this is the special texture for that.
  29500. * This special texture works similar to other textures, with the exception of a few parameters.
  29501. * @see https://doc.babylonjs.com/how_to/video_texture
  29502. * @param name optional name, will detect from video source, if not defined
  29503. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29504. * @param scene is obviously the current scene.
  29505. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29506. * @param invertY is false by default but can be used to invert video on Y axis
  29507. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29508. * @param settings allows finer control over video usage
  29509. */
  29510. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29511. private _getName;
  29512. private _getVideo;
  29513. private _createInternalTexture;
  29514. private reset;
  29515. /**
  29516. * @hidden Internal method to initiate `update`.
  29517. */
  29518. _rebuild(): void;
  29519. /**
  29520. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29521. */
  29522. update(): void;
  29523. /**
  29524. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29525. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29526. */
  29527. updateTexture(isVisible: boolean): void;
  29528. protected _updateInternalTexture: () => void;
  29529. /**
  29530. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29531. * @param url New url.
  29532. */
  29533. updateURL(url: string): void;
  29534. /**
  29535. * Dispose the texture and release its associated resources.
  29536. */
  29537. dispose(): void;
  29538. /**
  29539. * Creates a video texture straight from a stream.
  29540. * @param scene Define the scene the texture should be created in
  29541. * @param stream Define the stream the texture should be created from
  29542. * @returns The created video texture as a promise
  29543. */
  29544. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29545. /**
  29546. * Creates a video texture straight from your WebCam video feed.
  29547. * @param scene Define the scene the texture should be created in
  29548. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29549. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29550. * @returns The created video texture as a promise
  29551. */
  29552. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29553. minWidth: number;
  29554. maxWidth: number;
  29555. minHeight: number;
  29556. maxHeight: number;
  29557. deviceId: string;
  29558. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29559. /**
  29560. * Creates a video texture straight from your WebCam video feed.
  29561. * @param scene Define the scene the texture should be created in
  29562. * @param onReady Define a callback to triggered once the texture will be ready
  29563. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29564. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29565. */
  29566. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29567. minWidth: number;
  29568. maxWidth: number;
  29569. minHeight: number;
  29570. maxHeight: number;
  29571. deviceId: string;
  29572. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29573. }
  29574. }
  29575. declare module BABYLON {
  29576. /**
  29577. * Defines the interface used by objects containing a viewport (like a camera)
  29578. */
  29579. interface IViewportOwnerLike {
  29580. /**
  29581. * Gets or sets the viewport
  29582. */
  29583. viewport: IViewportLike;
  29584. }
  29585. /**
  29586. * Interface for attribute information associated with buffer instanciation
  29587. */
  29588. export class InstancingAttributeInfo {
  29589. /**
  29590. * Index/offset of the attribute in the vertex shader
  29591. */
  29592. index: number;
  29593. /**
  29594. * size of the attribute, 1, 2, 3 or 4
  29595. */
  29596. attributeSize: number;
  29597. /**
  29598. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29599. * default is FLOAT
  29600. */
  29601. attribyteType: number;
  29602. /**
  29603. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29604. */
  29605. normalized: boolean;
  29606. /**
  29607. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29608. */
  29609. offset: number;
  29610. /**
  29611. * Name of the GLSL attribute, for debugging purpose only
  29612. */
  29613. attributeName: string;
  29614. }
  29615. /**
  29616. * Define options used to create a depth texture
  29617. */
  29618. export class DepthTextureCreationOptions {
  29619. /** Specifies whether or not a stencil should be allocated in the texture */
  29620. generateStencil?: boolean;
  29621. /** Specifies whether or not bilinear filtering is enable on the texture */
  29622. bilinearFiltering?: boolean;
  29623. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29624. comparisonFunction?: number;
  29625. /** Specifies if the created texture is a cube texture */
  29626. isCube?: boolean;
  29627. }
  29628. /**
  29629. * Class used to describe the capabilities of the engine relatively to the current browser
  29630. */
  29631. export class EngineCapabilities {
  29632. /** Maximum textures units per fragment shader */
  29633. maxTexturesImageUnits: number;
  29634. /** Maximum texture units per vertex shader */
  29635. maxVertexTextureImageUnits: number;
  29636. /** Maximum textures units in the entire pipeline */
  29637. maxCombinedTexturesImageUnits: number;
  29638. /** Maximum texture size */
  29639. maxTextureSize: number;
  29640. /** Maximum cube texture size */
  29641. maxCubemapTextureSize: number;
  29642. /** Maximum render texture size */
  29643. maxRenderTextureSize: number;
  29644. /** Maximum number of vertex attributes */
  29645. maxVertexAttribs: number;
  29646. /** Maximum number of varyings */
  29647. maxVaryingVectors: number;
  29648. /** Maximum number of uniforms per vertex shader */
  29649. maxVertexUniformVectors: number;
  29650. /** Maximum number of uniforms per fragment shader */
  29651. maxFragmentUniformVectors: number;
  29652. /** Defines if standard derivates (dx/dy) are supported */
  29653. standardDerivatives: boolean;
  29654. /** Defines if s3tc texture compression is supported */
  29655. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29656. /** Defines if pvrtc texture compression is supported */
  29657. pvrtc: any;
  29658. /** Defines if etc1 texture compression is supported */
  29659. etc1: any;
  29660. /** Defines if etc2 texture compression is supported */
  29661. etc2: any;
  29662. /** Defines if astc texture compression is supported */
  29663. astc: any;
  29664. /** Defines if float textures are supported */
  29665. textureFloat: boolean;
  29666. /** Defines if vertex array objects are supported */
  29667. vertexArrayObject: boolean;
  29668. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29669. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29670. /** Gets the maximum level of anisotropy supported */
  29671. maxAnisotropy: number;
  29672. /** Defines if instancing is supported */
  29673. instancedArrays: boolean;
  29674. /** Defines if 32 bits indices are supported */
  29675. uintIndices: boolean;
  29676. /** Defines if high precision shaders are supported */
  29677. highPrecisionShaderSupported: boolean;
  29678. /** Defines if depth reading in the fragment shader is supported */
  29679. fragmentDepthSupported: boolean;
  29680. /** Defines if float texture linear filtering is supported*/
  29681. textureFloatLinearFiltering: boolean;
  29682. /** Defines if rendering to float textures is supported */
  29683. textureFloatRender: boolean;
  29684. /** Defines if half float textures are supported*/
  29685. textureHalfFloat: boolean;
  29686. /** Defines if half float texture linear filtering is supported*/
  29687. textureHalfFloatLinearFiltering: boolean;
  29688. /** Defines if rendering to half float textures is supported */
  29689. textureHalfFloatRender: boolean;
  29690. /** Defines if textureLOD shader command is supported */
  29691. textureLOD: boolean;
  29692. /** Defines if draw buffers extension is supported */
  29693. drawBuffersExtension: boolean;
  29694. /** Defines if depth textures are supported */
  29695. depthTextureExtension: boolean;
  29696. /** Defines if float color buffer are supported */
  29697. colorBufferFloat: boolean;
  29698. /** Gets disjoint timer query extension (null if not supported) */
  29699. timerQuery: EXT_disjoint_timer_query;
  29700. /** Defines if timestamp can be used with timer query */
  29701. canUseTimestampForTimerQuery: boolean;
  29702. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29703. multiview: any;
  29704. /** Function used to let the system compiles shaders in background */
  29705. parallelShaderCompile: {
  29706. COMPLETION_STATUS_KHR: number;
  29707. };
  29708. /** Max number of texture samples for MSAA */
  29709. maxMSAASamples: number;
  29710. }
  29711. /** Interface defining initialization parameters for Engine class */
  29712. export interface EngineOptions extends WebGLContextAttributes {
  29713. /**
  29714. * Defines if the engine should no exceed a specified device ratio
  29715. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29716. */
  29717. limitDeviceRatio?: number;
  29718. /**
  29719. * Defines if webvr should be enabled automatically
  29720. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29721. */
  29722. autoEnableWebVR?: boolean;
  29723. /**
  29724. * Defines if webgl2 should be turned off even if supported
  29725. * @see http://doc.babylonjs.com/features/webgl2
  29726. */
  29727. disableWebGL2Support?: boolean;
  29728. /**
  29729. * Defines if webaudio should be initialized as well
  29730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29731. */
  29732. audioEngine?: boolean;
  29733. /**
  29734. * Defines if animations should run using a deterministic lock step
  29735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29736. */
  29737. deterministicLockstep?: boolean;
  29738. /** Defines the maximum steps to use with deterministic lock step mode */
  29739. lockstepMaxSteps?: number;
  29740. /**
  29741. * Defines that engine should ignore context lost events
  29742. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29743. */
  29744. doNotHandleContextLost?: boolean;
  29745. /**
  29746. * Defines that engine should ignore modifying touch action attribute and style
  29747. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29748. */
  29749. doNotHandleTouchAction?: boolean;
  29750. /**
  29751. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29752. */
  29753. useHighPrecisionFloats?: boolean;
  29754. }
  29755. /**
  29756. * Defines the interface used by display changed events
  29757. */
  29758. export interface IDisplayChangedEventArgs {
  29759. /** Gets the vrDisplay object (if any) */
  29760. vrDisplay: Nullable<any>;
  29761. /** Gets a boolean indicating if webVR is supported */
  29762. vrSupported: boolean;
  29763. }
  29764. /**
  29765. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29766. */
  29767. export class Engine {
  29768. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29769. static ExceptionList: ({
  29770. key: string;
  29771. capture: string;
  29772. captureConstraint: number;
  29773. targets: string[];
  29774. } | {
  29775. key: string;
  29776. capture: null;
  29777. captureConstraint: null;
  29778. targets: string[];
  29779. })[];
  29780. /** Gets the list of created engines */
  29781. static readonly Instances: Engine[];
  29782. /**
  29783. * Gets the latest created engine
  29784. */
  29785. static readonly LastCreatedEngine: Nullable<Engine>;
  29786. /**
  29787. * Gets the latest created scene
  29788. */
  29789. static readonly LastCreatedScene: Nullable<Scene>;
  29790. /**
  29791. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29792. * @param flag defines which part of the materials must be marked as dirty
  29793. * @param predicate defines a predicate used to filter which materials should be affected
  29794. */
  29795. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29796. /** @hidden */
  29797. static _TextureLoaders: IInternalTextureLoader[];
  29798. /** Defines that alpha blending is disabled */
  29799. static readonly ALPHA_DISABLE: number;
  29800. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29801. static readonly ALPHA_ADD: number;
  29802. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29803. static readonly ALPHA_COMBINE: number;
  29804. /** Defines that alpha blending to DEST - SRC * DEST */
  29805. static readonly ALPHA_SUBTRACT: number;
  29806. /** Defines that alpha blending to SRC * DEST */
  29807. static readonly ALPHA_MULTIPLY: number;
  29808. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29809. static readonly ALPHA_MAXIMIZED: number;
  29810. /** Defines that alpha blending to SRC + DEST */
  29811. static readonly ALPHA_ONEONE: number;
  29812. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29813. static readonly ALPHA_PREMULTIPLIED: number;
  29814. /**
  29815. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29816. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29817. */
  29818. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29819. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29820. static readonly ALPHA_INTERPOLATE: number;
  29821. /**
  29822. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29823. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29824. */
  29825. static readonly ALPHA_SCREENMODE: number;
  29826. /** Defines that the ressource is not delayed*/
  29827. static readonly DELAYLOADSTATE_NONE: number;
  29828. /** Defines that the ressource was successfully delay loaded */
  29829. static readonly DELAYLOADSTATE_LOADED: number;
  29830. /** Defines that the ressource is currently delay loading */
  29831. static readonly DELAYLOADSTATE_LOADING: number;
  29832. /** Defines that the ressource is delayed and has not started loading */
  29833. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29835. static readonly NEVER: number;
  29836. /** 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 */
  29837. static readonly ALWAYS: number;
  29838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29839. static readonly LESS: number;
  29840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29841. static readonly EQUAL: number;
  29842. /** 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 */
  29843. static readonly LEQUAL: number;
  29844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29845. static readonly GREATER: number;
  29846. /** 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 */
  29847. static readonly GEQUAL: number;
  29848. /** 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 */
  29849. static readonly NOTEQUAL: number;
  29850. /** Passed to stencilOperation to specify that stencil value must be kept */
  29851. static readonly KEEP: number;
  29852. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29853. static readonly REPLACE: number;
  29854. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29855. static readonly INCR: number;
  29856. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29857. static readonly DECR: number;
  29858. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29859. static readonly INVERT: number;
  29860. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29861. static readonly INCR_WRAP: number;
  29862. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29863. static readonly DECR_WRAP: number;
  29864. /** Texture is not repeating outside of 0..1 UVs */
  29865. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29866. /** Texture is repeating outside of 0..1 UVs */
  29867. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29868. /** Texture is repeating and mirrored */
  29869. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29870. /** ALPHA */
  29871. static readonly TEXTUREFORMAT_ALPHA: number;
  29872. /** LUMINANCE */
  29873. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29874. /** LUMINANCE_ALPHA */
  29875. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29876. /** RGB */
  29877. static readonly TEXTUREFORMAT_RGB: number;
  29878. /** RGBA */
  29879. static readonly TEXTUREFORMAT_RGBA: number;
  29880. /** RED */
  29881. static readonly TEXTUREFORMAT_RED: number;
  29882. /** RED (2nd reference) */
  29883. static readonly TEXTUREFORMAT_R: number;
  29884. /** RG */
  29885. static readonly TEXTUREFORMAT_RG: number;
  29886. /** RED_INTEGER */
  29887. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29888. /** RED_INTEGER (2nd reference) */
  29889. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29890. /** RG_INTEGER */
  29891. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29892. /** RGB_INTEGER */
  29893. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29894. /** RGBA_INTEGER */
  29895. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29896. /** UNSIGNED_BYTE */
  29897. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29898. /** UNSIGNED_BYTE (2nd reference) */
  29899. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29900. /** FLOAT */
  29901. static readonly TEXTURETYPE_FLOAT: number;
  29902. /** HALF_FLOAT */
  29903. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29904. /** BYTE */
  29905. static readonly TEXTURETYPE_BYTE: number;
  29906. /** SHORT */
  29907. static readonly TEXTURETYPE_SHORT: number;
  29908. /** UNSIGNED_SHORT */
  29909. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29910. /** INT */
  29911. static readonly TEXTURETYPE_INT: number;
  29912. /** UNSIGNED_INT */
  29913. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29914. /** UNSIGNED_SHORT_4_4_4_4 */
  29915. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29916. /** UNSIGNED_SHORT_5_5_5_1 */
  29917. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29918. /** UNSIGNED_SHORT_5_6_5 */
  29919. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29920. /** UNSIGNED_INT_2_10_10_10_REV */
  29921. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29922. /** UNSIGNED_INT_24_8 */
  29923. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29924. /** UNSIGNED_INT_10F_11F_11F_REV */
  29925. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29926. /** UNSIGNED_INT_5_9_9_9_REV */
  29927. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29928. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29929. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29930. /** nearest is mag = nearest and min = nearest and mip = linear */
  29931. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29933. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29934. /** Trilinear is mag = linear and min = linear and mip = linear */
  29935. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29936. /** nearest is mag = nearest and min = nearest and mip = linear */
  29937. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29938. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29939. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29940. /** Trilinear is mag = linear and min = linear and mip = linear */
  29941. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29942. /** mag = nearest and min = nearest and mip = nearest */
  29943. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29944. /** mag = nearest and min = linear and mip = nearest */
  29945. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29946. /** mag = nearest and min = linear and mip = linear */
  29947. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29948. /** mag = nearest and min = linear and mip = none */
  29949. static readonly TEXTURE_NEAREST_LINEAR: number;
  29950. /** mag = nearest and min = nearest and mip = none */
  29951. static readonly TEXTURE_NEAREST_NEAREST: number;
  29952. /** mag = linear and min = nearest and mip = nearest */
  29953. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29954. /** mag = linear and min = nearest and mip = linear */
  29955. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29956. /** mag = linear and min = linear and mip = none */
  29957. static readonly TEXTURE_LINEAR_LINEAR: number;
  29958. /** mag = linear and min = nearest and mip = none */
  29959. static readonly TEXTURE_LINEAR_NEAREST: number;
  29960. /** Explicit coordinates mode */
  29961. static readonly TEXTURE_EXPLICIT_MODE: number;
  29962. /** Spherical coordinates mode */
  29963. static readonly TEXTURE_SPHERICAL_MODE: number;
  29964. /** Planar coordinates mode */
  29965. static readonly TEXTURE_PLANAR_MODE: number;
  29966. /** Cubic coordinates mode */
  29967. static readonly TEXTURE_CUBIC_MODE: number;
  29968. /** Projection coordinates mode */
  29969. static readonly TEXTURE_PROJECTION_MODE: number;
  29970. /** Skybox coordinates mode */
  29971. static readonly TEXTURE_SKYBOX_MODE: number;
  29972. /** Inverse Cubic coordinates mode */
  29973. static readonly TEXTURE_INVCUBIC_MODE: number;
  29974. /** Equirectangular coordinates mode */
  29975. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29976. /** Equirectangular Fixed coordinates mode */
  29977. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29978. /** Equirectangular Fixed Mirrored coordinates mode */
  29979. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29980. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29981. static readonly SCALEMODE_FLOOR: number;
  29982. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29983. static readonly SCALEMODE_NEAREST: number;
  29984. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29985. static readonly SCALEMODE_CEILING: number;
  29986. /**
  29987. * Returns the current npm package of the sdk
  29988. */
  29989. static readonly NpmPackage: string;
  29990. /**
  29991. * Returns the current version of the framework
  29992. */
  29993. static readonly Version: string;
  29994. /**
  29995. * Returns a string describing the current engine
  29996. */
  29997. readonly description: string;
  29998. /**
  29999. * Gets or sets the epsilon value used by collision engine
  30000. */
  30001. static CollisionsEpsilon: number;
  30002. /**
  30003. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30004. */
  30005. static ShadersRepository: string;
  30006. /**
  30007. * Method called to create the default loading screen.
  30008. * This can be overriden in your own app.
  30009. * @param canvas The rendering canvas element
  30010. * @returns The loading screen
  30011. */
  30012. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30013. /**
  30014. * Method called to create the default rescale post process on each engine.
  30015. */
  30016. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30017. /** @hidden */
  30018. _shaderProcessor: IShaderProcessor;
  30019. /**
  30020. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30021. */
  30022. forcePOTTextures: boolean;
  30023. /**
  30024. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30025. */
  30026. isFullscreen: boolean;
  30027. /**
  30028. * Gets a boolean indicating if the pointer is currently locked
  30029. */
  30030. isPointerLock: boolean;
  30031. /**
  30032. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30033. */
  30034. cullBackFaces: boolean;
  30035. /**
  30036. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30037. */
  30038. renderEvenInBackground: boolean;
  30039. /**
  30040. * Gets or sets a boolean indicating that cache can be kept between frames
  30041. */
  30042. preventCacheWipeBetweenFrames: boolean;
  30043. /**
  30044. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30045. **/
  30046. enableOfflineSupport: boolean;
  30047. /**
  30048. * 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)
  30049. **/
  30050. disableManifestCheck: boolean;
  30051. /**
  30052. * Gets the list of created scenes
  30053. */
  30054. scenes: Scene[];
  30055. /**
  30056. * Event raised when a new scene is created
  30057. */
  30058. onNewSceneAddedObservable: Observable<Scene>;
  30059. /**
  30060. * Gets the list of created postprocesses
  30061. */
  30062. postProcesses: PostProcess[];
  30063. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30064. validateShaderPrograms: boolean;
  30065. /**
  30066. * Observable event triggered each time the rendering canvas is resized
  30067. */
  30068. onResizeObservable: Observable<Engine>;
  30069. /**
  30070. * Observable event triggered each time the canvas loses focus
  30071. */
  30072. onCanvasBlurObservable: Observable<Engine>;
  30073. /**
  30074. * Observable event triggered each time the canvas gains focus
  30075. */
  30076. onCanvasFocusObservable: Observable<Engine>;
  30077. /**
  30078. * Observable event triggered each time the canvas receives pointerout event
  30079. */
  30080. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30081. /**
  30082. * Observable event triggered before each texture is initialized
  30083. */
  30084. onBeforeTextureInitObservable: Observable<Texture>;
  30085. /**
  30086. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30087. */
  30088. disableUniformBuffers: boolean;
  30089. /** @hidden */
  30090. _uniformBuffers: UniformBuffer[];
  30091. /**
  30092. * Gets a boolean indicating that the engine supports uniform buffers
  30093. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30094. */
  30095. readonly supportsUniformBuffers: boolean;
  30096. /**
  30097. * Observable raised when the engine begins a new frame
  30098. */
  30099. onBeginFrameObservable: Observable<Engine>;
  30100. /**
  30101. * If set, will be used to request the next animation frame for the render loop
  30102. */
  30103. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30104. /**
  30105. * Observable raised when the engine ends the current frame
  30106. */
  30107. onEndFrameObservable: Observable<Engine>;
  30108. /**
  30109. * Observable raised when the engine is about to compile a shader
  30110. */
  30111. onBeforeShaderCompilationObservable: Observable<Engine>;
  30112. /**
  30113. * Observable raised when the engine has jsut compiled a shader
  30114. */
  30115. onAfterShaderCompilationObservable: Observable<Engine>;
  30116. /** @hidden */
  30117. _gl: WebGLRenderingContext;
  30118. private _renderingCanvas;
  30119. private _windowIsBackground;
  30120. private _webGLVersion;
  30121. protected _highPrecisionShadersAllowed: boolean;
  30122. /** @hidden */
  30123. readonly _shouldUseHighPrecisionShader: boolean;
  30124. /**
  30125. * Gets a boolean indicating that only power of 2 textures are supported
  30126. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30127. */
  30128. readonly needPOTTextures: boolean;
  30129. /** @hidden */
  30130. _badOS: boolean;
  30131. /** @hidden */
  30132. _badDesktopOS: boolean;
  30133. /**
  30134. * Gets the audio engine
  30135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30136. * @ignorenaming
  30137. */
  30138. static audioEngine: IAudioEngine;
  30139. /**
  30140. * Default AudioEngine factory responsible of creating the Audio Engine.
  30141. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30142. */
  30143. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30144. /**
  30145. * Default offline support factory responsible of creating a tool used to store data locally.
  30146. * By default, this will create a Database object if the workload has been embedded.
  30147. */
  30148. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30149. private _onFocus;
  30150. private _onBlur;
  30151. private _onCanvasPointerOut;
  30152. private _onCanvasBlur;
  30153. private _onCanvasFocus;
  30154. private _onFullscreenChange;
  30155. private _onPointerLockChange;
  30156. private _hardwareScalingLevel;
  30157. /** @hidden */
  30158. _caps: EngineCapabilities;
  30159. private _pointerLockRequested;
  30160. private _isStencilEnable;
  30161. private _colorWrite;
  30162. private _loadingScreen;
  30163. /** @hidden */
  30164. _drawCalls: PerfCounter;
  30165. private _glVersion;
  30166. private _glRenderer;
  30167. private _glVendor;
  30168. private _videoTextureSupported;
  30169. private _renderingQueueLaunched;
  30170. private _activeRenderLoops;
  30171. private _deterministicLockstep;
  30172. private _lockstepMaxSteps;
  30173. /**
  30174. * Observable signaled when a context lost event is raised
  30175. */
  30176. onContextLostObservable: Observable<Engine>;
  30177. /**
  30178. * Observable signaled when a context restored event is raised
  30179. */
  30180. onContextRestoredObservable: Observable<Engine>;
  30181. private _onContextLost;
  30182. private _onContextRestored;
  30183. private _contextWasLost;
  30184. /** @hidden */
  30185. _doNotHandleContextLost: boolean;
  30186. /**
  30187. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30189. */
  30190. doNotHandleContextLost: boolean;
  30191. private _performanceMonitor;
  30192. private _fps;
  30193. private _deltaTime;
  30194. /**
  30195. * Turn this value on if you want to pause FPS computation when in background
  30196. */
  30197. disablePerformanceMonitorInBackground: boolean;
  30198. /**
  30199. * Gets the performance monitor attached to this engine
  30200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30201. */
  30202. readonly performanceMonitor: PerformanceMonitor;
  30203. /**
  30204. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30205. */
  30206. disableVertexArrayObjects: boolean;
  30207. /** @hidden */
  30208. protected _depthCullingState: _DepthCullingState;
  30209. /** @hidden */
  30210. protected _stencilState: _StencilState;
  30211. /** @hidden */
  30212. protected _alphaState: _AlphaState;
  30213. /** @hidden */
  30214. protected _alphaMode: number;
  30215. /** @hidden */
  30216. _internalTexturesCache: InternalTexture[];
  30217. /** @hidden */
  30218. protected _activeChannel: number;
  30219. private _currentTextureChannel;
  30220. /** @hidden */
  30221. protected _boundTexturesCache: {
  30222. [key: string]: Nullable<InternalTexture>;
  30223. };
  30224. /** @hidden */
  30225. protected _currentEffect: Nullable<Effect>;
  30226. /** @hidden */
  30227. protected _currentProgram: Nullable<WebGLProgram>;
  30228. private _compiledEffects;
  30229. private _vertexAttribArraysEnabled;
  30230. /** @hidden */
  30231. protected _cachedViewport: Nullable<IViewportLike>;
  30232. private _cachedVertexArrayObject;
  30233. /** @hidden */
  30234. protected _cachedVertexBuffers: any;
  30235. /** @hidden */
  30236. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30237. /** @hidden */
  30238. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30239. /** @hidden */
  30240. _currentRenderTarget: Nullable<InternalTexture>;
  30241. private _uintIndicesCurrentlySet;
  30242. private _currentBoundBuffer;
  30243. /** @hidden */
  30244. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30245. private _currentBufferPointers;
  30246. private _currentInstanceLocations;
  30247. private _currentInstanceBuffers;
  30248. private _textureUnits;
  30249. /** @hidden */
  30250. _workingCanvas: Nullable<HTMLCanvasElement>;
  30251. /** @hidden */
  30252. _workingContext: Nullable<CanvasRenderingContext2D>;
  30253. private _rescalePostProcess;
  30254. private _dummyFramebuffer;
  30255. private _externalData;
  30256. /** @hidden */
  30257. _bindedRenderFunction: any;
  30258. private _vaoRecordInProgress;
  30259. private _mustWipeVertexAttributes;
  30260. private _emptyTexture;
  30261. private _emptyCubeTexture;
  30262. private _emptyTexture3D;
  30263. /** @hidden */
  30264. _frameHandler: number;
  30265. private _nextFreeTextureSlots;
  30266. private _maxSimultaneousTextures;
  30267. private _activeRequests;
  30268. private _texturesSupported;
  30269. /** @hidden */
  30270. _textureFormatInUse: Nullable<string>;
  30271. /**
  30272. * Gets the list of texture formats supported
  30273. */
  30274. readonly texturesSupported: Array<string>;
  30275. /**
  30276. * Gets the list of texture formats in use
  30277. */
  30278. readonly textureFormatInUse: Nullable<string>;
  30279. /**
  30280. * Gets the current viewport
  30281. */
  30282. readonly currentViewport: Nullable<IViewportLike>;
  30283. /**
  30284. * Gets the default empty texture
  30285. */
  30286. readonly emptyTexture: InternalTexture;
  30287. /**
  30288. * Gets the default empty 3D texture
  30289. */
  30290. readonly emptyTexture3D: InternalTexture;
  30291. /**
  30292. * Gets the default empty cube texture
  30293. */
  30294. readonly emptyCubeTexture: InternalTexture;
  30295. /**
  30296. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30297. */
  30298. readonly premultipliedAlpha: boolean;
  30299. /**
  30300. * Creates a new engine
  30301. * @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
  30302. * @param antialias defines enable antialiasing (default: false)
  30303. * @param options defines further options to be sent to the getContext() function
  30304. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30305. */
  30306. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30307. /**
  30308. * Initializes a webVR display and starts listening to display change events
  30309. * The onVRDisplayChangedObservable will be notified upon these changes
  30310. * @returns The onVRDisplayChangedObservable
  30311. */
  30312. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30313. /** @hidden */
  30314. _prepareVRComponent(): void;
  30315. /** @hidden */
  30316. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30317. /** @hidden */
  30318. _submitVRFrame(): void;
  30319. /**
  30320. * Call this function to leave webVR mode
  30321. * Will do nothing if webVR is not supported or if there is no webVR device
  30322. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30323. */
  30324. disableVR(): void;
  30325. /**
  30326. * Gets a boolean indicating that the system is in VR mode and is presenting
  30327. * @returns true if VR mode is engaged
  30328. */
  30329. isVRPresenting(): boolean;
  30330. /** @hidden */
  30331. _requestVRFrame(): void;
  30332. private _disableTouchAction;
  30333. private _rebuildInternalTextures;
  30334. private _rebuildEffects;
  30335. /**
  30336. * Gets a boolean indicating if all created effects are ready
  30337. * @returns true if all effects are ready
  30338. */
  30339. areAllEffectsReady(): boolean;
  30340. private _rebuildBuffers;
  30341. private _initGLContext;
  30342. /**
  30343. * Gets version of the current webGL context
  30344. */
  30345. readonly webGLVersion: number;
  30346. /**
  30347. * Gets a string idenfifying the name of the class
  30348. * @returns "Engine" string
  30349. */
  30350. getClassName(): string;
  30351. /**
  30352. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30353. */
  30354. readonly isStencilEnable: boolean;
  30355. /** @hidden */
  30356. _prepareWorkingCanvas(): void;
  30357. /**
  30358. * Reset the texture cache to empty state
  30359. */
  30360. resetTextureCache(): void;
  30361. /**
  30362. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30364. * @returns true if engine is in deterministic lock step mode
  30365. */
  30366. isDeterministicLockStep(): boolean;
  30367. /**
  30368. * Gets the max steps when engine is running in deterministic lock step
  30369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30370. * @returns the max steps
  30371. */
  30372. getLockstepMaxSteps(): number;
  30373. /**
  30374. * Gets an object containing information about the current webGL context
  30375. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30376. */
  30377. getGlInfo(): {
  30378. vendor: string;
  30379. renderer: string;
  30380. version: string;
  30381. };
  30382. /**
  30383. * Gets current aspect ratio
  30384. * @param viewportOwner defines the camera to use to get the aspect ratio
  30385. * @param useScreen defines if screen size must be used (or the current render target if any)
  30386. * @returns a number defining the aspect ratio
  30387. */
  30388. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30389. /**
  30390. * Gets current screen aspect ratio
  30391. * @returns a number defining the aspect ratio
  30392. */
  30393. getScreenAspectRatio(): number;
  30394. /**
  30395. * Gets the current render width
  30396. * @param useScreen defines if screen size must be used (or the current render target if any)
  30397. * @returns a number defining the current render width
  30398. */
  30399. getRenderWidth(useScreen?: boolean): number;
  30400. /**
  30401. * Gets the current render height
  30402. * @param useScreen defines if screen size must be used (or the current render target if any)
  30403. * @returns a number defining the current render height
  30404. */
  30405. getRenderHeight(useScreen?: boolean): number;
  30406. /**
  30407. * Gets the HTML canvas attached with the current webGL context
  30408. * @returns a HTML canvas
  30409. */
  30410. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30411. /**
  30412. * Gets host window
  30413. * @returns the host window object
  30414. */
  30415. getHostWindow(): Window;
  30416. /**
  30417. * Gets host document
  30418. * @returns the host document object
  30419. */
  30420. getHostDocument(): Document;
  30421. /**
  30422. * Gets the client rect of the HTML canvas attached with the current webGL context
  30423. * @returns a client rectanglee
  30424. */
  30425. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30426. /**
  30427. * Defines the hardware scaling level.
  30428. * By default the hardware scaling level is computed from the window device ratio.
  30429. * 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.
  30430. * @param level defines the level to use
  30431. */
  30432. setHardwareScalingLevel(level: number): void;
  30433. /**
  30434. * Gets the current hardware scaling level.
  30435. * By default the hardware scaling level is computed from the window device ratio.
  30436. * 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.
  30437. * @returns a number indicating the current hardware scaling level
  30438. */
  30439. getHardwareScalingLevel(): number;
  30440. /**
  30441. * Gets the list of loaded textures
  30442. * @returns an array containing all loaded textures
  30443. */
  30444. getLoadedTexturesCache(): InternalTexture[];
  30445. /**
  30446. * Gets the object containing all engine capabilities
  30447. * @returns the EngineCapabilities object
  30448. */
  30449. getCaps(): EngineCapabilities;
  30450. /**
  30451. * Gets the current depth function
  30452. * @returns a number defining the depth function
  30453. */
  30454. getDepthFunction(): Nullable<number>;
  30455. /**
  30456. * Sets the current depth function
  30457. * @param depthFunc defines the function to use
  30458. */
  30459. setDepthFunction(depthFunc: number): void;
  30460. /**
  30461. * Sets the current depth function to GREATER
  30462. */
  30463. setDepthFunctionToGreater(): void;
  30464. /**
  30465. * Sets the current depth function to GEQUAL
  30466. */
  30467. setDepthFunctionToGreaterOrEqual(): void;
  30468. /**
  30469. * Sets the current depth function to LESS
  30470. */
  30471. setDepthFunctionToLess(): void;
  30472. private _cachedStencilBuffer;
  30473. private _cachedStencilFunction;
  30474. private _cachedStencilMask;
  30475. private _cachedStencilOperationPass;
  30476. private _cachedStencilOperationFail;
  30477. private _cachedStencilOperationDepthFail;
  30478. private _cachedStencilReference;
  30479. /**
  30480. * Caches the the state of the stencil buffer
  30481. */
  30482. cacheStencilState(): void;
  30483. /**
  30484. * Restores the state of the stencil buffer
  30485. */
  30486. restoreStencilState(): void;
  30487. /**
  30488. * Sets the current depth function to LEQUAL
  30489. */
  30490. setDepthFunctionToLessOrEqual(): void;
  30491. /**
  30492. * Gets a boolean indicating if stencil buffer is enabled
  30493. * @returns the current stencil buffer state
  30494. */
  30495. getStencilBuffer(): boolean;
  30496. /**
  30497. * Enable or disable the stencil buffer
  30498. * @param enable defines if the stencil buffer must be enabled or disabled
  30499. */
  30500. setStencilBuffer(enable: boolean): void;
  30501. /**
  30502. * Gets the current stencil mask
  30503. * @returns a number defining the new stencil mask to use
  30504. */
  30505. getStencilMask(): number;
  30506. /**
  30507. * Sets the current stencil mask
  30508. * @param mask defines the new stencil mask to use
  30509. */
  30510. setStencilMask(mask: number): void;
  30511. /**
  30512. * Gets the current stencil function
  30513. * @returns a number defining the stencil function to use
  30514. */
  30515. getStencilFunction(): number;
  30516. /**
  30517. * Gets the current stencil reference value
  30518. * @returns a number defining the stencil reference value to use
  30519. */
  30520. getStencilFunctionReference(): number;
  30521. /**
  30522. * Gets the current stencil mask
  30523. * @returns a number defining the stencil mask to use
  30524. */
  30525. getStencilFunctionMask(): number;
  30526. /**
  30527. * Sets the current stencil function
  30528. * @param stencilFunc defines the new stencil function to use
  30529. */
  30530. setStencilFunction(stencilFunc: number): void;
  30531. /**
  30532. * Sets the current stencil reference
  30533. * @param reference defines the new stencil reference to use
  30534. */
  30535. setStencilFunctionReference(reference: number): void;
  30536. /**
  30537. * Sets the current stencil mask
  30538. * @param mask defines the new stencil mask to use
  30539. */
  30540. setStencilFunctionMask(mask: number): void;
  30541. /**
  30542. * Gets the current stencil operation when stencil fails
  30543. * @returns a number defining stencil operation to use when stencil fails
  30544. */
  30545. getStencilOperationFail(): number;
  30546. /**
  30547. * Gets the current stencil operation when depth fails
  30548. * @returns a number defining stencil operation to use when depth fails
  30549. */
  30550. getStencilOperationDepthFail(): number;
  30551. /**
  30552. * Gets the current stencil operation when stencil passes
  30553. * @returns a number defining stencil operation to use when stencil passes
  30554. */
  30555. getStencilOperationPass(): number;
  30556. /**
  30557. * Sets the stencil operation to use when stencil fails
  30558. * @param operation defines the stencil operation to use when stencil fails
  30559. */
  30560. setStencilOperationFail(operation: number): void;
  30561. /**
  30562. * Sets the stencil operation to use when depth fails
  30563. * @param operation defines the stencil operation to use when depth fails
  30564. */
  30565. setStencilOperationDepthFail(operation: number): void;
  30566. /**
  30567. * Sets the stencil operation to use when stencil passes
  30568. * @param operation defines the stencil operation to use when stencil passes
  30569. */
  30570. setStencilOperationPass(operation: number): void;
  30571. /**
  30572. * Sets a boolean indicating if the dithering state is enabled or disabled
  30573. * @param value defines the dithering state
  30574. */
  30575. setDitheringState(value: boolean): void;
  30576. /**
  30577. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30578. * @param value defines the rasterizer state
  30579. */
  30580. setRasterizerState(value: boolean): void;
  30581. /**
  30582. * stop executing a render loop function and remove it from the execution array
  30583. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30584. */
  30585. stopRenderLoop(renderFunction?: () => void): void;
  30586. /** @hidden */
  30587. _renderLoop(): void;
  30588. /**
  30589. * Register and execute a render loop. The engine can have more than one render function
  30590. * @param renderFunction defines the function to continuously execute
  30591. */
  30592. runRenderLoop(renderFunction: () => void): void;
  30593. /**
  30594. * Toggle full screen mode
  30595. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30596. */
  30597. switchFullscreen(requestPointerLock: boolean): void;
  30598. /**
  30599. * Enters full screen mode
  30600. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30601. */
  30602. enterFullscreen(requestPointerLock: boolean): void;
  30603. /**
  30604. * Exits full screen mode
  30605. */
  30606. exitFullscreen(): void;
  30607. /**
  30608. * Enters Pointerlock mode
  30609. */
  30610. enterPointerlock(): void;
  30611. /**
  30612. * Exits Pointerlock mode
  30613. */
  30614. exitPointerlock(): void;
  30615. /**
  30616. * Clear the current render buffer or the current render target (if any is set up)
  30617. * @param color defines the color to use
  30618. * @param backBuffer defines if the back buffer must be cleared
  30619. * @param depth defines if the depth buffer must be cleared
  30620. * @param stencil defines if the stencil buffer must be cleared
  30621. */
  30622. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30623. /**
  30624. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30625. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30626. * @param y defines the y-coordinate of the corner of the clear rectangle
  30627. * @param width defines the width of the clear rectangle
  30628. * @param height defines the height of the clear rectangle
  30629. * @param clearColor defines the clear color
  30630. */
  30631. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30632. /**
  30633. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30634. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30635. * @param y defines the y-coordinate of the corner of the clear rectangle
  30636. * @param width defines the width of the clear rectangle
  30637. * @param height defines the height of the clear rectangle
  30638. */
  30639. enableScissor(x: number, y: number, width: number, height: number): void;
  30640. /**
  30641. * Disable previously set scissor test rectangle
  30642. */
  30643. disableScissor(): void;
  30644. private _viewportCached;
  30645. /** @hidden */
  30646. _viewport(x: number, y: number, width: number, height: number): void;
  30647. /**
  30648. * Set the WebGL's viewport
  30649. * @param viewport defines the viewport element to be used
  30650. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30651. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30652. */
  30653. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30654. /**
  30655. * Directly set the WebGL Viewport
  30656. * @param x defines the x coordinate of the viewport (in screen space)
  30657. * @param y defines the y coordinate of the viewport (in screen space)
  30658. * @param width defines the width of the viewport (in screen space)
  30659. * @param height defines the height of the viewport (in screen space)
  30660. * @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
  30661. */
  30662. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30663. /**
  30664. * Begin a new frame
  30665. */
  30666. beginFrame(): void;
  30667. /**
  30668. * Enf the current frame
  30669. */
  30670. endFrame(): void;
  30671. /**
  30672. * Resize the view according to the canvas' size
  30673. */
  30674. resize(): void;
  30675. /**
  30676. * Force a specific size of the canvas
  30677. * @param width defines the new canvas' width
  30678. * @param height defines the new canvas' height
  30679. */
  30680. setSize(width: number, height: number): void;
  30681. /**
  30682. * Binds the frame buffer to the specified texture.
  30683. * @param texture The texture to render to or null for the default canvas
  30684. * @param faceIndex The face of the texture to render to in case of cube texture
  30685. * @param requiredWidth The width of the target to render to
  30686. * @param requiredHeight The height of the target to render to
  30687. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30688. * @param depthStencilTexture The depth stencil texture to use to render
  30689. * @param lodLevel defines le lod level to bind to the frame buffer
  30690. */
  30691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30692. /** @hidden */
  30693. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30694. /**
  30695. * Unbind the current render target texture from the webGL context
  30696. * @param texture defines the render target texture to unbind
  30697. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30698. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30699. */
  30700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30701. /**
  30702. * Force the mipmap generation for the given render target texture
  30703. * @param texture defines the render target texture to use
  30704. */
  30705. generateMipMapsForCubemap(texture: InternalTexture): void;
  30706. /**
  30707. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30708. */
  30709. flushFramebuffer(): void;
  30710. /**
  30711. * Unbind the current render target and bind the default framebuffer
  30712. */
  30713. restoreDefaultFramebuffer(): void;
  30714. /**
  30715. * Create an uniform buffer
  30716. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30717. * @param elements defines the content of the uniform buffer
  30718. * @returns the webGL uniform buffer
  30719. */
  30720. createUniformBuffer(elements: FloatArray): DataBuffer;
  30721. /**
  30722. * Create a dynamic uniform buffer
  30723. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30724. * @param elements defines the content of the uniform buffer
  30725. * @returns the webGL uniform buffer
  30726. */
  30727. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30728. /**
  30729. * Update an existing uniform buffer
  30730. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30731. * @param uniformBuffer defines the target uniform buffer
  30732. * @param elements defines the content to update
  30733. * @param offset defines the offset in the uniform buffer where update should start
  30734. * @param count defines the size of the data to update
  30735. */
  30736. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30737. private _resetVertexBufferBinding;
  30738. /**
  30739. * Creates a vertex buffer
  30740. * @param data the data for the vertex buffer
  30741. * @returns the new WebGL static buffer
  30742. */
  30743. createVertexBuffer(data: DataArray): DataBuffer;
  30744. /**
  30745. * Creates a dynamic vertex buffer
  30746. * @param data the data for the dynamic vertex buffer
  30747. * @returns the new WebGL dynamic buffer
  30748. */
  30749. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30750. /**
  30751. * Update a dynamic index buffer
  30752. * @param indexBuffer defines the target index buffer
  30753. * @param indices defines the data to update
  30754. * @param offset defines the offset in the target index buffer where update should start
  30755. */
  30756. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30757. /**
  30758. * Updates a dynamic vertex buffer.
  30759. * @param vertexBuffer the vertex buffer to update
  30760. * @param data the data used to update the vertex buffer
  30761. * @param byteOffset the byte offset of the data
  30762. * @param byteLength the byte length of the data
  30763. */
  30764. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30765. private _resetIndexBufferBinding;
  30766. /**
  30767. * Creates a new index buffer
  30768. * @param indices defines the content of the index buffer
  30769. * @param updatable defines if the index buffer must be updatable
  30770. * @returns a new webGL buffer
  30771. */
  30772. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30773. /**
  30774. * Bind a webGL buffer to the webGL context
  30775. * @param buffer defines the buffer to bind
  30776. */
  30777. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30778. /**
  30779. * Bind an uniform buffer to the current webGL context
  30780. * @param buffer defines the buffer to bind
  30781. */
  30782. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30783. /**
  30784. * Bind a buffer to the current webGL context at a given location
  30785. * @param buffer defines the buffer to bind
  30786. * @param location defines the index where to bind the buffer
  30787. */
  30788. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30789. /**
  30790. * Bind a specific block at a given index in a specific shader program
  30791. * @param pipelineContext defines the pipeline context to use
  30792. * @param blockName defines the block name
  30793. * @param index defines the index where to bind the block
  30794. */
  30795. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30796. private bindIndexBuffer;
  30797. private bindBuffer;
  30798. /**
  30799. * update the bound buffer with the given data
  30800. * @param data defines the data to update
  30801. */
  30802. updateArrayBuffer(data: Float32Array): void;
  30803. private _vertexAttribPointer;
  30804. private _bindIndexBufferWithCache;
  30805. private _bindVertexBuffersAttributes;
  30806. /**
  30807. * Records a vertex array object
  30808. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30809. * @param vertexBuffers defines the list of vertex buffers to store
  30810. * @param indexBuffer defines the index buffer to store
  30811. * @param effect defines the effect to store
  30812. * @returns the new vertex array object
  30813. */
  30814. recordVertexArrayObject(vertexBuffers: {
  30815. [key: string]: VertexBuffer;
  30816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30817. /**
  30818. * Bind a specific vertex array object
  30819. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30820. * @param vertexArrayObject defines the vertex array object to bind
  30821. * @param indexBuffer defines the index buffer to bind
  30822. */
  30823. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30824. /**
  30825. * Bind webGl buffers directly to the webGL context
  30826. * @param vertexBuffer defines the vertex buffer to bind
  30827. * @param indexBuffer defines the index buffer to bind
  30828. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30829. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30830. * @param effect defines the effect associated with the vertex buffer
  30831. */
  30832. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30833. private _unbindVertexArrayObject;
  30834. /**
  30835. * Bind a list of vertex buffers to the webGL context
  30836. * @param vertexBuffers defines the list of vertex buffers to bind
  30837. * @param indexBuffer defines the index buffer to bind
  30838. * @param effect defines the effect associated with the vertex buffers
  30839. */
  30840. bindBuffers(vertexBuffers: {
  30841. [key: string]: Nullable<VertexBuffer>;
  30842. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30843. /**
  30844. * Unbind all instance attributes
  30845. */
  30846. unbindInstanceAttributes(): void;
  30847. /**
  30848. * Release and free the memory of a vertex array object
  30849. * @param vao defines the vertex array object to delete
  30850. */
  30851. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30852. /** @hidden */
  30853. _releaseBuffer(buffer: DataBuffer): boolean;
  30854. /**
  30855. * Creates a webGL buffer to use with instanciation
  30856. * @param capacity defines the size of the buffer
  30857. * @returns the webGL buffer
  30858. */
  30859. createInstancesBuffer(capacity: number): DataBuffer;
  30860. /**
  30861. * Delete a webGL buffer used with instanciation
  30862. * @param buffer defines the webGL buffer to delete
  30863. */
  30864. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30865. /**
  30866. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30867. * @param instancesBuffer defines the webGL buffer to update and bind
  30868. * @param data defines the data to store in the buffer
  30869. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30870. */
  30871. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30872. /**
  30873. * Apply all cached states (depth, culling, stencil and alpha)
  30874. */
  30875. applyStates(): void;
  30876. /**
  30877. * Send a draw order
  30878. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30879. * @param indexStart defines the starting index
  30880. * @param indexCount defines the number of index to draw
  30881. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30882. */
  30883. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30884. /**
  30885. * Draw a list of points
  30886. * @param verticesStart defines the index of first vertex to draw
  30887. * @param verticesCount defines the count of vertices to draw
  30888. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30889. */
  30890. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30891. /**
  30892. * Draw a list of unindexed primitives
  30893. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30894. * @param verticesStart defines the index of first vertex to draw
  30895. * @param verticesCount defines the count of vertices to draw
  30896. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30897. */
  30898. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30899. /**
  30900. * Draw a list of indexed primitives
  30901. * @param fillMode defines the primitive to use
  30902. * @param indexStart defines the starting index
  30903. * @param indexCount defines the number of index to draw
  30904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30905. */
  30906. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30907. /**
  30908. * Draw a list of unindexed primitives
  30909. * @param fillMode defines the primitive to use
  30910. * @param verticesStart defines the index of first vertex to draw
  30911. * @param verticesCount defines the count of vertices to draw
  30912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30913. */
  30914. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30915. private _drawMode;
  30916. /** @hidden */
  30917. _releaseEffect(effect: Effect): void;
  30918. /** @hidden */
  30919. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30920. /**
  30921. * Create a new effect (used to store vertex/fragment shaders)
  30922. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30923. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30924. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30925. * @param samplers defines an array of string used to represent textures
  30926. * @param defines defines the string containing the defines to use to compile the shaders
  30927. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30928. * @param onCompiled defines a function to call when the effect creation is successful
  30929. * @param onError defines a function to call when the effect creation has failed
  30930. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30931. * @returns the new Effect
  30932. */
  30933. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30934. private _compileShader;
  30935. private _compileRawShader;
  30936. /**
  30937. * Directly creates a webGL program
  30938. * @param pipelineContext defines the pipeline context to attach to
  30939. * @param vertexCode defines the vertex shader code to use
  30940. * @param fragmentCode defines the fragment shader code to use
  30941. * @param context defines the webGL context to use (if not set, the current one will be used)
  30942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30943. * @returns the new webGL program
  30944. */
  30945. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30946. /**
  30947. * Creates a webGL program
  30948. * @param pipelineContext defines the pipeline context to attach to
  30949. * @param vertexCode defines the vertex shader code to use
  30950. * @param fragmentCode defines the fragment shader code to use
  30951. * @param defines defines the string containing the defines to use to compile the shaders
  30952. * @param context defines the webGL context to use (if not set, the current one will be used)
  30953. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30954. * @returns the new webGL program
  30955. */
  30956. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30957. /**
  30958. * Creates a new pipeline context
  30959. * @returns the new pipeline
  30960. */
  30961. createPipelineContext(): WebGLPipelineContext;
  30962. private _createShaderProgram;
  30963. private _finalizePipelineContext;
  30964. /** @hidden */
  30965. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30966. /** @hidden */
  30967. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30968. /** @hidden */
  30969. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30970. /**
  30971. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30972. * @param pipelineContext defines the pipeline context to use
  30973. * @param uniformsNames defines the list of uniform names
  30974. * @returns an array of webGL uniform locations
  30975. */
  30976. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30977. /**
  30978. * Gets the lsit of active attributes for a given webGL program
  30979. * @param pipelineContext defines the pipeline context to use
  30980. * @param attributesNames defines the list of attribute names to get
  30981. * @returns an array of indices indicating the offset of each attribute
  30982. */
  30983. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30984. /**
  30985. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30986. * @param effect defines the effect to activate
  30987. */
  30988. enableEffect(effect: Nullable<Effect>): void;
  30989. /**
  30990. * Set the value of an uniform to an array of int32
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param array defines the array of int32 to store
  30993. */
  30994. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30995. /**
  30996. * Set the value of an uniform to an array of int32 (stored as vec2)
  30997. * @param uniform defines the webGL uniform location where to store the value
  30998. * @param array defines the array of int32 to store
  30999. */
  31000. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31001. /**
  31002. * Set the value of an uniform to an array of int32 (stored as vec3)
  31003. * @param uniform defines the webGL uniform location where to store the value
  31004. * @param array defines the array of int32 to store
  31005. */
  31006. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31007. /**
  31008. * Set the value of an uniform to an array of int32 (stored as vec4)
  31009. * @param uniform defines the webGL uniform location where to store the value
  31010. * @param array defines the array of int32 to store
  31011. */
  31012. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31013. /**
  31014. * Set the value of an uniform to an array of float32
  31015. * @param uniform defines the webGL uniform location where to store the value
  31016. * @param array defines the array of float32 to store
  31017. */
  31018. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31019. /**
  31020. * Set the value of an uniform to an array of float32 (stored as vec2)
  31021. * @param uniform defines the webGL uniform location where to store the value
  31022. * @param array defines the array of float32 to store
  31023. */
  31024. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31025. /**
  31026. * Set the value of an uniform to an array of float32 (stored as vec3)
  31027. * @param uniform defines the webGL uniform location where to store the value
  31028. * @param array defines the array of float32 to store
  31029. */
  31030. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31031. /**
  31032. * Set the value of an uniform to an array of float32 (stored as vec4)
  31033. * @param uniform defines the webGL uniform location where to store the value
  31034. * @param array defines the array of float32 to store
  31035. */
  31036. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31037. /**
  31038. * Set the value of an uniform to an array of number
  31039. * @param uniform defines the webGL uniform location where to store the value
  31040. * @param array defines the array of number to store
  31041. */
  31042. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31043. /**
  31044. * Set the value of an uniform to an array of number (stored as vec2)
  31045. * @param uniform defines the webGL uniform location where to store the value
  31046. * @param array defines the array of number to store
  31047. */
  31048. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31049. /**
  31050. * Set the value of an uniform to an array of number (stored as vec3)
  31051. * @param uniform defines the webGL uniform location where to store the value
  31052. * @param array defines the array of number to store
  31053. */
  31054. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31055. /**
  31056. * Set the value of an uniform to an array of number (stored as vec4)
  31057. * @param uniform defines the webGL uniform location where to store the value
  31058. * @param array defines the array of number to store
  31059. */
  31060. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31061. /**
  31062. * Set the value of an uniform to an array of float32 (stored as matrices)
  31063. * @param uniform defines the webGL uniform location where to store the value
  31064. * @param matrices defines the array of float32 to store
  31065. */
  31066. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31067. /**
  31068. * Set the value of an uniform to a matrix (3x3)
  31069. * @param uniform defines the webGL uniform location where to store the value
  31070. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31071. */
  31072. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31073. /**
  31074. * Set the value of an uniform to a matrix (2x2)
  31075. * @param uniform defines the webGL uniform location where to store the value
  31076. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31077. */
  31078. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31079. /**
  31080. * Set the value of an uniform to a number (int)
  31081. * @param uniform defines the webGL uniform location where to store the value
  31082. * @param value defines the int number to store
  31083. */
  31084. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31085. /**
  31086. * Set the value of an uniform to a number (float)
  31087. * @param uniform defines the webGL uniform location where to store the value
  31088. * @param value defines the float number to store
  31089. */
  31090. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31091. /**
  31092. * Set the value of an uniform to a vec2
  31093. * @param uniform defines the webGL uniform location where to store the value
  31094. * @param x defines the 1st component of the value
  31095. * @param y defines the 2nd component of the value
  31096. */
  31097. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31098. /**
  31099. * Set the value of an uniform to a vec3
  31100. * @param uniform defines the webGL uniform location where to store the value
  31101. * @param x defines the 1st component of the value
  31102. * @param y defines the 2nd component of the value
  31103. * @param z defines the 3rd component of the value
  31104. */
  31105. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31106. /**
  31107. * Set the value of an uniform to a boolean
  31108. * @param uniform defines the webGL uniform location where to store the value
  31109. * @param bool defines the boolean to store
  31110. */
  31111. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31112. /**
  31113. * Set the value of an uniform to a vec4
  31114. * @param uniform defines the webGL uniform location where to store the value
  31115. * @param x defines the 1st component of the value
  31116. * @param y defines the 2nd component of the value
  31117. * @param z defines the 3rd component of the value
  31118. * @param w defines the 4th component of the value
  31119. */
  31120. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31121. /**
  31122. * Sets a Color4 on a uniform variable
  31123. * @param uniform defines the uniform location
  31124. * @param color4 defines the value to be set
  31125. */
  31126. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31127. /**
  31128. * Set various states to the webGL context
  31129. * @param culling defines backface culling state
  31130. * @param zOffset defines the value to apply to zOffset (0 by default)
  31131. * @param force defines if states must be applied even if cache is up to date
  31132. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31133. */
  31134. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31135. /**
  31136. * Set the z offset to apply to current rendering
  31137. * @param value defines the offset to apply
  31138. */
  31139. setZOffset(value: number): void;
  31140. /**
  31141. * Gets the current value of the zOffset
  31142. * @returns the current zOffset state
  31143. */
  31144. getZOffset(): number;
  31145. /**
  31146. * Enable or disable depth buffering
  31147. * @param enable defines the state to set
  31148. */
  31149. setDepthBuffer(enable: boolean): void;
  31150. /**
  31151. * Gets a boolean indicating if depth writing is enabled
  31152. * @returns the current depth writing state
  31153. */
  31154. getDepthWrite(): boolean;
  31155. /**
  31156. * Enable or disable depth writing
  31157. * @param enable defines the state to set
  31158. */
  31159. setDepthWrite(enable: boolean): void;
  31160. /**
  31161. * Enable or disable color writing
  31162. * @param enable defines the state to set
  31163. */
  31164. setColorWrite(enable: boolean): void;
  31165. /**
  31166. * Gets a boolean indicating if color writing is enabled
  31167. * @returns the current color writing state
  31168. */
  31169. getColorWrite(): boolean;
  31170. /**
  31171. * Sets alpha constants used by some alpha blending modes
  31172. * @param r defines the red component
  31173. * @param g defines the green component
  31174. * @param b defines the blue component
  31175. * @param a defines the alpha component
  31176. */
  31177. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31178. /**
  31179. * Sets the current alpha mode
  31180. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31181. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31182. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31183. */
  31184. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31185. /**
  31186. * Gets the current alpha mode
  31187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31188. * @returns the current alpha mode
  31189. */
  31190. getAlphaMode(): number;
  31191. /**
  31192. * Clears the list of texture accessible through engine.
  31193. * This can help preventing texture load conflict due to name collision.
  31194. */
  31195. clearInternalTexturesCache(): void;
  31196. /**
  31197. * Force the entire cache to be cleared
  31198. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31199. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31200. */
  31201. wipeCaches(bruteForce?: boolean): void;
  31202. /**
  31203. * Set the compressed texture format to use, based on the formats you have, and the formats
  31204. * supported by the hardware / browser.
  31205. *
  31206. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31207. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31208. * to API arguments needed to compressed textures. This puts the burden on the container
  31209. * generator to house the arcane code for determining these for current & future formats.
  31210. *
  31211. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31212. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31213. *
  31214. * Note: The result of this call is not taken into account when a texture is base64.
  31215. *
  31216. * @param formatsAvailable defines the list of those format families you have created
  31217. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31218. *
  31219. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31220. * @returns The extension selected.
  31221. */
  31222. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31223. /** @hidden */
  31224. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31225. min: number;
  31226. mag: number;
  31227. };
  31228. /** @hidden */
  31229. _createTexture(): WebGLTexture;
  31230. /**
  31231. * Usually called from Texture.ts.
  31232. * Passed information to create a WebGLTexture
  31233. * @param urlArg defines a value which contains one of the following:
  31234. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31235. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31236. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31237. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31238. * @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)
  31239. * @param scene needed for loading to the correct scene
  31240. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31241. * @param onLoad optional callback to be called upon successful completion
  31242. * @param onError optional callback to be called upon failure
  31243. * @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
  31244. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31245. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31246. * @param forcedExtension defines the extension to use to pick the right loader
  31247. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31248. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31249. */
  31250. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31251. /**
  31252. * @hidden
  31253. * Rescales a texture
  31254. * @param source input texutre
  31255. * @param destination destination texture
  31256. * @param scene scene to use to render the resize
  31257. * @param internalFormat format to use when resizing
  31258. * @param onComplete callback to be called when resize has completed
  31259. */
  31260. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31261. private _unpackFlipYCached;
  31262. /**
  31263. * In case you are sharing the context with other applications, it might
  31264. * be interested to not cache the unpack flip y state to ensure a consistent
  31265. * value would be set.
  31266. */
  31267. enableUnpackFlipYCached: boolean;
  31268. /** @hidden */
  31269. _unpackFlipY(value: boolean): void;
  31270. /** @hidden */
  31271. _getUnpackAlignement(): number;
  31272. /**
  31273. * Creates a dynamic texture
  31274. * @param width defines the width of the texture
  31275. * @param height defines the height of the texture
  31276. * @param generateMipMaps defines if the engine should generate the mip levels
  31277. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31278. * @returns the dynamic texture inside an InternalTexture
  31279. */
  31280. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31281. /**
  31282. * Update the sampling mode of a given texture
  31283. * @param samplingMode defines the required sampling mode
  31284. * @param texture defines the texture to update
  31285. */
  31286. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31287. /**
  31288. * Update the content of a dynamic texture
  31289. * @param texture defines the texture to update
  31290. * @param canvas defines the canvas containing the source
  31291. * @param invertY defines if data must be stored with Y axis inverted
  31292. * @param premulAlpha defines if alpha is stored as premultiplied
  31293. * @param format defines the format of the data
  31294. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31295. */
  31296. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31297. /**
  31298. * Update a video texture
  31299. * @param texture defines the texture to update
  31300. * @param video defines the video element to use
  31301. * @param invertY defines if data must be stored with Y axis inverted
  31302. */
  31303. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31304. /**
  31305. * Updates a depth texture Comparison Mode and Function.
  31306. * If the comparison Function is equal to 0, the mode will be set to none.
  31307. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31308. * @param texture The texture to set the comparison function for
  31309. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31310. */
  31311. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31312. /** @hidden */
  31313. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31314. width: number;
  31315. height: number;
  31316. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31317. /**
  31318. * Creates a depth stencil texture.
  31319. * This is only available in WebGL 2 or with the depth texture extension available.
  31320. * @param size The size of face edge in the texture.
  31321. * @param options The options defining the texture.
  31322. * @returns The texture
  31323. */
  31324. createDepthStencilTexture(size: number | {
  31325. width: number;
  31326. height: number;
  31327. }, options: DepthTextureCreationOptions): InternalTexture;
  31328. /**
  31329. * Creates a depth stencil texture.
  31330. * This is only available in WebGL 2 or with the depth texture extension available.
  31331. * @param size The size of face edge in the texture.
  31332. * @param options The options defining the texture.
  31333. * @returns The texture
  31334. */
  31335. private _createDepthStencilTexture;
  31336. /**
  31337. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31338. * @param renderTarget The render target to set the frame buffer for
  31339. */
  31340. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31341. /**
  31342. * Creates a new render target texture
  31343. * @param size defines the size of the texture
  31344. * @param options defines the options used to create the texture
  31345. * @returns a new render target texture stored in an InternalTexture
  31346. */
  31347. createRenderTargetTexture(size: number | {
  31348. width: number;
  31349. height: number;
  31350. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31351. /** @hidden */
  31352. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31353. /**
  31354. * Updates the sample count of a render target texture
  31355. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31356. * @param texture defines the texture to update
  31357. * @param samples defines the sample count to set
  31358. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31359. */
  31360. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31361. /** @hidden */
  31362. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31363. /** @hidden */
  31364. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31365. /** @hidden */
  31366. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31367. /** @hidden */
  31368. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31369. /**
  31370. * @hidden
  31371. */
  31372. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31373. private _prepareWebGLTextureContinuation;
  31374. private _prepareWebGLTexture;
  31375. /** @hidden */
  31376. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31377. /** @hidden */
  31378. _releaseFramebufferObjects(texture: InternalTexture): void;
  31379. /** @hidden */
  31380. _releaseTexture(texture: InternalTexture): void;
  31381. private setProgram;
  31382. private _boundUniforms;
  31383. /**
  31384. * Binds an effect to the webGL context
  31385. * @param effect defines the effect to bind
  31386. */
  31387. bindSamplers(effect: Effect): void;
  31388. private _activateCurrentTexture;
  31389. /** @hidden */
  31390. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31391. /** @hidden */
  31392. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31393. /**
  31394. * Sets a texture to the webGL context from a postprocess
  31395. * @param channel defines the channel to use
  31396. * @param postProcess defines the source postprocess
  31397. */
  31398. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31399. /**
  31400. * Binds the output of the passed in post process to the texture channel specified
  31401. * @param channel The channel the texture should be bound to
  31402. * @param postProcess The post process which's output should be bound
  31403. */
  31404. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31405. /**
  31406. * Unbind all textures from the webGL context
  31407. */
  31408. unbindAllTextures(): void;
  31409. /**
  31410. * Sets a texture to the according uniform.
  31411. * @param channel The texture channel
  31412. * @param uniform The uniform to set
  31413. * @param texture The texture to apply
  31414. */
  31415. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31416. /**
  31417. * Sets a depth stencil texture from a render target to the according uniform.
  31418. * @param channel The texture channel
  31419. * @param uniform The uniform to set
  31420. * @param texture The render target texture containing the depth stencil texture to apply
  31421. */
  31422. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31423. private _bindSamplerUniformToChannel;
  31424. private _getTextureWrapMode;
  31425. private _setTexture;
  31426. /**
  31427. * Sets an array of texture to the webGL context
  31428. * @param channel defines the channel where the texture array must be set
  31429. * @param uniform defines the associated uniform location
  31430. * @param textures defines the array of textures to bind
  31431. */
  31432. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31433. /** @hidden */
  31434. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31435. private _setTextureParameterFloat;
  31436. private _setTextureParameterInteger;
  31437. /**
  31438. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31439. * @param x defines the x coordinate of the rectangle where pixels must be read
  31440. * @param y defines the y coordinate of the rectangle where pixels must be read
  31441. * @param width defines the width of the rectangle where pixels must be read
  31442. * @param height defines the height of the rectangle where pixels must be read
  31443. * @returns a Uint8Array containing RGBA colors
  31444. */
  31445. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31446. /**
  31447. * Add an externaly attached data from its key.
  31448. * This method call will fail and return false, if such key already exists.
  31449. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31450. * @param key the unique key that identifies the data
  31451. * @param data the data object to associate to the key for this Engine instance
  31452. * @return true if no such key were already present and the data was added successfully, false otherwise
  31453. */
  31454. addExternalData<T>(key: string, data: T): boolean;
  31455. /**
  31456. * Get an externaly attached data from its key
  31457. * @param key the unique key that identifies the data
  31458. * @return the associated data, if present (can be null), or undefined if not present
  31459. */
  31460. getExternalData<T>(key: string): T;
  31461. /**
  31462. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31463. * @param key the unique key that identifies the data
  31464. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31465. * @return the associated data, can be null if the factory returned null.
  31466. */
  31467. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31468. /**
  31469. * Remove an externaly attached data from the Engine instance
  31470. * @param key the unique key that identifies the data
  31471. * @return true if the data was successfully removed, false if it doesn't exist
  31472. */
  31473. removeExternalData(key: string): boolean;
  31474. /**
  31475. * Unbind all vertex attributes from the webGL context
  31476. */
  31477. unbindAllAttributes(): void;
  31478. /**
  31479. * 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
  31480. */
  31481. releaseEffects(): void;
  31482. /**
  31483. * Dispose and release all associated resources
  31484. */
  31485. dispose(): void;
  31486. /**
  31487. * Display the loading screen
  31488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31489. */
  31490. displayLoadingUI(): void;
  31491. /**
  31492. * Hide the loading screen
  31493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31494. */
  31495. hideLoadingUI(): void;
  31496. /**
  31497. * Gets the current loading screen object
  31498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31499. */
  31500. /**
  31501. * Sets the current loading screen object
  31502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31503. */
  31504. loadingScreen: ILoadingScreen;
  31505. /**
  31506. * Sets the current loading screen text
  31507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31508. */
  31509. loadingUIText: string;
  31510. /**
  31511. * Sets the current loading screen background color
  31512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31513. */
  31514. loadingUIBackgroundColor: string;
  31515. /**
  31516. * Attach a new callback raised when context lost event is fired
  31517. * @param callback defines the callback to call
  31518. */
  31519. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31520. /**
  31521. * Attach a new callback raised when context restored event is fired
  31522. * @param callback defines the callback to call
  31523. */
  31524. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31525. /**
  31526. * Gets the source code of the vertex shader associated with a specific webGL program
  31527. * @param program defines the program to use
  31528. * @returns a string containing the source code of the vertex shader associated with the program
  31529. */
  31530. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31531. /**
  31532. * Gets the source code of the fragment shader associated with a specific webGL program
  31533. * @param program defines the program to use
  31534. * @returns a string containing the source code of the fragment shader associated with the program
  31535. */
  31536. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31537. /**
  31538. * Get the current error code of the webGL context
  31539. * @returns the error code
  31540. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31541. */
  31542. getError(): number;
  31543. /**
  31544. * Gets the current framerate
  31545. * @returns a number representing the framerate
  31546. */
  31547. getFps(): number;
  31548. /**
  31549. * Gets the time spent between current and previous frame
  31550. * @returns a number representing the delta time in ms
  31551. */
  31552. getDeltaTime(): number;
  31553. private _measureFps;
  31554. /** @hidden */
  31555. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31556. private _canRenderToFloatFramebuffer;
  31557. private _canRenderToHalfFloatFramebuffer;
  31558. private _canRenderToFramebuffer;
  31559. /** @hidden */
  31560. _getWebGLTextureType(type: number): number;
  31561. /** @hidden */
  31562. _getInternalFormat(format: number): number;
  31563. /** @hidden */
  31564. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31565. /** @hidden */
  31566. _getRGBAMultiSampleBufferFormat(type: number): number;
  31567. /** @hidden */
  31568. _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;
  31569. /** @hidden */
  31570. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31571. /**
  31572. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31573. * @returns true if the engine can be created
  31574. * @ignorenaming
  31575. */
  31576. static isSupported(): boolean;
  31577. /**
  31578. * Find the next highest power of two.
  31579. * @param x Number to start search from.
  31580. * @return Next highest power of two.
  31581. */
  31582. static CeilingPOT(x: number): number;
  31583. /**
  31584. * Find the next lowest power of two.
  31585. * @param x Number to start search from.
  31586. * @return Next lowest power of two.
  31587. */
  31588. static FloorPOT(x: number): number;
  31589. /**
  31590. * Find the nearest power of two.
  31591. * @param x Number to start search from.
  31592. * @return Next nearest power of two.
  31593. */
  31594. static NearestPOT(x: number): number;
  31595. /**
  31596. * Get the closest exponent of two
  31597. * @param value defines the value to approximate
  31598. * @param max defines the maximum value to return
  31599. * @param mode defines how to define the closest value
  31600. * @returns closest exponent of two of the given value
  31601. */
  31602. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31603. /**
  31604. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31605. * @param func - the function to be called
  31606. * @param requester - the object that will request the next frame. Falls back to window.
  31607. * @returns frame number
  31608. */
  31609. static QueueNewFrame(func: () => void, requester?: any): number;
  31610. /**
  31611. * Ask the browser to promote the current element to pointerlock mode
  31612. * @param element defines the DOM element to promote
  31613. */
  31614. static _RequestPointerlock(element: HTMLElement): void;
  31615. /**
  31616. * Asks the browser to exit pointerlock mode
  31617. */
  31618. static _ExitPointerlock(): void;
  31619. /**
  31620. * Ask the browser to promote the current element to fullscreen rendering mode
  31621. * @param element defines the DOM element to promote
  31622. */
  31623. static _RequestFullscreen(element: HTMLElement): void;
  31624. /**
  31625. * Asks the browser to exit fullscreen mode
  31626. */
  31627. static _ExitFullscreen(): void;
  31628. }
  31629. }
  31630. declare module BABYLON {
  31631. /**
  31632. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31633. * during the life time of the application.
  31634. */
  31635. export class EngineStore {
  31636. /** Gets the list of created engines */
  31637. static Instances: Engine[];
  31638. /** @hidden */
  31639. static _LastCreatedScene: Nullable<Scene>;
  31640. /**
  31641. * Gets the latest created engine
  31642. */
  31643. static readonly LastCreatedEngine: Nullable<Engine>;
  31644. /**
  31645. * Gets the latest created scene
  31646. */
  31647. static readonly LastCreatedScene: Nullable<Scene>;
  31648. /**
  31649. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31650. * @ignorenaming
  31651. */
  31652. static UseFallbackTexture: boolean;
  31653. /**
  31654. * Texture content used if a texture cannot loaded
  31655. * @ignorenaming
  31656. */
  31657. static FallbackTexture: string;
  31658. }
  31659. }
  31660. declare module BABYLON {
  31661. /**
  31662. * Helper class that provides a small promise polyfill
  31663. */
  31664. export class PromisePolyfill {
  31665. /**
  31666. * Static function used to check if the polyfill is required
  31667. * If this is the case then the function will inject the polyfill to window.Promise
  31668. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31669. */
  31670. static Apply(force?: boolean): void;
  31671. }
  31672. }
  31673. declare module BABYLON {
  31674. /**
  31675. * Interface for screenshot methods with describe argument called `size` as object with options
  31676. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31677. */
  31678. export interface IScreenshotSize {
  31679. /**
  31680. * number in pixels for canvas height
  31681. */
  31682. height?: number;
  31683. /**
  31684. * multiplier allowing render at a higher or lower resolution
  31685. * If value is defined then height and width will be ignored and taken from camera
  31686. */
  31687. precision?: number;
  31688. /**
  31689. * number in pixels for canvas width
  31690. */
  31691. width?: number;
  31692. }
  31693. }
  31694. declare module BABYLON {
  31695. interface IColor4Like {
  31696. r: float;
  31697. g: float;
  31698. b: float;
  31699. a: float;
  31700. }
  31701. /**
  31702. * Class containing a set of static utilities functions
  31703. */
  31704. export class Tools {
  31705. /**
  31706. * Gets or sets the base URL to use to load assets
  31707. */
  31708. static BaseUrl: string;
  31709. /**
  31710. * Enable/Disable Custom HTTP Request Headers globally.
  31711. * default = false
  31712. * @see CustomRequestHeaders
  31713. */
  31714. static UseCustomRequestHeaders: boolean;
  31715. /**
  31716. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31717. * i.e. when loading files, where the server/service expects an Authorization header
  31718. */
  31719. static CustomRequestHeaders: {
  31720. [key: string]: string;
  31721. };
  31722. /**
  31723. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31724. */
  31725. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31726. /**
  31727. * Default behaviour for cors in the application.
  31728. * It can be a string if the expected behavior is identical in the entire app.
  31729. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31730. */
  31731. static CorsBehavior: string | ((url: string | string[]) => string);
  31732. /**
  31733. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31734. * @ignorenaming
  31735. */
  31736. static UseFallbackTexture: boolean;
  31737. /**
  31738. * Use this object to register external classes like custom textures or material
  31739. * to allow the laoders to instantiate them
  31740. */
  31741. static RegisteredExternalClasses: {
  31742. [key: string]: Object;
  31743. };
  31744. /**
  31745. * Texture content used if a texture cannot loaded
  31746. * @ignorenaming
  31747. */
  31748. static fallbackTexture: string;
  31749. /**
  31750. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31751. * @param u defines the coordinate on X axis
  31752. * @param v defines the coordinate on Y axis
  31753. * @param width defines the width of the source data
  31754. * @param height defines the height of the source data
  31755. * @param pixels defines the source byte array
  31756. * @param color defines the output color
  31757. */
  31758. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31759. /**
  31760. * Interpolates between a and b via alpha
  31761. * @param a The lower value (returned when alpha = 0)
  31762. * @param b The upper value (returned when alpha = 1)
  31763. * @param alpha The interpolation-factor
  31764. * @return The mixed value
  31765. */
  31766. static Mix(a: number, b: number, alpha: number): number;
  31767. /**
  31768. * Tries to instantiate a new object from a given class name
  31769. * @param className defines the class name to instantiate
  31770. * @returns the new object or null if the system was not able to do the instantiation
  31771. */
  31772. static Instantiate(className: string): any;
  31773. /**
  31774. * Provides a slice function that will work even on IE
  31775. * @param data defines the array to slice
  31776. * @param start defines the start of the data (optional)
  31777. * @param end defines the end of the data (optional)
  31778. * @returns the new sliced array
  31779. */
  31780. static Slice<T>(data: T, start?: number, end?: number): T;
  31781. /**
  31782. * Polyfill for setImmediate
  31783. * @param action defines the action to execute after the current execution block
  31784. */
  31785. static SetImmediate(action: () => void): void;
  31786. /**
  31787. * Function indicating if a number is an exponent of 2
  31788. * @param value defines the value to test
  31789. * @returns true if the value is an exponent of 2
  31790. */
  31791. static IsExponentOfTwo(value: number): boolean;
  31792. private static _tmpFloatArray;
  31793. /**
  31794. * Returns the nearest 32-bit single precision float representation of a Number
  31795. * @param value A Number. If the parameter is of a different type, it will get converted
  31796. * to a number or to NaN if it cannot be converted
  31797. * @returns number
  31798. */
  31799. static FloatRound(value: number): number;
  31800. /**
  31801. * Extracts the filename from a path
  31802. * @param path defines the path to use
  31803. * @returns the filename
  31804. */
  31805. static GetFilename(path: string): string;
  31806. /**
  31807. * Extracts the "folder" part of a path (everything before the filename).
  31808. * @param uri The URI to extract the info from
  31809. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31810. * @returns The "folder" part of the path
  31811. */
  31812. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31813. /**
  31814. * Extracts text content from a DOM element hierarchy
  31815. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31816. */
  31817. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31818. /**
  31819. * Convert an angle in radians to degrees
  31820. * @param angle defines the angle to convert
  31821. * @returns the angle in degrees
  31822. */
  31823. static ToDegrees(angle: number): number;
  31824. /**
  31825. * Convert an angle in degrees to radians
  31826. * @param angle defines the angle to convert
  31827. * @returns the angle in radians
  31828. */
  31829. static ToRadians(angle: number): number;
  31830. /**
  31831. * Encode a buffer to a base64 string
  31832. * @param buffer defines the buffer to encode
  31833. * @returns the encoded string
  31834. */
  31835. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31836. /**
  31837. * Returns an array if obj is not an array
  31838. * @param obj defines the object to evaluate as an array
  31839. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31840. * @returns either obj directly if obj is an array or a new array containing obj
  31841. */
  31842. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31843. /**
  31844. * Gets the pointer prefix to use
  31845. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31846. */
  31847. static GetPointerPrefix(): string;
  31848. /**
  31849. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31850. * @param url define the url we are trying
  31851. * @param element define the dom element where to configure the cors policy
  31852. */
  31853. static SetCorsBehavior(url: string | string[], element: {
  31854. crossOrigin: string | null;
  31855. }): void;
  31856. /**
  31857. * Removes unwanted characters from an url
  31858. * @param url defines the url to clean
  31859. * @returns the cleaned url
  31860. */
  31861. static CleanUrl(url: string): string;
  31862. /**
  31863. * Gets or sets a function used to pre-process url before using them to load assets
  31864. */
  31865. static PreprocessUrl: (url: string) => string;
  31866. /**
  31867. * Loads an image as an HTMLImageElement.
  31868. * @param input url string, ArrayBuffer, or Blob to load
  31869. * @param onLoad callback called when the image successfully loads
  31870. * @param onError callback called when the image fails to load
  31871. * @param offlineProvider offline provider for caching
  31872. * @returns the HTMLImageElement of the loaded image
  31873. */
  31874. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31875. /**
  31876. * Loads a file
  31877. * @param url url string, ArrayBuffer, or Blob to load
  31878. * @param onSuccess callback called when the file successfully loads
  31879. * @param onProgress callback called while file is loading (if the server supports this mode)
  31880. * @param offlineProvider defines the offline provider for caching
  31881. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31882. * @param onError callback called when the file fails to load
  31883. * @returns a file request object
  31884. */
  31885. 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;
  31886. /**
  31887. * Loads a file from a url
  31888. * @param url the file url to load
  31889. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31890. */
  31891. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31892. /**
  31893. * Load a script (identified by an url). When the url returns, the
  31894. * content of this file is added into a new script element, attached to the DOM (body element)
  31895. * @param scriptUrl defines the url of the script to laod
  31896. * @param onSuccess defines the callback called when the script is loaded
  31897. * @param onError defines the callback to call if an error occurs
  31898. * @param scriptId defines the id of the script element
  31899. */
  31900. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31901. /**
  31902. * Load an asynchronous script (identified by an url). When the url returns, the
  31903. * content of this file is added into a new script element, attached to the DOM (body element)
  31904. * @param scriptUrl defines the url of the script to laod
  31905. * @param scriptId defines the id of the script element
  31906. * @returns a promise request object
  31907. */
  31908. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31909. /**
  31910. * Loads a file from a blob
  31911. * @param fileToLoad defines the blob to use
  31912. * @param callback defines the callback to call when data is loaded
  31913. * @param progressCallback defines the callback to call during loading process
  31914. * @returns a file request object
  31915. */
  31916. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31917. /**
  31918. * Loads a file
  31919. * @param fileToLoad defines the file to load
  31920. * @param callback defines the callback to call when data is loaded
  31921. * @param progressCallBack defines the callback to call during loading process
  31922. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31923. * @returns a file request object
  31924. */
  31925. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31926. /**
  31927. * Creates a data url from a given string content
  31928. * @param content defines the content to convert
  31929. * @returns the new data url link
  31930. */
  31931. static FileAsURL(content: string): string;
  31932. /**
  31933. * Format the given number to a specific decimal format
  31934. * @param value defines the number to format
  31935. * @param decimals defines the number of decimals to use
  31936. * @returns the formatted string
  31937. */
  31938. static Format(value: number, decimals?: number): string;
  31939. /**
  31940. * Tries to copy an object by duplicating every property
  31941. * @param source defines the source object
  31942. * @param destination defines the target object
  31943. * @param doNotCopyList defines a list of properties to avoid
  31944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31945. */
  31946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31947. /**
  31948. * Gets a boolean indicating if the given object has no own property
  31949. * @param obj defines the object to test
  31950. * @returns true if object has no own property
  31951. */
  31952. static IsEmpty(obj: any): boolean;
  31953. /**
  31954. * Function used to register events at window level
  31955. * @param windowElement defines the Window object to use
  31956. * @param events defines the events to register
  31957. */
  31958. static RegisterTopRootEvents(windowElement: Window, events: {
  31959. name: string;
  31960. handler: Nullable<(e: FocusEvent) => any>;
  31961. }[]): void;
  31962. /**
  31963. * Function used to unregister events from window level
  31964. * @param windowElement defines the Window object to use
  31965. * @param events defines the events to unregister
  31966. */
  31967. static UnregisterTopRootEvents(windowElement: Window, events: {
  31968. name: string;
  31969. handler: Nullable<(e: FocusEvent) => any>;
  31970. }[]): void;
  31971. /**
  31972. * @ignore
  31973. */
  31974. static _ScreenshotCanvas: HTMLCanvasElement;
  31975. /**
  31976. * Dumps the current bound framebuffer
  31977. * @param width defines the rendering width
  31978. * @param height defines the rendering height
  31979. * @param engine defines the hosting engine
  31980. * @param successCallback defines the callback triggered once the data are available
  31981. * @param mimeType defines the mime type of the result
  31982. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31983. */
  31984. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31985. /**
  31986. * Converts the canvas data to blob.
  31987. * This acts as a polyfill for browsers not supporting the to blob function.
  31988. * @param canvas Defines the canvas to extract the data from
  31989. * @param successCallback Defines the callback triggered once the data are available
  31990. * @param mimeType Defines the mime type of the result
  31991. */
  31992. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31993. /**
  31994. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31995. * @param successCallback defines the callback triggered once the data are available
  31996. * @param mimeType defines the mime type of the result
  31997. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31998. */
  31999. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32000. /**
  32001. * Downloads a blob in the browser
  32002. * @param blob defines the blob to download
  32003. * @param fileName defines the name of the downloaded file
  32004. */
  32005. static Download(blob: Blob, fileName: string): void;
  32006. /**
  32007. * Captures a screenshot of the current rendering
  32008. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32009. * @param engine defines the rendering engine
  32010. * @param camera defines the source camera
  32011. * @param size This parameter can be set to a single number or to an object with the
  32012. * following (optional) properties: precision, width, height. If a single number is passed,
  32013. * it will be used for both width and height. If an object is passed, the screenshot size
  32014. * will be derived from the parameters. The precision property is a multiplier allowing
  32015. * rendering at a higher or lower resolution
  32016. * @param successCallback defines the callback receives a single parameter which contains the
  32017. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32018. * src parameter of an <img> to display it
  32019. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32020. * Check your browser for supported MIME types
  32021. */
  32022. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32023. /**
  32024. * Captures a screenshot of the current rendering
  32025. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32026. * @param engine defines the rendering engine
  32027. * @param camera defines the source camera
  32028. * @param size This parameter can be set to a single number or to an object with the
  32029. * following (optional) properties: precision, width, height. If a single number is passed,
  32030. * it will be used for both width and height. If an object is passed, the screenshot size
  32031. * will be derived from the parameters. The precision property is a multiplier allowing
  32032. * rendering at a higher or lower resolution
  32033. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32034. * Check your browser for supported MIME types
  32035. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32036. * to the src parameter of an <img> to display it
  32037. */
  32038. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32039. /**
  32040. * Generates an image screenshot from the specified camera.
  32041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32042. * @param engine The engine to use for rendering
  32043. * @param camera The camera to use for rendering
  32044. * @param size This parameter can be set to a single number or to an object with the
  32045. * following (optional) properties: precision, width, height. If a single number is passed,
  32046. * it will be used for both width and height. If an object is passed, the screenshot size
  32047. * will be derived from the parameters. The precision property is a multiplier allowing
  32048. * rendering at a higher or lower resolution
  32049. * @param successCallback The callback receives a single parameter which contains the
  32050. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32051. * src parameter of an <img> to display it
  32052. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32053. * Check your browser for supported MIME types
  32054. * @param samples Texture samples (default: 1)
  32055. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32056. * @param fileName A name for for the downloaded file.
  32057. */
  32058. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32059. /**
  32060. * Generates an image screenshot from the specified camera.
  32061. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32062. * @param engine The engine to use for rendering
  32063. * @param camera The camera to use for rendering
  32064. * @param size This parameter can be set to a single number or to an object with the
  32065. * following (optional) properties: precision, width, height. If a single number is passed,
  32066. * it will be used for both width and height. If an object is passed, the screenshot size
  32067. * will be derived from the parameters. The precision property is a multiplier allowing
  32068. * rendering at a higher or lower resolution
  32069. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32070. * Check your browser for supported MIME types
  32071. * @param samples Texture samples (default: 1)
  32072. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32073. * @param fileName A name for for the downloaded file.
  32074. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32075. * to the src parameter of an <img> to display it
  32076. */
  32077. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32078. /**
  32079. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32080. * Be aware Math.random() could cause collisions, but:
  32081. * "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"
  32082. * @returns a pseudo random id
  32083. */
  32084. static RandomId(): string;
  32085. /**
  32086. * Test if the given uri is a base64 string
  32087. * @param uri The uri to test
  32088. * @return True if the uri is a base64 string or false otherwise
  32089. */
  32090. static IsBase64(uri: string): boolean;
  32091. /**
  32092. * Decode the given base64 uri.
  32093. * @param uri The uri to decode
  32094. * @return The decoded base64 data.
  32095. */
  32096. static DecodeBase64(uri: string): ArrayBuffer;
  32097. /**
  32098. * Gets the absolute url.
  32099. * @param url the input url
  32100. * @return the absolute url
  32101. */
  32102. static GetAbsoluteUrl(url: string): string;
  32103. /**
  32104. * No log
  32105. */
  32106. static readonly NoneLogLevel: number;
  32107. /**
  32108. * Only message logs
  32109. */
  32110. static readonly MessageLogLevel: number;
  32111. /**
  32112. * Only warning logs
  32113. */
  32114. static readonly WarningLogLevel: number;
  32115. /**
  32116. * Only error logs
  32117. */
  32118. static readonly ErrorLogLevel: number;
  32119. /**
  32120. * All logs
  32121. */
  32122. static readonly AllLogLevel: number;
  32123. /**
  32124. * Gets a value indicating the number of loading errors
  32125. * @ignorenaming
  32126. */
  32127. static readonly errorsCount: number;
  32128. /**
  32129. * Callback called when a new log is added
  32130. */
  32131. static OnNewCacheEntry: (entry: string) => void;
  32132. /**
  32133. * Log a message to the console
  32134. * @param message defines the message to log
  32135. */
  32136. static Log(message: string): void;
  32137. /**
  32138. * Write a warning message to the console
  32139. * @param message defines the message to log
  32140. */
  32141. static Warn(message: string): void;
  32142. /**
  32143. * Write an error message to the console
  32144. * @param message defines the message to log
  32145. */
  32146. static Error(message: string): void;
  32147. /**
  32148. * Gets current log cache (list of logs)
  32149. */
  32150. static readonly LogCache: string;
  32151. /**
  32152. * Clears the log cache
  32153. */
  32154. static ClearLogCache(): void;
  32155. /**
  32156. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32157. */
  32158. static LogLevels: number;
  32159. /**
  32160. * Checks if the window object exists
  32161. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32162. */
  32163. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32164. /**
  32165. * No performance log
  32166. */
  32167. static readonly PerformanceNoneLogLevel: number;
  32168. /**
  32169. * Use user marks to log performance
  32170. */
  32171. static readonly PerformanceUserMarkLogLevel: number;
  32172. /**
  32173. * Log performance to the console
  32174. */
  32175. static readonly PerformanceConsoleLogLevel: number;
  32176. private static _performance;
  32177. /**
  32178. * Sets the current performance log level
  32179. */
  32180. static PerformanceLogLevel: number;
  32181. private static _StartPerformanceCounterDisabled;
  32182. private static _EndPerformanceCounterDisabled;
  32183. private static _StartUserMark;
  32184. private static _EndUserMark;
  32185. private static _StartPerformanceConsole;
  32186. private static _EndPerformanceConsole;
  32187. /**
  32188. * Starts a performance counter
  32189. */
  32190. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32191. /**
  32192. * Ends a specific performance coutner
  32193. */
  32194. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32195. /**
  32196. * Gets either window.performance.now() if supported or Date.now() else
  32197. */
  32198. static readonly Now: number;
  32199. /**
  32200. * This method will return the name of the class used to create the instance of the given object.
  32201. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32202. * @param object the object to get the class name from
  32203. * @param isType defines if the object is actually a type
  32204. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32205. */
  32206. static GetClassName(object: any, isType?: boolean): string;
  32207. /**
  32208. * Gets the first element of an array satisfying a given predicate
  32209. * @param array defines the array to browse
  32210. * @param predicate defines the predicate to use
  32211. * @returns null if not found or the element
  32212. */
  32213. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32214. /**
  32215. * This method will return the name of the full name of the class, including its owning module (if any).
  32216. * 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).
  32217. * @param object the object to get the class name from
  32218. * @param isType defines if the object is actually a type
  32219. * @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.
  32220. * @ignorenaming
  32221. */
  32222. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32223. /**
  32224. * Returns a promise that resolves after the given amount of time.
  32225. * @param delay Number of milliseconds to delay
  32226. * @returns Promise that resolves after the given amount of time
  32227. */
  32228. static DelayAsync(delay: number): Promise<void>;
  32229. }
  32230. /**
  32231. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32232. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32233. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32234. * @param name The name of the class, case should be preserved
  32235. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32236. */
  32237. export function className(name: string, module?: string): (target: Object) => void;
  32238. /**
  32239. * An implementation of a loop for asynchronous functions.
  32240. */
  32241. export class AsyncLoop {
  32242. /**
  32243. * Defines the number of iterations for the loop
  32244. */
  32245. iterations: number;
  32246. /**
  32247. * Defines the current index of the loop.
  32248. */
  32249. index: number;
  32250. private _done;
  32251. private _fn;
  32252. private _successCallback;
  32253. /**
  32254. * Constructor.
  32255. * @param iterations the number of iterations.
  32256. * @param func the function to run each iteration
  32257. * @param successCallback the callback that will be called upon succesful execution
  32258. * @param offset starting offset.
  32259. */
  32260. constructor(
  32261. /**
  32262. * Defines the number of iterations for the loop
  32263. */
  32264. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32265. /**
  32266. * Execute the next iteration. Must be called after the last iteration was finished.
  32267. */
  32268. executeNext(): void;
  32269. /**
  32270. * Break the loop and run the success callback.
  32271. */
  32272. breakLoop(): void;
  32273. /**
  32274. * Create and run an async loop.
  32275. * @param iterations the number of iterations.
  32276. * @param fn the function to run each iteration
  32277. * @param successCallback the callback that will be called upon succesful execution
  32278. * @param offset starting offset.
  32279. * @returns the created async loop object
  32280. */
  32281. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32282. /**
  32283. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32284. * @param iterations total number of iterations
  32285. * @param syncedIterations number of synchronous iterations in each async iteration.
  32286. * @param fn the function to call each iteration.
  32287. * @param callback a success call back that will be called when iterating stops.
  32288. * @param breakFunction a break condition (optional)
  32289. * @param timeout timeout settings for the setTimeout function. default - 0.
  32290. * @returns the created async loop object
  32291. */
  32292. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32293. }
  32294. }
  32295. declare module BABYLON {
  32296. /** @hidden */
  32297. export interface ICollisionCoordinator {
  32298. createCollider(): Collider;
  32299. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32300. init(scene: Scene): void;
  32301. }
  32302. /** @hidden */
  32303. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32304. private _scene;
  32305. private _scaledPosition;
  32306. private _scaledVelocity;
  32307. private _finalPosition;
  32308. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32309. createCollider(): Collider;
  32310. init(scene: Scene): void;
  32311. private _collideWithWorld;
  32312. }
  32313. }
  32314. declare module BABYLON {
  32315. /**
  32316. * Class used to manage all inputs for the scene.
  32317. */
  32318. export class InputManager {
  32319. /** The distance in pixel that you have to move to prevent some events */
  32320. static DragMovementThreshold: number;
  32321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32322. static LongPressDelay: number;
  32323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32324. static DoubleClickDelay: number;
  32325. /** If you need to check double click without raising a single click at first click, enable this flag */
  32326. static ExclusiveDoubleClickMode: boolean;
  32327. private _wheelEventName;
  32328. private _onPointerMove;
  32329. private _onPointerDown;
  32330. private _onPointerUp;
  32331. private _initClickEvent;
  32332. private _initActionManager;
  32333. private _delayedSimpleClick;
  32334. private _delayedSimpleClickTimeout;
  32335. private _previousDelayedSimpleClickTimeout;
  32336. private _meshPickProceed;
  32337. private _previousButtonPressed;
  32338. private _currentPickResult;
  32339. private _previousPickResult;
  32340. private _totalPointersPressed;
  32341. private _doubleClickOccured;
  32342. private _pointerOverMesh;
  32343. private _pickedDownMesh;
  32344. private _pickedUpMesh;
  32345. private _pointerX;
  32346. private _pointerY;
  32347. private _unTranslatedPointerX;
  32348. private _unTranslatedPointerY;
  32349. private _startingPointerPosition;
  32350. private _previousStartingPointerPosition;
  32351. private _startingPointerTime;
  32352. private _previousStartingPointerTime;
  32353. private _pointerCaptures;
  32354. private _onKeyDown;
  32355. private _onKeyUp;
  32356. private _onCanvasFocusObserver;
  32357. private _onCanvasBlurObserver;
  32358. private _scene;
  32359. /**
  32360. * Creates a new InputManager
  32361. * @param scene defines the hosting scene
  32362. */
  32363. constructor(scene: Scene);
  32364. /**
  32365. * Gets the mesh that is currently under the pointer
  32366. */
  32367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32368. /**
  32369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32370. */
  32371. readonly unTranslatedPointer: Vector2;
  32372. /**
  32373. * Gets or sets the current on-screen X position of the pointer
  32374. */
  32375. pointerX: number;
  32376. /**
  32377. * Gets or sets the current on-screen Y position of the pointer
  32378. */
  32379. pointerY: number;
  32380. private _updatePointerPosition;
  32381. private _processPointerMove;
  32382. private _setRayOnPointerInfo;
  32383. private _checkPrePointerObservable;
  32384. /**
  32385. * Use this method to simulate a pointer move on a mesh
  32386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32389. */
  32390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32391. /**
  32392. * Use this method to simulate a pointer down on a mesh
  32393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32396. */
  32397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32398. private _processPointerDown;
  32399. /** @hidden */
  32400. _isPointerSwiping(): boolean;
  32401. /**
  32402. * Use this method to simulate a pointer up on a mesh
  32403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32407. */
  32408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32409. private _processPointerUp;
  32410. /**
  32411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32413. * @returns true if the pointer was captured
  32414. */
  32415. isPointerCaptured(pointerId?: number): boolean;
  32416. /**
  32417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32418. * @param attachUp defines if you want to attach events to pointerup
  32419. * @param attachDown defines if you want to attach events to pointerdown
  32420. * @param attachMove defines if you want to attach events to pointermove
  32421. */
  32422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32423. /**
  32424. * Detaches all event handlers
  32425. */
  32426. detachControl(): void;
  32427. /**
  32428. * Force the value of meshUnderPointer
  32429. * @param mesh defines the mesh to use
  32430. */
  32431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32432. /**
  32433. * Gets the mesh under the pointer
  32434. * @returns a Mesh or null if no mesh is under the pointer
  32435. */
  32436. getPointerOverMesh(): Nullable<AbstractMesh>;
  32437. }
  32438. }
  32439. declare module BABYLON {
  32440. /**
  32441. * Helper class used to generate session unique ID
  32442. */
  32443. export class UniqueIdGenerator {
  32444. private static _UniqueIdCounter;
  32445. /**
  32446. * Gets an unique (relatively to the current scene) Id
  32447. */
  32448. static readonly UniqueId: number;
  32449. }
  32450. }
  32451. declare module BABYLON {
  32452. /**
  32453. * This class defines the direct association between an animation and a target
  32454. */
  32455. export class TargetedAnimation {
  32456. /**
  32457. * Animation to perform
  32458. */
  32459. animation: Animation;
  32460. /**
  32461. * Target to animate
  32462. */
  32463. target: any;
  32464. /**
  32465. * Serialize the object
  32466. * @returns the JSON object representing the current entity
  32467. */
  32468. serialize(): any;
  32469. }
  32470. /**
  32471. * Use this class to create coordinated animations on multiple targets
  32472. */
  32473. export class AnimationGroup implements IDisposable {
  32474. /** The name of the animation group */
  32475. name: string;
  32476. private _scene;
  32477. private _targetedAnimations;
  32478. private _animatables;
  32479. private _from;
  32480. private _to;
  32481. private _isStarted;
  32482. private _isPaused;
  32483. private _speedRatio;
  32484. private _loopAnimation;
  32485. /**
  32486. * Gets or sets the unique id of the node
  32487. */
  32488. uniqueId: number;
  32489. /**
  32490. * This observable will notify when one animation have ended
  32491. */
  32492. onAnimationEndObservable: Observable<TargetedAnimation>;
  32493. /**
  32494. * Observer raised when one animation loops
  32495. */
  32496. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32497. /**
  32498. * This observable will notify when all animations have ended.
  32499. */
  32500. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32501. /**
  32502. * This observable will notify when all animations have paused.
  32503. */
  32504. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32505. /**
  32506. * This observable will notify when all animations are playing.
  32507. */
  32508. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32509. /**
  32510. * Gets the first frame
  32511. */
  32512. readonly from: number;
  32513. /**
  32514. * Gets the last frame
  32515. */
  32516. readonly to: number;
  32517. /**
  32518. * Define if the animations are started
  32519. */
  32520. readonly isStarted: boolean;
  32521. /**
  32522. * Gets a value indicating that the current group is playing
  32523. */
  32524. readonly isPlaying: boolean;
  32525. /**
  32526. * Gets or sets the speed ratio to use for all animations
  32527. */
  32528. /**
  32529. * Gets or sets the speed ratio to use for all animations
  32530. */
  32531. speedRatio: number;
  32532. /**
  32533. * Gets or sets if all animations should loop or not
  32534. */
  32535. loopAnimation: boolean;
  32536. /**
  32537. * Gets the targeted animations for this animation group
  32538. */
  32539. readonly targetedAnimations: Array<TargetedAnimation>;
  32540. /**
  32541. * returning the list of animatables controlled by this animation group.
  32542. */
  32543. readonly animatables: Array<Animatable>;
  32544. /**
  32545. * Instantiates a new Animation Group.
  32546. * This helps managing several animations at once.
  32547. * @see http://doc.babylonjs.com/how_to/group
  32548. * @param name Defines the name of the group
  32549. * @param scene Defines the scene the group belongs to
  32550. */
  32551. constructor(
  32552. /** The name of the animation group */
  32553. name: string, scene?: Nullable<Scene>);
  32554. /**
  32555. * Add an animation (with its target) in the group
  32556. * @param animation defines the animation we want to add
  32557. * @param target defines the target of the animation
  32558. * @returns the TargetedAnimation object
  32559. */
  32560. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32561. /**
  32562. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32563. * It can add constant keys at begin or end
  32564. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32565. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32566. * @returns the animation group
  32567. */
  32568. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32569. /**
  32570. * Start all animations on given targets
  32571. * @param loop defines if animations must loop
  32572. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32573. * @param from defines the from key (optional)
  32574. * @param to defines the to key (optional)
  32575. * @returns the current animation group
  32576. */
  32577. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32578. /**
  32579. * Pause all animations
  32580. * @returns the animation group
  32581. */
  32582. pause(): AnimationGroup;
  32583. /**
  32584. * Play all animations to initial state
  32585. * This function will start() the animations if they were not started or will restart() them if they were paused
  32586. * @param loop defines if animations must loop
  32587. * @returns the animation group
  32588. */
  32589. play(loop?: boolean): AnimationGroup;
  32590. /**
  32591. * Reset all animations to initial state
  32592. * @returns the animation group
  32593. */
  32594. reset(): AnimationGroup;
  32595. /**
  32596. * Restart animations from key 0
  32597. * @returns the animation group
  32598. */
  32599. restart(): AnimationGroup;
  32600. /**
  32601. * Stop all animations
  32602. * @returns the animation group
  32603. */
  32604. stop(): AnimationGroup;
  32605. /**
  32606. * Set animation weight for all animatables
  32607. * @param weight defines the weight to use
  32608. * @return the animationGroup
  32609. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32610. */
  32611. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32612. /**
  32613. * Synchronize and normalize all animatables with a source animatable
  32614. * @param root defines the root animatable to synchronize with
  32615. * @return the animationGroup
  32616. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32617. */
  32618. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32619. /**
  32620. * Goes to a specific frame in this animation group
  32621. * @param frame the frame number to go to
  32622. * @return the animationGroup
  32623. */
  32624. goToFrame(frame: number): AnimationGroup;
  32625. /**
  32626. * Dispose all associated resources
  32627. */
  32628. dispose(): void;
  32629. private _checkAnimationGroupEnded;
  32630. /**
  32631. * Clone the current animation group and returns a copy
  32632. * @param newName defines the name of the new group
  32633. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32634. * @returns the new aniamtion group
  32635. */
  32636. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32637. /**
  32638. * Serializes the animationGroup to an object
  32639. * @returns Serialized object
  32640. */
  32641. serialize(): any;
  32642. /**
  32643. * Returns a new AnimationGroup object parsed from the source provided.
  32644. * @param parsedAnimationGroup defines the source
  32645. * @param scene defines the scene that will receive the animationGroup
  32646. * @returns a new AnimationGroup
  32647. */
  32648. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32649. /**
  32650. * Returns the string "AnimationGroup"
  32651. * @returns "AnimationGroup"
  32652. */
  32653. getClassName(): string;
  32654. /**
  32655. * Creates a detailled string about the object
  32656. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32657. * @returns a string representing the object
  32658. */
  32659. toString(fullDetails?: boolean): string;
  32660. }
  32661. }
  32662. declare module BABYLON {
  32663. /**
  32664. * Define an interface for all classes that will hold resources
  32665. */
  32666. export interface IDisposable {
  32667. /**
  32668. * Releases all held resources
  32669. */
  32670. dispose(): void;
  32671. }
  32672. /** Interface defining initialization parameters for Scene class */
  32673. export interface SceneOptions {
  32674. /**
  32675. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32676. * It will improve performance when the number of geometries becomes important.
  32677. */
  32678. useGeometryUniqueIdsMap?: boolean;
  32679. /**
  32680. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32681. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32682. */
  32683. useMaterialMeshMap?: boolean;
  32684. /**
  32685. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32686. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32687. */
  32688. useClonedMeshhMap?: boolean;
  32689. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32690. virtual?: boolean;
  32691. }
  32692. /**
  32693. * Represents a scene to be rendered by the engine.
  32694. * @see http://doc.babylonjs.com/features/scene
  32695. */
  32696. export class Scene extends AbstractScene implements IAnimatable {
  32697. /** The fog is deactivated */
  32698. static readonly FOGMODE_NONE: number;
  32699. /** The fog density is following an exponential function */
  32700. static readonly FOGMODE_EXP: number;
  32701. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32702. static readonly FOGMODE_EXP2: number;
  32703. /** The fog density is following a linear function. */
  32704. static readonly FOGMODE_LINEAR: number;
  32705. /**
  32706. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32708. */
  32709. static MinDeltaTime: number;
  32710. /**
  32711. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32713. */
  32714. static MaxDeltaTime: number;
  32715. /**
  32716. * Factory used to create the default material.
  32717. * @param name The name of the material to create
  32718. * @param scene The scene to create the material for
  32719. * @returns The default material
  32720. */
  32721. static DefaultMaterialFactory(scene: Scene): Material;
  32722. /**
  32723. * Factory used to create the a collision coordinator.
  32724. * @returns The collision coordinator
  32725. */
  32726. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32727. /** @hidden */
  32728. _inputManager: InputManager;
  32729. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32730. cameraToUseForPointers: Nullable<Camera>;
  32731. /** @hidden */
  32732. readonly _isScene: boolean;
  32733. /**
  32734. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32735. */
  32736. autoClear: boolean;
  32737. /**
  32738. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32739. */
  32740. autoClearDepthAndStencil: boolean;
  32741. /**
  32742. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32743. */
  32744. clearColor: Color4;
  32745. /**
  32746. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32747. */
  32748. ambientColor: Color3;
  32749. /**
  32750. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32751. * It should only be one of the following (if not the default embedded one):
  32752. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32753. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32754. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32755. * The material properties need to be setup according to the type of texture in use.
  32756. */
  32757. environmentBRDFTexture: BaseTexture;
  32758. /** @hidden */
  32759. protected _environmentTexture: Nullable<BaseTexture>;
  32760. /**
  32761. * Texture used in all pbr material as the reflection texture.
  32762. * As in the majority of the scene they are the same (exception for multi room and so on),
  32763. * this is easier to reference from here than from all the materials.
  32764. */
  32765. /**
  32766. * Texture used in all pbr material as the reflection texture.
  32767. * As in the majority of the scene they are the same (exception for multi room and so on),
  32768. * this is easier to set here than in all the materials.
  32769. */
  32770. environmentTexture: Nullable<BaseTexture>;
  32771. /** @hidden */
  32772. protected _environmentIntensity: number;
  32773. /**
  32774. * Intensity of the environment in all pbr material.
  32775. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32776. * As in the majority of the scene they are the same (exception for multi room and so on),
  32777. * this is easier to reference from here than from all the materials.
  32778. */
  32779. /**
  32780. * Intensity of the environment in all pbr material.
  32781. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32782. * As in the majority of the scene they are the same (exception for multi room and so on),
  32783. * this is easier to set here than in all the materials.
  32784. */
  32785. environmentIntensity: number;
  32786. /** @hidden */
  32787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32788. /**
  32789. * Default image processing configuration used either in the rendering
  32790. * Forward main pass or through the imageProcessingPostProcess if present.
  32791. * As in the majority of the scene they are the same (exception for multi camera),
  32792. * this is easier to reference from here than from all the materials and post process.
  32793. *
  32794. * No setter as we it is a shared configuration, you can set the values instead.
  32795. */
  32796. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32797. private _forceWireframe;
  32798. /**
  32799. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32800. */
  32801. forceWireframe: boolean;
  32802. private _forcePointsCloud;
  32803. /**
  32804. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32805. */
  32806. forcePointsCloud: boolean;
  32807. /**
  32808. * Gets or sets the active clipplane 1
  32809. */
  32810. clipPlane: Nullable<Plane>;
  32811. /**
  32812. * Gets or sets the active clipplane 2
  32813. */
  32814. clipPlane2: Nullable<Plane>;
  32815. /**
  32816. * Gets or sets the active clipplane 3
  32817. */
  32818. clipPlane3: Nullable<Plane>;
  32819. /**
  32820. * Gets or sets the active clipplane 4
  32821. */
  32822. clipPlane4: Nullable<Plane>;
  32823. /**
  32824. * Gets or sets a boolean indicating if animations are enabled
  32825. */
  32826. animationsEnabled: boolean;
  32827. private _animationPropertiesOverride;
  32828. /**
  32829. * Gets or sets the animation properties override
  32830. */
  32831. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32832. /**
  32833. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32834. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32835. */
  32836. useConstantAnimationDeltaTime: boolean;
  32837. /**
  32838. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32839. * Please note that it requires to run a ray cast through the scene on every frame
  32840. */
  32841. constantlyUpdateMeshUnderPointer: boolean;
  32842. /**
  32843. * Defines the HTML cursor to use when hovering over interactive elements
  32844. */
  32845. hoverCursor: string;
  32846. /**
  32847. * Defines the HTML default cursor to use (empty by default)
  32848. */
  32849. defaultCursor: string;
  32850. /**
  32851. * This is used to call preventDefault() on pointer down
  32852. * in order to block unwanted artifacts like system double clicks
  32853. */
  32854. preventDefaultOnPointerDown: boolean;
  32855. /**
  32856. * This is used to call preventDefault() on pointer up
  32857. * in order to block unwanted artifacts like system double clicks
  32858. */
  32859. preventDefaultOnPointerUp: boolean;
  32860. /**
  32861. * Gets or sets user defined metadata
  32862. */
  32863. metadata: any;
  32864. /**
  32865. * For internal use only. Please do not use.
  32866. */
  32867. reservedDataStore: any;
  32868. /**
  32869. * Gets the name of the plugin used to load this scene (null by default)
  32870. */
  32871. loadingPluginName: string;
  32872. /**
  32873. * Use this array to add regular expressions used to disable offline support for specific urls
  32874. */
  32875. disableOfflineSupportExceptionRules: RegExp[];
  32876. /**
  32877. * An event triggered when the scene is disposed.
  32878. */
  32879. onDisposeObservable: Observable<Scene>;
  32880. private _onDisposeObserver;
  32881. /** Sets a function to be executed when this scene is disposed. */
  32882. onDispose: () => void;
  32883. /**
  32884. * An event triggered before rendering the scene (right after animations and physics)
  32885. */
  32886. onBeforeRenderObservable: Observable<Scene>;
  32887. private _onBeforeRenderObserver;
  32888. /** Sets a function to be executed before rendering this scene */
  32889. beforeRender: Nullable<() => void>;
  32890. /**
  32891. * An event triggered after rendering the scene
  32892. */
  32893. onAfterRenderObservable: Observable<Scene>;
  32894. /**
  32895. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32896. */
  32897. onAfterRenderCameraObservable: Observable<Camera>;
  32898. private _onAfterRenderObserver;
  32899. /** Sets a function to be executed after rendering this scene */
  32900. afterRender: Nullable<() => void>;
  32901. /**
  32902. * An event triggered before animating the scene
  32903. */
  32904. onBeforeAnimationsObservable: Observable<Scene>;
  32905. /**
  32906. * An event triggered after animations processing
  32907. */
  32908. onAfterAnimationsObservable: Observable<Scene>;
  32909. /**
  32910. * An event triggered before draw calls are ready to be sent
  32911. */
  32912. onBeforeDrawPhaseObservable: Observable<Scene>;
  32913. /**
  32914. * An event triggered after draw calls have been sent
  32915. */
  32916. onAfterDrawPhaseObservable: Observable<Scene>;
  32917. /**
  32918. * An event triggered when the scene is ready
  32919. */
  32920. onReadyObservable: Observable<Scene>;
  32921. /**
  32922. * An event triggered before rendering a camera
  32923. */
  32924. onBeforeCameraRenderObservable: Observable<Camera>;
  32925. private _onBeforeCameraRenderObserver;
  32926. /** Sets a function to be executed before rendering a camera*/
  32927. beforeCameraRender: () => void;
  32928. /**
  32929. * An event triggered after rendering a camera
  32930. */
  32931. onAfterCameraRenderObservable: Observable<Camera>;
  32932. private _onAfterCameraRenderObserver;
  32933. /** Sets a function to be executed after rendering a camera*/
  32934. afterCameraRender: () => void;
  32935. /**
  32936. * An event triggered when active meshes evaluation is about to start
  32937. */
  32938. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32939. /**
  32940. * An event triggered when active meshes evaluation is done
  32941. */
  32942. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32943. /**
  32944. * An event triggered when particles rendering is about to start
  32945. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32946. */
  32947. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32948. /**
  32949. * An event triggered when particles rendering is done
  32950. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32951. */
  32952. onAfterParticlesRenderingObservable: Observable<Scene>;
  32953. /**
  32954. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32955. */
  32956. onDataLoadedObservable: Observable<Scene>;
  32957. /**
  32958. * An event triggered when a camera is created
  32959. */
  32960. onNewCameraAddedObservable: Observable<Camera>;
  32961. /**
  32962. * An event triggered when a camera is removed
  32963. */
  32964. onCameraRemovedObservable: Observable<Camera>;
  32965. /**
  32966. * An event triggered when a light is created
  32967. */
  32968. onNewLightAddedObservable: Observable<Light>;
  32969. /**
  32970. * An event triggered when a light is removed
  32971. */
  32972. onLightRemovedObservable: Observable<Light>;
  32973. /**
  32974. * An event triggered when a geometry is created
  32975. */
  32976. onNewGeometryAddedObservable: Observable<Geometry>;
  32977. /**
  32978. * An event triggered when a geometry is removed
  32979. */
  32980. onGeometryRemovedObservable: Observable<Geometry>;
  32981. /**
  32982. * An event triggered when a transform node is created
  32983. */
  32984. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32985. /**
  32986. * An event triggered when a transform node is removed
  32987. */
  32988. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32989. /**
  32990. * An event triggered when a mesh is created
  32991. */
  32992. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32993. /**
  32994. * An event triggered when a mesh is removed
  32995. */
  32996. onMeshRemovedObservable: Observable<AbstractMesh>;
  32997. /**
  32998. * An event triggered when a skeleton is created
  32999. */
  33000. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33001. /**
  33002. * An event triggered when a skeleton is removed
  33003. */
  33004. onSkeletonRemovedObservable: Observable<Skeleton>;
  33005. /**
  33006. * An event triggered when a material is created
  33007. */
  33008. onNewMaterialAddedObservable: Observable<Material>;
  33009. /**
  33010. * An event triggered when a material is removed
  33011. */
  33012. onMaterialRemovedObservable: Observable<Material>;
  33013. /**
  33014. * An event triggered when a texture is created
  33015. */
  33016. onNewTextureAddedObservable: Observable<BaseTexture>;
  33017. /**
  33018. * An event triggered when a texture is removed
  33019. */
  33020. onTextureRemovedObservable: Observable<BaseTexture>;
  33021. /**
  33022. * An event triggered when render targets are about to be rendered
  33023. * Can happen multiple times per frame.
  33024. */
  33025. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33026. /**
  33027. * An event triggered when render targets were rendered.
  33028. * Can happen multiple times per frame.
  33029. */
  33030. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33031. /**
  33032. * An event triggered before calculating deterministic simulation step
  33033. */
  33034. onBeforeStepObservable: Observable<Scene>;
  33035. /**
  33036. * An event triggered after calculating deterministic simulation step
  33037. */
  33038. onAfterStepObservable: Observable<Scene>;
  33039. /**
  33040. * An event triggered when the activeCamera property is updated
  33041. */
  33042. onActiveCameraChanged: Observable<Scene>;
  33043. /**
  33044. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33045. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33046. * 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)
  33047. */
  33048. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33049. /**
  33050. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33051. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33052. * 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)
  33053. */
  33054. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33055. /**
  33056. * This Observable will when a mesh has been imported into the scene.
  33057. */
  33058. onMeshImportedObservable: Observable<AbstractMesh>;
  33059. /**
  33060. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33061. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33062. */
  33063. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33064. /** @hidden */
  33065. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33066. /**
  33067. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33068. */
  33069. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33070. /**
  33071. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33072. */
  33073. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33074. /**
  33075. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33076. */
  33077. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33078. /** Callback called when a pointer move is detected */
  33079. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33080. /** Callback called when a pointer down is detected */
  33081. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33082. /** Callback called when a pointer up is detected */
  33083. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33084. /** Callback called when a pointer pick is detected */
  33085. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33086. /**
  33087. * 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).
  33088. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33089. */
  33090. onPrePointerObservable: Observable<PointerInfoPre>;
  33091. /**
  33092. * Observable event triggered each time an input event is received from the rendering canvas
  33093. */
  33094. onPointerObservable: Observable<PointerInfo>;
  33095. /**
  33096. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33097. */
  33098. readonly unTranslatedPointer: Vector2;
  33099. /**
  33100. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33101. */
  33102. static DragMovementThreshold: number;
  33103. /**
  33104. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33105. */
  33106. static LongPressDelay: number;
  33107. /**
  33108. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33109. */
  33110. static DoubleClickDelay: number;
  33111. /** If you need to check double click without raising a single click at first click, enable this flag */
  33112. static ExclusiveDoubleClickMode: boolean;
  33113. /** @hidden */
  33114. _mirroredCameraPosition: Nullable<Vector3>;
  33115. /**
  33116. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33117. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33118. */
  33119. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33120. /**
  33121. * Observable event triggered each time an keyboard event is received from the hosting window
  33122. */
  33123. onKeyboardObservable: Observable<KeyboardInfo>;
  33124. private _useRightHandedSystem;
  33125. /**
  33126. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33127. */
  33128. useRightHandedSystem: boolean;
  33129. private _timeAccumulator;
  33130. private _currentStepId;
  33131. private _currentInternalStep;
  33132. /**
  33133. * Sets the step Id used by deterministic lock step
  33134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33135. * @param newStepId defines the step Id
  33136. */
  33137. setStepId(newStepId: number): void;
  33138. /**
  33139. * Gets the step Id used by deterministic lock step
  33140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33141. * @returns the step Id
  33142. */
  33143. getStepId(): number;
  33144. /**
  33145. * Gets the internal step used by deterministic lock step
  33146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33147. * @returns the internal step
  33148. */
  33149. getInternalStep(): number;
  33150. private _fogEnabled;
  33151. /**
  33152. * Gets or sets a boolean indicating if fog is enabled on this scene
  33153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33154. * (Default is true)
  33155. */
  33156. fogEnabled: boolean;
  33157. private _fogMode;
  33158. /**
  33159. * Gets or sets the fog mode to use
  33160. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33161. * | mode | value |
  33162. * | --- | --- |
  33163. * | FOGMODE_NONE | 0 |
  33164. * | FOGMODE_EXP | 1 |
  33165. * | FOGMODE_EXP2 | 2 |
  33166. * | FOGMODE_LINEAR | 3 |
  33167. */
  33168. fogMode: number;
  33169. /**
  33170. * Gets or sets the fog color to use
  33171. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33172. * (Default is Color3(0.2, 0.2, 0.3))
  33173. */
  33174. fogColor: Color3;
  33175. /**
  33176. * Gets or sets the fog density to use
  33177. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33178. * (Default is 0.1)
  33179. */
  33180. fogDensity: number;
  33181. /**
  33182. * Gets or sets the fog start distance to use
  33183. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33184. * (Default is 0)
  33185. */
  33186. fogStart: number;
  33187. /**
  33188. * Gets or sets the fog end distance to use
  33189. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33190. * (Default is 1000)
  33191. */
  33192. fogEnd: number;
  33193. private _shadowsEnabled;
  33194. /**
  33195. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33196. */
  33197. shadowsEnabled: boolean;
  33198. private _lightsEnabled;
  33199. /**
  33200. * Gets or sets a boolean indicating if lights are enabled on this scene
  33201. */
  33202. lightsEnabled: boolean;
  33203. /** All of the active cameras added to this scene. */
  33204. activeCameras: Camera[];
  33205. /** @hidden */
  33206. _activeCamera: Nullable<Camera>;
  33207. /** Gets or sets the current active camera */
  33208. activeCamera: Nullable<Camera>;
  33209. private _defaultMaterial;
  33210. /** The default material used on meshes when no material is affected */
  33211. /** The default material used on meshes when no material is affected */
  33212. defaultMaterial: Material;
  33213. private _texturesEnabled;
  33214. /**
  33215. * Gets or sets a boolean indicating if textures are enabled on this scene
  33216. */
  33217. texturesEnabled: boolean;
  33218. /**
  33219. * Gets or sets a boolean indicating if particles are enabled on this scene
  33220. */
  33221. particlesEnabled: boolean;
  33222. /**
  33223. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33224. */
  33225. spritesEnabled: boolean;
  33226. private _skeletonsEnabled;
  33227. /**
  33228. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33229. */
  33230. skeletonsEnabled: boolean;
  33231. /**
  33232. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33233. */
  33234. lensFlaresEnabled: boolean;
  33235. /**
  33236. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33238. */
  33239. collisionsEnabled: boolean;
  33240. private _collisionCoordinator;
  33241. /** @hidden */
  33242. readonly collisionCoordinator: ICollisionCoordinator;
  33243. /**
  33244. * Defines the gravity applied to this scene (used only for collisions)
  33245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33246. */
  33247. gravity: Vector3;
  33248. /**
  33249. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33250. */
  33251. postProcessesEnabled: boolean;
  33252. /**
  33253. * The list of postprocesses added to the scene
  33254. */
  33255. postProcesses: PostProcess[];
  33256. /**
  33257. * Gets the current postprocess manager
  33258. */
  33259. postProcessManager: PostProcessManager;
  33260. /**
  33261. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33262. */
  33263. renderTargetsEnabled: boolean;
  33264. /**
  33265. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33266. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33267. */
  33268. dumpNextRenderTargets: boolean;
  33269. /**
  33270. * The list of user defined render targets added to the scene
  33271. */
  33272. customRenderTargets: RenderTargetTexture[];
  33273. /**
  33274. * Defines if texture loading must be delayed
  33275. * If true, textures will only be loaded when they need to be rendered
  33276. */
  33277. useDelayedTextureLoading: boolean;
  33278. /**
  33279. * Gets the list of meshes imported to the scene through SceneLoader
  33280. */
  33281. importedMeshesFiles: String[];
  33282. /**
  33283. * Gets or sets a boolean indicating if probes are enabled on this scene
  33284. */
  33285. probesEnabled: boolean;
  33286. /**
  33287. * Gets or sets the current offline provider to use to store scene data
  33288. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33289. */
  33290. offlineProvider: IOfflineProvider;
  33291. /**
  33292. * Gets or sets the action manager associated with the scene
  33293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33294. */
  33295. actionManager: AbstractActionManager;
  33296. private _meshesForIntersections;
  33297. /**
  33298. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33299. */
  33300. proceduralTexturesEnabled: boolean;
  33301. private _engine;
  33302. private _totalVertices;
  33303. /** @hidden */
  33304. _activeIndices: PerfCounter;
  33305. /** @hidden */
  33306. _activeParticles: PerfCounter;
  33307. /** @hidden */
  33308. _activeBones: PerfCounter;
  33309. private _animationRatio;
  33310. /** @hidden */
  33311. _animationTimeLast: number;
  33312. /** @hidden */
  33313. _animationTime: number;
  33314. /**
  33315. * Gets or sets a general scale for animation speed
  33316. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33317. */
  33318. animationTimeScale: number;
  33319. /** @hidden */
  33320. _cachedMaterial: Nullable<Material>;
  33321. /** @hidden */
  33322. _cachedEffect: Nullable<Effect>;
  33323. /** @hidden */
  33324. _cachedVisibility: Nullable<number>;
  33325. private _renderId;
  33326. private _frameId;
  33327. private _executeWhenReadyTimeoutId;
  33328. private _intermediateRendering;
  33329. private _viewUpdateFlag;
  33330. private _projectionUpdateFlag;
  33331. /** @hidden */
  33332. _toBeDisposed: Nullable<IDisposable>[];
  33333. private _activeRequests;
  33334. /** @hidden */
  33335. _pendingData: any[];
  33336. private _isDisposed;
  33337. /**
  33338. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33339. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33340. */
  33341. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33342. private _activeMeshes;
  33343. private _processedMaterials;
  33344. private _renderTargets;
  33345. /** @hidden */
  33346. _activeParticleSystems: SmartArray<IParticleSystem>;
  33347. private _activeSkeletons;
  33348. private _softwareSkinnedMeshes;
  33349. private _renderingManager;
  33350. /** @hidden */
  33351. _activeAnimatables: Animatable[];
  33352. private _transformMatrix;
  33353. private _sceneUbo;
  33354. /** @hidden */
  33355. _viewMatrix: Matrix;
  33356. private _projectionMatrix;
  33357. /** @hidden */
  33358. _forcedViewPosition: Nullable<Vector3>;
  33359. /** @hidden */
  33360. _frustumPlanes: Plane[];
  33361. /**
  33362. * Gets the list of frustum planes (built from the active camera)
  33363. */
  33364. readonly frustumPlanes: Plane[];
  33365. /**
  33366. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33367. * This is useful if there are more lights that the maximum simulteanous authorized
  33368. */
  33369. requireLightSorting: boolean;
  33370. /** @hidden */
  33371. readonly useMaterialMeshMap: boolean;
  33372. /** @hidden */
  33373. readonly useClonedMeshhMap: boolean;
  33374. private _externalData;
  33375. private _uid;
  33376. /**
  33377. * @hidden
  33378. * Backing store of defined scene components.
  33379. */
  33380. _components: ISceneComponent[];
  33381. /**
  33382. * @hidden
  33383. * Backing store of defined scene components.
  33384. */
  33385. _serializableComponents: ISceneSerializableComponent[];
  33386. /**
  33387. * List of components to register on the next registration step.
  33388. */
  33389. private _transientComponents;
  33390. /**
  33391. * Registers the transient components if needed.
  33392. */
  33393. private _registerTransientComponents;
  33394. /**
  33395. * @hidden
  33396. * Add a component to the scene.
  33397. * Note that the ccomponent could be registered on th next frame if this is called after
  33398. * the register component stage.
  33399. * @param component Defines the component to add to the scene
  33400. */
  33401. _addComponent(component: ISceneComponent): void;
  33402. /**
  33403. * @hidden
  33404. * Gets a component from the scene.
  33405. * @param name defines the name of the component to retrieve
  33406. * @returns the component or null if not present
  33407. */
  33408. _getComponent(name: string): Nullable<ISceneComponent>;
  33409. /**
  33410. * @hidden
  33411. * Defines the actions happening before camera updates.
  33412. */
  33413. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33414. /**
  33415. * @hidden
  33416. * Defines the actions happening before clear the canvas.
  33417. */
  33418. _beforeClearStage: Stage<SimpleStageAction>;
  33419. /**
  33420. * @hidden
  33421. * Defines the actions when collecting render targets for the frame.
  33422. */
  33423. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33424. /**
  33425. * @hidden
  33426. * Defines the actions happening for one camera in the frame.
  33427. */
  33428. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33429. /**
  33430. * @hidden
  33431. * Defines the actions happening during the per mesh ready checks.
  33432. */
  33433. _isReadyForMeshStage: Stage<MeshStageAction>;
  33434. /**
  33435. * @hidden
  33436. * Defines the actions happening before evaluate active mesh checks.
  33437. */
  33438. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33439. /**
  33440. * @hidden
  33441. * Defines the actions happening during the evaluate sub mesh checks.
  33442. */
  33443. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33444. /**
  33445. * @hidden
  33446. * Defines the actions happening during the active mesh stage.
  33447. */
  33448. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33449. /**
  33450. * @hidden
  33451. * Defines the actions happening during the per camera render target step.
  33452. */
  33453. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33454. /**
  33455. * @hidden
  33456. * Defines the actions happening just before the active camera is drawing.
  33457. */
  33458. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33459. /**
  33460. * @hidden
  33461. * Defines the actions happening just before a render target is drawing.
  33462. */
  33463. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33464. /**
  33465. * @hidden
  33466. * Defines the actions happening just before a rendering group is drawing.
  33467. */
  33468. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33469. /**
  33470. * @hidden
  33471. * Defines the actions happening just before a mesh is drawing.
  33472. */
  33473. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33474. /**
  33475. * @hidden
  33476. * Defines the actions happening just after a mesh has been drawn.
  33477. */
  33478. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33479. /**
  33480. * @hidden
  33481. * Defines the actions happening just after a rendering group has been drawn.
  33482. */
  33483. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33484. /**
  33485. * @hidden
  33486. * Defines the actions happening just after the active camera has been drawn.
  33487. */
  33488. _afterCameraDrawStage: Stage<CameraStageAction>;
  33489. /**
  33490. * @hidden
  33491. * Defines the actions happening just after a render target has been drawn.
  33492. */
  33493. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33494. /**
  33495. * @hidden
  33496. * Defines the actions happening just after rendering all cameras and computing intersections.
  33497. */
  33498. _afterRenderStage: Stage<SimpleStageAction>;
  33499. /**
  33500. * @hidden
  33501. * Defines the actions happening when a pointer move event happens.
  33502. */
  33503. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33504. /**
  33505. * @hidden
  33506. * Defines the actions happening when a pointer down event happens.
  33507. */
  33508. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33509. /**
  33510. * @hidden
  33511. * Defines the actions happening when a pointer up event happens.
  33512. */
  33513. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33514. /**
  33515. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33516. */
  33517. private geometriesByUniqueId;
  33518. /**
  33519. * Creates a new Scene
  33520. * @param engine defines the engine to use to render this scene
  33521. * @param options defines the scene options
  33522. */
  33523. constructor(engine: Engine, options?: SceneOptions);
  33524. /**
  33525. * Gets a string idenfifying the name of the class
  33526. * @returns "Scene" string
  33527. */
  33528. getClassName(): string;
  33529. private _defaultMeshCandidates;
  33530. /**
  33531. * @hidden
  33532. */
  33533. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33534. private _defaultSubMeshCandidates;
  33535. /**
  33536. * @hidden
  33537. */
  33538. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33539. /**
  33540. * Sets the default candidate providers for the scene.
  33541. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33542. * and getCollidingSubMeshCandidates to their default function
  33543. */
  33544. setDefaultCandidateProviders(): void;
  33545. /**
  33546. * Gets the mesh that is currently under the pointer
  33547. */
  33548. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33549. /**
  33550. * Gets or sets the current on-screen X position of the pointer
  33551. */
  33552. pointerX: number;
  33553. /**
  33554. * Gets or sets the current on-screen Y position of the pointer
  33555. */
  33556. pointerY: number;
  33557. /**
  33558. * Gets the cached material (ie. the latest rendered one)
  33559. * @returns the cached material
  33560. */
  33561. getCachedMaterial(): Nullable<Material>;
  33562. /**
  33563. * Gets the cached effect (ie. the latest rendered one)
  33564. * @returns the cached effect
  33565. */
  33566. getCachedEffect(): Nullable<Effect>;
  33567. /**
  33568. * Gets the cached visibility state (ie. the latest rendered one)
  33569. * @returns the cached visibility state
  33570. */
  33571. getCachedVisibility(): Nullable<number>;
  33572. /**
  33573. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33574. * @param material defines the current material
  33575. * @param effect defines the current effect
  33576. * @param visibility defines the current visibility state
  33577. * @returns true if one parameter is not cached
  33578. */
  33579. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33580. /**
  33581. * Gets the engine associated with the scene
  33582. * @returns an Engine
  33583. */
  33584. getEngine(): Engine;
  33585. /**
  33586. * Gets the total number of vertices rendered per frame
  33587. * @returns the total number of vertices rendered per frame
  33588. */
  33589. getTotalVertices(): number;
  33590. /**
  33591. * Gets the performance counter for total vertices
  33592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33593. */
  33594. readonly totalVerticesPerfCounter: PerfCounter;
  33595. /**
  33596. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33597. * @returns the total number of active indices rendered per frame
  33598. */
  33599. getActiveIndices(): number;
  33600. /**
  33601. * Gets the performance counter for active indices
  33602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33603. */
  33604. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33605. /**
  33606. * Gets the total number of active particles rendered per frame
  33607. * @returns the total number of active particles rendered per frame
  33608. */
  33609. getActiveParticles(): number;
  33610. /**
  33611. * Gets the performance counter for active particles
  33612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33613. */
  33614. readonly activeParticlesPerfCounter: PerfCounter;
  33615. /**
  33616. * Gets the total number of active bones rendered per frame
  33617. * @returns the total number of active bones rendered per frame
  33618. */
  33619. getActiveBones(): number;
  33620. /**
  33621. * Gets the performance counter for active bones
  33622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33623. */
  33624. readonly activeBonesPerfCounter: PerfCounter;
  33625. /**
  33626. * Gets the array of active meshes
  33627. * @returns an array of AbstractMesh
  33628. */
  33629. getActiveMeshes(): SmartArray<AbstractMesh>;
  33630. /**
  33631. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33632. * @returns a number
  33633. */
  33634. getAnimationRatio(): number;
  33635. /**
  33636. * Gets an unique Id for the current render phase
  33637. * @returns a number
  33638. */
  33639. getRenderId(): number;
  33640. /**
  33641. * Gets an unique Id for the current frame
  33642. * @returns a number
  33643. */
  33644. getFrameId(): number;
  33645. /** Call this function if you want to manually increment the render Id*/
  33646. incrementRenderId(): void;
  33647. private _createUbo;
  33648. /**
  33649. * Use this method to simulate a pointer move on a mesh
  33650. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33651. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33652. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33653. * @returns the current scene
  33654. */
  33655. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33656. /**
  33657. * Use this method to simulate a pointer down on a mesh
  33658. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33659. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33660. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33661. * @returns the current scene
  33662. */
  33663. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33664. /**
  33665. * Use this method to simulate a pointer up on a mesh
  33666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33669. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33670. * @returns the current scene
  33671. */
  33672. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33673. /**
  33674. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33675. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33676. * @returns true if the pointer was captured
  33677. */
  33678. isPointerCaptured(pointerId?: number): boolean;
  33679. /**
  33680. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33681. * @param attachUp defines if you want to attach events to pointerup
  33682. * @param attachDown defines if you want to attach events to pointerdown
  33683. * @param attachMove defines if you want to attach events to pointermove
  33684. */
  33685. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33686. /** Detaches all event handlers*/
  33687. detachControl(): void;
  33688. /**
  33689. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33690. * Delay loaded resources are not taking in account
  33691. * @return true if all required resources are ready
  33692. */
  33693. isReady(): boolean;
  33694. /** Resets all cached information relative to material (including effect and visibility) */
  33695. resetCachedMaterial(): void;
  33696. /**
  33697. * Registers a function to be called before every frame render
  33698. * @param func defines the function to register
  33699. */
  33700. registerBeforeRender(func: () => void): void;
  33701. /**
  33702. * Unregisters a function called before every frame render
  33703. * @param func defines the function to unregister
  33704. */
  33705. unregisterBeforeRender(func: () => void): void;
  33706. /**
  33707. * Registers a function to be called after every frame render
  33708. * @param func defines the function to register
  33709. */
  33710. registerAfterRender(func: () => void): void;
  33711. /**
  33712. * Unregisters a function called after every frame render
  33713. * @param func defines the function to unregister
  33714. */
  33715. unregisterAfterRender(func: () => void): void;
  33716. private _executeOnceBeforeRender;
  33717. /**
  33718. * The provided function will run before render once and will be disposed afterwards.
  33719. * A timeout delay can be provided so that the function will be executed in N ms.
  33720. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33721. * @param func The function to be executed.
  33722. * @param timeout optional delay in ms
  33723. */
  33724. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33725. /** @hidden */
  33726. _addPendingData(data: any): void;
  33727. /** @hidden */
  33728. _removePendingData(data: any): void;
  33729. /**
  33730. * Returns the number of items waiting to be loaded
  33731. * @returns the number of items waiting to be loaded
  33732. */
  33733. getWaitingItemsCount(): number;
  33734. /**
  33735. * Returns a boolean indicating if the scene is still loading data
  33736. */
  33737. readonly isLoading: boolean;
  33738. /**
  33739. * Registers a function to be executed when the scene is ready
  33740. * @param {Function} func - the function to be executed
  33741. */
  33742. executeWhenReady(func: () => void): void;
  33743. /**
  33744. * Returns a promise that resolves when the scene is ready
  33745. * @returns A promise that resolves when the scene is ready
  33746. */
  33747. whenReadyAsync(): Promise<void>;
  33748. /** @hidden */
  33749. _checkIsReady(): void;
  33750. /**
  33751. * Gets all animatable attached to the scene
  33752. */
  33753. readonly animatables: Animatable[];
  33754. /**
  33755. * Resets the last animation time frame.
  33756. * Useful to override when animations start running when loading a scene for the first time.
  33757. */
  33758. resetLastAnimationTimeFrame(): void;
  33759. /**
  33760. * Gets the current view matrix
  33761. * @returns a Matrix
  33762. */
  33763. getViewMatrix(): Matrix;
  33764. /**
  33765. * Gets the current projection matrix
  33766. * @returns a Matrix
  33767. */
  33768. getProjectionMatrix(): Matrix;
  33769. /**
  33770. * Gets the current transform matrix
  33771. * @returns a Matrix made of View * Projection
  33772. */
  33773. getTransformMatrix(): Matrix;
  33774. /**
  33775. * Sets the current transform matrix
  33776. * @param viewL defines the View matrix to use
  33777. * @param projectionL defines the Projection matrix to use
  33778. * @param viewR defines the right View matrix to use (if provided)
  33779. * @param projectionR defines the right Projection matrix to use (if provided)
  33780. */
  33781. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33782. /**
  33783. * Gets the uniform buffer used to store scene data
  33784. * @returns a UniformBuffer
  33785. */
  33786. getSceneUniformBuffer(): UniformBuffer;
  33787. /**
  33788. * Gets an unique (relatively to the current scene) Id
  33789. * @returns an unique number for the scene
  33790. */
  33791. getUniqueId(): number;
  33792. /**
  33793. * Add a mesh to the list of scene's meshes
  33794. * @param newMesh defines the mesh to add
  33795. * @param recursive if all child meshes should also be added to the scene
  33796. */
  33797. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33798. /**
  33799. * Remove a mesh for the list of scene's meshes
  33800. * @param toRemove defines the mesh to remove
  33801. * @param recursive if all child meshes should also be removed from the scene
  33802. * @returns the index where the mesh was in the mesh list
  33803. */
  33804. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33805. /**
  33806. * Add a transform node to the list of scene's transform nodes
  33807. * @param newTransformNode defines the transform node to add
  33808. */
  33809. addTransformNode(newTransformNode: TransformNode): void;
  33810. /**
  33811. * Remove a transform node for the list of scene's transform nodes
  33812. * @param toRemove defines the transform node to remove
  33813. * @returns the index where the transform node was in the transform node list
  33814. */
  33815. removeTransformNode(toRemove: TransformNode): number;
  33816. /**
  33817. * Remove a skeleton for the list of scene's skeletons
  33818. * @param toRemove defines the skeleton to remove
  33819. * @returns the index where the skeleton was in the skeleton list
  33820. */
  33821. removeSkeleton(toRemove: Skeleton): number;
  33822. /**
  33823. * Remove a morph target for the list of scene's morph targets
  33824. * @param toRemove defines the morph target to remove
  33825. * @returns the index where the morph target was in the morph target list
  33826. */
  33827. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33828. /**
  33829. * Remove a light for the list of scene's lights
  33830. * @param toRemove defines the light to remove
  33831. * @returns the index where the light was in the light list
  33832. */
  33833. removeLight(toRemove: Light): number;
  33834. /**
  33835. * Remove a camera for the list of scene's cameras
  33836. * @param toRemove defines the camera to remove
  33837. * @returns the index where the camera was in the camera list
  33838. */
  33839. removeCamera(toRemove: Camera): number;
  33840. /**
  33841. * Remove a particle system for the list of scene's particle systems
  33842. * @param toRemove defines the particle system to remove
  33843. * @returns the index where the particle system was in the particle system list
  33844. */
  33845. removeParticleSystem(toRemove: IParticleSystem): number;
  33846. /**
  33847. * Remove a animation for the list of scene's animations
  33848. * @param toRemove defines the animation to remove
  33849. * @returns the index where the animation was in the animation list
  33850. */
  33851. removeAnimation(toRemove: Animation): number;
  33852. /**
  33853. * Will stop the animation of the given target
  33854. * @param target - the target
  33855. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33856. * @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)
  33857. */
  33858. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33859. /**
  33860. * Removes the given animation group from this scene.
  33861. * @param toRemove The animation group to remove
  33862. * @returns The index of the removed animation group
  33863. */
  33864. removeAnimationGroup(toRemove: AnimationGroup): number;
  33865. /**
  33866. * Removes the given multi-material from this scene.
  33867. * @param toRemove The multi-material to remove
  33868. * @returns The index of the removed multi-material
  33869. */
  33870. removeMultiMaterial(toRemove: MultiMaterial): number;
  33871. /**
  33872. * Removes the given material from this scene.
  33873. * @param toRemove The material to remove
  33874. * @returns The index of the removed material
  33875. */
  33876. removeMaterial(toRemove: Material): number;
  33877. /**
  33878. * Removes the given action manager from this scene.
  33879. * @param toRemove The action manager to remove
  33880. * @returns The index of the removed action manager
  33881. */
  33882. removeActionManager(toRemove: AbstractActionManager): number;
  33883. /**
  33884. * Removes the given texture from this scene.
  33885. * @param toRemove The texture to remove
  33886. * @returns The index of the removed texture
  33887. */
  33888. removeTexture(toRemove: BaseTexture): number;
  33889. /**
  33890. * Adds the given light to this scene
  33891. * @param newLight The light to add
  33892. */
  33893. addLight(newLight: Light): void;
  33894. /**
  33895. * Sorts the list list based on light priorities
  33896. */
  33897. sortLightsByPriority(): void;
  33898. /**
  33899. * Adds the given camera to this scene
  33900. * @param newCamera The camera to add
  33901. */
  33902. addCamera(newCamera: Camera): void;
  33903. /**
  33904. * Adds the given skeleton to this scene
  33905. * @param newSkeleton The skeleton to add
  33906. */
  33907. addSkeleton(newSkeleton: Skeleton): void;
  33908. /**
  33909. * Adds the given particle system to this scene
  33910. * @param newParticleSystem The particle system to add
  33911. */
  33912. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33913. /**
  33914. * Adds the given animation to this scene
  33915. * @param newAnimation The animation to add
  33916. */
  33917. addAnimation(newAnimation: Animation): void;
  33918. /**
  33919. * Adds the given animation group to this scene.
  33920. * @param newAnimationGroup The animation group to add
  33921. */
  33922. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33923. /**
  33924. * Adds the given multi-material to this scene
  33925. * @param newMultiMaterial The multi-material to add
  33926. */
  33927. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33928. /**
  33929. * Adds the given material to this scene
  33930. * @param newMaterial The material to add
  33931. */
  33932. addMaterial(newMaterial: Material): void;
  33933. /**
  33934. * Adds the given morph target to this scene
  33935. * @param newMorphTargetManager The morph target to add
  33936. */
  33937. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33938. /**
  33939. * Adds the given geometry to this scene
  33940. * @param newGeometry The geometry to add
  33941. */
  33942. addGeometry(newGeometry: Geometry): void;
  33943. /**
  33944. * Adds the given action manager to this scene
  33945. * @param newActionManager The action manager to add
  33946. */
  33947. addActionManager(newActionManager: AbstractActionManager): void;
  33948. /**
  33949. * Adds the given texture to this scene.
  33950. * @param newTexture The texture to add
  33951. */
  33952. addTexture(newTexture: BaseTexture): void;
  33953. /**
  33954. * Switch active camera
  33955. * @param newCamera defines the new active camera
  33956. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33957. */
  33958. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33959. /**
  33960. * sets the active camera of the scene using its ID
  33961. * @param id defines the camera's ID
  33962. * @return the new active camera or null if none found.
  33963. */
  33964. setActiveCameraByID(id: string): Nullable<Camera>;
  33965. /**
  33966. * sets the active camera of the scene using its name
  33967. * @param name defines the camera's name
  33968. * @returns the new active camera or null if none found.
  33969. */
  33970. setActiveCameraByName(name: string): Nullable<Camera>;
  33971. /**
  33972. * get an animation group using its name
  33973. * @param name defines the material's name
  33974. * @return the animation group or null if none found.
  33975. */
  33976. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33977. /**
  33978. * Get a material using its unique id
  33979. * @param uniqueId defines the material's unique id
  33980. * @return the material or null if none found.
  33981. */
  33982. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33983. /**
  33984. * get a material using its id
  33985. * @param id defines the material's ID
  33986. * @return the material or null if none found.
  33987. */
  33988. getMaterialByID(id: string): Nullable<Material>;
  33989. /**
  33990. * Gets a the last added material using a given id
  33991. * @param id defines the material's ID
  33992. * @return the last material with the given id or null if none found.
  33993. */
  33994. getLastMaterialByID(id: string): Nullable<Material>;
  33995. /**
  33996. * Gets a material using its name
  33997. * @param name defines the material's name
  33998. * @return the material or null if none found.
  33999. */
  34000. getMaterialByName(name: string): Nullable<Material>;
  34001. /**
  34002. * Get a texture using its unique id
  34003. * @param uniqueId defines the texture's unique id
  34004. * @return the texture or null if none found.
  34005. */
  34006. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34007. /**
  34008. * Gets a camera using its id
  34009. * @param id defines the id to look for
  34010. * @returns the camera or null if not found
  34011. */
  34012. getCameraByID(id: string): Nullable<Camera>;
  34013. /**
  34014. * Gets a camera using its unique id
  34015. * @param uniqueId defines the unique id to look for
  34016. * @returns the camera or null if not found
  34017. */
  34018. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34019. /**
  34020. * Gets a camera using its name
  34021. * @param name defines the camera's name
  34022. * @return the camera or null if none found.
  34023. */
  34024. getCameraByName(name: string): Nullable<Camera>;
  34025. /**
  34026. * Gets a bone using its id
  34027. * @param id defines the bone's id
  34028. * @return the bone or null if not found
  34029. */
  34030. getBoneByID(id: string): Nullable<Bone>;
  34031. /**
  34032. * Gets a bone using its id
  34033. * @param name defines the bone's name
  34034. * @return the bone or null if not found
  34035. */
  34036. getBoneByName(name: string): Nullable<Bone>;
  34037. /**
  34038. * Gets a light node using its name
  34039. * @param name defines the the light's name
  34040. * @return the light or null if none found.
  34041. */
  34042. getLightByName(name: string): Nullable<Light>;
  34043. /**
  34044. * Gets a light node using its id
  34045. * @param id defines the light's id
  34046. * @return the light or null if none found.
  34047. */
  34048. getLightByID(id: string): Nullable<Light>;
  34049. /**
  34050. * Gets a light node using its scene-generated unique ID
  34051. * @param uniqueId defines the light's unique id
  34052. * @return the light or null if none found.
  34053. */
  34054. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34055. /**
  34056. * Gets a particle system by id
  34057. * @param id defines the particle system id
  34058. * @return the corresponding system or null if none found
  34059. */
  34060. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34061. /**
  34062. * Gets a geometry using its ID
  34063. * @param id defines the geometry's id
  34064. * @return the geometry or null if none found.
  34065. */
  34066. getGeometryByID(id: string): Nullable<Geometry>;
  34067. private _getGeometryByUniqueID;
  34068. /**
  34069. * Add a new geometry to this scene
  34070. * @param geometry defines the geometry to be added to the scene.
  34071. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34072. * @return a boolean defining if the geometry was added or not
  34073. */
  34074. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34075. /**
  34076. * Removes an existing geometry
  34077. * @param geometry defines the geometry to be removed from the scene
  34078. * @return a boolean defining if the geometry was removed or not
  34079. */
  34080. removeGeometry(geometry: Geometry): boolean;
  34081. /**
  34082. * Gets the list of geometries attached to the scene
  34083. * @returns an array of Geometry
  34084. */
  34085. getGeometries(): Geometry[];
  34086. /**
  34087. * Gets the first added mesh found of a given ID
  34088. * @param id defines the id to search for
  34089. * @return the mesh found or null if not found at all
  34090. */
  34091. getMeshByID(id: string): Nullable<AbstractMesh>;
  34092. /**
  34093. * Gets a list of meshes using their id
  34094. * @param id defines the id to search for
  34095. * @returns a list of meshes
  34096. */
  34097. getMeshesByID(id: string): Array<AbstractMesh>;
  34098. /**
  34099. * Gets the first added transform node found of a given ID
  34100. * @param id defines the id to search for
  34101. * @return the found transform node or null if not found at all.
  34102. */
  34103. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34104. /**
  34105. * Gets a transform node with its auto-generated unique id
  34106. * @param uniqueId efines the unique id to search for
  34107. * @return the found transform node or null if not found at all.
  34108. */
  34109. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34110. /**
  34111. * Gets a list of transform nodes using their id
  34112. * @param id defines the id to search for
  34113. * @returns a list of transform nodes
  34114. */
  34115. getTransformNodesByID(id: string): Array<TransformNode>;
  34116. /**
  34117. * Gets a mesh with its auto-generated unique id
  34118. * @param uniqueId defines the unique id to search for
  34119. * @return the found mesh or null if not found at all.
  34120. */
  34121. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34122. /**
  34123. * Gets a the last added mesh using a given id
  34124. * @param id defines the id to search for
  34125. * @return the found mesh or null if not found at all.
  34126. */
  34127. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34128. /**
  34129. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34130. * @param id defines the id to search for
  34131. * @return the found node or null if not found at all
  34132. */
  34133. getLastEntryByID(id: string): Nullable<Node>;
  34134. /**
  34135. * Gets a node (Mesh, Camera, Light) using a given id
  34136. * @param id defines the id to search for
  34137. * @return the found node or null if not found at all
  34138. */
  34139. getNodeByID(id: string): Nullable<Node>;
  34140. /**
  34141. * Gets a node (Mesh, Camera, Light) using a given name
  34142. * @param name defines the name to search for
  34143. * @return the found node or null if not found at all.
  34144. */
  34145. getNodeByName(name: string): Nullable<Node>;
  34146. /**
  34147. * Gets a mesh using a given name
  34148. * @param name defines the name to search for
  34149. * @return the found mesh or null if not found at all.
  34150. */
  34151. getMeshByName(name: string): Nullable<AbstractMesh>;
  34152. /**
  34153. * Gets a transform node using a given name
  34154. * @param name defines the name to search for
  34155. * @return the found transform node or null if not found at all.
  34156. */
  34157. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34158. /**
  34159. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34160. * @param id defines the id to search for
  34161. * @return the found skeleton or null if not found at all.
  34162. */
  34163. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34164. /**
  34165. * Gets a skeleton using a given auto generated unique id
  34166. * @param uniqueId defines the unique id to search for
  34167. * @return the found skeleton or null if not found at all.
  34168. */
  34169. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34170. /**
  34171. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34172. * @param id defines the id to search for
  34173. * @return the found skeleton or null if not found at all.
  34174. */
  34175. getSkeletonById(id: string): Nullable<Skeleton>;
  34176. /**
  34177. * Gets a skeleton using a given name
  34178. * @param name defines the name to search for
  34179. * @return the found skeleton or null if not found at all.
  34180. */
  34181. getSkeletonByName(name: string): Nullable<Skeleton>;
  34182. /**
  34183. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34184. * @param id defines the id to search for
  34185. * @return the found morph target manager or null if not found at all.
  34186. */
  34187. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34188. /**
  34189. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34190. * @param id defines the id to search for
  34191. * @return the found morph target or null if not found at all.
  34192. */
  34193. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34194. /**
  34195. * Gets a boolean indicating if the given mesh is active
  34196. * @param mesh defines the mesh to look for
  34197. * @returns true if the mesh is in the active list
  34198. */
  34199. isActiveMesh(mesh: AbstractMesh): boolean;
  34200. /**
  34201. * Return a unique id as a string which can serve as an identifier for the scene
  34202. */
  34203. readonly uid: string;
  34204. /**
  34205. * Add an externaly attached data from its key.
  34206. * This method call will fail and return false, if such key already exists.
  34207. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34208. * @param key the unique key that identifies the data
  34209. * @param data the data object to associate to the key for this Engine instance
  34210. * @return true if no such key were already present and the data was added successfully, false otherwise
  34211. */
  34212. addExternalData<T>(key: string, data: T): boolean;
  34213. /**
  34214. * Get an externaly attached data from its key
  34215. * @param key the unique key that identifies the data
  34216. * @return the associated data, if present (can be null), or undefined if not present
  34217. */
  34218. getExternalData<T>(key: string): Nullable<T>;
  34219. /**
  34220. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34221. * @param key the unique key that identifies the data
  34222. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34223. * @return the associated data, can be null if the factory returned null.
  34224. */
  34225. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34226. /**
  34227. * Remove an externaly attached data from the Engine instance
  34228. * @param key the unique key that identifies the data
  34229. * @return true if the data was successfully removed, false if it doesn't exist
  34230. */
  34231. removeExternalData(key: string): boolean;
  34232. private _evaluateSubMesh;
  34233. /**
  34234. * Clear the processed materials smart array preventing retention point in material dispose.
  34235. */
  34236. freeProcessedMaterials(): void;
  34237. private _preventFreeActiveMeshesAndRenderingGroups;
  34238. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34239. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34240. * when disposing several meshes in a row or a hierarchy of meshes.
  34241. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34242. */
  34243. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34244. /**
  34245. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34246. */
  34247. freeActiveMeshes(): void;
  34248. /**
  34249. * Clear the info related to rendering groups preventing retention points during dispose.
  34250. */
  34251. freeRenderingGroups(): void;
  34252. /** @hidden */
  34253. _isInIntermediateRendering(): boolean;
  34254. /**
  34255. * Lambda returning the list of potentially active meshes.
  34256. */
  34257. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34258. /**
  34259. * Lambda returning the list of potentially active sub meshes.
  34260. */
  34261. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34262. /**
  34263. * Lambda returning the list of potentially intersecting sub meshes.
  34264. */
  34265. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34266. /**
  34267. * Lambda returning the list of potentially colliding sub meshes.
  34268. */
  34269. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34270. private _activeMeshesFrozen;
  34271. /**
  34272. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34273. * @returns the current scene
  34274. */
  34275. freezeActiveMeshes(): Scene;
  34276. /**
  34277. * Use this function to restart evaluating active meshes on every frame
  34278. * @returns the current scene
  34279. */
  34280. unfreezeActiveMeshes(): Scene;
  34281. private _evaluateActiveMeshes;
  34282. private _activeMesh;
  34283. /**
  34284. * Update the transform matrix to update from the current active camera
  34285. * @param force defines a boolean used to force the update even if cache is up to date
  34286. */
  34287. updateTransformMatrix(force?: boolean): void;
  34288. private _bindFrameBuffer;
  34289. /** @hidden */
  34290. _allowPostProcessClearColor: boolean;
  34291. /** @hidden */
  34292. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34293. private _processSubCameras;
  34294. private _checkIntersections;
  34295. /** @hidden */
  34296. _advancePhysicsEngineStep(step: number): void;
  34297. /**
  34298. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34299. */
  34300. getDeterministicFrameTime: () => number;
  34301. /** @hidden */
  34302. _animate(): void;
  34303. /** Execute all animations (for a frame) */
  34304. animate(): void;
  34305. /**
  34306. * Render the scene
  34307. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34308. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34309. */
  34310. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34311. /**
  34312. * Freeze all materials
  34313. * A frozen material will not be updatable but should be faster to render
  34314. */
  34315. freezeMaterials(): void;
  34316. /**
  34317. * Unfreeze all materials
  34318. * A frozen material will not be updatable but should be faster to render
  34319. */
  34320. unfreezeMaterials(): void;
  34321. /**
  34322. * Releases all held ressources
  34323. */
  34324. dispose(): void;
  34325. /**
  34326. * Gets if the scene is already disposed
  34327. */
  34328. readonly isDisposed: boolean;
  34329. /**
  34330. * Call this function to reduce memory footprint of the scene.
  34331. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34332. */
  34333. clearCachedVertexData(): void;
  34334. /**
  34335. * This function will remove the local cached buffer data from texture.
  34336. * It will save memory but will prevent the texture from being rebuilt
  34337. */
  34338. cleanCachedTextureBuffer(): void;
  34339. /**
  34340. * Get the world extend vectors with an optional filter
  34341. *
  34342. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34343. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34344. */
  34345. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34346. min: Vector3;
  34347. max: Vector3;
  34348. };
  34349. /**
  34350. * Creates a ray that can be used to pick in the scene
  34351. * @param x defines the x coordinate of the origin (on-screen)
  34352. * @param y defines the y coordinate of the origin (on-screen)
  34353. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34354. * @param camera defines the camera to use for the picking
  34355. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34356. * @returns a Ray
  34357. */
  34358. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34359. /**
  34360. * Creates a ray that can be used to pick in the scene
  34361. * @param x defines the x coordinate of the origin (on-screen)
  34362. * @param y defines the y coordinate of the origin (on-screen)
  34363. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34364. * @param result defines the ray where to store the picking ray
  34365. * @param camera defines the camera to use for the picking
  34366. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34367. * @returns the current scene
  34368. */
  34369. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34370. /**
  34371. * Creates a ray that can be used to pick in the scene
  34372. * @param x defines the x coordinate of the origin (on-screen)
  34373. * @param y defines the y coordinate of the origin (on-screen)
  34374. * @param camera defines the camera to use for the picking
  34375. * @returns a Ray
  34376. */
  34377. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34378. /**
  34379. * Creates a ray that can be used to pick in the scene
  34380. * @param x defines the x coordinate of the origin (on-screen)
  34381. * @param y defines the y coordinate of the origin (on-screen)
  34382. * @param result defines the ray where to store the picking ray
  34383. * @param camera defines the camera to use for the picking
  34384. * @returns the current scene
  34385. */
  34386. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34387. /** Launch a ray to try to pick a mesh in the scene
  34388. * @param x position on screen
  34389. * @param y position on screen
  34390. * @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
  34391. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34392. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34394. * @returns a PickingInfo
  34395. */
  34396. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34397. /** Use the given ray to pick a mesh in the scene
  34398. * @param ray The ray to use to pick meshes
  34399. * @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
  34400. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34402. * @returns a PickingInfo
  34403. */
  34404. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34405. /**
  34406. * Launch a ray to try to pick a mesh in the scene
  34407. * @param x X position on screen
  34408. * @param y Y position on screen
  34409. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  34410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34412. * @returns an array of PickingInfo
  34413. */
  34414. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34415. /**
  34416. * Launch a ray to try to pick a mesh in the scene
  34417. * @param ray Ray to use
  34418. * @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
  34419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34420. * @returns an array of PickingInfo
  34421. */
  34422. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34423. /**
  34424. * Force the value of meshUnderPointer
  34425. * @param mesh defines the mesh to use
  34426. */
  34427. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34428. /**
  34429. * Gets the mesh under the pointer
  34430. * @returns a Mesh or null if no mesh is under the pointer
  34431. */
  34432. getPointerOverMesh(): Nullable<AbstractMesh>;
  34433. /** @hidden */
  34434. _rebuildGeometries(): void;
  34435. /** @hidden */
  34436. _rebuildTextures(): void;
  34437. private _getByTags;
  34438. /**
  34439. * Get a list of meshes by tags
  34440. * @param tagsQuery defines the tags query to use
  34441. * @param forEach defines a predicate used to filter results
  34442. * @returns an array of Mesh
  34443. */
  34444. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34445. /**
  34446. * Get a list of cameras by tags
  34447. * @param tagsQuery defines the tags query to use
  34448. * @param forEach defines a predicate used to filter results
  34449. * @returns an array of Camera
  34450. */
  34451. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34452. /**
  34453. * Get a list of lights by tags
  34454. * @param tagsQuery defines the tags query to use
  34455. * @param forEach defines a predicate used to filter results
  34456. * @returns an array of Light
  34457. */
  34458. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34459. /**
  34460. * Get a list of materials by tags
  34461. * @param tagsQuery defines the tags query to use
  34462. * @param forEach defines a predicate used to filter results
  34463. * @returns an array of Material
  34464. */
  34465. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34466. /**
  34467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34468. * This allowed control for front to back rendering or reversly depending of the special needs.
  34469. *
  34470. * @param renderingGroupId The rendering group id corresponding to its index
  34471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34474. */
  34475. 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;
  34476. /**
  34477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34478. *
  34479. * @param renderingGroupId The rendering group id corresponding to its index
  34480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34481. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34482. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34483. */
  34484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34485. /**
  34486. * Gets the current auto clear configuration for one rendering group of the rendering
  34487. * manager.
  34488. * @param index the rendering group index to get the information for
  34489. * @returns The auto clear setup for the requested rendering group
  34490. */
  34491. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34492. private _blockMaterialDirtyMechanism;
  34493. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34494. blockMaterialDirtyMechanism: boolean;
  34495. /**
  34496. * Will flag all materials as dirty to trigger new shader compilation
  34497. * @param flag defines the flag used to specify which material part must be marked as dirty
  34498. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34499. */
  34500. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34501. /** @hidden */
  34502. _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;
  34503. /** @hidden */
  34504. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34505. }
  34506. }
  34507. declare module BABYLON {
  34508. /**
  34509. * Set of assets to keep when moving a scene into an asset container.
  34510. */
  34511. export class KeepAssets extends AbstractScene {
  34512. }
  34513. /**
  34514. * Container with a set of assets that can be added or removed from a scene.
  34515. */
  34516. export class AssetContainer extends AbstractScene {
  34517. /**
  34518. * The scene the AssetContainer belongs to.
  34519. */
  34520. scene: Scene;
  34521. /**
  34522. * Instantiates an AssetContainer.
  34523. * @param scene The scene the AssetContainer belongs to.
  34524. */
  34525. constructor(scene: Scene);
  34526. /**
  34527. * Adds all the assets from the container to the scene.
  34528. */
  34529. addAllToScene(): void;
  34530. /**
  34531. * Removes all the assets in the container from the scene
  34532. */
  34533. removeAllFromScene(): void;
  34534. /**
  34535. * Disposes all the assets in the container
  34536. */
  34537. dispose(): void;
  34538. private _moveAssets;
  34539. /**
  34540. * Removes all the assets contained in the scene and adds them to the container.
  34541. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34542. */
  34543. moveAllFromScene(keepAssets?: KeepAssets): void;
  34544. /**
  34545. * 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.
  34546. * @returns the root mesh
  34547. */
  34548. createRootMesh(): Mesh;
  34549. }
  34550. }
  34551. declare module BABYLON {
  34552. /**
  34553. * Defines how the parser contract is defined.
  34554. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34555. */
  34556. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34557. /**
  34558. * Defines how the individual parser contract is defined.
  34559. * These parser can parse an individual asset
  34560. */
  34561. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34562. /**
  34563. * Base class of the scene acting as a container for the different elements composing a scene.
  34564. * This class is dynamically extended by the different components of the scene increasing
  34565. * flexibility and reducing coupling
  34566. */
  34567. export abstract class AbstractScene {
  34568. /**
  34569. * Stores the list of available parsers in the application.
  34570. */
  34571. private static _BabylonFileParsers;
  34572. /**
  34573. * Stores the list of available individual parsers in the application.
  34574. */
  34575. private static _IndividualBabylonFileParsers;
  34576. /**
  34577. * Adds a parser in the list of available ones
  34578. * @param name Defines the name of the parser
  34579. * @param parser Defines the parser to add
  34580. */
  34581. static AddParser(name: string, parser: BabylonFileParser): void;
  34582. /**
  34583. * Gets a general parser from the list of avaialble ones
  34584. * @param name Defines the name of the parser
  34585. * @returns the requested parser or null
  34586. */
  34587. static GetParser(name: string): Nullable<BabylonFileParser>;
  34588. /**
  34589. * Adds n individual parser in the list of available ones
  34590. * @param name Defines the name of the parser
  34591. * @param parser Defines the parser to add
  34592. */
  34593. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34594. /**
  34595. * Gets an individual parser from the list of avaialble ones
  34596. * @param name Defines the name of the parser
  34597. * @returns the requested parser or null
  34598. */
  34599. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34600. /**
  34601. * Parser json data and populate both a scene and its associated container object
  34602. * @param jsonData Defines the data to parse
  34603. * @param scene Defines the scene to parse the data for
  34604. * @param container Defines the container attached to the parsing sequence
  34605. * @param rootUrl Defines the root url of the data
  34606. */
  34607. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34608. /**
  34609. * Gets the list of root nodes (ie. nodes with no parent)
  34610. */
  34611. rootNodes: Node[];
  34612. /** All of the cameras added to this scene
  34613. * @see http://doc.babylonjs.com/babylon101/cameras
  34614. */
  34615. cameras: Camera[];
  34616. /**
  34617. * All of the lights added to this scene
  34618. * @see http://doc.babylonjs.com/babylon101/lights
  34619. */
  34620. lights: Light[];
  34621. /**
  34622. * All of the (abstract) meshes added to this scene
  34623. */
  34624. meshes: AbstractMesh[];
  34625. /**
  34626. * The list of skeletons added to the scene
  34627. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34628. */
  34629. skeletons: Skeleton[];
  34630. /**
  34631. * All of the particle systems added to this scene
  34632. * @see http://doc.babylonjs.com/babylon101/particles
  34633. */
  34634. particleSystems: IParticleSystem[];
  34635. /**
  34636. * Gets a list of Animations associated with the scene
  34637. */
  34638. animations: Animation[];
  34639. /**
  34640. * All of the animation groups added to this scene
  34641. * @see http://doc.babylonjs.com/how_to/group
  34642. */
  34643. animationGroups: AnimationGroup[];
  34644. /**
  34645. * All of the multi-materials added to this scene
  34646. * @see http://doc.babylonjs.com/how_to/multi_materials
  34647. */
  34648. multiMaterials: MultiMaterial[];
  34649. /**
  34650. * All of the materials added to this scene
  34651. * In the context of a Scene, it is not supposed to be modified manually.
  34652. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34653. * Note also that the order of the Material wihin the array is not significant and might change.
  34654. * @see http://doc.babylonjs.com/babylon101/materials
  34655. */
  34656. materials: Material[];
  34657. /**
  34658. * The list of morph target managers added to the scene
  34659. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34660. */
  34661. morphTargetManagers: MorphTargetManager[];
  34662. /**
  34663. * The list of geometries used in the scene.
  34664. */
  34665. geometries: Geometry[];
  34666. /**
  34667. * All of the tranform nodes added to this scene
  34668. * In the context of a Scene, it is not supposed to be modified manually.
  34669. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34670. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34671. * @see http://doc.babylonjs.com/how_to/transformnode
  34672. */
  34673. transformNodes: TransformNode[];
  34674. /**
  34675. * ActionManagers available on the scene.
  34676. */
  34677. actionManagers: AbstractActionManager[];
  34678. /**
  34679. * Textures to keep.
  34680. */
  34681. textures: BaseTexture[];
  34682. /**
  34683. * Environment texture for the scene
  34684. */
  34685. environmentTexture: Nullable<BaseTexture>;
  34686. }
  34687. }
  34688. declare module BABYLON {
  34689. /**
  34690. * Interface used to define options for Sound class
  34691. */
  34692. export interface ISoundOptions {
  34693. /**
  34694. * Does the sound autoplay once loaded.
  34695. */
  34696. autoplay?: boolean;
  34697. /**
  34698. * Does the sound loop after it finishes playing once.
  34699. */
  34700. loop?: boolean;
  34701. /**
  34702. * Sound's volume
  34703. */
  34704. volume?: number;
  34705. /**
  34706. * Is it a spatial sound?
  34707. */
  34708. spatialSound?: boolean;
  34709. /**
  34710. * Maximum distance to hear that sound
  34711. */
  34712. maxDistance?: number;
  34713. /**
  34714. * Uses user defined attenuation function
  34715. */
  34716. useCustomAttenuation?: boolean;
  34717. /**
  34718. * Define the roll off factor of spatial sounds.
  34719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34720. */
  34721. rolloffFactor?: number;
  34722. /**
  34723. * Define the reference distance the sound should be heard perfectly.
  34724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34725. */
  34726. refDistance?: number;
  34727. /**
  34728. * Define the distance attenuation model the sound will follow.
  34729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34730. */
  34731. distanceModel?: string;
  34732. /**
  34733. * Defines the playback speed (1 by default)
  34734. */
  34735. playbackRate?: number;
  34736. /**
  34737. * Defines if the sound is from a streaming source
  34738. */
  34739. streaming?: boolean;
  34740. /**
  34741. * Defines an optional length (in seconds) inside the sound file
  34742. */
  34743. length?: number;
  34744. /**
  34745. * Defines an optional offset (in seconds) inside the sound file
  34746. */
  34747. offset?: number;
  34748. /**
  34749. * If true, URLs will not be required to state the audio file codec to use.
  34750. */
  34751. skipCodecCheck?: boolean;
  34752. }
  34753. /**
  34754. * Defines a sound that can be played in the application.
  34755. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34757. */
  34758. export class Sound {
  34759. /**
  34760. * The name of the sound in the scene.
  34761. */
  34762. name: string;
  34763. /**
  34764. * Does the sound autoplay once loaded.
  34765. */
  34766. autoplay: boolean;
  34767. /**
  34768. * Does the sound loop after it finishes playing once.
  34769. */
  34770. loop: boolean;
  34771. /**
  34772. * Does the sound use a custom attenuation curve to simulate the falloff
  34773. * happening when the source gets further away from the camera.
  34774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34775. */
  34776. useCustomAttenuation: boolean;
  34777. /**
  34778. * The sound track id this sound belongs to.
  34779. */
  34780. soundTrackId: number;
  34781. /**
  34782. * Is this sound currently played.
  34783. */
  34784. isPlaying: boolean;
  34785. /**
  34786. * Is this sound currently paused.
  34787. */
  34788. isPaused: boolean;
  34789. /**
  34790. * Does this sound enables spatial sound.
  34791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34792. */
  34793. spatialSound: boolean;
  34794. /**
  34795. * Define the reference distance the sound should be heard perfectly.
  34796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34797. */
  34798. refDistance: number;
  34799. /**
  34800. * Define the roll off factor of spatial sounds.
  34801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34802. */
  34803. rolloffFactor: number;
  34804. /**
  34805. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34807. */
  34808. maxDistance: number;
  34809. /**
  34810. * Define the distance attenuation model the sound will follow.
  34811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34812. */
  34813. distanceModel: string;
  34814. /**
  34815. * @hidden
  34816. * Back Compat
  34817. **/
  34818. onended: () => any;
  34819. /**
  34820. * Observable event when the current playing sound finishes.
  34821. */
  34822. onEndedObservable: Observable<Sound>;
  34823. private _panningModel;
  34824. private _playbackRate;
  34825. private _streaming;
  34826. private _startTime;
  34827. private _startOffset;
  34828. private _position;
  34829. /** @hidden */
  34830. _positionInEmitterSpace: boolean;
  34831. private _localDirection;
  34832. private _volume;
  34833. private _isReadyToPlay;
  34834. private _isDirectional;
  34835. private _readyToPlayCallback;
  34836. private _audioBuffer;
  34837. private _soundSource;
  34838. private _streamingSource;
  34839. private _soundPanner;
  34840. private _soundGain;
  34841. private _inputAudioNode;
  34842. private _outputAudioNode;
  34843. private _coneInnerAngle;
  34844. private _coneOuterAngle;
  34845. private _coneOuterGain;
  34846. private _scene;
  34847. private _connectedTransformNode;
  34848. private _customAttenuationFunction;
  34849. private _registerFunc;
  34850. private _isOutputConnected;
  34851. private _htmlAudioElement;
  34852. private _urlType;
  34853. private _length?;
  34854. private _offset?;
  34855. /** @hidden */
  34856. static _SceneComponentInitialization: (scene: Scene) => void;
  34857. /**
  34858. * Create a sound and attach it to a scene
  34859. * @param name Name of your sound
  34860. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34861. * @param scene defines the scene the sound belongs to
  34862. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34863. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34864. */
  34865. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34866. /**
  34867. * Release the sound and its associated resources
  34868. */
  34869. dispose(): void;
  34870. /**
  34871. * Gets if the sounds is ready to be played or not.
  34872. * @returns true if ready, otherwise false
  34873. */
  34874. isReady(): boolean;
  34875. private _soundLoaded;
  34876. /**
  34877. * Sets the data of the sound from an audiobuffer
  34878. * @param audioBuffer The audioBuffer containing the data
  34879. */
  34880. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34881. /**
  34882. * Updates the current sounds options such as maxdistance, loop...
  34883. * @param options A JSON object containing values named as the object properties
  34884. */
  34885. updateOptions(options: ISoundOptions): void;
  34886. private _createSpatialParameters;
  34887. private _updateSpatialParameters;
  34888. /**
  34889. * Switch the panning model to HRTF:
  34890. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34892. */
  34893. switchPanningModelToHRTF(): void;
  34894. /**
  34895. * Switch the panning model to Equal Power:
  34896. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34898. */
  34899. switchPanningModelToEqualPower(): void;
  34900. private _switchPanningModel;
  34901. /**
  34902. * Connect this sound to a sound track audio node like gain...
  34903. * @param soundTrackAudioNode the sound track audio node to connect to
  34904. */
  34905. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34906. /**
  34907. * Transform this sound into a directional source
  34908. * @param coneInnerAngle Size of the inner cone in degree
  34909. * @param coneOuterAngle Size of the outer cone in degree
  34910. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34911. */
  34912. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34913. /**
  34914. * Gets or sets the inner angle for the directional cone.
  34915. */
  34916. /**
  34917. * Gets or sets the inner angle for the directional cone.
  34918. */
  34919. directionalConeInnerAngle: number;
  34920. /**
  34921. * Gets or sets the outer angle for the directional cone.
  34922. */
  34923. /**
  34924. * Gets or sets the outer angle for the directional cone.
  34925. */
  34926. directionalConeOuterAngle: number;
  34927. /**
  34928. * Sets the position of the emitter if spatial sound is enabled
  34929. * @param newPosition Defines the new posisiton
  34930. */
  34931. setPosition(newPosition: Vector3): void;
  34932. /**
  34933. * Sets the local direction of the emitter if spatial sound is enabled
  34934. * @param newLocalDirection Defines the new local direction
  34935. */
  34936. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34937. private _updateDirection;
  34938. /** @hidden */
  34939. updateDistanceFromListener(): void;
  34940. /**
  34941. * Sets a new custom attenuation function for the sound.
  34942. * @param callback Defines the function used for the attenuation
  34943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34944. */
  34945. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34946. /**
  34947. * Play the sound
  34948. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34949. * @param offset (optional) Start the sound at a specific time in seconds
  34950. * @param length (optional) Sound duration (in seconds)
  34951. */
  34952. play(time?: number, offset?: number, length?: number): void;
  34953. private _onended;
  34954. /**
  34955. * Stop the sound
  34956. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34957. */
  34958. stop(time?: number): void;
  34959. /**
  34960. * Put the sound in pause
  34961. */
  34962. pause(): void;
  34963. /**
  34964. * Sets a dedicated volume for this sounds
  34965. * @param newVolume Define the new volume of the sound
  34966. * @param time Define time for gradual change to new volume
  34967. */
  34968. setVolume(newVolume: number, time?: number): void;
  34969. /**
  34970. * Set the sound play back rate
  34971. * @param newPlaybackRate Define the playback rate the sound should be played at
  34972. */
  34973. setPlaybackRate(newPlaybackRate: number): void;
  34974. /**
  34975. * Gets the volume of the sound.
  34976. * @returns the volume of the sound
  34977. */
  34978. getVolume(): number;
  34979. /**
  34980. * Attach the sound to a dedicated mesh
  34981. * @param transformNode The transform node to connect the sound with
  34982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34983. */
  34984. attachToMesh(transformNode: TransformNode): void;
  34985. /**
  34986. * Detach the sound from the previously attached mesh
  34987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34988. */
  34989. detachFromMesh(): void;
  34990. private _onRegisterAfterWorldMatrixUpdate;
  34991. /**
  34992. * Clone the current sound in the scene.
  34993. * @returns the new sound clone
  34994. */
  34995. clone(): Nullable<Sound>;
  34996. /**
  34997. * Gets the current underlying audio buffer containing the data
  34998. * @returns the audio buffer
  34999. */
  35000. getAudioBuffer(): Nullable<AudioBuffer>;
  35001. /**
  35002. * Serializes the Sound in a JSON representation
  35003. * @returns the JSON representation of the sound
  35004. */
  35005. serialize(): any;
  35006. /**
  35007. * Parse a JSON representation of a sound to innstantiate in a given scene
  35008. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35009. * @param scene Define the scene the new parsed sound should be created in
  35010. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35011. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35012. * @returns the newly parsed sound
  35013. */
  35014. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35015. }
  35016. }
  35017. declare module BABYLON {
  35018. /**
  35019. * This defines an action helpful to play a defined sound on a triggered action.
  35020. */
  35021. export class PlaySoundAction extends Action {
  35022. private _sound;
  35023. /**
  35024. * Instantiate the action
  35025. * @param triggerOptions defines the trigger options
  35026. * @param sound defines the sound to play
  35027. * @param condition defines the trigger related conditions
  35028. */
  35029. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35030. /** @hidden */
  35031. _prepare(): void;
  35032. /**
  35033. * Execute the action and play the sound.
  35034. */
  35035. execute(): void;
  35036. /**
  35037. * Serializes the actions and its related information.
  35038. * @param parent defines the object to serialize in
  35039. * @returns the serialized object
  35040. */
  35041. serialize(parent: any): any;
  35042. }
  35043. /**
  35044. * This defines an action helpful to stop a defined sound on a triggered action.
  35045. */
  35046. export class StopSoundAction extends Action {
  35047. private _sound;
  35048. /**
  35049. * Instantiate the action
  35050. * @param triggerOptions defines the trigger options
  35051. * @param sound defines the sound to stop
  35052. * @param condition defines the trigger related conditions
  35053. */
  35054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35055. /** @hidden */
  35056. _prepare(): void;
  35057. /**
  35058. * Execute the action and stop the sound.
  35059. */
  35060. execute(): void;
  35061. /**
  35062. * Serializes the actions and its related information.
  35063. * @param parent defines the object to serialize in
  35064. * @returns the serialized object
  35065. */
  35066. serialize(parent: any): any;
  35067. }
  35068. }
  35069. declare module BABYLON {
  35070. /**
  35071. * This defines an action responsible to change the value of a property
  35072. * by interpolating between its current value and the newly set one once triggered.
  35073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35074. */
  35075. export class InterpolateValueAction extends Action {
  35076. /**
  35077. * Defines the path of the property where the value should be interpolated
  35078. */
  35079. propertyPath: string;
  35080. /**
  35081. * Defines the target value at the end of the interpolation.
  35082. */
  35083. value: any;
  35084. /**
  35085. * Defines the time it will take for the property to interpolate to the value.
  35086. */
  35087. duration: number;
  35088. /**
  35089. * Defines if the other scene animations should be stopped when the action has been triggered
  35090. */
  35091. stopOtherAnimations?: boolean;
  35092. /**
  35093. * Defines a callback raised once the interpolation animation has been done.
  35094. */
  35095. onInterpolationDone?: () => void;
  35096. /**
  35097. * Observable triggered once the interpolation animation has been done.
  35098. */
  35099. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35100. private _target;
  35101. private _effectiveTarget;
  35102. private _property;
  35103. /**
  35104. * Instantiate the action
  35105. * @param triggerOptions defines the trigger options
  35106. * @param target defines the object containing the value to interpolate
  35107. * @param propertyPath defines the path to the property in the target object
  35108. * @param value defines the target value at the end of the interpolation
  35109. * @param duration deines the time it will take for the property to interpolate to the value.
  35110. * @param condition defines the trigger related conditions
  35111. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35112. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35113. */
  35114. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35115. /** @hidden */
  35116. _prepare(): void;
  35117. /**
  35118. * Execute the action starts the value interpolation.
  35119. */
  35120. execute(): void;
  35121. /**
  35122. * Serializes the actions and its related information.
  35123. * @param parent defines the object to serialize in
  35124. * @returns the serialized object
  35125. */
  35126. serialize(parent: any): any;
  35127. }
  35128. }
  35129. declare module BABYLON {
  35130. /**
  35131. * Options allowed during the creation of a sound track.
  35132. */
  35133. export interface ISoundTrackOptions {
  35134. /**
  35135. * The volume the sound track should take during creation
  35136. */
  35137. volume?: number;
  35138. /**
  35139. * Define if the sound track is the main sound track of the scene
  35140. */
  35141. mainTrack?: boolean;
  35142. }
  35143. /**
  35144. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35145. * It will be also used in a future release to apply effects on a specific track.
  35146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35147. */
  35148. export class SoundTrack {
  35149. /**
  35150. * The unique identifier of the sound track in the scene.
  35151. */
  35152. id: number;
  35153. /**
  35154. * The list of sounds included in the sound track.
  35155. */
  35156. soundCollection: Array<Sound>;
  35157. private _outputAudioNode;
  35158. private _scene;
  35159. private _isMainTrack;
  35160. private _connectedAnalyser;
  35161. private _options;
  35162. private _isInitialized;
  35163. /**
  35164. * Creates a new sound track.
  35165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35166. * @param scene Define the scene the sound track belongs to
  35167. * @param options
  35168. */
  35169. constructor(scene: Scene, options?: ISoundTrackOptions);
  35170. private _initializeSoundTrackAudioGraph;
  35171. /**
  35172. * Release the sound track and its associated resources
  35173. */
  35174. dispose(): void;
  35175. /**
  35176. * Adds a sound to this sound track
  35177. * @param sound define the cound to add
  35178. * @ignoreNaming
  35179. */
  35180. AddSound(sound: Sound): void;
  35181. /**
  35182. * Removes a sound to this sound track
  35183. * @param sound define the cound to remove
  35184. * @ignoreNaming
  35185. */
  35186. RemoveSound(sound: Sound): void;
  35187. /**
  35188. * Set a global volume for the full sound track.
  35189. * @param newVolume Define the new volume of the sound track
  35190. */
  35191. setVolume(newVolume: number): void;
  35192. /**
  35193. * Switch the panning model to HRTF:
  35194. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35196. */
  35197. switchPanningModelToHRTF(): void;
  35198. /**
  35199. * Switch the panning model to Equal Power:
  35200. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35202. */
  35203. switchPanningModelToEqualPower(): void;
  35204. /**
  35205. * Connect the sound track to an audio analyser allowing some amazing
  35206. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35208. * @param analyser The analyser to connect to the engine
  35209. */
  35210. connectToAnalyser(analyser: Analyser): void;
  35211. }
  35212. }
  35213. declare module BABYLON {
  35214. interface AbstractScene {
  35215. /**
  35216. * The list of sounds used in the scene.
  35217. */
  35218. sounds: Nullable<Array<Sound>>;
  35219. }
  35220. interface Scene {
  35221. /**
  35222. * @hidden
  35223. * Backing field
  35224. */
  35225. _mainSoundTrack: SoundTrack;
  35226. /**
  35227. * The main sound track played by the scene.
  35228. * It cotains your primary collection of sounds.
  35229. */
  35230. mainSoundTrack: SoundTrack;
  35231. /**
  35232. * The list of sound tracks added to the scene
  35233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35234. */
  35235. soundTracks: Nullable<Array<SoundTrack>>;
  35236. /**
  35237. * Gets a sound using a given name
  35238. * @param name defines the name to search for
  35239. * @return the found sound or null if not found at all.
  35240. */
  35241. getSoundByName(name: string): Nullable<Sound>;
  35242. /**
  35243. * Gets or sets if audio support is enabled
  35244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35245. */
  35246. audioEnabled: boolean;
  35247. /**
  35248. * Gets or sets if audio will be output to headphones
  35249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35250. */
  35251. headphone: boolean;
  35252. /**
  35253. * Gets or sets custom audio listener position provider
  35254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35255. */
  35256. audioListenerPositionProvider: Nullable<() => Vector3>;
  35257. }
  35258. /**
  35259. * Defines the sound scene component responsible to manage any sounds
  35260. * in a given scene.
  35261. */
  35262. export class AudioSceneComponent implements ISceneSerializableComponent {
  35263. /**
  35264. * The component name helpfull to identify the component in the list of scene components.
  35265. */
  35266. readonly name: string;
  35267. /**
  35268. * The scene the component belongs to.
  35269. */
  35270. scene: Scene;
  35271. private _audioEnabled;
  35272. /**
  35273. * Gets whether audio is enabled or not.
  35274. * Please use related enable/disable method to switch state.
  35275. */
  35276. readonly audioEnabled: boolean;
  35277. private _headphone;
  35278. /**
  35279. * Gets whether audio is outputing to headphone or not.
  35280. * Please use the according Switch methods to change output.
  35281. */
  35282. readonly headphone: boolean;
  35283. private _audioListenerPositionProvider;
  35284. /**
  35285. * Gets the current audio listener position provider
  35286. */
  35287. /**
  35288. * Sets a custom listener position for all sounds in the scene
  35289. * By default, this is the position of the first active camera
  35290. */
  35291. audioListenerPositionProvider: Nullable<() => Vector3>;
  35292. /**
  35293. * Creates a new instance of the component for the given scene
  35294. * @param scene Defines the scene to register the component in
  35295. */
  35296. constructor(scene: Scene);
  35297. /**
  35298. * Registers the component in a given scene
  35299. */
  35300. register(): void;
  35301. /**
  35302. * Rebuilds the elements related to this component in case of
  35303. * context lost for instance.
  35304. */
  35305. rebuild(): void;
  35306. /**
  35307. * Serializes the component data to the specified json object
  35308. * @param serializationObject The object to serialize to
  35309. */
  35310. serialize(serializationObject: any): void;
  35311. /**
  35312. * Adds all the elements from the container to the scene
  35313. * @param container the container holding the elements
  35314. */
  35315. addFromContainer(container: AbstractScene): void;
  35316. /**
  35317. * Removes all the elements in the container from the scene
  35318. * @param container contains the elements to remove
  35319. * @param dispose if the removed element should be disposed (default: false)
  35320. */
  35321. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35322. /**
  35323. * Disposes the component and the associated ressources.
  35324. */
  35325. dispose(): void;
  35326. /**
  35327. * Disables audio in the associated scene.
  35328. */
  35329. disableAudio(): void;
  35330. /**
  35331. * Enables audio in the associated scene.
  35332. */
  35333. enableAudio(): void;
  35334. /**
  35335. * Switch audio to headphone output.
  35336. */
  35337. switchAudioModeForHeadphones(): void;
  35338. /**
  35339. * Switch audio to normal speakers.
  35340. */
  35341. switchAudioModeForNormalSpeakers(): void;
  35342. private _afterRender;
  35343. }
  35344. }
  35345. declare module BABYLON {
  35346. /**
  35347. * Wraps one or more Sound objects and selects one with random weight for playback.
  35348. */
  35349. export class WeightedSound {
  35350. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35351. loop: boolean;
  35352. private _coneInnerAngle;
  35353. private _coneOuterAngle;
  35354. private _volume;
  35355. /** A Sound is currently playing. */
  35356. isPlaying: boolean;
  35357. /** A Sound is currently paused. */
  35358. isPaused: boolean;
  35359. private _sounds;
  35360. private _weights;
  35361. private _currentIndex?;
  35362. /**
  35363. * Creates a new WeightedSound from the list of sounds given.
  35364. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35365. * @param sounds Array of Sounds that will be selected from.
  35366. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35367. */
  35368. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35369. /**
  35370. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35371. */
  35372. /**
  35373. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35374. */
  35375. directionalConeInnerAngle: number;
  35376. /**
  35377. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35378. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35379. */
  35380. /**
  35381. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35382. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35383. */
  35384. directionalConeOuterAngle: number;
  35385. /**
  35386. * Playback volume.
  35387. */
  35388. /**
  35389. * Playback volume.
  35390. */
  35391. volume: number;
  35392. private _onended;
  35393. /**
  35394. * Suspend playback
  35395. */
  35396. pause(): void;
  35397. /**
  35398. * Stop playback
  35399. */
  35400. stop(): void;
  35401. /**
  35402. * Start playback.
  35403. * @param startOffset Position the clip head at a specific time in seconds.
  35404. */
  35405. play(startOffset?: number): void;
  35406. }
  35407. }
  35408. declare module BABYLON {
  35409. /**
  35410. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35412. */
  35413. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35414. /**
  35415. * Gets the name of the behavior.
  35416. */
  35417. readonly name: string;
  35418. /**
  35419. * The easing function used by animations
  35420. */
  35421. static EasingFunction: BackEase;
  35422. /**
  35423. * The easing mode used by animations
  35424. */
  35425. static EasingMode: number;
  35426. /**
  35427. * The duration of the animation, in milliseconds
  35428. */
  35429. transitionDuration: number;
  35430. /**
  35431. * Length of the distance animated by the transition when lower radius is reached
  35432. */
  35433. lowerRadiusTransitionRange: number;
  35434. /**
  35435. * Length of the distance animated by the transition when upper radius is reached
  35436. */
  35437. upperRadiusTransitionRange: number;
  35438. private _autoTransitionRange;
  35439. /**
  35440. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35441. */
  35442. /**
  35443. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35444. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35445. */
  35446. autoTransitionRange: boolean;
  35447. private _attachedCamera;
  35448. private _onAfterCheckInputsObserver;
  35449. private _onMeshTargetChangedObserver;
  35450. /**
  35451. * Initializes the behavior.
  35452. */
  35453. init(): void;
  35454. /**
  35455. * Attaches the behavior to its arc rotate camera.
  35456. * @param camera Defines the camera to attach the behavior to
  35457. */
  35458. attach(camera: ArcRotateCamera): void;
  35459. /**
  35460. * Detaches the behavior from its current arc rotate camera.
  35461. */
  35462. detach(): void;
  35463. private _radiusIsAnimating;
  35464. private _radiusBounceTransition;
  35465. private _animatables;
  35466. private _cachedWheelPrecision;
  35467. /**
  35468. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35469. * @param radiusLimit The limit to check against.
  35470. * @return Bool to indicate if at limit.
  35471. */
  35472. private _isRadiusAtLimit;
  35473. /**
  35474. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35475. * @param radiusDelta The delta by which to animate to. Can be negative.
  35476. */
  35477. private _applyBoundRadiusAnimation;
  35478. /**
  35479. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35480. */
  35481. protected _clearAnimationLocks(): void;
  35482. /**
  35483. * Stops and removes all animations that have been applied to the camera
  35484. */
  35485. stopAllAnimations(): void;
  35486. }
  35487. }
  35488. declare module BABYLON {
  35489. /**
  35490. * 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.
  35491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35492. */
  35493. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35494. /**
  35495. * Gets the name of the behavior.
  35496. */
  35497. readonly name: string;
  35498. private _mode;
  35499. private _radiusScale;
  35500. private _positionScale;
  35501. private _defaultElevation;
  35502. private _elevationReturnTime;
  35503. private _elevationReturnWaitTime;
  35504. private _zoomStopsAnimation;
  35505. private _framingTime;
  35506. /**
  35507. * The easing function used by animations
  35508. */
  35509. static EasingFunction: ExponentialEase;
  35510. /**
  35511. * The easing mode used by animations
  35512. */
  35513. static EasingMode: number;
  35514. /**
  35515. * Sets the current mode used by the behavior
  35516. */
  35517. /**
  35518. * Gets current mode used by the behavior.
  35519. */
  35520. mode: number;
  35521. /**
  35522. * Sets the scale applied to the radius (1 by default)
  35523. */
  35524. /**
  35525. * Gets the scale applied to the radius
  35526. */
  35527. radiusScale: number;
  35528. /**
  35529. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35530. */
  35531. /**
  35532. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35533. */
  35534. positionScale: number;
  35535. /**
  35536. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35537. * behaviour is triggered, in radians.
  35538. */
  35539. /**
  35540. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35541. * behaviour is triggered, in radians.
  35542. */
  35543. defaultElevation: number;
  35544. /**
  35545. * Sets the time (in milliseconds) taken to return to the default beta position.
  35546. * Negative value indicates camera should not return to default.
  35547. */
  35548. /**
  35549. * Gets the time (in milliseconds) taken to return to the default beta position.
  35550. * Negative value indicates camera should not return to default.
  35551. */
  35552. elevationReturnTime: number;
  35553. /**
  35554. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35555. */
  35556. /**
  35557. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35558. */
  35559. elevationReturnWaitTime: number;
  35560. /**
  35561. * Sets the flag that indicates if user zooming should stop animation.
  35562. */
  35563. /**
  35564. * Gets the flag that indicates if user zooming should stop animation.
  35565. */
  35566. zoomStopsAnimation: boolean;
  35567. /**
  35568. * Sets the transition time when framing the mesh, in milliseconds
  35569. */
  35570. /**
  35571. * Gets the transition time when framing the mesh, in milliseconds
  35572. */
  35573. framingTime: number;
  35574. /**
  35575. * Define if the behavior should automatically change the configured
  35576. * camera limits and sensibilities.
  35577. */
  35578. autoCorrectCameraLimitsAndSensibility: boolean;
  35579. private _onPrePointerObservableObserver;
  35580. private _onAfterCheckInputsObserver;
  35581. private _onMeshTargetChangedObserver;
  35582. private _attachedCamera;
  35583. private _isPointerDown;
  35584. private _lastInteractionTime;
  35585. /**
  35586. * Initializes the behavior.
  35587. */
  35588. init(): void;
  35589. /**
  35590. * Attaches the behavior to its arc rotate camera.
  35591. * @param camera Defines the camera to attach the behavior to
  35592. */
  35593. attach(camera: ArcRotateCamera): void;
  35594. /**
  35595. * Detaches the behavior from its current arc rotate camera.
  35596. */
  35597. detach(): void;
  35598. private _animatables;
  35599. private _betaIsAnimating;
  35600. private _betaTransition;
  35601. private _radiusTransition;
  35602. private _vectorTransition;
  35603. /**
  35604. * Targets the given mesh and updates zoom level accordingly.
  35605. * @param mesh The mesh to target.
  35606. * @param radius Optional. If a cached radius position already exists, overrides default.
  35607. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35610. */
  35611. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35612. /**
  35613. * Targets the given mesh with its children and updates zoom level accordingly.
  35614. * @param mesh The mesh to target.
  35615. * @param radius Optional. If a cached radius position already exists, overrides default.
  35616. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35619. */
  35620. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35621. /**
  35622. * Targets the given meshes with their children and updates zoom level accordingly.
  35623. * @param meshes The mesh to target.
  35624. * @param radius Optional. If a cached radius position already exists, overrides default.
  35625. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35626. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35627. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35628. */
  35629. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35630. /**
  35631. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35632. * @param minimumWorld Determines the smaller position of the bounding box extend
  35633. * @param maximumWorld Determines the bigger position of the bounding box extend
  35634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35636. */
  35637. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35638. /**
  35639. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35640. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35641. * frustum width.
  35642. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35643. * to fully enclose the mesh in the viewing frustum.
  35644. */
  35645. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35646. /**
  35647. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35648. * is automatically returned to its default position (expected to be above ground plane).
  35649. */
  35650. private _maintainCameraAboveGround;
  35651. /**
  35652. * Returns the frustum slope based on the canvas ratio and camera FOV
  35653. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35654. */
  35655. private _getFrustumSlope;
  35656. /**
  35657. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35658. */
  35659. private _clearAnimationLocks;
  35660. /**
  35661. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35662. */
  35663. private _applyUserInteraction;
  35664. /**
  35665. * Stops and removes all animations that have been applied to the camera
  35666. */
  35667. stopAllAnimations(): void;
  35668. /**
  35669. * Gets a value indicating if the user is moving the camera
  35670. */
  35671. readonly isUserIsMoving: boolean;
  35672. /**
  35673. * The camera can move all the way towards the mesh.
  35674. */
  35675. static IgnoreBoundsSizeMode: number;
  35676. /**
  35677. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35678. */
  35679. static FitFrustumSidesMode: number;
  35680. }
  35681. }
  35682. declare module BABYLON {
  35683. /**
  35684. * Base class for Camera Pointer Inputs.
  35685. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35686. * for example usage.
  35687. */
  35688. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35689. /**
  35690. * Defines the camera the input is attached to.
  35691. */
  35692. abstract camera: Camera;
  35693. /**
  35694. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35695. */
  35696. protected _altKey: boolean;
  35697. protected _ctrlKey: boolean;
  35698. protected _metaKey: boolean;
  35699. protected _shiftKey: boolean;
  35700. /**
  35701. * Which mouse buttons were pressed at time of last mouse event.
  35702. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35703. */
  35704. protected _buttonsPressed: number;
  35705. /**
  35706. * Defines the buttons associated with the input to handle camera move.
  35707. */
  35708. buttons: number[];
  35709. /**
  35710. * Attach the input controls to a specific dom element to get the input from.
  35711. * @param element Defines the element the controls should be listened from
  35712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35713. */
  35714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35715. /**
  35716. * Detach the current controls from the specified dom element.
  35717. * @param element Defines the element to stop listening the inputs from
  35718. */
  35719. detachControl(element: Nullable<HTMLElement>): void;
  35720. /**
  35721. * Gets the class name of the current input.
  35722. * @returns the class name
  35723. */
  35724. getClassName(): string;
  35725. /**
  35726. * Get the friendly name associated with the input class.
  35727. * @returns the input friendly name
  35728. */
  35729. getSimpleName(): string;
  35730. /**
  35731. * Called on pointer POINTERDOUBLETAP event.
  35732. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35733. */
  35734. protected onDoubleTap(type: string): void;
  35735. /**
  35736. * Called on pointer POINTERMOVE event if only a single touch is active.
  35737. * Override this method to provide functionality.
  35738. */
  35739. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35740. /**
  35741. * Called on pointer POINTERMOVE event if multiple touches are active.
  35742. * Override this method to provide functionality.
  35743. */
  35744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35745. /**
  35746. * Called on JS contextmenu event.
  35747. * Override this method to provide functionality.
  35748. */
  35749. protected onContextMenu(evt: PointerEvent): void;
  35750. /**
  35751. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35752. * press.
  35753. * Override this method to provide functionality.
  35754. */
  35755. protected onButtonDown(evt: PointerEvent): void;
  35756. /**
  35757. * Called each time a new POINTERUP event occurs. Ie, for each button
  35758. * release.
  35759. * Override this method to provide functionality.
  35760. */
  35761. protected onButtonUp(evt: PointerEvent): void;
  35762. /**
  35763. * Called when window becomes inactive.
  35764. * Override this method to provide functionality.
  35765. */
  35766. protected onLostFocus(): void;
  35767. private _pointerInput;
  35768. private _observer;
  35769. private _onLostFocus;
  35770. private pointA;
  35771. private pointB;
  35772. }
  35773. }
  35774. declare module BABYLON {
  35775. /**
  35776. * Manage the pointers inputs to control an arc rotate camera.
  35777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35778. */
  35779. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35780. /**
  35781. * Defines the camera the input is attached to.
  35782. */
  35783. camera: ArcRotateCamera;
  35784. /**
  35785. * Gets the class name of the current input.
  35786. * @returns the class name
  35787. */
  35788. getClassName(): string;
  35789. /**
  35790. * Defines the buttons associated with the input to handle camera move.
  35791. */
  35792. buttons: number[];
  35793. /**
  35794. * Defines the pointer angular sensibility along the X axis or how fast is
  35795. * the camera rotating.
  35796. */
  35797. angularSensibilityX: number;
  35798. /**
  35799. * Defines the pointer angular sensibility along the Y axis or how fast is
  35800. * the camera rotating.
  35801. */
  35802. angularSensibilityY: number;
  35803. /**
  35804. * Defines the pointer pinch precision or how fast is the camera zooming.
  35805. */
  35806. pinchPrecision: number;
  35807. /**
  35808. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35809. * from 0.
  35810. * It defines the percentage of current camera.radius to use as delta when
  35811. * pinch zoom is used.
  35812. */
  35813. pinchDeltaPercentage: number;
  35814. /**
  35815. * Defines the pointer panning sensibility or how fast is the camera moving.
  35816. */
  35817. panningSensibility: number;
  35818. /**
  35819. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35820. */
  35821. multiTouchPanning: boolean;
  35822. /**
  35823. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35824. * zoom (pinch) through multitouch.
  35825. */
  35826. multiTouchPanAndZoom: boolean;
  35827. /**
  35828. * Revers pinch action direction.
  35829. */
  35830. pinchInwards: boolean;
  35831. private _isPanClick;
  35832. private _twoFingerActivityCount;
  35833. private _isPinching;
  35834. /**
  35835. * Called on pointer POINTERMOVE event if only a single touch is active.
  35836. */
  35837. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35838. /**
  35839. * Called on pointer POINTERDOUBLETAP event.
  35840. */
  35841. protected onDoubleTap(type: string): void;
  35842. /**
  35843. * Called on pointer POINTERMOVE event if multiple touches are active.
  35844. */
  35845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35846. /**
  35847. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35848. * press.
  35849. */
  35850. protected onButtonDown(evt: PointerEvent): void;
  35851. /**
  35852. * Called each time a new POINTERUP event occurs. Ie, for each button
  35853. * release.
  35854. */
  35855. protected onButtonUp(evt: PointerEvent): void;
  35856. /**
  35857. * Called when window becomes inactive.
  35858. */
  35859. protected onLostFocus(): void;
  35860. }
  35861. }
  35862. declare module BABYLON {
  35863. /**
  35864. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35866. */
  35867. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35868. /**
  35869. * Defines the camera the input is attached to.
  35870. */
  35871. camera: ArcRotateCamera;
  35872. /**
  35873. * Defines the list of key codes associated with the up action (increase alpha)
  35874. */
  35875. keysUp: number[];
  35876. /**
  35877. * Defines the list of key codes associated with the down action (decrease alpha)
  35878. */
  35879. keysDown: number[];
  35880. /**
  35881. * Defines the list of key codes associated with the left action (increase beta)
  35882. */
  35883. keysLeft: number[];
  35884. /**
  35885. * Defines the list of key codes associated with the right action (decrease beta)
  35886. */
  35887. keysRight: number[];
  35888. /**
  35889. * Defines the list of key codes associated with the reset action.
  35890. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35891. */
  35892. keysReset: number[];
  35893. /**
  35894. * Defines the panning sensibility of the inputs.
  35895. * (How fast is the camera paning)
  35896. */
  35897. panningSensibility: number;
  35898. /**
  35899. * Defines the zooming sensibility of the inputs.
  35900. * (How fast is the camera zooming)
  35901. */
  35902. zoomingSensibility: number;
  35903. /**
  35904. * Defines wether maintaining the alt key down switch the movement mode from
  35905. * orientation to zoom.
  35906. */
  35907. useAltToZoom: boolean;
  35908. /**
  35909. * Rotation speed of the camera
  35910. */
  35911. angularSpeed: number;
  35912. private _keys;
  35913. private _ctrlPressed;
  35914. private _altPressed;
  35915. private _onCanvasBlurObserver;
  35916. private _onKeyboardObserver;
  35917. private _engine;
  35918. private _scene;
  35919. /**
  35920. * Attach the input controls to a specific dom element to get the input from.
  35921. * @param element Defines the element the controls should be listened from
  35922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35923. */
  35924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35925. /**
  35926. * Detach the current controls from the specified dom element.
  35927. * @param element Defines the element to stop listening the inputs from
  35928. */
  35929. detachControl(element: Nullable<HTMLElement>): void;
  35930. /**
  35931. * Update the current camera state depending on the inputs that have been used this frame.
  35932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35933. */
  35934. checkInputs(): void;
  35935. /**
  35936. * Gets the class name of the current intput.
  35937. * @returns the class name
  35938. */
  35939. getClassName(): string;
  35940. /**
  35941. * Get the friendly name associated with the input class.
  35942. * @returns the input friendly name
  35943. */
  35944. getSimpleName(): string;
  35945. }
  35946. }
  35947. declare module BABYLON {
  35948. /**
  35949. * Manage the mouse wheel inputs to control an arc rotate camera.
  35950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35951. */
  35952. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35953. /**
  35954. * Defines the camera the input is attached to.
  35955. */
  35956. camera: ArcRotateCamera;
  35957. /**
  35958. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35959. */
  35960. wheelPrecision: number;
  35961. /**
  35962. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35963. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35964. */
  35965. wheelDeltaPercentage: number;
  35966. private _wheel;
  35967. private _observer;
  35968. private computeDeltaFromMouseWheelLegacyEvent;
  35969. /**
  35970. * Attach the input controls to a specific dom element to get the input from.
  35971. * @param element Defines the element the controls should be listened from
  35972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35973. */
  35974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35975. /**
  35976. * Detach the current controls from the specified dom element.
  35977. * @param element Defines the element to stop listening the inputs from
  35978. */
  35979. detachControl(element: Nullable<HTMLElement>): void;
  35980. /**
  35981. * Gets the class name of the current intput.
  35982. * @returns the class name
  35983. */
  35984. getClassName(): string;
  35985. /**
  35986. * Get the friendly name associated with the input class.
  35987. * @returns the input friendly name
  35988. */
  35989. getSimpleName(): string;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * Default Inputs manager for the ArcRotateCamera.
  35995. * It groups all the default supported inputs for ease of use.
  35996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35997. */
  35998. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35999. /**
  36000. * Instantiates a new ArcRotateCameraInputsManager.
  36001. * @param camera Defines the camera the inputs belong to
  36002. */
  36003. constructor(camera: ArcRotateCamera);
  36004. /**
  36005. * Add mouse wheel input support to the input manager.
  36006. * @returns the current input manager
  36007. */
  36008. addMouseWheel(): ArcRotateCameraInputsManager;
  36009. /**
  36010. * Add pointers input support to the input manager.
  36011. * @returns the current input manager
  36012. */
  36013. addPointers(): ArcRotateCameraInputsManager;
  36014. /**
  36015. * Add keyboard input support to the input manager.
  36016. * @returns the current input manager
  36017. */
  36018. addKeyboard(): ArcRotateCameraInputsManager;
  36019. }
  36020. }
  36021. declare module BABYLON {
  36022. /**
  36023. * This represents an orbital type of camera.
  36024. *
  36025. * 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.
  36026. * 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.
  36027. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36028. */
  36029. export class ArcRotateCamera extends TargetCamera {
  36030. /**
  36031. * Defines the rotation angle of the camera along the longitudinal axis.
  36032. */
  36033. alpha: number;
  36034. /**
  36035. * Defines the rotation angle of the camera along the latitudinal axis.
  36036. */
  36037. beta: number;
  36038. /**
  36039. * Defines the radius of the camera from it s target point.
  36040. */
  36041. radius: number;
  36042. protected _target: Vector3;
  36043. protected _targetHost: Nullable<AbstractMesh>;
  36044. /**
  36045. * Defines the target point of the camera.
  36046. * The camera looks towards it form the radius distance.
  36047. */
  36048. target: Vector3;
  36049. /**
  36050. * Define the current local position of the camera in the scene
  36051. */
  36052. position: Vector3;
  36053. protected _upVector: Vector3;
  36054. protected _upToYMatrix: Matrix;
  36055. protected _YToUpMatrix: Matrix;
  36056. /**
  36057. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36058. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36059. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36060. */
  36061. upVector: Vector3;
  36062. /**
  36063. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36064. */
  36065. setMatUp(): void;
  36066. /**
  36067. * Current inertia value on the longitudinal axis.
  36068. * The bigger this number the longer it will take for the camera to stop.
  36069. */
  36070. inertialAlphaOffset: number;
  36071. /**
  36072. * Current inertia value on the latitudinal axis.
  36073. * The bigger this number the longer it will take for the camera to stop.
  36074. */
  36075. inertialBetaOffset: number;
  36076. /**
  36077. * Current inertia value on the radius axis.
  36078. * The bigger this number the longer it will take for the camera to stop.
  36079. */
  36080. inertialRadiusOffset: number;
  36081. /**
  36082. * Minimum allowed angle on the longitudinal axis.
  36083. * This can help limiting how the Camera is able to move in the scene.
  36084. */
  36085. lowerAlphaLimit: Nullable<number>;
  36086. /**
  36087. * Maximum allowed angle on the longitudinal axis.
  36088. * This can help limiting how the Camera is able to move in the scene.
  36089. */
  36090. upperAlphaLimit: Nullable<number>;
  36091. /**
  36092. * Minimum allowed angle on the latitudinal axis.
  36093. * This can help limiting how the Camera is able to move in the scene.
  36094. */
  36095. lowerBetaLimit: number;
  36096. /**
  36097. * Maximum allowed angle on the latitudinal axis.
  36098. * This can help limiting how the Camera is able to move in the scene.
  36099. */
  36100. upperBetaLimit: number;
  36101. /**
  36102. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36103. * This can help limiting how the Camera is able to move in the scene.
  36104. */
  36105. lowerRadiusLimit: Nullable<number>;
  36106. /**
  36107. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36108. * This can help limiting how the Camera is able to move in the scene.
  36109. */
  36110. upperRadiusLimit: Nullable<number>;
  36111. /**
  36112. * Defines the current inertia value used during panning of the camera along the X axis.
  36113. */
  36114. inertialPanningX: number;
  36115. /**
  36116. * Defines the current inertia value used during panning of the camera along the Y axis.
  36117. */
  36118. inertialPanningY: number;
  36119. /**
  36120. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36121. * Basically if your fingers moves away from more than this distance you will be considered
  36122. * in pinch mode.
  36123. */
  36124. pinchToPanMaxDistance: number;
  36125. /**
  36126. * Defines the maximum distance the camera can pan.
  36127. * This could help keeping the cammera always in your scene.
  36128. */
  36129. panningDistanceLimit: Nullable<number>;
  36130. /**
  36131. * Defines the target of the camera before paning.
  36132. */
  36133. panningOriginTarget: Vector3;
  36134. /**
  36135. * Defines the value of the inertia used during panning.
  36136. * 0 would mean stop inertia and one would mean no decelleration at all.
  36137. */
  36138. panningInertia: number;
  36139. /**
  36140. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36141. */
  36142. angularSensibilityX: number;
  36143. /**
  36144. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36145. */
  36146. angularSensibilityY: number;
  36147. /**
  36148. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36149. */
  36150. pinchPrecision: number;
  36151. /**
  36152. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36153. * It will be used instead of pinchDeltaPrecision if different from 0.
  36154. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36155. */
  36156. pinchDeltaPercentage: number;
  36157. /**
  36158. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36159. */
  36160. panningSensibility: number;
  36161. /**
  36162. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36163. */
  36164. keysUp: number[];
  36165. /**
  36166. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36167. */
  36168. keysDown: number[];
  36169. /**
  36170. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36171. */
  36172. keysLeft: number[];
  36173. /**
  36174. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36175. */
  36176. keysRight: number[];
  36177. /**
  36178. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36179. */
  36180. wheelPrecision: number;
  36181. /**
  36182. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36183. * It will be used instead of pinchDeltaPrecision if different from 0.
  36184. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36185. */
  36186. wheelDeltaPercentage: number;
  36187. /**
  36188. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36189. */
  36190. zoomOnFactor: number;
  36191. /**
  36192. * Defines a screen offset for the camera position.
  36193. */
  36194. targetScreenOffset: Vector2;
  36195. /**
  36196. * Allows the camera to be completely reversed.
  36197. * If false the camera can not arrive upside down.
  36198. */
  36199. allowUpsideDown: boolean;
  36200. /**
  36201. * Define if double tap/click is used to restore the previously saved state of the camera.
  36202. */
  36203. useInputToRestoreState: boolean;
  36204. /** @hidden */
  36205. _viewMatrix: Matrix;
  36206. /** @hidden */
  36207. _useCtrlForPanning: boolean;
  36208. /** @hidden */
  36209. _panningMouseButton: number;
  36210. /**
  36211. * Defines the input associated to the camera.
  36212. */
  36213. inputs: ArcRotateCameraInputsManager;
  36214. /** @hidden */
  36215. _reset: () => void;
  36216. /**
  36217. * Defines the allowed panning axis.
  36218. */
  36219. panningAxis: Vector3;
  36220. protected _localDirection: Vector3;
  36221. protected _transformedDirection: Vector3;
  36222. private _bouncingBehavior;
  36223. /**
  36224. * Gets the bouncing behavior of the camera if it has been enabled.
  36225. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36226. */
  36227. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36228. /**
  36229. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36230. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36231. */
  36232. useBouncingBehavior: boolean;
  36233. private _framingBehavior;
  36234. /**
  36235. * Gets the framing behavior of the camera if it has been enabled.
  36236. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36237. */
  36238. readonly framingBehavior: Nullable<FramingBehavior>;
  36239. /**
  36240. * Defines if the framing behavior of the camera is enabled on the camera.
  36241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36242. */
  36243. useFramingBehavior: boolean;
  36244. private _autoRotationBehavior;
  36245. /**
  36246. * Gets the auto rotation behavior of the camera if it has been enabled.
  36247. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36248. */
  36249. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36250. /**
  36251. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36253. */
  36254. useAutoRotationBehavior: boolean;
  36255. /**
  36256. * Observable triggered when the mesh target has been changed on the camera.
  36257. */
  36258. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36259. /**
  36260. * Event raised when the camera is colliding with a mesh.
  36261. */
  36262. onCollide: (collidedMesh: AbstractMesh) => void;
  36263. /**
  36264. * Defines whether the camera should check collision with the objects oh the scene.
  36265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36266. */
  36267. checkCollisions: boolean;
  36268. /**
  36269. * Defines the collision radius of the camera.
  36270. * This simulates a sphere around the camera.
  36271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36272. */
  36273. collisionRadius: Vector3;
  36274. protected _collider: Collider;
  36275. protected _previousPosition: Vector3;
  36276. protected _collisionVelocity: Vector3;
  36277. protected _newPosition: Vector3;
  36278. protected _previousAlpha: number;
  36279. protected _previousBeta: number;
  36280. protected _previousRadius: number;
  36281. protected _collisionTriggered: boolean;
  36282. protected _targetBoundingCenter: Nullable<Vector3>;
  36283. private _computationVector;
  36284. /**
  36285. * Instantiates a new ArcRotateCamera in a given scene
  36286. * @param name Defines the name of the camera
  36287. * @param alpha Defines the camera rotation along the logitudinal axis
  36288. * @param beta Defines the camera rotation along the latitudinal axis
  36289. * @param radius Defines the camera distance from its target
  36290. * @param target Defines the camera target
  36291. * @param scene Defines the scene the camera belongs to
  36292. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36293. */
  36294. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36295. /** @hidden */
  36296. _initCache(): void;
  36297. /** @hidden */
  36298. _updateCache(ignoreParentClass?: boolean): void;
  36299. protected _getTargetPosition(): Vector3;
  36300. private _storedAlpha;
  36301. private _storedBeta;
  36302. private _storedRadius;
  36303. private _storedTarget;
  36304. private _storedTargetScreenOffset;
  36305. /**
  36306. * Stores the current state of the camera (alpha, beta, radius and target)
  36307. * @returns the camera itself
  36308. */
  36309. storeState(): Camera;
  36310. /**
  36311. * @hidden
  36312. * Restored camera state. You must call storeState() first
  36313. */
  36314. _restoreStateValues(): boolean;
  36315. /** @hidden */
  36316. _isSynchronizedViewMatrix(): boolean;
  36317. /**
  36318. * Attached controls to the current camera.
  36319. * @param element Defines the element the controls should be listened from
  36320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36321. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36322. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36323. */
  36324. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36325. /**
  36326. * Detach the current controls from the camera.
  36327. * The camera will stop reacting to inputs.
  36328. * @param element Defines the element to stop listening the inputs from
  36329. */
  36330. detachControl(element: HTMLElement): void;
  36331. /** @hidden */
  36332. _checkInputs(): void;
  36333. protected _checkLimits(): void;
  36334. /**
  36335. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36336. */
  36337. rebuildAnglesAndRadius(): void;
  36338. /**
  36339. * Use a position to define the current camera related information like aplha, beta and radius
  36340. * @param position Defines the position to set the camera at
  36341. */
  36342. setPosition(position: Vector3): void;
  36343. /**
  36344. * Defines the target the camera should look at.
  36345. * This will automatically adapt alpha beta and radius to fit within the new target.
  36346. * @param target Defines the new target as a Vector or a mesh
  36347. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36348. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36349. */
  36350. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36351. /** @hidden */
  36352. _getViewMatrix(): Matrix;
  36353. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36354. /**
  36355. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36356. * @param meshes Defines the mesh to zoom on
  36357. * @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)
  36358. */
  36359. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36360. /**
  36361. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36362. * The target will be changed but the radius
  36363. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36364. * @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)
  36365. */
  36366. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36367. min: Vector3;
  36368. max: Vector3;
  36369. distance: number;
  36370. }, doNotUpdateMaxZ?: boolean): void;
  36371. /**
  36372. * @override
  36373. * Override Camera.createRigCamera
  36374. */
  36375. createRigCamera(name: string, cameraIndex: number): Camera;
  36376. /**
  36377. * @hidden
  36378. * @override
  36379. * Override Camera._updateRigCameras
  36380. */
  36381. _updateRigCameras(): void;
  36382. /**
  36383. * Destroy the camera and release the current resources hold by it.
  36384. */
  36385. dispose(): void;
  36386. /**
  36387. * Gets the current object class name.
  36388. * @return the class name
  36389. */
  36390. getClassName(): string;
  36391. }
  36392. }
  36393. declare module BABYLON {
  36394. /**
  36395. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36397. */
  36398. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36399. /**
  36400. * Gets the name of the behavior.
  36401. */
  36402. readonly name: string;
  36403. private _zoomStopsAnimation;
  36404. private _idleRotationSpeed;
  36405. private _idleRotationWaitTime;
  36406. private _idleRotationSpinupTime;
  36407. /**
  36408. * Sets the flag that indicates if user zooming should stop animation.
  36409. */
  36410. /**
  36411. * Gets the flag that indicates if user zooming should stop animation.
  36412. */
  36413. zoomStopsAnimation: boolean;
  36414. /**
  36415. * Sets the default speed at which the camera rotates around the model.
  36416. */
  36417. /**
  36418. * Gets the default speed at which the camera rotates around the model.
  36419. */
  36420. idleRotationSpeed: number;
  36421. /**
  36422. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36423. */
  36424. /**
  36425. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36426. */
  36427. idleRotationWaitTime: number;
  36428. /**
  36429. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36430. */
  36431. /**
  36432. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36433. */
  36434. idleRotationSpinupTime: number;
  36435. /**
  36436. * Gets a value indicating if the camera is currently rotating because of this behavior
  36437. */
  36438. readonly rotationInProgress: boolean;
  36439. private _onPrePointerObservableObserver;
  36440. private _onAfterCheckInputsObserver;
  36441. private _attachedCamera;
  36442. private _isPointerDown;
  36443. private _lastFrameTime;
  36444. private _lastInteractionTime;
  36445. private _cameraRotationSpeed;
  36446. /**
  36447. * Initializes the behavior.
  36448. */
  36449. init(): void;
  36450. /**
  36451. * Attaches the behavior to its arc rotate camera.
  36452. * @param camera Defines the camera to attach the behavior to
  36453. */
  36454. attach(camera: ArcRotateCamera): void;
  36455. /**
  36456. * Detaches the behavior from its current arc rotate camera.
  36457. */
  36458. detach(): void;
  36459. /**
  36460. * Returns true if user is scrolling.
  36461. * @return true if user is scrolling.
  36462. */
  36463. private _userIsZooming;
  36464. private _lastFrameRadius;
  36465. private _shouldAnimationStopForInteraction;
  36466. /**
  36467. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36468. */
  36469. private _applyUserInteraction;
  36470. private _userIsMoving;
  36471. }
  36472. }
  36473. declare module BABYLON {
  36474. /**
  36475. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36476. */
  36477. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36478. private ui;
  36479. /**
  36480. * The name of the behavior
  36481. */
  36482. name: string;
  36483. /**
  36484. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36485. */
  36486. distanceAwayFromFace: number;
  36487. /**
  36488. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36489. */
  36490. distanceAwayFromBottomOfFace: number;
  36491. private _faceVectors;
  36492. private _target;
  36493. private _scene;
  36494. private _onRenderObserver;
  36495. private _tmpMatrix;
  36496. private _tmpVector;
  36497. /**
  36498. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36499. * @param ui The transform node that should be attched to the mesh
  36500. */
  36501. constructor(ui: TransformNode);
  36502. /**
  36503. * Initializes the behavior
  36504. */
  36505. init(): void;
  36506. private _closestFace;
  36507. private _zeroVector;
  36508. private _lookAtTmpMatrix;
  36509. private _lookAtToRef;
  36510. /**
  36511. * Attaches the AttachToBoxBehavior to the passed in mesh
  36512. * @param target The mesh that the specified node will be attached to
  36513. */
  36514. attach(target: Mesh): void;
  36515. /**
  36516. * Detaches the behavior from the mesh
  36517. */
  36518. detach(): void;
  36519. }
  36520. }
  36521. declare module BABYLON {
  36522. /**
  36523. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36524. */
  36525. export class FadeInOutBehavior implements Behavior<Mesh> {
  36526. /**
  36527. * Time in milliseconds to delay before fading in (Default: 0)
  36528. */
  36529. delay: number;
  36530. /**
  36531. * Time in milliseconds for the mesh to fade in (Default: 300)
  36532. */
  36533. fadeInTime: number;
  36534. private _millisecondsPerFrame;
  36535. private _hovered;
  36536. private _hoverValue;
  36537. private _ownerNode;
  36538. /**
  36539. * Instatiates the FadeInOutBehavior
  36540. */
  36541. constructor();
  36542. /**
  36543. * The name of the behavior
  36544. */
  36545. readonly name: string;
  36546. /**
  36547. * Initializes the behavior
  36548. */
  36549. init(): void;
  36550. /**
  36551. * Attaches the fade behavior on the passed in mesh
  36552. * @param ownerNode The mesh that will be faded in/out once attached
  36553. */
  36554. attach(ownerNode: Mesh): void;
  36555. /**
  36556. * Detaches the behavior from the mesh
  36557. */
  36558. detach(): void;
  36559. /**
  36560. * Triggers the mesh to begin fading in or out
  36561. * @param value if the object should fade in or out (true to fade in)
  36562. */
  36563. fadeIn(value: boolean): void;
  36564. private _update;
  36565. private _setAllVisibility;
  36566. }
  36567. }
  36568. declare module BABYLON {
  36569. /**
  36570. * Class containing a set of static utilities functions for managing Pivots
  36571. * @hidden
  36572. */
  36573. export class PivotTools {
  36574. private static _PivotCached;
  36575. private static _OldPivotPoint;
  36576. private static _PivotTranslation;
  36577. private static _PivotTmpVector;
  36578. /** @hidden */
  36579. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36580. /** @hidden */
  36581. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36582. }
  36583. }
  36584. declare module BABYLON {
  36585. /**
  36586. * Class containing static functions to help procedurally build meshes
  36587. */
  36588. export class PlaneBuilder {
  36589. /**
  36590. * Creates a plane mesh
  36591. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36592. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36593. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36595. * * 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
  36596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36597. * @param name defines the name of the mesh
  36598. * @param options defines the options used to create the mesh
  36599. * @param scene defines the hosting scene
  36600. * @returns the plane mesh
  36601. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36602. */
  36603. static CreatePlane(name: string, options: {
  36604. size?: number;
  36605. width?: number;
  36606. height?: number;
  36607. sideOrientation?: number;
  36608. frontUVs?: Vector4;
  36609. backUVs?: Vector4;
  36610. updatable?: boolean;
  36611. sourcePlane?: Plane;
  36612. }, scene?: Nullable<Scene>): Mesh;
  36613. }
  36614. }
  36615. declare module BABYLON {
  36616. /**
  36617. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36618. */
  36619. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36620. private static _AnyMouseID;
  36621. /**
  36622. * Abstract mesh the behavior is set on
  36623. */
  36624. attachedNode: AbstractMesh;
  36625. private _dragPlane;
  36626. private _scene;
  36627. private _pointerObserver;
  36628. private _beforeRenderObserver;
  36629. private static _planeScene;
  36630. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36631. /**
  36632. * 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)
  36633. */
  36634. maxDragAngle: number;
  36635. /**
  36636. * @hidden
  36637. */
  36638. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36639. /**
  36640. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36641. */
  36642. currentDraggingPointerID: number;
  36643. /**
  36644. * The last position where the pointer hit the drag plane in world space
  36645. */
  36646. lastDragPosition: Vector3;
  36647. /**
  36648. * If the behavior is currently in a dragging state
  36649. */
  36650. dragging: boolean;
  36651. /**
  36652. * 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)
  36653. */
  36654. dragDeltaRatio: number;
  36655. /**
  36656. * If the drag plane orientation should be updated during the dragging (Default: true)
  36657. */
  36658. updateDragPlane: boolean;
  36659. private _debugMode;
  36660. private _moving;
  36661. /**
  36662. * Fires each time the attached mesh is dragged with the pointer
  36663. * * delta between last drag position and current drag position in world space
  36664. * * dragDistance along the drag axis
  36665. * * dragPlaneNormal normal of the current drag plane used during the drag
  36666. * * dragPlanePoint in world space where the drag intersects the drag plane
  36667. */
  36668. onDragObservable: Observable<{
  36669. delta: Vector3;
  36670. dragPlanePoint: Vector3;
  36671. dragPlaneNormal: Vector3;
  36672. dragDistance: number;
  36673. pointerId: number;
  36674. }>;
  36675. /**
  36676. * Fires each time a drag begins (eg. mouse down on mesh)
  36677. */
  36678. onDragStartObservable: Observable<{
  36679. dragPlanePoint: Vector3;
  36680. pointerId: number;
  36681. }>;
  36682. /**
  36683. * Fires each time a drag ends (eg. mouse release after drag)
  36684. */
  36685. onDragEndObservable: Observable<{
  36686. dragPlanePoint: Vector3;
  36687. pointerId: number;
  36688. }>;
  36689. /**
  36690. * If the attached mesh should be moved when dragged
  36691. */
  36692. moveAttached: boolean;
  36693. /**
  36694. * If the drag behavior will react to drag events (Default: true)
  36695. */
  36696. enabled: boolean;
  36697. /**
  36698. * If pointer events should start and release the drag (Default: true)
  36699. */
  36700. startAndReleaseDragOnPointerEvents: boolean;
  36701. /**
  36702. * If camera controls should be detached during the drag
  36703. */
  36704. detachCameraControls: boolean;
  36705. /**
  36706. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36707. */
  36708. useObjectOrienationForDragging: boolean;
  36709. private _options;
  36710. /**
  36711. * Creates a pointer drag behavior that can be attached to a mesh
  36712. * @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)
  36713. */
  36714. constructor(options?: {
  36715. dragAxis?: Vector3;
  36716. dragPlaneNormal?: Vector3;
  36717. });
  36718. /**
  36719. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36720. */
  36721. validateDrag: (targetPosition: Vector3) => boolean;
  36722. /**
  36723. * The name of the behavior
  36724. */
  36725. readonly name: string;
  36726. /**
  36727. * Initializes the behavior
  36728. */
  36729. init(): void;
  36730. private _tmpVector;
  36731. private _alternatePickedPoint;
  36732. private _worldDragAxis;
  36733. private _targetPosition;
  36734. private _attachedElement;
  36735. /**
  36736. * Attaches the drag behavior the passed in mesh
  36737. * @param ownerNode The mesh that will be dragged around once attached
  36738. */
  36739. attach(ownerNode: AbstractMesh): void;
  36740. /**
  36741. * Force relase the drag action by code.
  36742. */
  36743. releaseDrag(): void;
  36744. private _startDragRay;
  36745. private _lastPointerRay;
  36746. /**
  36747. * Simulates the start of a pointer drag event on the behavior
  36748. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36749. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36750. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36751. */
  36752. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36753. private _startDrag;
  36754. private _dragDelta;
  36755. private _moveDrag;
  36756. private _pickWithRayOnDragPlane;
  36757. private _pointA;
  36758. private _pointB;
  36759. private _pointC;
  36760. private _lineA;
  36761. private _lineB;
  36762. private _localAxis;
  36763. private _lookAt;
  36764. private _updateDragPlanePosition;
  36765. /**
  36766. * Detaches the behavior from the mesh
  36767. */
  36768. detach(): void;
  36769. }
  36770. }
  36771. declare module BABYLON {
  36772. /**
  36773. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36774. */
  36775. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36776. private _dragBehaviorA;
  36777. private _dragBehaviorB;
  36778. private _startDistance;
  36779. private _initialScale;
  36780. private _targetScale;
  36781. private _ownerNode;
  36782. private _sceneRenderObserver;
  36783. /**
  36784. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36785. */
  36786. constructor();
  36787. /**
  36788. * The name of the behavior
  36789. */
  36790. readonly name: string;
  36791. /**
  36792. * Initializes the behavior
  36793. */
  36794. init(): void;
  36795. private _getCurrentDistance;
  36796. /**
  36797. * Attaches the scale behavior the passed in mesh
  36798. * @param ownerNode The mesh that will be scaled around once attached
  36799. */
  36800. attach(ownerNode: Mesh): void;
  36801. /**
  36802. * Detaches the behavior from the mesh
  36803. */
  36804. detach(): void;
  36805. }
  36806. }
  36807. declare module BABYLON {
  36808. /**
  36809. * 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
  36810. */
  36811. export class SixDofDragBehavior implements Behavior<Mesh> {
  36812. private static _virtualScene;
  36813. private _ownerNode;
  36814. private _sceneRenderObserver;
  36815. private _scene;
  36816. private _targetPosition;
  36817. private _virtualOriginMesh;
  36818. private _virtualDragMesh;
  36819. private _pointerObserver;
  36820. private _moving;
  36821. private _startingOrientation;
  36822. /**
  36823. * 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)
  36824. */
  36825. private zDragFactor;
  36826. /**
  36827. * If the object should rotate to face the drag origin
  36828. */
  36829. rotateDraggedObject: boolean;
  36830. /**
  36831. * If the behavior is currently in a dragging state
  36832. */
  36833. dragging: boolean;
  36834. /**
  36835. * 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)
  36836. */
  36837. dragDeltaRatio: number;
  36838. /**
  36839. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36840. */
  36841. currentDraggingPointerID: number;
  36842. /**
  36843. * If camera controls should be detached during the drag
  36844. */
  36845. detachCameraControls: boolean;
  36846. /**
  36847. * Fires each time a drag starts
  36848. */
  36849. onDragStartObservable: Observable<{}>;
  36850. /**
  36851. * Fires each time a drag ends (eg. mouse release after drag)
  36852. */
  36853. onDragEndObservable: Observable<{}>;
  36854. /**
  36855. * 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
  36856. */
  36857. constructor();
  36858. /**
  36859. * The name of the behavior
  36860. */
  36861. readonly name: string;
  36862. /**
  36863. * Initializes the behavior
  36864. */
  36865. init(): void;
  36866. /**
  36867. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36868. */
  36869. private readonly _pointerCamera;
  36870. /**
  36871. * Attaches the scale behavior the passed in mesh
  36872. * @param ownerNode The mesh that will be scaled around once attached
  36873. */
  36874. attach(ownerNode: Mesh): void;
  36875. /**
  36876. * Detaches the behavior from the mesh
  36877. */
  36878. detach(): void;
  36879. }
  36880. }
  36881. declare module BABYLON {
  36882. /**
  36883. * Class used to apply inverse kinematics to bones
  36884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36885. */
  36886. export class BoneIKController {
  36887. private static _tmpVecs;
  36888. private static _tmpQuat;
  36889. private static _tmpMats;
  36890. /**
  36891. * Gets or sets the target mesh
  36892. */
  36893. targetMesh: AbstractMesh;
  36894. /** Gets or sets the mesh used as pole */
  36895. poleTargetMesh: AbstractMesh;
  36896. /**
  36897. * Gets or sets the bone used as pole
  36898. */
  36899. poleTargetBone: Nullable<Bone>;
  36900. /**
  36901. * Gets or sets the target position
  36902. */
  36903. targetPosition: Vector3;
  36904. /**
  36905. * Gets or sets the pole target position
  36906. */
  36907. poleTargetPosition: Vector3;
  36908. /**
  36909. * Gets or sets the pole target local offset
  36910. */
  36911. poleTargetLocalOffset: Vector3;
  36912. /**
  36913. * Gets or sets the pole angle
  36914. */
  36915. poleAngle: number;
  36916. /**
  36917. * Gets or sets the mesh associated with the controller
  36918. */
  36919. mesh: AbstractMesh;
  36920. /**
  36921. * 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)
  36922. */
  36923. slerpAmount: number;
  36924. private _bone1Quat;
  36925. private _bone1Mat;
  36926. private _bone2Ang;
  36927. private _bone1;
  36928. private _bone2;
  36929. private _bone1Length;
  36930. private _bone2Length;
  36931. private _maxAngle;
  36932. private _maxReach;
  36933. private _rightHandedSystem;
  36934. private _bendAxis;
  36935. private _slerping;
  36936. private _adjustRoll;
  36937. /**
  36938. * Gets or sets maximum allowed angle
  36939. */
  36940. maxAngle: number;
  36941. /**
  36942. * Creates a new BoneIKController
  36943. * @param mesh defines the mesh to control
  36944. * @param bone defines the bone to control
  36945. * @param options defines options to set up the controller
  36946. */
  36947. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36948. targetMesh?: AbstractMesh;
  36949. poleTargetMesh?: AbstractMesh;
  36950. poleTargetBone?: Bone;
  36951. poleTargetLocalOffset?: Vector3;
  36952. poleAngle?: number;
  36953. bendAxis?: Vector3;
  36954. maxAngle?: number;
  36955. slerpAmount?: number;
  36956. });
  36957. private _setMaxAngle;
  36958. /**
  36959. * Force the controller to update the bones
  36960. */
  36961. update(): void;
  36962. }
  36963. }
  36964. declare module BABYLON {
  36965. /**
  36966. * Class used to make a bone look toward a point in space
  36967. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36968. */
  36969. export class BoneLookController {
  36970. private static _tmpVecs;
  36971. private static _tmpQuat;
  36972. private static _tmpMats;
  36973. /**
  36974. * The target Vector3 that the bone will look at
  36975. */
  36976. target: Vector3;
  36977. /**
  36978. * The mesh that the bone is attached to
  36979. */
  36980. mesh: AbstractMesh;
  36981. /**
  36982. * The bone that will be looking to the target
  36983. */
  36984. bone: Bone;
  36985. /**
  36986. * The up axis of the coordinate system that is used when the bone is rotated
  36987. */
  36988. upAxis: Vector3;
  36989. /**
  36990. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36991. */
  36992. upAxisSpace: Space;
  36993. /**
  36994. * Used to make an adjustment to the yaw of the bone
  36995. */
  36996. adjustYaw: number;
  36997. /**
  36998. * Used to make an adjustment to the pitch of the bone
  36999. */
  37000. adjustPitch: number;
  37001. /**
  37002. * Used to make an adjustment to the roll of the bone
  37003. */
  37004. adjustRoll: number;
  37005. /**
  37006. * 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)
  37007. */
  37008. slerpAmount: number;
  37009. private _minYaw;
  37010. private _maxYaw;
  37011. private _minPitch;
  37012. private _maxPitch;
  37013. private _minYawSin;
  37014. private _minYawCos;
  37015. private _maxYawSin;
  37016. private _maxYawCos;
  37017. private _midYawConstraint;
  37018. private _minPitchTan;
  37019. private _maxPitchTan;
  37020. private _boneQuat;
  37021. private _slerping;
  37022. private _transformYawPitch;
  37023. private _transformYawPitchInv;
  37024. private _firstFrameSkipped;
  37025. private _yawRange;
  37026. private _fowardAxis;
  37027. /**
  37028. * Gets or sets the minimum yaw angle that the bone can look to
  37029. */
  37030. minYaw: number;
  37031. /**
  37032. * Gets or sets the maximum yaw angle that the bone can look to
  37033. */
  37034. maxYaw: number;
  37035. /**
  37036. * Gets or sets the minimum pitch angle that the bone can look to
  37037. */
  37038. minPitch: number;
  37039. /**
  37040. * Gets or sets the maximum pitch angle that the bone can look to
  37041. */
  37042. maxPitch: number;
  37043. /**
  37044. * Create a BoneLookController
  37045. * @param mesh the mesh that the bone belongs to
  37046. * @param bone the bone that will be looking to the target
  37047. * @param target the target Vector3 to look at
  37048. * @param options optional settings:
  37049. * * maxYaw: the maximum angle the bone will yaw to
  37050. * * minYaw: the minimum angle the bone will yaw to
  37051. * * maxPitch: the maximum angle the bone will pitch to
  37052. * * minPitch: the minimum angle the bone will yaw to
  37053. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37054. * * upAxis: the up axis of the coordinate system
  37055. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37056. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37057. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37058. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37059. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37060. * * adjustRoll: used to make an adjustment to the roll of the bone
  37061. **/
  37062. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37063. maxYaw?: number;
  37064. minYaw?: number;
  37065. maxPitch?: number;
  37066. minPitch?: number;
  37067. slerpAmount?: number;
  37068. upAxis?: Vector3;
  37069. upAxisSpace?: Space;
  37070. yawAxis?: Vector3;
  37071. pitchAxis?: Vector3;
  37072. adjustYaw?: number;
  37073. adjustPitch?: number;
  37074. adjustRoll?: number;
  37075. });
  37076. /**
  37077. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37078. */
  37079. update(): void;
  37080. private _getAngleDiff;
  37081. private _getAngleBetween;
  37082. private _isAngleBetween;
  37083. }
  37084. }
  37085. declare module BABYLON {
  37086. /**
  37087. * Manage the gamepad inputs to control an arc rotate camera.
  37088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37089. */
  37090. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37091. /**
  37092. * Defines the camera the input is attached to.
  37093. */
  37094. camera: ArcRotateCamera;
  37095. /**
  37096. * Defines the gamepad the input is gathering event from.
  37097. */
  37098. gamepad: Nullable<Gamepad>;
  37099. /**
  37100. * Defines the gamepad rotation sensiblity.
  37101. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37102. */
  37103. gamepadRotationSensibility: number;
  37104. /**
  37105. * Defines the gamepad move sensiblity.
  37106. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37107. */
  37108. gamepadMoveSensibility: number;
  37109. private _onGamepadConnectedObserver;
  37110. private _onGamepadDisconnectedObserver;
  37111. /**
  37112. * Attach the input controls to a specific dom element to get the input from.
  37113. * @param element Defines the element the controls should be listened from
  37114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37115. */
  37116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37117. /**
  37118. * Detach the current controls from the specified dom element.
  37119. * @param element Defines the element to stop listening the inputs from
  37120. */
  37121. detachControl(element: Nullable<HTMLElement>): void;
  37122. /**
  37123. * Update the current camera state depending on the inputs that have been used this frame.
  37124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37125. */
  37126. checkInputs(): void;
  37127. /**
  37128. * Gets the class name of the current intput.
  37129. * @returns the class name
  37130. */
  37131. getClassName(): string;
  37132. /**
  37133. * Get the friendly name associated with the input class.
  37134. * @returns the input friendly name
  37135. */
  37136. getSimpleName(): string;
  37137. }
  37138. }
  37139. declare module BABYLON {
  37140. interface ArcRotateCameraInputsManager {
  37141. /**
  37142. * Add orientation input support to the input manager.
  37143. * @returns the current input manager
  37144. */
  37145. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37146. }
  37147. /**
  37148. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37150. */
  37151. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37152. /**
  37153. * Defines the camera the input is attached to.
  37154. */
  37155. camera: ArcRotateCamera;
  37156. /**
  37157. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37158. */
  37159. alphaCorrection: number;
  37160. /**
  37161. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37162. */
  37163. gammaCorrection: number;
  37164. private _alpha;
  37165. private _gamma;
  37166. private _dirty;
  37167. private _deviceOrientationHandler;
  37168. /**
  37169. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37170. */
  37171. constructor();
  37172. /**
  37173. * Attach the input controls to a specific dom element to get the input from.
  37174. * @param element Defines the element the controls should be listened from
  37175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37176. */
  37177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37178. /** @hidden */
  37179. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37180. /**
  37181. * Update the current camera state depending on the inputs that have been used this frame.
  37182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37183. */
  37184. checkInputs(): void;
  37185. /**
  37186. * Detach the current controls from the specified dom element.
  37187. * @param element Defines the element to stop listening the inputs from
  37188. */
  37189. detachControl(element: Nullable<HTMLElement>): void;
  37190. /**
  37191. * Gets the class name of the current intput.
  37192. * @returns the class name
  37193. */
  37194. getClassName(): string;
  37195. /**
  37196. * Get the friendly name associated with the input class.
  37197. * @returns the input friendly name
  37198. */
  37199. getSimpleName(): string;
  37200. }
  37201. }
  37202. declare module BABYLON {
  37203. /**
  37204. * Listen to mouse events to control the camera.
  37205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37206. */
  37207. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37208. /**
  37209. * Defines the camera the input is attached to.
  37210. */
  37211. camera: FlyCamera;
  37212. /**
  37213. * Defines if touch is enabled. (Default is true.)
  37214. */
  37215. touchEnabled: boolean;
  37216. /**
  37217. * Defines the buttons associated with the input to handle camera rotation.
  37218. */
  37219. buttons: number[];
  37220. /**
  37221. * Assign buttons for Yaw control.
  37222. */
  37223. buttonsYaw: number[];
  37224. /**
  37225. * Assign buttons for Pitch control.
  37226. */
  37227. buttonsPitch: number[];
  37228. /**
  37229. * Assign buttons for Roll control.
  37230. */
  37231. buttonsRoll: number[];
  37232. /**
  37233. * Detect if any button is being pressed while mouse is moved.
  37234. * -1 = Mouse locked.
  37235. * 0 = Left button.
  37236. * 1 = Middle Button.
  37237. * 2 = Right Button.
  37238. */
  37239. activeButton: number;
  37240. /**
  37241. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37242. * Higher values reduce its sensitivity.
  37243. */
  37244. angularSensibility: number;
  37245. private _mousemoveCallback;
  37246. private _observer;
  37247. private _rollObserver;
  37248. private previousPosition;
  37249. private noPreventDefault;
  37250. private element;
  37251. /**
  37252. * Listen to mouse events to control the camera.
  37253. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37255. */
  37256. constructor(touchEnabled?: boolean);
  37257. /**
  37258. * Attach the mouse control to the HTML DOM element.
  37259. * @param element Defines the element that listens to the input events.
  37260. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37261. */
  37262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37263. /**
  37264. * Detach the current controls from the specified dom element.
  37265. * @param element Defines the element to stop listening the inputs from
  37266. */
  37267. detachControl(element: Nullable<HTMLElement>): void;
  37268. /**
  37269. * Gets the class name of the current input.
  37270. * @returns the class name.
  37271. */
  37272. getClassName(): string;
  37273. /**
  37274. * Get the friendly name associated with the input class.
  37275. * @returns the input's friendly name.
  37276. */
  37277. getSimpleName(): string;
  37278. private _pointerInput;
  37279. private _onMouseMove;
  37280. /**
  37281. * Rotate camera by mouse offset.
  37282. */
  37283. private rotateCamera;
  37284. }
  37285. }
  37286. declare module BABYLON {
  37287. /**
  37288. * Default Inputs manager for the FlyCamera.
  37289. * It groups all the default supported inputs for ease of use.
  37290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37291. */
  37292. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37293. /**
  37294. * Instantiates a new FlyCameraInputsManager.
  37295. * @param camera Defines the camera the inputs belong to.
  37296. */
  37297. constructor(camera: FlyCamera);
  37298. /**
  37299. * Add keyboard input support to the input manager.
  37300. * @returns the new FlyCameraKeyboardMoveInput().
  37301. */
  37302. addKeyboard(): FlyCameraInputsManager;
  37303. /**
  37304. * Add mouse input support to the input manager.
  37305. * @param touchEnabled Enable touch screen support.
  37306. * @returns the new FlyCameraMouseInput().
  37307. */
  37308. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37314. * such as in a 3D Space Shooter or a Flight Simulator.
  37315. */
  37316. export class FlyCamera extends TargetCamera {
  37317. /**
  37318. * Define the collision ellipsoid of the camera.
  37319. * This is helpful for simulating a camera body, like a player's body.
  37320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37321. */
  37322. ellipsoid: Vector3;
  37323. /**
  37324. * Define an offset for the position of the ellipsoid around the camera.
  37325. * This can be helpful if the camera is attached away from the player's body center,
  37326. * such as at its head.
  37327. */
  37328. ellipsoidOffset: Vector3;
  37329. /**
  37330. * Enable or disable collisions of the camera with the rest of the scene objects.
  37331. */
  37332. checkCollisions: boolean;
  37333. /**
  37334. * Enable or disable gravity on the camera.
  37335. */
  37336. applyGravity: boolean;
  37337. /**
  37338. * Define the current direction the camera is moving to.
  37339. */
  37340. cameraDirection: Vector3;
  37341. /**
  37342. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37343. * This overrides and empties cameraRotation.
  37344. */
  37345. rotationQuaternion: Quaternion;
  37346. /**
  37347. * Track Roll to maintain the wanted Rolling when looking around.
  37348. */
  37349. _trackRoll: number;
  37350. /**
  37351. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37352. */
  37353. rollCorrect: number;
  37354. /**
  37355. * Mimic a banked turn, Rolling the camera when Yawing.
  37356. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37357. */
  37358. bankedTurn: boolean;
  37359. /**
  37360. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37361. */
  37362. bankedTurnLimit: number;
  37363. /**
  37364. * Value of 0 disables the banked Roll.
  37365. * Value of 1 is equal to the Yaw angle in radians.
  37366. */
  37367. bankedTurnMultiplier: number;
  37368. /**
  37369. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37370. */
  37371. inputs: FlyCameraInputsManager;
  37372. /**
  37373. * Gets the input sensibility for mouse input.
  37374. * Higher values reduce sensitivity.
  37375. */
  37376. /**
  37377. * Sets the input sensibility for a mouse input.
  37378. * Higher values reduce sensitivity.
  37379. */
  37380. angularSensibility: number;
  37381. /**
  37382. * Get the keys for camera movement forward.
  37383. */
  37384. /**
  37385. * Set the keys for camera movement forward.
  37386. */
  37387. keysForward: number[];
  37388. /**
  37389. * Get the keys for camera movement backward.
  37390. */
  37391. keysBackward: number[];
  37392. /**
  37393. * Get the keys for camera movement up.
  37394. */
  37395. /**
  37396. * Set the keys for camera movement up.
  37397. */
  37398. keysUp: number[];
  37399. /**
  37400. * Get the keys for camera movement down.
  37401. */
  37402. /**
  37403. * Set the keys for camera movement down.
  37404. */
  37405. keysDown: number[];
  37406. /**
  37407. * Get the keys for camera movement left.
  37408. */
  37409. /**
  37410. * Set the keys for camera movement left.
  37411. */
  37412. keysLeft: number[];
  37413. /**
  37414. * Set the keys for camera movement right.
  37415. */
  37416. /**
  37417. * Set the keys for camera movement right.
  37418. */
  37419. keysRight: number[];
  37420. /**
  37421. * Event raised when the camera collides with a mesh in the scene.
  37422. */
  37423. onCollide: (collidedMesh: AbstractMesh) => void;
  37424. private _collider;
  37425. private _needMoveForGravity;
  37426. private _oldPosition;
  37427. private _diffPosition;
  37428. private _newPosition;
  37429. /** @hidden */
  37430. _localDirection: Vector3;
  37431. /** @hidden */
  37432. _transformedDirection: Vector3;
  37433. /**
  37434. * Instantiates a FlyCamera.
  37435. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37436. * such as in a 3D Space Shooter or a Flight Simulator.
  37437. * @param name Define the name of the camera in the scene.
  37438. * @param position Define the starting position of the camera in the scene.
  37439. * @param scene Define the scene the camera belongs to.
  37440. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37441. */
  37442. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37443. /**
  37444. * Attach a control to the HTML DOM element.
  37445. * @param element Defines the element that listens to the input events.
  37446. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37447. */
  37448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37449. /**
  37450. * Detach a control from the HTML DOM element.
  37451. * The camera will stop reacting to that input.
  37452. * @param element Defines the element that listens to the input events.
  37453. */
  37454. detachControl(element: HTMLElement): void;
  37455. private _collisionMask;
  37456. /**
  37457. * Get the mask that the camera ignores in collision events.
  37458. */
  37459. /**
  37460. * Set the mask that the camera ignores in collision events.
  37461. */
  37462. collisionMask: number;
  37463. /** @hidden */
  37464. _collideWithWorld(displacement: Vector3): void;
  37465. /** @hidden */
  37466. private _onCollisionPositionChange;
  37467. /** @hidden */
  37468. _checkInputs(): void;
  37469. /** @hidden */
  37470. _decideIfNeedsToMove(): boolean;
  37471. /** @hidden */
  37472. _updatePosition(): void;
  37473. /**
  37474. * Restore the Roll to its target value at the rate specified.
  37475. * @param rate - Higher means slower restoring.
  37476. * @hidden
  37477. */
  37478. restoreRoll(rate: number): void;
  37479. /**
  37480. * Destroy the camera and release the current resources held by it.
  37481. */
  37482. dispose(): void;
  37483. /**
  37484. * Get the current object class name.
  37485. * @returns the class name.
  37486. */
  37487. getClassName(): string;
  37488. }
  37489. }
  37490. declare module BABYLON {
  37491. /**
  37492. * Listen to keyboard events to control the camera.
  37493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37494. */
  37495. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37496. /**
  37497. * Defines the camera the input is attached to.
  37498. */
  37499. camera: FlyCamera;
  37500. /**
  37501. * The list of keyboard keys used to control the forward move of the camera.
  37502. */
  37503. keysForward: number[];
  37504. /**
  37505. * The list of keyboard keys used to control the backward move of the camera.
  37506. */
  37507. keysBackward: number[];
  37508. /**
  37509. * The list of keyboard keys used to control the forward move of the camera.
  37510. */
  37511. keysUp: number[];
  37512. /**
  37513. * The list of keyboard keys used to control the backward move of the camera.
  37514. */
  37515. keysDown: number[];
  37516. /**
  37517. * The list of keyboard keys used to control the right strafe move of the camera.
  37518. */
  37519. keysRight: number[];
  37520. /**
  37521. * The list of keyboard keys used to control the left strafe move of the camera.
  37522. */
  37523. keysLeft: number[];
  37524. private _keys;
  37525. private _onCanvasBlurObserver;
  37526. private _onKeyboardObserver;
  37527. private _engine;
  37528. private _scene;
  37529. /**
  37530. * Attach the input controls to a specific dom element to get the input from.
  37531. * @param element Defines the element the controls should be listened from
  37532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37533. */
  37534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37535. /**
  37536. * Detach the current controls from the specified dom element.
  37537. * @param element Defines the element to stop listening the inputs from
  37538. */
  37539. detachControl(element: Nullable<HTMLElement>): void;
  37540. /**
  37541. * Gets the class name of the current intput.
  37542. * @returns the class name
  37543. */
  37544. getClassName(): string;
  37545. /** @hidden */
  37546. _onLostFocus(e: FocusEvent): void;
  37547. /**
  37548. * Get the friendly name associated with the input class.
  37549. * @returns the input friendly name
  37550. */
  37551. getSimpleName(): string;
  37552. /**
  37553. * Update the current camera state depending on the inputs that have been used this frame.
  37554. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37555. */
  37556. checkInputs(): void;
  37557. }
  37558. }
  37559. declare module BABYLON {
  37560. /**
  37561. * Manage the mouse wheel inputs to control a follow camera.
  37562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37563. */
  37564. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37565. /**
  37566. * Defines the camera the input is attached to.
  37567. */
  37568. camera: FollowCamera;
  37569. /**
  37570. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37571. */
  37572. axisControlRadius: boolean;
  37573. /**
  37574. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37575. */
  37576. axisControlHeight: boolean;
  37577. /**
  37578. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37579. */
  37580. axisControlRotation: boolean;
  37581. /**
  37582. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37583. * relation to mouseWheel events.
  37584. */
  37585. wheelPrecision: number;
  37586. /**
  37587. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37588. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37589. */
  37590. wheelDeltaPercentage: number;
  37591. private _wheel;
  37592. private _observer;
  37593. /**
  37594. * Attach the input controls to a specific dom element to get the input from.
  37595. * @param element Defines the element the controls should be listened from
  37596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37597. */
  37598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37599. /**
  37600. * Detach the current controls from the specified dom element.
  37601. * @param element Defines the element to stop listening the inputs from
  37602. */
  37603. detachControl(element: Nullable<HTMLElement>): void;
  37604. /**
  37605. * Gets the class name of the current intput.
  37606. * @returns the class name
  37607. */
  37608. getClassName(): string;
  37609. /**
  37610. * Get the friendly name associated with the input class.
  37611. * @returns the input friendly name
  37612. */
  37613. getSimpleName(): string;
  37614. }
  37615. }
  37616. declare module BABYLON {
  37617. /**
  37618. * Manage the pointers inputs to control an follow camera.
  37619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37620. */
  37621. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37622. /**
  37623. * Defines the camera the input is attached to.
  37624. */
  37625. camera: FollowCamera;
  37626. /**
  37627. * Gets the class name of the current input.
  37628. * @returns the class name
  37629. */
  37630. getClassName(): string;
  37631. /**
  37632. * Defines the pointer angular sensibility along the X axis or how fast is
  37633. * the camera rotating.
  37634. * A negative number will reverse the axis direction.
  37635. */
  37636. angularSensibilityX: number;
  37637. /**
  37638. * Defines the pointer angular sensibility along the Y axis or how fast is
  37639. * the camera rotating.
  37640. * A negative number will reverse the axis direction.
  37641. */
  37642. angularSensibilityY: number;
  37643. /**
  37644. * Defines the pointer pinch precision or how fast is the camera zooming.
  37645. * A negative number will reverse the axis direction.
  37646. */
  37647. pinchPrecision: number;
  37648. /**
  37649. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37650. * from 0.
  37651. * It defines the percentage of current camera.radius to use as delta when
  37652. * pinch zoom is used.
  37653. */
  37654. pinchDeltaPercentage: number;
  37655. /**
  37656. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37657. */
  37658. axisXControlRadius: boolean;
  37659. /**
  37660. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37661. */
  37662. axisXControlHeight: boolean;
  37663. /**
  37664. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37665. */
  37666. axisXControlRotation: boolean;
  37667. /**
  37668. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37669. */
  37670. axisYControlRadius: boolean;
  37671. /**
  37672. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37673. */
  37674. axisYControlHeight: boolean;
  37675. /**
  37676. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37677. */
  37678. axisYControlRotation: boolean;
  37679. /**
  37680. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37681. */
  37682. axisPinchControlRadius: boolean;
  37683. /**
  37684. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37685. */
  37686. axisPinchControlHeight: boolean;
  37687. /**
  37688. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37689. */
  37690. axisPinchControlRotation: boolean;
  37691. /**
  37692. * Log error messages if basic misconfiguration has occurred.
  37693. */
  37694. warningEnable: boolean;
  37695. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37696. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37697. private _warningCounter;
  37698. private _warning;
  37699. }
  37700. }
  37701. declare module BABYLON {
  37702. /**
  37703. * Default Inputs manager for the FollowCamera.
  37704. * It groups all the default supported inputs for ease of use.
  37705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37706. */
  37707. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37708. /**
  37709. * Instantiates a new FollowCameraInputsManager.
  37710. * @param camera Defines the camera the inputs belong to
  37711. */
  37712. constructor(camera: FollowCamera);
  37713. /**
  37714. * Add keyboard input support to the input manager.
  37715. * @returns the current input manager
  37716. */
  37717. addKeyboard(): FollowCameraInputsManager;
  37718. /**
  37719. * Add mouse wheel input support to the input manager.
  37720. * @returns the current input manager
  37721. */
  37722. addMouseWheel(): FollowCameraInputsManager;
  37723. /**
  37724. * Add pointers input support to the input manager.
  37725. * @returns the current input manager
  37726. */
  37727. addPointers(): FollowCameraInputsManager;
  37728. /**
  37729. * Add orientation input support to the input manager.
  37730. * @returns the current input manager
  37731. */
  37732. addVRDeviceOrientation(): FollowCameraInputsManager;
  37733. }
  37734. }
  37735. declare module BABYLON {
  37736. /**
  37737. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37738. * an arc rotate version arcFollowCamera are available.
  37739. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37740. */
  37741. export class FollowCamera extends TargetCamera {
  37742. /**
  37743. * Distance the follow camera should follow an object at
  37744. */
  37745. radius: number;
  37746. /**
  37747. * Minimum allowed distance of the camera to the axis of rotation
  37748. * (The camera can not get closer).
  37749. * This can help limiting how the Camera is able to move in the scene.
  37750. */
  37751. lowerRadiusLimit: Nullable<number>;
  37752. /**
  37753. * Maximum allowed distance of the camera to the axis of rotation
  37754. * (The camera can not get further).
  37755. * This can help limiting how the Camera is able to move in the scene.
  37756. */
  37757. upperRadiusLimit: Nullable<number>;
  37758. /**
  37759. * Define a rotation offset between the camera and the object it follows
  37760. */
  37761. rotationOffset: number;
  37762. /**
  37763. * Minimum allowed angle to camera position relative to target object.
  37764. * This can help limiting how the Camera is able to move in the scene.
  37765. */
  37766. lowerRotationOffsetLimit: Nullable<number>;
  37767. /**
  37768. * Maximum allowed angle to camera position relative to target object.
  37769. * This can help limiting how the Camera is able to move in the scene.
  37770. */
  37771. upperRotationOffsetLimit: Nullable<number>;
  37772. /**
  37773. * Define a height offset between the camera and the object it follows.
  37774. * It can help following an object from the top (like a car chaing a plane)
  37775. */
  37776. heightOffset: number;
  37777. /**
  37778. * Minimum allowed height of camera position relative to target object.
  37779. * This can help limiting how the Camera is able to move in the scene.
  37780. */
  37781. lowerHeightOffsetLimit: Nullable<number>;
  37782. /**
  37783. * Maximum allowed height of camera position relative to target object.
  37784. * This can help limiting how the Camera is able to move in the scene.
  37785. */
  37786. upperHeightOffsetLimit: Nullable<number>;
  37787. /**
  37788. * Define how fast the camera can accelerate to follow it s target.
  37789. */
  37790. cameraAcceleration: number;
  37791. /**
  37792. * Define the speed limit of the camera following an object.
  37793. */
  37794. maxCameraSpeed: number;
  37795. /**
  37796. * Define the target of the camera.
  37797. */
  37798. lockedTarget: Nullable<AbstractMesh>;
  37799. /**
  37800. * Defines the input associated with the camera.
  37801. */
  37802. inputs: FollowCameraInputsManager;
  37803. /**
  37804. * Instantiates the follow camera.
  37805. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37806. * @param name Define the name of the camera in the scene
  37807. * @param position Define the position of the camera
  37808. * @param scene Define the scene the camera belong to
  37809. * @param lockedTarget Define the target of the camera
  37810. */
  37811. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37812. private _follow;
  37813. /**
  37814. * Attached controls to the current camera.
  37815. * @param element Defines the element the controls should be listened from
  37816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37817. */
  37818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37819. /**
  37820. * Detach the current controls from the camera.
  37821. * The camera will stop reacting to inputs.
  37822. * @param element Defines the element to stop listening the inputs from
  37823. */
  37824. detachControl(element: HTMLElement): void;
  37825. /** @hidden */
  37826. _checkInputs(): void;
  37827. private _checkLimits;
  37828. /**
  37829. * Gets the camera class name.
  37830. * @returns the class name
  37831. */
  37832. getClassName(): string;
  37833. }
  37834. /**
  37835. * Arc Rotate version of the follow camera.
  37836. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37837. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37838. */
  37839. export class ArcFollowCamera extends TargetCamera {
  37840. /** The longitudinal angle of the camera */
  37841. alpha: number;
  37842. /** The latitudinal angle of the camera */
  37843. beta: number;
  37844. /** The radius of the camera from its target */
  37845. radius: number;
  37846. /** Define the camera target (the messh it should follow) */
  37847. target: Nullable<AbstractMesh>;
  37848. private _cartesianCoordinates;
  37849. /**
  37850. * Instantiates a new ArcFollowCamera
  37851. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37852. * @param name Define the name of the camera
  37853. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37854. * @param beta Define the rotation angle of the camera around the elevation axis
  37855. * @param radius Define the radius of the camera from its target point
  37856. * @param target Define the target of the camera
  37857. * @param scene Define the scene the camera belongs to
  37858. */
  37859. constructor(name: string,
  37860. /** The longitudinal angle of the camera */
  37861. alpha: number,
  37862. /** The latitudinal angle of the camera */
  37863. beta: number,
  37864. /** The radius of the camera from its target */
  37865. radius: number,
  37866. /** Define the camera target (the messh it should follow) */
  37867. target: Nullable<AbstractMesh>, scene: Scene);
  37868. private _follow;
  37869. /** @hidden */
  37870. _checkInputs(): void;
  37871. /**
  37872. * Returns the class name of the object.
  37873. * It is mostly used internally for serialization purposes.
  37874. */
  37875. getClassName(): string;
  37876. }
  37877. }
  37878. declare module BABYLON {
  37879. /**
  37880. * Manage the keyboard inputs to control the movement of a follow camera.
  37881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37882. */
  37883. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37884. /**
  37885. * Defines the camera the input is attached to.
  37886. */
  37887. camera: FollowCamera;
  37888. /**
  37889. * Defines the list of key codes associated with the up action (increase heightOffset)
  37890. */
  37891. keysHeightOffsetIncr: number[];
  37892. /**
  37893. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37894. */
  37895. keysHeightOffsetDecr: number[];
  37896. /**
  37897. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37898. */
  37899. keysHeightOffsetModifierAlt: boolean;
  37900. /**
  37901. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37902. */
  37903. keysHeightOffsetModifierCtrl: boolean;
  37904. /**
  37905. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37906. */
  37907. keysHeightOffsetModifierShift: boolean;
  37908. /**
  37909. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37910. */
  37911. keysRotationOffsetIncr: number[];
  37912. /**
  37913. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37914. */
  37915. keysRotationOffsetDecr: number[];
  37916. /**
  37917. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37918. */
  37919. keysRotationOffsetModifierAlt: boolean;
  37920. /**
  37921. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37922. */
  37923. keysRotationOffsetModifierCtrl: boolean;
  37924. /**
  37925. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37926. */
  37927. keysRotationOffsetModifierShift: boolean;
  37928. /**
  37929. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37930. */
  37931. keysRadiusIncr: number[];
  37932. /**
  37933. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37934. */
  37935. keysRadiusDecr: number[];
  37936. /**
  37937. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37938. */
  37939. keysRadiusModifierAlt: boolean;
  37940. /**
  37941. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37942. */
  37943. keysRadiusModifierCtrl: boolean;
  37944. /**
  37945. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37946. */
  37947. keysRadiusModifierShift: boolean;
  37948. /**
  37949. * Defines the rate of change of heightOffset.
  37950. */
  37951. heightSensibility: number;
  37952. /**
  37953. * Defines the rate of change of rotationOffset.
  37954. */
  37955. rotationSensibility: number;
  37956. /**
  37957. * Defines the rate of change of radius.
  37958. */
  37959. radiusSensibility: number;
  37960. private _keys;
  37961. private _ctrlPressed;
  37962. private _altPressed;
  37963. private _shiftPressed;
  37964. private _onCanvasBlurObserver;
  37965. private _onKeyboardObserver;
  37966. private _engine;
  37967. private _scene;
  37968. /**
  37969. * Attach the input controls to a specific dom element to get the input from.
  37970. * @param element Defines the element the controls should be listened from
  37971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37972. */
  37973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37974. /**
  37975. * Detach the current controls from the specified dom element.
  37976. * @param element Defines the element to stop listening the inputs from
  37977. */
  37978. detachControl(element: Nullable<HTMLElement>): void;
  37979. /**
  37980. * Update the current camera state depending on the inputs that have been used this frame.
  37981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37982. */
  37983. checkInputs(): void;
  37984. /**
  37985. * Gets the class name of the current input.
  37986. * @returns the class name
  37987. */
  37988. getClassName(): string;
  37989. /**
  37990. * Get the friendly name associated with the input class.
  37991. * @returns the input friendly name
  37992. */
  37993. getSimpleName(): string;
  37994. /**
  37995. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37996. * allow modification of the heightOffset value.
  37997. */
  37998. private _modifierHeightOffset;
  37999. /**
  38000. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38001. * allow modification of the rotationOffset value.
  38002. */
  38003. private _modifierRotationOffset;
  38004. /**
  38005. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38006. * allow modification of the radius value.
  38007. */
  38008. private _modifierRadius;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. interface FreeCameraInputsManager {
  38013. /**
  38014. * @hidden
  38015. */
  38016. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38017. /**
  38018. * Add orientation input support to the input manager.
  38019. * @returns the current input manager
  38020. */
  38021. addDeviceOrientation(): FreeCameraInputsManager;
  38022. }
  38023. /**
  38024. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38025. * Screen rotation is taken into account.
  38026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38027. */
  38028. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38029. private _camera;
  38030. private _screenOrientationAngle;
  38031. private _constantTranform;
  38032. private _screenQuaternion;
  38033. private _alpha;
  38034. private _beta;
  38035. private _gamma;
  38036. /**
  38037. * Can be used to detect if a device orientation sensor is availible on a device
  38038. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38039. * @returns a promise that will resolve on orientation change
  38040. */
  38041. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38042. /**
  38043. * @hidden
  38044. */
  38045. _onDeviceOrientationChangedObservable: Observable<void>;
  38046. /**
  38047. * Instantiates a new input
  38048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38049. */
  38050. constructor();
  38051. /**
  38052. * Define the camera controlled by the input.
  38053. */
  38054. camera: FreeCamera;
  38055. /**
  38056. * Attach the input controls to a specific dom element to get the input from.
  38057. * @param element Defines the element the controls should be listened from
  38058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38059. */
  38060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38061. private _orientationChanged;
  38062. private _deviceOrientation;
  38063. /**
  38064. * Detach the current controls from the specified dom element.
  38065. * @param element Defines the element to stop listening the inputs from
  38066. */
  38067. detachControl(element: Nullable<HTMLElement>): void;
  38068. /**
  38069. * Update the current camera state depending on the inputs that have been used this frame.
  38070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38071. */
  38072. checkInputs(): void;
  38073. /**
  38074. * Gets the class name of the current intput.
  38075. * @returns the class name
  38076. */
  38077. getClassName(): string;
  38078. /**
  38079. * Get the friendly name associated with the input class.
  38080. * @returns the input friendly name
  38081. */
  38082. getSimpleName(): string;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Manage the gamepad inputs to control a free camera.
  38088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38089. */
  38090. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38091. /**
  38092. * Define the camera the input is attached to.
  38093. */
  38094. camera: FreeCamera;
  38095. /**
  38096. * Define the Gamepad controlling the input
  38097. */
  38098. gamepad: Nullable<Gamepad>;
  38099. /**
  38100. * Defines the gamepad rotation sensiblity.
  38101. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38102. */
  38103. gamepadAngularSensibility: number;
  38104. /**
  38105. * Defines the gamepad move sensiblity.
  38106. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38107. */
  38108. gamepadMoveSensibility: number;
  38109. private _onGamepadConnectedObserver;
  38110. private _onGamepadDisconnectedObserver;
  38111. private _cameraTransform;
  38112. private _deltaTransform;
  38113. private _vector3;
  38114. private _vector2;
  38115. /**
  38116. * Attach the input controls to a specific dom element to get the input from.
  38117. * @param element Defines the element the controls should be listened from
  38118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38119. */
  38120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38121. /**
  38122. * Detach the current controls from the specified dom element.
  38123. * @param element Defines the element to stop listening the inputs from
  38124. */
  38125. detachControl(element: Nullable<HTMLElement>): void;
  38126. /**
  38127. * Update the current camera state depending on the inputs that have been used this frame.
  38128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38129. */
  38130. checkInputs(): void;
  38131. /**
  38132. * Gets the class name of the current intput.
  38133. * @returns the class name
  38134. */
  38135. getClassName(): string;
  38136. /**
  38137. * Get the friendly name associated with the input class.
  38138. * @returns the input friendly name
  38139. */
  38140. getSimpleName(): string;
  38141. }
  38142. }
  38143. declare module BABYLON {
  38144. /**
  38145. * Defines the potential axis of a Joystick
  38146. */
  38147. export enum JoystickAxis {
  38148. /** X axis */
  38149. X = 0,
  38150. /** Y axis */
  38151. Y = 1,
  38152. /** Z axis */
  38153. Z = 2
  38154. }
  38155. /**
  38156. * Class used to define virtual joystick (used in touch mode)
  38157. */
  38158. export class VirtualJoystick {
  38159. /**
  38160. * Gets or sets a boolean indicating that left and right values must be inverted
  38161. */
  38162. reverseLeftRight: boolean;
  38163. /**
  38164. * Gets or sets a boolean indicating that up and down values must be inverted
  38165. */
  38166. reverseUpDown: boolean;
  38167. /**
  38168. * Gets the offset value for the position (ie. the change of the position value)
  38169. */
  38170. deltaPosition: Vector3;
  38171. /**
  38172. * Gets a boolean indicating if the virtual joystick was pressed
  38173. */
  38174. pressed: boolean;
  38175. /**
  38176. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38177. */
  38178. static Canvas: Nullable<HTMLCanvasElement>;
  38179. private static _globalJoystickIndex;
  38180. private static vjCanvasContext;
  38181. private static vjCanvasWidth;
  38182. private static vjCanvasHeight;
  38183. private static halfWidth;
  38184. private _action;
  38185. private _axisTargetedByLeftAndRight;
  38186. private _axisTargetedByUpAndDown;
  38187. private _joystickSensibility;
  38188. private _inversedSensibility;
  38189. private _joystickPointerID;
  38190. private _joystickColor;
  38191. private _joystickPointerPos;
  38192. private _joystickPreviousPointerPos;
  38193. private _joystickPointerStartPos;
  38194. private _deltaJoystickVector;
  38195. private _leftJoystick;
  38196. private _touches;
  38197. private _onPointerDownHandlerRef;
  38198. private _onPointerMoveHandlerRef;
  38199. private _onPointerUpHandlerRef;
  38200. private _onResize;
  38201. /**
  38202. * Creates a new virtual joystick
  38203. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38204. */
  38205. constructor(leftJoystick?: boolean);
  38206. /**
  38207. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38208. * @param newJoystickSensibility defines the new sensibility
  38209. */
  38210. setJoystickSensibility(newJoystickSensibility: number): void;
  38211. private _onPointerDown;
  38212. private _onPointerMove;
  38213. private _onPointerUp;
  38214. /**
  38215. * Change the color of the virtual joystick
  38216. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38217. */
  38218. setJoystickColor(newColor: string): void;
  38219. /**
  38220. * Defines a callback to call when the joystick is touched
  38221. * @param action defines the callback
  38222. */
  38223. setActionOnTouch(action: () => any): void;
  38224. /**
  38225. * Defines which axis you'd like to control for left & right
  38226. * @param axis defines the axis to use
  38227. */
  38228. setAxisForLeftRight(axis: JoystickAxis): void;
  38229. /**
  38230. * Defines which axis you'd like to control for up & down
  38231. * @param axis defines the axis to use
  38232. */
  38233. setAxisForUpDown(axis: JoystickAxis): void;
  38234. private _drawVirtualJoystick;
  38235. /**
  38236. * Release internal HTML canvas
  38237. */
  38238. releaseCanvas(): void;
  38239. }
  38240. }
  38241. declare module BABYLON {
  38242. interface FreeCameraInputsManager {
  38243. /**
  38244. * Add virtual joystick input support to the input manager.
  38245. * @returns the current input manager
  38246. */
  38247. addVirtualJoystick(): FreeCameraInputsManager;
  38248. }
  38249. /**
  38250. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38252. */
  38253. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38254. /**
  38255. * Defines the camera the input is attached to.
  38256. */
  38257. camera: FreeCamera;
  38258. private _leftjoystick;
  38259. private _rightjoystick;
  38260. /**
  38261. * Gets the left stick of the virtual joystick.
  38262. * @returns The virtual Joystick
  38263. */
  38264. getLeftJoystick(): VirtualJoystick;
  38265. /**
  38266. * Gets the right stick of the virtual joystick.
  38267. * @returns The virtual Joystick
  38268. */
  38269. getRightJoystick(): VirtualJoystick;
  38270. /**
  38271. * Update the current camera state depending on the inputs that have been used this frame.
  38272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38273. */
  38274. checkInputs(): void;
  38275. /**
  38276. * Attach the input controls to a specific dom element to get the input from.
  38277. * @param element Defines the element the controls should be listened from
  38278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38279. */
  38280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38281. /**
  38282. * Detach the current controls from the specified dom element.
  38283. * @param element Defines the element to stop listening the inputs from
  38284. */
  38285. detachControl(element: Nullable<HTMLElement>): void;
  38286. /**
  38287. * Gets the class name of the current intput.
  38288. * @returns the class name
  38289. */
  38290. getClassName(): string;
  38291. /**
  38292. * Get the friendly name associated with the input class.
  38293. * @returns the input friendly name
  38294. */
  38295. getSimpleName(): string;
  38296. }
  38297. }
  38298. declare module BABYLON {
  38299. /**
  38300. * This represents a FPS type of camera controlled by touch.
  38301. * This is like a universal camera minus the Gamepad controls.
  38302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38303. */
  38304. export class TouchCamera extends FreeCamera {
  38305. /**
  38306. * Defines the touch sensibility for rotation.
  38307. * The higher the faster.
  38308. */
  38309. touchAngularSensibility: number;
  38310. /**
  38311. * Defines the touch sensibility for move.
  38312. * The higher the faster.
  38313. */
  38314. touchMoveSensibility: number;
  38315. /**
  38316. * Instantiates a new touch camera.
  38317. * This represents a FPS type of camera controlled by touch.
  38318. * This is like a universal camera minus the Gamepad controls.
  38319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38320. * @param name Define the name of the camera in the scene
  38321. * @param position Define the start position of the camera in the scene
  38322. * @param scene Define the scene the camera belongs to
  38323. */
  38324. constructor(name: string, position: Vector3, scene: Scene);
  38325. /**
  38326. * Gets the current object class name.
  38327. * @return the class name
  38328. */
  38329. getClassName(): string;
  38330. /** @hidden */
  38331. _setupInputs(): void;
  38332. }
  38333. }
  38334. declare module BABYLON {
  38335. /**
  38336. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38337. * being tilted forward or back and left or right.
  38338. */
  38339. export class DeviceOrientationCamera extends FreeCamera {
  38340. private _initialQuaternion;
  38341. private _quaternionCache;
  38342. private _tmpDragQuaternion;
  38343. private _disablePointerInputWhenUsingDeviceOrientation;
  38344. /**
  38345. * Creates a new device orientation camera
  38346. * @param name The name of the camera
  38347. * @param position The start position camera
  38348. * @param scene The scene the camera belongs to
  38349. */
  38350. constructor(name: string, position: Vector3, scene: Scene);
  38351. /**
  38352. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38353. */
  38354. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38355. private _dragFactor;
  38356. /**
  38357. * Enabled turning on the y axis when the orientation sensor is active
  38358. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38359. */
  38360. enableHorizontalDragging(dragFactor?: number): void;
  38361. /**
  38362. * Gets the current instance class name ("DeviceOrientationCamera").
  38363. * This helps avoiding instanceof at run time.
  38364. * @returns the class name
  38365. */
  38366. getClassName(): string;
  38367. /**
  38368. * @hidden
  38369. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38370. */
  38371. _checkInputs(): void;
  38372. /**
  38373. * Reset the camera to its default orientation on the specified axis only.
  38374. * @param axis The axis to reset
  38375. */
  38376. resetToCurrentRotation(axis?: Axis): void;
  38377. }
  38378. }
  38379. declare module BABYLON {
  38380. /**
  38381. * Defines supported buttons for XBox360 compatible gamepads
  38382. */
  38383. export enum Xbox360Button {
  38384. /** A */
  38385. A = 0,
  38386. /** B */
  38387. B = 1,
  38388. /** X */
  38389. X = 2,
  38390. /** Y */
  38391. Y = 3,
  38392. /** Start */
  38393. Start = 4,
  38394. /** Back */
  38395. Back = 5,
  38396. /** Left button */
  38397. LB = 6,
  38398. /** Right button */
  38399. RB = 7,
  38400. /** Left stick */
  38401. LeftStick = 8,
  38402. /** Right stick */
  38403. RightStick = 9
  38404. }
  38405. /** Defines values for XBox360 DPad */
  38406. export enum Xbox360Dpad {
  38407. /** Up */
  38408. Up = 0,
  38409. /** Down */
  38410. Down = 1,
  38411. /** Left */
  38412. Left = 2,
  38413. /** Right */
  38414. Right = 3
  38415. }
  38416. /**
  38417. * Defines a XBox360 gamepad
  38418. */
  38419. export class Xbox360Pad extends Gamepad {
  38420. private _leftTrigger;
  38421. private _rightTrigger;
  38422. private _onlefttriggerchanged;
  38423. private _onrighttriggerchanged;
  38424. private _onbuttondown;
  38425. private _onbuttonup;
  38426. private _ondpaddown;
  38427. private _ondpadup;
  38428. /** Observable raised when a button is pressed */
  38429. onButtonDownObservable: Observable<Xbox360Button>;
  38430. /** Observable raised when a button is released */
  38431. onButtonUpObservable: Observable<Xbox360Button>;
  38432. /** Observable raised when a pad is pressed */
  38433. onPadDownObservable: Observable<Xbox360Dpad>;
  38434. /** Observable raised when a pad is released */
  38435. onPadUpObservable: Observable<Xbox360Dpad>;
  38436. private _buttonA;
  38437. private _buttonB;
  38438. private _buttonX;
  38439. private _buttonY;
  38440. private _buttonBack;
  38441. private _buttonStart;
  38442. private _buttonLB;
  38443. private _buttonRB;
  38444. private _buttonLeftStick;
  38445. private _buttonRightStick;
  38446. private _dPadUp;
  38447. private _dPadDown;
  38448. private _dPadLeft;
  38449. private _dPadRight;
  38450. private _isXboxOnePad;
  38451. /**
  38452. * Creates a new XBox360 gamepad object
  38453. * @param id defines the id of this gamepad
  38454. * @param index defines its index
  38455. * @param gamepad defines the internal HTML gamepad object
  38456. * @param xboxOne defines if it is a XBox One gamepad
  38457. */
  38458. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38459. /**
  38460. * Defines the callback to call when left trigger is pressed
  38461. * @param callback defines the callback to use
  38462. */
  38463. onlefttriggerchanged(callback: (value: number) => void): void;
  38464. /**
  38465. * Defines the callback to call when right trigger is pressed
  38466. * @param callback defines the callback to use
  38467. */
  38468. onrighttriggerchanged(callback: (value: number) => void): void;
  38469. /**
  38470. * Gets the left trigger value
  38471. */
  38472. /**
  38473. * Sets the left trigger value
  38474. */
  38475. leftTrigger: number;
  38476. /**
  38477. * Gets the right trigger value
  38478. */
  38479. /**
  38480. * Sets the right trigger value
  38481. */
  38482. rightTrigger: number;
  38483. /**
  38484. * Defines the callback to call when a button is pressed
  38485. * @param callback defines the callback to use
  38486. */
  38487. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38488. /**
  38489. * Defines the callback to call when a button is released
  38490. * @param callback defines the callback to use
  38491. */
  38492. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38493. /**
  38494. * Defines the callback to call when a pad is pressed
  38495. * @param callback defines the callback to use
  38496. */
  38497. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38498. /**
  38499. * Defines the callback to call when a pad is released
  38500. * @param callback defines the callback to use
  38501. */
  38502. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38503. private _setButtonValue;
  38504. private _setDPadValue;
  38505. /**
  38506. * Gets the value of the `A` button
  38507. */
  38508. /**
  38509. * Sets the value of the `A` button
  38510. */
  38511. buttonA: number;
  38512. /**
  38513. * Gets the value of the `B` button
  38514. */
  38515. /**
  38516. * Sets the value of the `B` button
  38517. */
  38518. buttonB: number;
  38519. /**
  38520. * Gets the value of the `X` button
  38521. */
  38522. /**
  38523. * Sets the value of the `X` button
  38524. */
  38525. buttonX: number;
  38526. /**
  38527. * Gets the value of the `Y` button
  38528. */
  38529. /**
  38530. * Sets the value of the `Y` button
  38531. */
  38532. buttonY: number;
  38533. /**
  38534. * Gets the value of the `Start` button
  38535. */
  38536. /**
  38537. * Sets the value of the `Start` button
  38538. */
  38539. buttonStart: number;
  38540. /**
  38541. * Gets the value of the `Back` button
  38542. */
  38543. /**
  38544. * Sets the value of the `Back` button
  38545. */
  38546. buttonBack: number;
  38547. /**
  38548. * Gets the value of the `Left` button
  38549. */
  38550. /**
  38551. * Sets the value of the `Left` button
  38552. */
  38553. buttonLB: number;
  38554. /**
  38555. * Gets the value of the `Right` button
  38556. */
  38557. /**
  38558. * Sets the value of the `Right` button
  38559. */
  38560. buttonRB: number;
  38561. /**
  38562. * Gets the value of the Left joystick
  38563. */
  38564. /**
  38565. * Sets the value of the Left joystick
  38566. */
  38567. buttonLeftStick: number;
  38568. /**
  38569. * Gets the value of the Right joystick
  38570. */
  38571. /**
  38572. * Sets the value of the Right joystick
  38573. */
  38574. buttonRightStick: number;
  38575. /**
  38576. * Gets the value of D-pad up
  38577. */
  38578. /**
  38579. * Sets the value of D-pad up
  38580. */
  38581. dPadUp: number;
  38582. /**
  38583. * Gets the value of D-pad down
  38584. */
  38585. /**
  38586. * Sets the value of D-pad down
  38587. */
  38588. dPadDown: number;
  38589. /**
  38590. * Gets the value of D-pad left
  38591. */
  38592. /**
  38593. * Sets the value of D-pad left
  38594. */
  38595. dPadLeft: number;
  38596. /**
  38597. * Gets the value of D-pad right
  38598. */
  38599. /**
  38600. * Sets the value of D-pad right
  38601. */
  38602. dPadRight: number;
  38603. /**
  38604. * Force the gamepad to synchronize with device values
  38605. */
  38606. update(): void;
  38607. /**
  38608. * Disposes the gamepad
  38609. */
  38610. dispose(): void;
  38611. }
  38612. }
  38613. declare module BABYLON {
  38614. /**
  38615. * Defines supported buttons for DualShock compatible gamepads
  38616. */
  38617. export enum DualShockButton {
  38618. /** Cross */
  38619. Cross = 0,
  38620. /** Circle */
  38621. Circle = 1,
  38622. /** Square */
  38623. Square = 2,
  38624. /** Triangle */
  38625. Triangle = 3,
  38626. /** Options */
  38627. Options = 4,
  38628. /** Share */
  38629. Share = 5,
  38630. /** L1 */
  38631. L1 = 6,
  38632. /** R1 */
  38633. R1 = 7,
  38634. /** Left stick */
  38635. LeftStick = 8,
  38636. /** Right stick */
  38637. RightStick = 9
  38638. }
  38639. /** Defines values for DualShock DPad */
  38640. export enum DualShockDpad {
  38641. /** Up */
  38642. Up = 0,
  38643. /** Down */
  38644. Down = 1,
  38645. /** Left */
  38646. Left = 2,
  38647. /** Right */
  38648. Right = 3
  38649. }
  38650. /**
  38651. * Defines a DualShock gamepad
  38652. */
  38653. export class DualShockPad extends Gamepad {
  38654. private _leftTrigger;
  38655. private _rightTrigger;
  38656. private _onlefttriggerchanged;
  38657. private _onrighttriggerchanged;
  38658. private _onbuttondown;
  38659. private _onbuttonup;
  38660. private _ondpaddown;
  38661. private _ondpadup;
  38662. /** Observable raised when a button is pressed */
  38663. onButtonDownObservable: Observable<DualShockButton>;
  38664. /** Observable raised when a button is released */
  38665. onButtonUpObservable: Observable<DualShockButton>;
  38666. /** Observable raised when a pad is pressed */
  38667. onPadDownObservable: Observable<DualShockDpad>;
  38668. /** Observable raised when a pad is released */
  38669. onPadUpObservable: Observable<DualShockDpad>;
  38670. private _buttonCross;
  38671. private _buttonCircle;
  38672. private _buttonSquare;
  38673. private _buttonTriangle;
  38674. private _buttonShare;
  38675. private _buttonOptions;
  38676. private _buttonL1;
  38677. private _buttonR1;
  38678. private _buttonLeftStick;
  38679. private _buttonRightStick;
  38680. private _dPadUp;
  38681. private _dPadDown;
  38682. private _dPadLeft;
  38683. private _dPadRight;
  38684. /**
  38685. * Creates a new DualShock gamepad object
  38686. * @param id defines the id of this gamepad
  38687. * @param index defines its index
  38688. * @param gamepad defines the internal HTML gamepad object
  38689. */
  38690. constructor(id: string, index: number, gamepad: any);
  38691. /**
  38692. * Defines the callback to call when left trigger is pressed
  38693. * @param callback defines the callback to use
  38694. */
  38695. onlefttriggerchanged(callback: (value: number) => void): void;
  38696. /**
  38697. * Defines the callback to call when right trigger is pressed
  38698. * @param callback defines the callback to use
  38699. */
  38700. onrighttriggerchanged(callback: (value: number) => void): void;
  38701. /**
  38702. * Gets the left trigger value
  38703. */
  38704. /**
  38705. * Sets the left trigger value
  38706. */
  38707. leftTrigger: number;
  38708. /**
  38709. * Gets the right trigger value
  38710. */
  38711. /**
  38712. * Sets the right trigger value
  38713. */
  38714. rightTrigger: number;
  38715. /**
  38716. * Defines the callback to call when a button is pressed
  38717. * @param callback defines the callback to use
  38718. */
  38719. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38720. /**
  38721. * Defines the callback to call when a button is released
  38722. * @param callback defines the callback to use
  38723. */
  38724. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38725. /**
  38726. * Defines the callback to call when a pad is pressed
  38727. * @param callback defines the callback to use
  38728. */
  38729. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38730. /**
  38731. * Defines the callback to call when a pad is released
  38732. * @param callback defines the callback to use
  38733. */
  38734. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38735. private _setButtonValue;
  38736. private _setDPadValue;
  38737. /**
  38738. * Gets the value of the `Cross` button
  38739. */
  38740. /**
  38741. * Sets the value of the `Cross` button
  38742. */
  38743. buttonCross: number;
  38744. /**
  38745. * Gets the value of the `Circle` button
  38746. */
  38747. /**
  38748. * Sets the value of the `Circle` button
  38749. */
  38750. buttonCircle: number;
  38751. /**
  38752. * Gets the value of the `Square` button
  38753. */
  38754. /**
  38755. * Sets the value of the `Square` button
  38756. */
  38757. buttonSquare: number;
  38758. /**
  38759. * Gets the value of the `Triangle` button
  38760. */
  38761. /**
  38762. * Sets the value of the `Triangle` button
  38763. */
  38764. buttonTriangle: number;
  38765. /**
  38766. * Gets the value of the `Options` button
  38767. */
  38768. /**
  38769. * Sets the value of the `Options` button
  38770. */
  38771. buttonOptions: number;
  38772. /**
  38773. * Gets the value of the `Share` button
  38774. */
  38775. /**
  38776. * Sets the value of the `Share` button
  38777. */
  38778. buttonShare: number;
  38779. /**
  38780. * Gets the value of the `L1` button
  38781. */
  38782. /**
  38783. * Sets the value of the `L1` button
  38784. */
  38785. buttonL1: number;
  38786. /**
  38787. * Gets the value of the `R1` button
  38788. */
  38789. /**
  38790. * Sets the value of the `R1` button
  38791. */
  38792. buttonR1: number;
  38793. /**
  38794. * Gets the value of the Left joystick
  38795. */
  38796. /**
  38797. * Sets the value of the Left joystick
  38798. */
  38799. buttonLeftStick: number;
  38800. /**
  38801. * Gets the value of the Right joystick
  38802. */
  38803. /**
  38804. * Sets the value of the Right joystick
  38805. */
  38806. buttonRightStick: number;
  38807. /**
  38808. * Gets the value of D-pad up
  38809. */
  38810. /**
  38811. * Sets the value of D-pad up
  38812. */
  38813. dPadUp: number;
  38814. /**
  38815. * Gets the value of D-pad down
  38816. */
  38817. /**
  38818. * Sets the value of D-pad down
  38819. */
  38820. dPadDown: number;
  38821. /**
  38822. * Gets the value of D-pad left
  38823. */
  38824. /**
  38825. * Sets the value of D-pad left
  38826. */
  38827. dPadLeft: number;
  38828. /**
  38829. * Gets the value of D-pad right
  38830. */
  38831. /**
  38832. * Sets the value of D-pad right
  38833. */
  38834. dPadRight: number;
  38835. /**
  38836. * Force the gamepad to synchronize with device values
  38837. */
  38838. update(): void;
  38839. /**
  38840. * Disposes the gamepad
  38841. */
  38842. dispose(): void;
  38843. }
  38844. }
  38845. declare module BABYLON {
  38846. /**
  38847. * Manager for handling gamepads
  38848. */
  38849. export class GamepadManager {
  38850. private _scene?;
  38851. private _babylonGamepads;
  38852. private _oneGamepadConnected;
  38853. /** @hidden */
  38854. _isMonitoring: boolean;
  38855. private _gamepadEventSupported;
  38856. private _gamepadSupport;
  38857. /**
  38858. * observable to be triggered when the gamepad controller has been connected
  38859. */
  38860. onGamepadConnectedObservable: Observable<Gamepad>;
  38861. /**
  38862. * observable to be triggered when the gamepad controller has been disconnected
  38863. */
  38864. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38865. private _onGamepadConnectedEvent;
  38866. private _onGamepadDisconnectedEvent;
  38867. /**
  38868. * Initializes the gamepad manager
  38869. * @param _scene BabylonJS scene
  38870. */
  38871. constructor(_scene?: Scene | undefined);
  38872. /**
  38873. * The gamepads in the game pad manager
  38874. */
  38875. readonly gamepads: Gamepad[];
  38876. /**
  38877. * Get the gamepad controllers based on type
  38878. * @param type The type of gamepad controller
  38879. * @returns Nullable gamepad
  38880. */
  38881. getGamepadByType(type?: number): Nullable<Gamepad>;
  38882. /**
  38883. * Disposes the gamepad manager
  38884. */
  38885. dispose(): void;
  38886. private _addNewGamepad;
  38887. private _startMonitoringGamepads;
  38888. private _stopMonitoringGamepads;
  38889. /** @hidden */
  38890. _checkGamepadsStatus(): void;
  38891. private _updateGamepadObjects;
  38892. }
  38893. }
  38894. declare module BABYLON {
  38895. interface Scene {
  38896. /** @hidden */
  38897. _gamepadManager: Nullable<GamepadManager>;
  38898. /**
  38899. * Gets the gamepad manager associated with the scene
  38900. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38901. */
  38902. gamepadManager: GamepadManager;
  38903. }
  38904. /**
  38905. * Interface representing a free camera inputs manager
  38906. */
  38907. interface FreeCameraInputsManager {
  38908. /**
  38909. * Adds gamepad input support to the FreeCameraInputsManager.
  38910. * @returns the FreeCameraInputsManager
  38911. */
  38912. addGamepad(): FreeCameraInputsManager;
  38913. }
  38914. /**
  38915. * Interface representing an arc rotate camera inputs manager
  38916. */
  38917. interface ArcRotateCameraInputsManager {
  38918. /**
  38919. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38920. * @returns the camera inputs manager
  38921. */
  38922. addGamepad(): ArcRotateCameraInputsManager;
  38923. }
  38924. /**
  38925. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38926. */
  38927. export class GamepadSystemSceneComponent implements ISceneComponent {
  38928. /**
  38929. * The component name helpfull to identify the component in the list of scene components.
  38930. */
  38931. readonly name: string;
  38932. /**
  38933. * The scene the component belongs to.
  38934. */
  38935. scene: Scene;
  38936. /**
  38937. * Creates a new instance of the component for the given scene
  38938. * @param scene Defines the scene to register the component in
  38939. */
  38940. constructor(scene: Scene);
  38941. /**
  38942. * Registers the component in a given scene
  38943. */
  38944. register(): void;
  38945. /**
  38946. * Rebuilds the elements related to this component in case of
  38947. * context lost for instance.
  38948. */
  38949. rebuild(): void;
  38950. /**
  38951. * Disposes the component and the associated ressources
  38952. */
  38953. dispose(): void;
  38954. private _beforeCameraUpdate;
  38955. }
  38956. }
  38957. declare module BABYLON {
  38958. /**
  38959. * 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,
  38960. * which still works and will still be found in many Playgrounds.
  38961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38962. */
  38963. export class UniversalCamera extends TouchCamera {
  38964. /**
  38965. * Defines the gamepad rotation sensiblity.
  38966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38967. */
  38968. gamepadAngularSensibility: number;
  38969. /**
  38970. * Defines the gamepad move sensiblity.
  38971. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38972. */
  38973. gamepadMoveSensibility: number;
  38974. /**
  38975. * 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,
  38976. * which still works and will still be found in many Playgrounds.
  38977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38978. * @param name Define the name of the camera in the scene
  38979. * @param position Define the start position of the camera in the scene
  38980. * @param scene Define the scene the camera belongs to
  38981. */
  38982. constructor(name: string, position: Vector3, scene: Scene);
  38983. /**
  38984. * Gets the current object class name.
  38985. * @return the class name
  38986. */
  38987. getClassName(): string;
  38988. }
  38989. }
  38990. declare module BABYLON {
  38991. /**
  38992. * This represents a FPS type of camera. This is only here for back compat purpose.
  38993. * Please use the UniversalCamera instead as both are identical.
  38994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38995. */
  38996. export class GamepadCamera extends UniversalCamera {
  38997. /**
  38998. * Instantiates a new Gamepad Camera
  38999. * This represents a FPS type of camera. This is only here for back compat purpose.
  39000. * Please use the UniversalCamera instead as both are identical.
  39001. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39002. * @param name Define the name of the camera in the scene
  39003. * @param position Define the start position of the camera in the scene
  39004. * @param scene Define the scene the camera belongs to
  39005. */
  39006. constructor(name: string, position: Vector3, scene: Scene);
  39007. /**
  39008. * Gets the current object class name.
  39009. * @return the class name
  39010. */
  39011. getClassName(): string;
  39012. }
  39013. }
  39014. declare module BABYLON {
  39015. /** @hidden */
  39016. export var passPixelShader: {
  39017. name: string;
  39018. shader: string;
  39019. };
  39020. }
  39021. declare module BABYLON {
  39022. /** @hidden */
  39023. export var passCubePixelShader: {
  39024. name: string;
  39025. shader: string;
  39026. };
  39027. }
  39028. declare module BABYLON {
  39029. /**
  39030. * PassPostProcess which produces an output the same as it's input
  39031. */
  39032. export class PassPostProcess extends PostProcess {
  39033. /**
  39034. * Creates the PassPostProcess
  39035. * @param name The name of the effect.
  39036. * @param options The required width/height ratio to downsize to before computing the render pass.
  39037. * @param camera The camera to apply the render pass to.
  39038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39039. * @param engine The engine which the post process will be applied. (default: current engine)
  39040. * @param reusable If the post process can be reused on the same frame. (default: false)
  39041. * @param textureType The type of texture to be used when performing the post processing.
  39042. * @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)
  39043. */
  39044. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39045. }
  39046. /**
  39047. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39048. */
  39049. export class PassCubePostProcess extends PostProcess {
  39050. private _face;
  39051. /**
  39052. * Gets or sets the cube face to display.
  39053. * * 0 is +X
  39054. * * 1 is -X
  39055. * * 2 is +Y
  39056. * * 3 is -Y
  39057. * * 4 is +Z
  39058. * * 5 is -Z
  39059. */
  39060. face: number;
  39061. /**
  39062. * Creates the PassCubePostProcess
  39063. * @param name The name of the effect.
  39064. * @param options The required width/height ratio to downsize to before computing the render pass.
  39065. * @param camera The camera to apply the render pass to.
  39066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39067. * @param engine The engine which the post process will be applied. (default: current engine)
  39068. * @param reusable If the post process can be reused on the same frame. (default: false)
  39069. * @param textureType The type of texture to be used when performing the post processing.
  39070. * @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)
  39071. */
  39072. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /** @hidden */
  39077. export var anaglyphPixelShader: {
  39078. name: string;
  39079. shader: string;
  39080. };
  39081. }
  39082. declare module BABYLON {
  39083. /**
  39084. * Postprocess used to generate anaglyphic rendering
  39085. */
  39086. export class AnaglyphPostProcess extends PostProcess {
  39087. private _passedProcess;
  39088. /**
  39089. * Creates a new AnaglyphPostProcess
  39090. * @param name defines postprocess name
  39091. * @param options defines creation options or target ratio scale
  39092. * @param rigCameras defines cameras using this postprocess
  39093. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39094. * @param engine defines hosting engine
  39095. * @param reusable defines if the postprocess will be reused multiple times per frame
  39096. */
  39097. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39098. }
  39099. }
  39100. declare module BABYLON {
  39101. /**
  39102. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39103. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39104. */
  39105. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39106. /**
  39107. * Creates a new AnaglyphArcRotateCamera
  39108. * @param name defines camera name
  39109. * @param alpha defines alpha angle (in radians)
  39110. * @param beta defines beta angle (in radians)
  39111. * @param radius defines radius
  39112. * @param target defines camera target
  39113. * @param interaxialDistance defines distance between each color axis
  39114. * @param scene defines the hosting scene
  39115. */
  39116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39117. /**
  39118. * Gets camera class name
  39119. * @returns AnaglyphArcRotateCamera
  39120. */
  39121. getClassName(): string;
  39122. }
  39123. }
  39124. declare module BABYLON {
  39125. /**
  39126. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39127. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39128. */
  39129. export class AnaglyphFreeCamera extends FreeCamera {
  39130. /**
  39131. * Creates a new AnaglyphFreeCamera
  39132. * @param name defines camera name
  39133. * @param position defines initial position
  39134. * @param interaxialDistance defines distance between each color axis
  39135. * @param scene defines the hosting scene
  39136. */
  39137. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39138. /**
  39139. * Gets camera class name
  39140. * @returns AnaglyphFreeCamera
  39141. */
  39142. getClassName(): string;
  39143. }
  39144. }
  39145. declare module BABYLON {
  39146. /**
  39147. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39148. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39149. */
  39150. export class AnaglyphGamepadCamera extends GamepadCamera {
  39151. /**
  39152. * Creates a new AnaglyphGamepadCamera
  39153. * @param name defines camera name
  39154. * @param position defines initial position
  39155. * @param interaxialDistance defines distance between each color axis
  39156. * @param scene defines the hosting scene
  39157. */
  39158. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39159. /**
  39160. * Gets camera class name
  39161. * @returns AnaglyphGamepadCamera
  39162. */
  39163. getClassName(): string;
  39164. }
  39165. }
  39166. declare module BABYLON {
  39167. /**
  39168. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39169. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39170. */
  39171. export class AnaglyphUniversalCamera extends UniversalCamera {
  39172. /**
  39173. * Creates a new AnaglyphUniversalCamera
  39174. * @param name defines camera name
  39175. * @param position defines initial position
  39176. * @param interaxialDistance defines distance between each color axis
  39177. * @param scene defines the hosting scene
  39178. */
  39179. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39180. /**
  39181. * Gets camera class name
  39182. * @returns AnaglyphUniversalCamera
  39183. */
  39184. getClassName(): string;
  39185. }
  39186. }
  39187. declare module BABYLON {
  39188. /** @hidden */
  39189. export var stereoscopicInterlacePixelShader: {
  39190. name: string;
  39191. shader: string;
  39192. };
  39193. }
  39194. declare module BABYLON {
  39195. /**
  39196. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39197. */
  39198. export class StereoscopicInterlacePostProcess extends PostProcess {
  39199. private _stepSize;
  39200. private _passedProcess;
  39201. /**
  39202. * Initializes a StereoscopicInterlacePostProcess
  39203. * @param name The name of the effect.
  39204. * @param rigCameras The rig cameras to be appled to the post process
  39205. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39207. * @param engine The engine which the post process will be applied. (default: current engine)
  39208. * @param reusable If the post process can be reused on the same frame. (default: false)
  39209. */
  39210. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39211. }
  39212. }
  39213. declare module BABYLON {
  39214. /**
  39215. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39216. * @see http://doc.babylonjs.com/features/cameras
  39217. */
  39218. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39219. /**
  39220. * Creates a new StereoscopicArcRotateCamera
  39221. * @param name defines camera name
  39222. * @param alpha defines alpha angle (in radians)
  39223. * @param beta defines beta angle (in radians)
  39224. * @param radius defines radius
  39225. * @param target defines camera target
  39226. * @param interaxialDistance defines distance between each color axis
  39227. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39228. * @param scene defines the hosting scene
  39229. */
  39230. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39231. /**
  39232. * Gets camera class name
  39233. * @returns StereoscopicArcRotateCamera
  39234. */
  39235. getClassName(): string;
  39236. }
  39237. }
  39238. declare module BABYLON {
  39239. /**
  39240. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39241. * @see http://doc.babylonjs.com/features/cameras
  39242. */
  39243. export class StereoscopicFreeCamera extends FreeCamera {
  39244. /**
  39245. * Creates a new StereoscopicFreeCamera
  39246. * @param name defines camera name
  39247. * @param position defines initial position
  39248. * @param interaxialDistance defines distance between each color axis
  39249. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39250. * @param scene defines the hosting scene
  39251. */
  39252. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39253. /**
  39254. * Gets camera class name
  39255. * @returns StereoscopicFreeCamera
  39256. */
  39257. getClassName(): string;
  39258. }
  39259. }
  39260. declare module BABYLON {
  39261. /**
  39262. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39263. * @see http://doc.babylonjs.com/features/cameras
  39264. */
  39265. export class StereoscopicGamepadCamera extends GamepadCamera {
  39266. /**
  39267. * Creates a new StereoscopicGamepadCamera
  39268. * @param name defines camera name
  39269. * @param position defines initial position
  39270. * @param interaxialDistance defines distance between each color axis
  39271. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39272. * @param scene defines the hosting scene
  39273. */
  39274. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39275. /**
  39276. * Gets camera class name
  39277. * @returns StereoscopicGamepadCamera
  39278. */
  39279. getClassName(): string;
  39280. }
  39281. }
  39282. declare module BABYLON {
  39283. /**
  39284. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39285. * @see http://doc.babylonjs.com/features/cameras
  39286. */
  39287. export class StereoscopicUniversalCamera extends UniversalCamera {
  39288. /**
  39289. * Creates a new StereoscopicUniversalCamera
  39290. * @param name defines camera name
  39291. * @param position defines initial position
  39292. * @param interaxialDistance defines distance between each color axis
  39293. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39294. * @param scene defines the hosting scene
  39295. */
  39296. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39297. /**
  39298. * Gets camera class name
  39299. * @returns StereoscopicUniversalCamera
  39300. */
  39301. getClassName(): string;
  39302. }
  39303. }
  39304. declare module BABYLON {
  39305. /**
  39306. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39307. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39308. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39309. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39310. */
  39311. export class VirtualJoysticksCamera extends FreeCamera {
  39312. /**
  39313. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39314. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39315. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39316. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39317. * @param name Define the name of the camera in the scene
  39318. * @param position Define the start position of the camera in the scene
  39319. * @param scene Define the scene the camera belongs to
  39320. */
  39321. constructor(name: string, position: Vector3, scene: Scene);
  39322. /**
  39323. * Gets the current object class name.
  39324. * @return the class name
  39325. */
  39326. getClassName(): string;
  39327. }
  39328. }
  39329. declare module BABYLON {
  39330. /**
  39331. * This represents all the required metrics to create a VR camera.
  39332. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39333. */
  39334. export class VRCameraMetrics {
  39335. /**
  39336. * Define the horizontal resolution off the screen.
  39337. */
  39338. hResolution: number;
  39339. /**
  39340. * Define the vertical resolution off the screen.
  39341. */
  39342. vResolution: number;
  39343. /**
  39344. * Define the horizontal screen size.
  39345. */
  39346. hScreenSize: number;
  39347. /**
  39348. * Define the vertical screen size.
  39349. */
  39350. vScreenSize: number;
  39351. /**
  39352. * Define the vertical screen center position.
  39353. */
  39354. vScreenCenter: number;
  39355. /**
  39356. * Define the distance of the eyes to the screen.
  39357. */
  39358. eyeToScreenDistance: number;
  39359. /**
  39360. * Define the distance between both lenses
  39361. */
  39362. lensSeparationDistance: number;
  39363. /**
  39364. * Define the distance between both viewer's eyes.
  39365. */
  39366. interpupillaryDistance: number;
  39367. /**
  39368. * Define the distortion factor of the VR postprocess.
  39369. * Please, touch with care.
  39370. */
  39371. distortionK: number[];
  39372. /**
  39373. * Define the chromatic aberration correction factors for the VR post process.
  39374. */
  39375. chromaAbCorrection: number[];
  39376. /**
  39377. * Define the scale factor of the post process.
  39378. * The smaller the better but the slower.
  39379. */
  39380. postProcessScaleFactor: number;
  39381. /**
  39382. * Define an offset for the lens center.
  39383. */
  39384. lensCenterOffset: number;
  39385. /**
  39386. * Define if the current vr camera should compensate the distortion of the lense or not.
  39387. */
  39388. compensateDistortion: boolean;
  39389. /**
  39390. * Defines if multiview should be enabled when rendering (Default: false)
  39391. */
  39392. multiviewEnabled: boolean;
  39393. /**
  39394. * Gets the rendering aspect ratio based on the provided resolutions.
  39395. */
  39396. readonly aspectRatio: number;
  39397. /**
  39398. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39399. */
  39400. readonly aspectRatioFov: number;
  39401. /**
  39402. * @hidden
  39403. */
  39404. readonly leftHMatrix: Matrix;
  39405. /**
  39406. * @hidden
  39407. */
  39408. readonly rightHMatrix: Matrix;
  39409. /**
  39410. * @hidden
  39411. */
  39412. readonly leftPreViewMatrix: Matrix;
  39413. /**
  39414. * @hidden
  39415. */
  39416. readonly rightPreViewMatrix: Matrix;
  39417. /**
  39418. * Get the default VRMetrics based on the most generic setup.
  39419. * @returns the default vr metrics
  39420. */
  39421. static GetDefault(): VRCameraMetrics;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /** @hidden */
  39426. export var vrDistortionCorrectionPixelShader: {
  39427. name: string;
  39428. shader: string;
  39429. };
  39430. }
  39431. declare module BABYLON {
  39432. /**
  39433. * VRDistortionCorrectionPostProcess used for mobile VR
  39434. */
  39435. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39436. private _isRightEye;
  39437. private _distortionFactors;
  39438. private _postProcessScaleFactor;
  39439. private _lensCenterOffset;
  39440. private _scaleIn;
  39441. private _scaleFactor;
  39442. private _lensCenter;
  39443. /**
  39444. * Initializes the VRDistortionCorrectionPostProcess
  39445. * @param name The name of the effect.
  39446. * @param camera The camera to apply the render pass to.
  39447. * @param isRightEye If this is for the right eye distortion
  39448. * @param vrMetrics All the required metrics for the VR camera
  39449. */
  39450. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39451. }
  39452. }
  39453. declare module BABYLON {
  39454. /**
  39455. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39456. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39457. */
  39458. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39459. /**
  39460. * Creates a new VRDeviceOrientationArcRotateCamera
  39461. * @param name defines camera name
  39462. * @param alpha defines the camera rotation along the logitudinal axis
  39463. * @param beta defines the camera rotation along the latitudinal axis
  39464. * @param radius defines the camera distance from its target
  39465. * @param target defines the camera target
  39466. * @param scene defines the scene the camera belongs to
  39467. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39468. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39469. */
  39470. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39471. /**
  39472. * Gets camera class name
  39473. * @returns VRDeviceOrientationArcRotateCamera
  39474. */
  39475. getClassName(): string;
  39476. }
  39477. }
  39478. declare module BABYLON {
  39479. /**
  39480. * Camera used to simulate VR rendering (based on FreeCamera)
  39481. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39482. */
  39483. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39484. /**
  39485. * Creates a new VRDeviceOrientationFreeCamera
  39486. * @param name defines camera name
  39487. * @param position defines the start position of the camera
  39488. * @param scene defines the scene the camera belongs to
  39489. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39490. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39491. */
  39492. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39493. /**
  39494. * Gets camera class name
  39495. * @returns VRDeviceOrientationFreeCamera
  39496. */
  39497. getClassName(): string;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39504. */
  39505. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39506. /**
  39507. * Creates a new VRDeviceOrientationGamepadCamera
  39508. * @param name defines camera name
  39509. * @param position defines the start position of the camera
  39510. * @param scene defines the scene the camera belongs to
  39511. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39512. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39513. */
  39514. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39515. /**
  39516. * Gets camera class name
  39517. * @returns VRDeviceOrientationGamepadCamera
  39518. */
  39519. getClassName(): string;
  39520. }
  39521. }
  39522. declare module BABYLON {
  39523. /**
  39524. * Base class of materials working in push mode in babylon JS
  39525. * @hidden
  39526. */
  39527. export class PushMaterial extends Material {
  39528. protected _activeEffect: Effect;
  39529. protected _normalMatrix: Matrix;
  39530. /**
  39531. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39532. * This means that the material can keep using a previous shader while a new one is being compiled.
  39533. * This is mostly used when shader parallel compilation is supported (true by default)
  39534. */
  39535. allowShaderHotSwapping: boolean;
  39536. constructor(name: string, scene: Scene);
  39537. getEffect(): Effect;
  39538. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39539. /**
  39540. * Binds the given world matrix to the active effect
  39541. *
  39542. * @param world the matrix to bind
  39543. */
  39544. bindOnlyWorldMatrix(world: Matrix): void;
  39545. /**
  39546. * Binds the given normal matrix to the active effect
  39547. *
  39548. * @param normalMatrix the matrix to bind
  39549. */
  39550. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39551. bind(world: Matrix, mesh?: Mesh): void;
  39552. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39553. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39554. }
  39555. }
  39556. declare module BABYLON {
  39557. /**
  39558. * This groups all the flags used to control the materials channel.
  39559. */
  39560. export class MaterialFlags {
  39561. private static _DiffuseTextureEnabled;
  39562. /**
  39563. * Are diffuse textures enabled in the application.
  39564. */
  39565. static DiffuseTextureEnabled: boolean;
  39566. private static _AmbientTextureEnabled;
  39567. /**
  39568. * Are ambient textures enabled in the application.
  39569. */
  39570. static AmbientTextureEnabled: boolean;
  39571. private static _OpacityTextureEnabled;
  39572. /**
  39573. * Are opacity textures enabled in the application.
  39574. */
  39575. static OpacityTextureEnabled: boolean;
  39576. private static _ReflectionTextureEnabled;
  39577. /**
  39578. * Are reflection textures enabled in the application.
  39579. */
  39580. static ReflectionTextureEnabled: boolean;
  39581. private static _EmissiveTextureEnabled;
  39582. /**
  39583. * Are emissive textures enabled in the application.
  39584. */
  39585. static EmissiveTextureEnabled: boolean;
  39586. private static _SpecularTextureEnabled;
  39587. /**
  39588. * Are specular textures enabled in the application.
  39589. */
  39590. static SpecularTextureEnabled: boolean;
  39591. private static _BumpTextureEnabled;
  39592. /**
  39593. * Are bump textures enabled in the application.
  39594. */
  39595. static BumpTextureEnabled: boolean;
  39596. private static _LightmapTextureEnabled;
  39597. /**
  39598. * Are lightmap textures enabled in the application.
  39599. */
  39600. static LightmapTextureEnabled: boolean;
  39601. private static _RefractionTextureEnabled;
  39602. /**
  39603. * Are refraction textures enabled in the application.
  39604. */
  39605. static RefractionTextureEnabled: boolean;
  39606. private static _ColorGradingTextureEnabled;
  39607. /**
  39608. * Are color grading textures enabled in the application.
  39609. */
  39610. static ColorGradingTextureEnabled: boolean;
  39611. private static _FresnelEnabled;
  39612. /**
  39613. * Are fresnels enabled in the application.
  39614. */
  39615. static FresnelEnabled: boolean;
  39616. private static _ClearCoatTextureEnabled;
  39617. /**
  39618. * Are clear coat textures enabled in the application.
  39619. */
  39620. static ClearCoatTextureEnabled: boolean;
  39621. private static _ClearCoatBumpTextureEnabled;
  39622. /**
  39623. * Are clear coat bump textures enabled in the application.
  39624. */
  39625. static ClearCoatBumpTextureEnabled: boolean;
  39626. private static _ClearCoatTintTextureEnabled;
  39627. /**
  39628. * Are clear coat tint textures enabled in the application.
  39629. */
  39630. static ClearCoatTintTextureEnabled: boolean;
  39631. private static _SheenTextureEnabled;
  39632. /**
  39633. * Are sheen textures enabled in the application.
  39634. */
  39635. static SheenTextureEnabled: boolean;
  39636. private static _AnisotropicTextureEnabled;
  39637. /**
  39638. * Are anisotropic textures enabled in the application.
  39639. */
  39640. static AnisotropicTextureEnabled: boolean;
  39641. private static _ThicknessTextureEnabled;
  39642. /**
  39643. * Are thickness textures enabled in the application.
  39644. */
  39645. static ThicknessTextureEnabled: boolean;
  39646. }
  39647. }
  39648. declare module BABYLON {
  39649. /** @hidden */
  39650. export var defaultFragmentDeclaration: {
  39651. name: string;
  39652. shader: string;
  39653. };
  39654. }
  39655. declare module BABYLON {
  39656. /** @hidden */
  39657. export var defaultUboDeclaration: {
  39658. name: string;
  39659. shader: string;
  39660. };
  39661. }
  39662. declare module BABYLON {
  39663. /** @hidden */
  39664. export var lightFragmentDeclaration: {
  39665. name: string;
  39666. shader: string;
  39667. };
  39668. }
  39669. declare module BABYLON {
  39670. /** @hidden */
  39671. export var lightUboDeclaration: {
  39672. name: string;
  39673. shader: string;
  39674. };
  39675. }
  39676. declare module BABYLON {
  39677. /** @hidden */
  39678. export var lightsFragmentFunctions: {
  39679. name: string;
  39680. shader: string;
  39681. };
  39682. }
  39683. declare module BABYLON {
  39684. /** @hidden */
  39685. export var shadowsFragmentFunctions: {
  39686. name: string;
  39687. shader: string;
  39688. };
  39689. }
  39690. declare module BABYLON {
  39691. /** @hidden */
  39692. export var fresnelFunction: {
  39693. name: string;
  39694. shader: string;
  39695. };
  39696. }
  39697. declare module BABYLON {
  39698. /** @hidden */
  39699. export var reflectionFunction: {
  39700. name: string;
  39701. shader: string;
  39702. };
  39703. }
  39704. declare module BABYLON {
  39705. /** @hidden */
  39706. export var bumpFragmentFunctions: {
  39707. name: string;
  39708. shader: string;
  39709. };
  39710. }
  39711. declare module BABYLON {
  39712. /** @hidden */
  39713. export var logDepthDeclaration: {
  39714. name: string;
  39715. shader: string;
  39716. };
  39717. }
  39718. declare module BABYLON {
  39719. /** @hidden */
  39720. export var bumpFragment: {
  39721. name: string;
  39722. shader: string;
  39723. };
  39724. }
  39725. declare module BABYLON {
  39726. /** @hidden */
  39727. export var depthPrePass: {
  39728. name: string;
  39729. shader: string;
  39730. };
  39731. }
  39732. declare module BABYLON {
  39733. /** @hidden */
  39734. export var lightFragment: {
  39735. name: string;
  39736. shader: string;
  39737. };
  39738. }
  39739. declare module BABYLON {
  39740. /** @hidden */
  39741. export var logDepthFragment: {
  39742. name: string;
  39743. shader: string;
  39744. };
  39745. }
  39746. declare module BABYLON {
  39747. /** @hidden */
  39748. export var defaultPixelShader: {
  39749. name: string;
  39750. shader: string;
  39751. };
  39752. }
  39753. declare module BABYLON {
  39754. /** @hidden */
  39755. export var defaultVertexDeclaration: {
  39756. name: string;
  39757. shader: string;
  39758. };
  39759. }
  39760. declare module BABYLON {
  39761. /** @hidden */
  39762. export var bumpVertexDeclaration: {
  39763. name: string;
  39764. shader: string;
  39765. };
  39766. }
  39767. declare module BABYLON {
  39768. /** @hidden */
  39769. export var bumpVertex: {
  39770. name: string;
  39771. shader: string;
  39772. };
  39773. }
  39774. declare module BABYLON {
  39775. /** @hidden */
  39776. export var fogVertex: {
  39777. name: string;
  39778. shader: string;
  39779. };
  39780. }
  39781. declare module BABYLON {
  39782. /** @hidden */
  39783. export var shadowsVertex: {
  39784. name: string;
  39785. shader: string;
  39786. };
  39787. }
  39788. declare module BABYLON {
  39789. /** @hidden */
  39790. export var pointCloudVertex: {
  39791. name: string;
  39792. shader: string;
  39793. };
  39794. }
  39795. declare module BABYLON {
  39796. /** @hidden */
  39797. export var logDepthVertex: {
  39798. name: string;
  39799. shader: string;
  39800. };
  39801. }
  39802. declare module BABYLON {
  39803. /** @hidden */
  39804. export var defaultVertexShader: {
  39805. name: string;
  39806. shader: string;
  39807. };
  39808. }
  39809. declare module BABYLON {
  39810. /** @hidden */
  39811. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39812. MAINUV1: boolean;
  39813. MAINUV2: boolean;
  39814. DIFFUSE: boolean;
  39815. DIFFUSEDIRECTUV: number;
  39816. AMBIENT: boolean;
  39817. AMBIENTDIRECTUV: number;
  39818. OPACITY: boolean;
  39819. OPACITYDIRECTUV: number;
  39820. OPACITYRGB: boolean;
  39821. REFLECTION: boolean;
  39822. EMISSIVE: boolean;
  39823. EMISSIVEDIRECTUV: number;
  39824. SPECULAR: boolean;
  39825. SPECULARDIRECTUV: number;
  39826. BUMP: boolean;
  39827. BUMPDIRECTUV: number;
  39828. PARALLAX: boolean;
  39829. PARALLAXOCCLUSION: boolean;
  39830. SPECULAROVERALPHA: boolean;
  39831. CLIPPLANE: boolean;
  39832. CLIPPLANE2: boolean;
  39833. CLIPPLANE3: boolean;
  39834. CLIPPLANE4: boolean;
  39835. ALPHATEST: boolean;
  39836. DEPTHPREPASS: boolean;
  39837. ALPHAFROMDIFFUSE: boolean;
  39838. POINTSIZE: boolean;
  39839. FOG: boolean;
  39840. SPECULARTERM: boolean;
  39841. DIFFUSEFRESNEL: boolean;
  39842. OPACITYFRESNEL: boolean;
  39843. REFLECTIONFRESNEL: boolean;
  39844. REFRACTIONFRESNEL: boolean;
  39845. EMISSIVEFRESNEL: boolean;
  39846. FRESNEL: boolean;
  39847. NORMAL: boolean;
  39848. UV1: boolean;
  39849. UV2: boolean;
  39850. VERTEXCOLOR: boolean;
  39851. VERTEXALPHA: boolean;
  39852. NUM_BONE_INFLUENCERS: number;
  39853. BonesPerMesh: number;
  39854. BONETEXTURE: boolean;
  39855. INSTANCES: boolean;
  39856. GLOSSINESS: boolean;
  39857. ROUGHNESS: boolean;
  39858. EMISSIVEASILLUMINATION: boolean;
  39859. LINKEMISSIVEWITHDIFFUSE: boolean;
  39860. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39861. LIGHTMAP: boolean;
  39862. LIGHTMAPDIRECTUV: number;
  39863. OBJECTSPACE_NORMALMAP: boolean;
  39864. USELIGHTMAPASSHADOWMAP: boolean;
  39865. REFLECTIONMAP_3D: boolean;
  39866. REFLECTIONMAP_SPHERICAL: boolean;
  39867. REFLECTIONMAP_PLANAR: boolean;
  39868. REFLECTIONMAP_CUBIC: boolean;
  39869. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39870. REFLECTIONMAP_PROJECTION: boolean;
  39871. REFLECTIONMAP_SKYBOX: boolean;
  39872. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39873. REFLECTIONMAP_EXPLICIT: boolean;
  39874. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39875. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39876. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39877. INVERTCUBICMAP: boolean;
  39878. LOGARITHMICDEPTH: boolean;
  39879. REFRACTION: boolean;
  39880. REFRACTIONMAP_3D: boolean;
  39881. REFLECTIONOVERALPHA: boolean;
  39882. TWOSIDEDLIGHTING: boolean;
  39883. SHADOWFLOAT: boolean;
  39884. MORPHTARGETS: boolean;
  39885. MORPHTARGETS_NORMAL: boolean;
  39886. MORPHTARGETS_TANGENT: boolean;
  39887. MORPHTARGETS_UV: boolean;
  39888. NUM_MORPH_INFLUENCERS: number;
  39889. NONUNIFORMSCALING: boolean;
  39890. PREMULTIPLYALPHA: boolean;
  39891. IMAGEPROCESSING: boolean;
  39892. VIGNETTE: boolean;
  39893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39894. VIGNETTEBLENDMODEOPAQUE: boolean;
  39895. TONEMAPPING: boolean;
  39896. TONEMAPPING_ACES: boolean;
  39897. CONTRAST: boolean;
  39898. COLORCURVES: boolean;
  39899. COLORGRADING: boolean;
  39900. COLORGRADING3D: boolean;
  39901. SAMPLER3DGREENDEPTH: boolean;
  39902. SAMPLER3DBGRMAP: boolean;
  39903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39904. MULTIVIEW: boolean;
  39905. /**
  39906. * If the reflection texture on this material is in linear color space
  39907. * @hidden
  39908. */
  39909. IS_REFLECTION_LINEAR: boolean;
  39910. /**
  39911. * If the refraction texture on this material is in linear color space
  39912. * @hidden
  39913. */
  39914. IS_REFRACTION_LINEAR: boolean;
  39915. EXPOSURE: boolean;
  39916. constructor();
  39917. setReflectionMode(modeToEnable: string): void;
  39918. }
  39919. /**
  39920. * This is the default material used in Babylon. It is the best trade off between quality
  39921. * and performances.
  39922. * @see http://doc.babylonjs.com/babylon101/materials
  39923. */
  39924. export class StandardMaterial extends PushMaterial {
  39925. private _diffuseTexture;
  39926. /**
  39927. * The basic texture of the material as viewed under a light.
  39928. */
  39929. diffuseTexture: Nullable<BaseTexture>;
  39930. private _ambientTexture;
  39931. /**
  39932. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39933. */
  39934. ambientTexture: Nullable<BaseTexture>;
  39935. private _opacityTexture;
  39936. /**
  39937. * Define the transparency of the material from a texture.
  39938. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39939. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39940. */
  39941. opacityTexture: Nullable<BaseTexture>;
  39942. private _reflectionTexture;
  39943. /**
  39944. * Define the texture used to display the reflection.
  39945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39946. */
  39947. reflectionTexture: Nullable<BaseTexture>;
  39948. private _emissiveTexture;
  39949. /**
  39950. * Define texture of the material as if self lit.
  39951. * This will be mixed in the final result even in the absence of light.
  39952. */
  39953. emissiveTexture: Nullable<BaseTexture>;
  39954. private _specularTexture;
  39955. /**
  39956. * Define how the color and intensity of the highlight given by the light in the material.
  39957. */
  39958. specularTexture: Nullable<BaseTexture>;
  39959. private _bumpTexture;
  39960. /**
  39961. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39962. * 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.
  39963. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39964. */
  39965. bumpTexture: Nullable<BaseTexture>;
  39966. private _lightmapTexture;
  39967. /**
  39968. * Complex lighting can be computationally expensive to compute at runtime.
  39969. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39970. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39971. */
  39972. lightmapTexture: Nullable<BaseTexture>;
  39973. private _refractionTexture;
  39974. /**
  39975. * Define the texture used to display the refraction.
  39976. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39977. */
  39978. refractionTexture: Nullable<BaseTexture>;
  39979. /**
  39980. * The color of the material lit by the environmental background lighting.
  39981. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39982. */
  39983. ambientColor: Color3;
  39984. /**
  39985. * The basic color of the material as viewed under a light.
  39986. */
  39987. diffuseColor: Color3;
  39988. /**
  39989. * Define how the color and intensity of the highlight given by the light in the material.
  39990. */
  39991. specularColor: Color3;
  39992. /**
  39993. * Define the color of the material as if self lit.
  39994. * This will be mixed in the final result even in the absence of light.
  39995. */
  39996. emissiveColor: Color3;
  39997. /**
  39998. * Defines how sharp are the highlights in the material.
  39999. * The bigger the value the sharper giving a more glossy feeling to the result.
  40000. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40001. */
  40002. specularPower: number;
  40003. private _useAlphaFromDiffuseTexture;
  40004. /**
  40005. * Does the transparency come from the diffuse texture alpha channel.
  40006. */
  40007. useAlphaFromDiffuseTexture: boolean;
  40008. private _useEmissiveAsIllumination;
  40009. /**
  40010. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40011. */
  40012. useEmissiveAsIllumination: boolean;
  40013. private _linkEmissiveWithDiffuse;
  40014. /**
  40015. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40016. * the emissive level when the final color is close to one.
  40017. */
  40018. linkEmissiveWithDiffuse: boolean;
  40019. private _useSpecularOverAlpha;
  40020. /**
  40021. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40022. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40023. */
  40024. useSpecularOverAlpha: boolean;
  40025. private _useReflectionOverAlpha;
  40026. /**
  40027. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40028. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40029. */
  40030. useReflectionOverAlpha: boolean;
  40031. private _disableLighting;
  40032. /**
  40033. * Does lights from the scene impacts this material.
  40034. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40035. */
  40036. disableLighting: boolean;
  40037. private _useObjectSpaceNormalMap;
  40038. /**
  40039. * Allows using an object space normal map (instead of tangent space).
  40040. */
  40041. useObjectSpaceNormalMap: boolean;
  40042. private _useParallax;
  40043. /**
  40044. * Is parallax enabled or not.
  40045. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40046. */
  40047. useParallax: boolean;
  40048. private _useParallaxOcclusion;
  40049. /**
  40050. * Is parallax occlusion enabled or not.
  40051. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40052. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40053. */
  40054. useParallaxOcclusion: boolean;
  40055. /**
  40056. * 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.
  40057. */
  40058. parallaxScaleBias: number;
  40059. private _roughness;
  40060. /**
  40061. * Helps to define how blurry the reflections should appears in the material.
  40062. */
  40063. roughness: number;
  40064. /**
  40065. * In case of refraction, define the value of the index of refraction.
  40066. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40067. */
  40068. indexOfRefraction: number;
  40069. /**
  40070. * Invert the refraction texture alongside the y axis.
  40071. * It can be useful with procedural textures or probe for instance.
  40072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40073. */
  40074. invertRefractionY: boolean;
  40075. /**
  40076. * Defines the alpha limits in alpha test mode.
  40077. */
  40078. alphaCutOff: number;
  40079. private _useLightmapAsShadowmap;
  40080. /**
  40081. * In case of light mapping, define whether the map contains light or shadow informations.
  40082. */
  40083. useLightmapAsShadowmap: boolean;
  40084. private _diffuseFresnelParameters;
  40085. /**
  40086. * Define the diffuse fresnel parameters of the material.
  40087. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40088. */
  40089. diffuseFresnelParameters: FresnelParameters;
  40090. private _opacityFresnelParameters;
  40091. /**
  40092. * Define the opacity fresnel parameters of the material.
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40094. */
  40095. opacityFresnelParameters: FresnelParameters;
  40096. private _reflectionFresnelParameters;
  40097. /**
  40098. * Define the reflection fresnel parameters of the material.
  40099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40100. */
  40101. reflectionFresnelParameters: FresnelParameters;
  40102. private _refractionFresnelParameters;
  40103. /**
  40104. * Define the refraction fresnel parameters of the material.
  40105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40106. */
  40107. refractionFresnelParameters: FresnelParameters;
  40108. private _emissiveFresnelParameters;
  40109. /**
  40110. * Define the emissive fresnel parameters of the material.
  40111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40112. */
  40113. emissiveFresnelParameters: FresnelParameters;
  40114. private _useReflectionFresnelFromSpecular;
  40115. /**
  40116. * If true automatically deducts the fresnels values from the material specularity.
  40117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40118. */
  40119. useReflectionFresnelFromSpecular: boolean;
  40120. private _useGlossinessFromSpecularMapAlpha;
  40121. /**
  40122. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40123. */
  40124. useGlossinessFromSpecularMapAlpha: boolean;
  40125. private _maxSimultaneousLights;
  40126. /**
  40127. * Defines the maximum number of lights that can be used in the material
  40128. */
  40129. maxSimultaneousLights: number;
  40130. private _invertNormalMapX;
  40131. /**
  40132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40133. */
  40134. invertNormalMapX: boolean;
  40135. private _invertNormalMapY;
  40136. /**
  40137. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40138. */
  40139. invertNormalMapY: boolean;
  40140. private _twoSidedLighting;
  40141. /**
  40142. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40143. */
  40144. twoSidedLighting: boolean;
  40145. /**
  40146. * Default configuration related to image processing available in the standard Material.
  40147. */
  40148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40149. /**
  40150. * Gets the image processing configuration used either in this material.
  40151. */
  40152. /**
  40153. * Sets the Default image processing configuration used either in the this material.
  40154. *
  40155. * If sets to null, the scene one is in use.
  40156. */
  40157. imageProcessingConfiguration: ImageProcessingConfiguration;
  40158. /**
  40159. * Keep track of the image processing observer to allow dispose and replace.
  40160. */
  40161. private _imageProcessingObserver;
  40162. /**
  40163. * Attaches a new image processing configuration to the Standard Material.
  40164. * @param configuration
  40165. */
  40166. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40167. /**
  40168. * Gets wether the color curves effect is enabled.
  40169. */
  40170. /**
  40171. * Sets wether the color curves effect is enabled.
  40172. */
  40173. cameraColorCurvesEnabled: boolean;
  40174. /**
  40175. * Gets wether the color grading effect is enabled.
  40176. */
  40177. /**
  40178. * Gets wether the color grading effect is enabled.
  40179. */
  40180. cameraColorGradingEnabled: boolean;
  40181. /**
  40182. * Gets wether tonemapping is enabled or not.
  40183. */
  40184. /**
  40185. * Sets wether tonemapping is enabled or not
  40186. */
  40187. cameraToneMappingEnabled: boolean;
  40188. /**
  40189. * The camera exposure used on this material.
  40190. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40191. * This corresponds to a photographic exposure.
  40192. */
  40193. /**
  40194. * The camera exposure used on this material.
  40195. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40196. * This corresponds to a photographic exposure.
  40197. */
  40198. cameraExposure: number;
  40199. /**
  40200. * Gets The camera contrast used on this material.
  40201. */
  40202. /**
  40203. * Sets The camera contrast used on this material.
  40204. */
  40205. cameraContrast: number;
  40206. /**
  40207. * Gets the Color Grading 2D Lookup Texture.
  40208. */
  40209. /**
  40210. * Sets the Color Grading 2D Lookup Texture.
  40211. */
  40212. cameraColorGradingTexture: Nullable<BaseTexture>;
  40213. /**
  40214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40216. * 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;
  40217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40218. */
  40219. /**
  40220. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40221. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40222. * 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;
  40223. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40224. */
  40225. cameraColorCurves: Nullable<ColorCurves>;
  40226. /**
  40227. * Custom callback helping to override the default shader used in the material.
  40228. */
  40229. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40230. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40231. protected _worldViewProjectionMatrix: Matrix;
  40232. protected _globalAmbientColor: Color3;
  40233. protected _useLogarithmicDepth: boolean;
  40234. protected _rebuildInParallel: boolean;
  40235. /**
  40236. * Instantiates a new standard material.
  40237. * This is the default material used in Babylon. It is the best trade off between quality
  40238. * and performances.
  40239. * @see http://doc.babylonjs.com/babylon101/materials
  40240. * @param name Define the name of the material in the scene
  40241. * @param scene Define the scene the material belong to
  40242. */
  40243. constructor(name: string, scene: Scene);
  40244. /**
  40245. * Gets a boolean indicating that current material needs to register RTT
  40246. */
  40247. readonly hasRenderTargetTextures: boolean;
  40248. /**
  40249. * Gets the current class name of the material e.g. "StandardMaterial"
  40250. * Mainly use in serialization.
  40251. * @returns the class name
  40252. */
  40253. getClassName(): string;
  40254. /**
  40255. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40256. * You can try switching to logarithmic depth.
  40257. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40258. */
  40259. useLogarithmicDepth: boolean;
  40260. /**
  40261. * Specifies if the material will require alpha blending
  40262. * @returns a boolean specifying if alpha blending is needed
  40263. */
  40264. needAlphaBlending(): boolean;
  40265. /**
  40266. * Specifies if this material should be rendered in alpha test mode
  40267. * @returns a boolean specifying if an alpha test is needed.
  40268. */
  40269. needAlphaTesting(): boolean;
  40270. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40271. /**
  40272. * Get the texture used for alpha test purpose.
  40273. * @returns the diffuse texture in case of the standard material.
  40274. */
  40275. getAlphaTestTexture(): Nullable<BaseTexture>;
  40276. /**
  40277. * Get if the submesh is ready to be used and all its information available.
  40278. * Child classes can use it to update shaders
  40279. * @param mesh defines the mesh to check
  40280. * @param subMesh defines which submesh to check
  40281. * @param useInstances specifies that instances should be used
  40282. * @returns a boolean indicating that the submesh is ready or not
  40283. */
  40284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40285. /**
  40286. * Builds the material UBO layouts.
  40287. * Used internally during the effect preparation.
  40288. */
  40289. buildUniformLayout(): void;
  40290. /**
  40291. * Unbinds the material from the mesh
  40292. */
  40293. unbind(): void;
  40294. /**
  40295. * Binds the submesh to this material by preparing the effect and shader to draw
  40296. * @param world defines the world transformation matrix
  40297. * @param mesh defines the mesh containing the submesh
  40298. * @param subMesh defines the submesh to bind the material to
  40299. */
  40300. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40301. /**
  40302. * Get the list of animatables in the material.
  40303. * @returns the list of animatables object used in the material
  40304. */
  40305. getAnimatables(): IAnimatable[];
  40306. /**
  40307. * Gets the active textures from the material
  40308. * @returns an array of textures
  40309. */
  40310. getActiveTextures(): BaseTexture[];
  40311. /**
  40312. * Specifies if the material uses a texture
  40313. * @param texture defines the texture to check against the material
  40314. * @returns a boolean specifying if the material uses the texture
  40315. */
  40316. hasTexture(texture: BaseTexture): boolean;
  40317. /**
  40318. * Disposes the material
  40319. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40320. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40321. */
  40322. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40323. /**
  40324. * Makes a duplicate of the material, and gives it a new name
  40325. * @param name defines the new name for the duplicated material
  40326. * @returns the cloned material
  40327. */
  40328. clone(name: string): StandardMaterial;
  40329. /**
  40330. * Serializes this material in a JSON representation
  40331. * @returns the serialized material object
  40332. */
  40333. serialize(): any;
  40334. /**
  40335. * Creates a standard material from parsed material data
  40336. * @param source defines the JSON representation of the material
  40337. * @param scene defines the hosting scene
  40338. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40339. * @returns a new standard material
  40340. */
  40341. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40342. /**
  40343. * Are diffuse textures enabled in the application.
  40344. */
  40345. static DiffuseTextureEnabled: boolean;
  40346. /**
  40347. * Are ambient textures enabled in the application.
  40348. */
  40349. static AmbientTextureEnabled: boolean;
  40350. /**
  40351. * Are opacity textures enabled in the application.
  40352. */
  40353. static OpacityTextureEnabled: boolean;
  40354. /**
  40355. * Are reflection textures enabled in the application.
  40356. */
  40357. static ReflectionTextureEnabled: boolean;
  40358. /**
  40359. * Are emissive textures enabled in the application.
  40360. */
  40361. static EmissiveTextureEnabled: boolean;
  40362. /**
  40363. * Are specular textures enabled in the application.
  40364. */
  40365. static SpecularTextureEnabled: boolean;
  40366. /**
  40367. * Are bump textures enabled in the application.
  40368. */
  40369. static BumpTextureEnabled: boolean;
  40370. /**
  40371. * Are lightmap textures enabled in the application.
  40372. */
  40373. static LightmapTextureEnabled: boolean;
  40374. /**
  40375. * Are refraction textures enabled in the application.
  40376. */
  40377. static RefractionTextureEnabled: boolean;
  40378. /**
  40379. * Are color grading textures enabled in the application.
  40380. */
  40381. static ColorGradingTextureEnabled: boolean;
  40382. /**
  40383. * Are fresnels enabled in the application.
  40384. */
  40385. static FresnelEnabled: boolean;
  40386. }
  40387. }
  40388. declare module BABYLON {
  40389. /**
  40390. * A class extending Texture allowing drawing on a texture
  40391. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40392. */
  40393. export class DynamicTexture extends Texture {
  40394. private _generateMipMaps;
  40395. private _canvas;
  40396. private _context;
  40397. private _engine;
  40398. /**
  40399. * Creates a DynamicTexture
  40400. * @param name defines the name of the texture
  40401. * @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
  40402. * @param scene defines the scene where you want the texture
  40403. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40404. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40405. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40406. */
  40407. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40408. /**
  40409. * Get the current class name of the texture useful for serialization or dynamic coding.
  40410. * @returns "DynamicTexture"
  40411. */
  40412. getClassName(): string;
  40413. /**
  40414. * Gets the current state of canRescale
  40415. */
  40416. readonly canRescale: boolean;
  40417. private _recreate;
  40418. /**
  40419. * Scales the texture
  40420. * @param ratio the scale factor to apply to both width and height
  40421. */
  40422. scale(ratio: number): void;
  40423. /**
  40424. * Resizes the texture
  40425. * @param width the new width
  40426. * @param height the new height
  40427. */
  40428. scaleTo(width: number, height: number): void;
  40429. /**
  40430. * Gets the context of the canvas used by the texture
  40431. * @returns the canvas context of the dynamic texture
  40432. */
  40433. getContext(): CanvasRenderingContext2D;
  40434. /**
  40435. * Clears the texture
  40436. */
  40437. clear(): void;
  40438. /**
  40439. * Updates the texture
  40440. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40441. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40442. */
  40443. update(invertY?: boolean, premulAlpha?: boolean): void;
  40444. /**
  40445. * Draws text onto the texture
  40446. * @param text defines the text to be drawn
  40447. * @param x defines the placement of the text from the left
  40448. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40449. * @param font defines the font to be used with font-style, font-size, font-name
  40450. * @param color defines the color used for the text
  40451. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40452. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40453. * @param update defines whether texture is immediately update (default is true)
  40454. */
  40455. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40456. /**
  40457. * Clones the texture
  40458. * @returns the clone of the texture.
  40459. */
  40460. clone(): DynamicTexture;
  40461. /**
  40462. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40463. * @returns a serialized dynamic texture object
  40464. */
  40465. serialize(): any;
  40466. /** @hidden */
  40467. _rebuild(): void;
  40468. }
  40469. }
  40470. declare module BABYLON {
  40471. /** @hidden */
  40472. export var imageProcessingPixelShader: {
  40473. name: string;
  40474. shader: string;
  40475. };
  40476. }
  40477. declare module BABYLON {
  40478. /**
  40479. * ImageProcessingPostProcess
  40480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40481. */
  40482. export class ImageProcessingPostProcess extends PostProcess {
  40483. /**
  40484. * Default configuration related to image processing available in the PBR Material.
  40485. */
  40486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40487. /**
  40488. * Gets the image processing configuration used either in this material.
  40489. */
  40490. /**
  40491. * Sets the Default image processing configuration used either in the this material.
  40492. *
  40493. * If sets to null, the scene one is in use.
  40494. */
  40495. imageProcessingConfiguration: ImageProcessingConfiguration;
  40496. /**
  40497. * Keep track of the image processing observer to allow dispose and replace.
  40498. */
  40499. private _imageProcessingObserver;
  40500. /**
  40501. * Attaches a new image processing configuration to the PBR Material.
  40502. * @param configuration
  40503. */
  40504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40505. /**
  40506. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40507. */
  40508. /**
  40509. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40510. */
  40511. colorCurves: Nullable<ColorCurves>;
  40512. /**
  40513. * Gets wether the color curves effect is enabled.
  40514. */
  40515. /**
  40516. * Sets wether the color curves effect is enabled.
  40517. */
  40518. colorCurvesEnabled: boolean;
  40519. /**
  40520. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40521. */
  40522. /**
  40523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40524. */
  40525. colorGradingTexture: Nullable<BaseTexture>;
  40526. /**
  40527. * Gets wether the color grading effect is enabled.
  40528. */
  40529. /**
  40530. * Gets wether the color grading effect is enabled.
  40531. */
  40532. colorGradingEnabled: boolean;
  40533. /**
  40534. * Gets exposure used in the effect.
  40535. */
  40536. /**
  40537. * Sets exposure used in the effect.
  40538. */
  40539. exposure: number;
  40540. /**
  40541. * Gets wether tonemapping is enabled or not.
  40542. */
  40543. /**
  40544. * Sets wether tonemapping is enabled or not
  40545. */
  40546. toneMappingEnabled: boolean;
  40547. /**
  40548. * Gets the type of tone mapping effect.
  40549. */
  40550. /**
  40551. * Sets the type of tone mapping effect.
  40552. */
  40553. toneMappingType: number;
  40554. /**
  40555. * Gets contrast used in the effect.
  40556. */
  40557. /**
  40558. * Sets contrast used in the effect.
  40559. */
  40560. contrast: number;
  40561. /**
  40562. * Gets Vignette stretch size.
  40563. */
  40564. /**
  40565. * Sets Vignette stretch size.
  40566. */
  40567. vignetteStretch: number;
  40568. /**
  40569. * Gets Vignette centre X Offset.
  40570. */
  40571. /**
  40572. * Sets Vignette centre X Offset.
  40573. */
  40574. vignetteCentreX: number;
  40575. /**
  40576. * Gets Vignette centre Y Offset.
  40577. */
  40578. /**
  40579. * Sets Vignette centre Y Offset.
  40580. */
  40581. vignetteCentreY: number;
  40582. /**
  40583. * Gets Vignette weight or intensity of the vignette effect.
  40584. */
  40585. /**
  40586. * Sets Vignette weight or intensity of the vignette effect.
  40587. */
  40588. vignetteWeight: number;
  40589. /**
  40590. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40591. * if vignetteEnabled is set to true.
  40592. */
  40593. /**
  40594. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40595. * if vignetteEnabled is set to true.
  40596. */
  40597. vignetteColor: Color4;
  40598. /**
  40599. * Gets Camera field of view used by the Vignette effect.
  40600. */
  40601. /**
  40602. * Sets Camera field of view used by the Vignette effect.
  40603. */
  40604. vignetteCameraFov: number;
  40605. /**
  40606. * Gets the vignette blend mode allowing different kind of effect.
  40607. */
  40608. /**
  40609. * Sets the vignette blend mode allowing different kind of effect.
  40610. */
  40611. vignetteBlendMode: number;
  40612. /**
  40613. * Gets wether the vignette effect is enabled.
  40614. */
  40615. /**
  40616. * Sets wether the vignette effect is enabled.
  40617. */
  40618. vignetteEnabled: boolean;
  40619. private _fromLinearSpace;
  40620. /**
  40621. * Gets wether the input of the processing is in Gamma or Linear Space.
  40622. */
  40623. /**
  40624. * Sets wether the input of the processing is in Gamma or Linear Space.
  40625. */
  40626. fromLinearSpace: boolean;
  40627. /**
  40628. * Defines cache preventing GC.
  40629. */
  40630. private _defines;
  40631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40632. /**
  40633. * "ImageProcessingPostProcess"
  40634. * @returns "ImageProcessingPostProcess"
  40635. */
  40636. getClassName(): string;
  40637. protected _updateParameters(): void;
  40638. dispose(camera?: Camera): void;
  40639. }
  40640. }
  40641. declare module BABYLON {
  40642. /**
  40643. * Class containing static functions to help procedurally build meshes
  40644. */
  40645. export class GroundBuilder {
  40646. /**
  40647. * Creates a ground mesh
  40648. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40649. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40651. * @param name defines the name of the mesh
  40652. * @param options defines the options used to create the mesh
  40653. * @param scene defines the hosting scene
  40654. * @returns the ground mesh
  40655. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40656. */
  40657. static CreateGround(name: string, options: {
  40658. width?: number;
  40659. height?: number;
  40660. subdivisions?: number;
  40661. subdivisionsX?: number;
  40662. subdivisionsY?: number;
  40663. updatable?: boolean;
  40664. }, scene: any): Mesh;
  40665. /**
  40666. * Creates a tiled ground mesh
  40667. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40668. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40669. * * 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
  40670. * * 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
  40671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40672. * @param name defines the name of the mesh
  40673. * @param options defines the options used to create the mesh
  40674. * @param scene defines the hosting scene
  40675. * @returns the tiled ground mesh
  40676. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40677. */
  40678. static CreateTiledGround(name: string, options: {
  40679. xmin: number;
  40680. zmin: number;
  40681. xmax: number;
  40682. zmax: number;
  40683. subdivisions?: {
  40684. w: number;
  40685. h: number;
  40686. };
  40687. precision?: {
  40688. w: number;
  40689. h: number;
  40690. };
  40691. updatable?: boolean;
  40692. }, scene?: Nullable<Scene>): Mesh;
  40693. /**
  40694. * Creates a ground mesh from a height map
  40695. * * The parameter `url` sets the URL of the height map image resource.
  40696. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40697. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40698. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40699. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40700. * * 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.
  40701. * * 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).
  40702. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40704. * @param name defines the name of the mesh
  40705. * @param url defines the url to the height map
  40706. * @param options defines the options used to create the mesh
  40707. * @param scene defines the hosting scene
  40708. * @returns the ground mesh
  40709. * @see https://doc.babylonjs.com/babylon101/height_map
  40710. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40711. */
  40712. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40713. width?: number;
  40714. height?: number;
  40715. subdivisions?: number;
  40716. minHeight?: number;
  40717. maxHeight?: number;
  40718. colorFilter?: Color3;
  40719. alphaFilter?: number;
  40720. updatable?: boolean;
  40721. onReady?: (mesh: GroundMesh) => void;
  40722. }, scene?: Nullable<Scene>): GroundMesh;
  40723. }
  40724. }
  40725. declare module BABYLON {
  40726. /**
  40727. * Class containing static functions to help procedurally build meshes
  40728. */
  40729. export class TorusBuilder {
  40730. /**
  40731. * Creates a torus mesh
  40732. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40733. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40734. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40736. * * 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
  40737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40738. * @param name defines the name of the mesh
  40739. * @param options defines the options used to create the mesh
  40740. * @param scene defines the hosting scene
  40741. * @returns the torus mesh
  40742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40743. */
  40744. static CreateTorus(name: string, options: {
  40745. diameter?: number;
  40746. thickness?: number;
  40747. tessellation?: number;
  40748. updatable?: boolean;
  40749. sideOrientation?: number;
  40750. frontUVs?: Vector4;
  40751. backUVs?: Vector4;
  40752. }, scene: any): Mesh;
  40753. }
  40754. }
  40755. declare module BABYLON {
  40756. /**
  40757. * Class containing static functions to help procedurally build meshes
  40758. */
  40759. export class CylinderBuilder {
  40760. /**
  40761. * Creates a cylinder or a cone mesh
  40762. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40763. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40764. * * 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.
  40765. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40766. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40767. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40768. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40769. * * 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).
  40770. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40771. * * 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).
  40772. * * 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
  40773. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40774. * * 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
  40775. * * 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.
  40776. * * If `enclose` is false, a ring surface is one element.
  40777. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40778. * * 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
  40779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40780. * * 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
  40781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40782. * @param name defines the name of the mesh
  40783. * @param options defines the options used to create the mesh
  40784. * @param scene defines the hosting scene
  40785. * @returns the cylinder mesh
  40786. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40787. */
  40788. static CreateCylinder(name: string, options: {
  40789. height?: number;
  40790. diameterTop?: number;
  40791. diameterBottom?: number;
  40792. diameter?: number;
  40793. tessellation?: number;
  40794. subdivisions?: number;
  40795. arc?: number;
  40796. faceColors?: Color4[];
  40797. faceUV?: Vector4[];
  40798. updatable?: boolean;
  40799. hasRings?: boolean;
  40800. enclose?: boolean;
  40801. cap?: number;
  40802. sideOrientation?: number;
  40803. frontUVs?: Vector4;
  40804. backUVs?: Vector4;
  40805. }, scene: any): Mesh;
  40806. }
  40807. }
  40808. declare module BABYLON {
  40809. /**
  40810. * Options to modify the vr teleportation behavior.
  40811. */
  40812. export interface VRTeleportationOptions {
  40813. /**
  40814. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40815. */
  40816. floorMeshName?: string;
  40817. /**
  40818. * A list of meshes to be used as the teleportation floor. (default: empty)
  40819. */
  40820. floorMeshes?: Mesh[];
  40821. }
  40822. /**
  40823. * Options to modify the vr experience helper's behavior.
  40824. */
  40825. export interface VRExperienceHelperOptions extends WebVROptions {
  40826. /**
  40827. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40828. */
  40829. createDeviceOrientationCamera?: boolean;
  40830. /**
  40831. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40832. */
  40833. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40834. /**
  40835. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40836. */
  40837. laserToggle?: boolean;
  40838. /**
  40839. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40840. */
  40841. floorMeshes?: Mesh[];
  40842. /**
  40843. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40844. */
  40845. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40846. }
  40847. /**
  40848. * Event containing information after VR has been entered
  40849. */
  40850. export class OnAfterEnteringVRObservableEvent {
  40851. /**
  40852. * If entering vr was successful
  40853. */
  40854. success: boolean;
  40855. }
  40856. /**
  40857. * Helps to quickly add VR support to an existing scene.
  40858. * See http://doc.babylonjs.com/how_to/webvr_helper
  40859. */
  40860. export class VRExperienceHelper {
  40861. /** Options to modify the vr experience helper's behavior. */
  40862. webVROptions: VRExperienceHelperOptions;
  40863. private _scene;
  40864. private _position;
  40865. private _btnVR;
  40866. private _btnVRDisplayed;
  40867. private _webVRsupported;
  40868. private _webVRready;
  40869. private _webVRrequesting;
  40870. private _webVRpresenting;
  40871. private _hasEnteredVR;
  40872. private _fullscreenVRpresenting;
  40873. private _canvas;
  40874. private _webVRCamera;
  40875. private _vrDeviceOrientationCamera;
  40876. private _deviceOrientationCamera;
  40877. private _existingCamera;
  40878. private _onKeyDown;
  40879. private _onVrDisplayPresentChange;
  40880. private _onVRDisplayChanged;
  40881. private _onVRRequestPresentStart;
  40882. private _onVRRequestPresentComplete;
  40883. /**
  40884. * 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)
  40885. */
  40886. enableGazeEvenWhenNoPointerLock: boolean;
  40887. /**
  40888. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40889. */
  40890. exitVROnDoubleTap: boolean;
  40891. /**
  40892. * Observable raised right before entering VR.
  40893. */
  40894. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40895. /**
  40896. * Observable raised when entering VR has completed.
  40897. */
  40898. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40899. /**
  40900. * Observable raised when exiting VR.
  40901. */
  40902. onExitingVRObservable: Observable<VRExperienceHelper>;
  40903. /**
  40904. * Observable raised when controller mesh is loaded.
  40905. */
  40906. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40907. /** Return this.onEnteringVRObservable
  40908. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40909. */
  40910. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40911. /** Return this.onExitingVRObservable
  40912. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40913. */
  40914. readonly onExitingVR: Observable<VRExperienceHelper>;
  40915. /** Return this.onControllerMeshLoadedObservable
  40916. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40917. */
  40918. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40919. private _rayLength;
  40920. private _useCustomVRButton;
  40921. private _teleportationRequested;
  40922. private _teleportActive;
  40923. private _floorMeshName;
  40924. private _floorMeshesCollection;
  40925. private _rotationAllowed;
  40926. private _teleportBackwardsVector;
  40927. private _teleportationTarget;
  40928. private _isDefaultTeleportationTarget;
  40929. private _postProcessMove;
  40930. private _teleportationFillColor;
  40931. private _teleportationBorderColor;
  40932. private _rotationAngle;
  40933. private _haloCenter;
  40934. private _cameraGazer;
  40935. private _padSensibilityUp;
  40936. private _padSensibilityDown;
  40937. private _leftController;
  40938. private _rightController;
  40939. /**
  40940. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40941. */
  40942. onNewMeshSelected: Observable<AbstractMesh>;
  40943. /**
  40944. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40945. * This observable will provide the mesh and the controller used to select the mesh
  40946. */
  40947. onMeshSelectedWithController: Observable<{
  40948. mesh: AbstractMesh;
  40949. controller: WebVRController;
  40950. }>;
  40951. /**
  40952. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40953. */
  40954. onNewMeshPicked: Observable<PickingInfo>;
  40955. private _circleEase;
  40956. /**
  40957. * Observable raised before camera teleportation
  40958. */
  40959. onBeforeCameraTeleport: Observable<Vector3>;
  40960. /**
  40961. * Observable raised after camera teleportation
  40962. */
  40963. onAfterCameraTeleport: Observable<Vector3>;
  40964. /**
  40965. * Observable raised when current selected mesh gets unselected
  40966. */
  40967. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40968. private _raySelectionPredicate;
  40969. /**
  40970. * To be optionaly changed by user to define custom ray selection
  40971. */
  40972. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40973. /**
  40974. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40975. */
  40976. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40977. /**
  40978. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40979. */
  40980. teleportationEnabled: boolean;
  40981. private _defaultHeight;
  40982. private _teleportationInitialized;
  40983. private _interactionsEnabled;
  40984. private _interactionsRequested;
  40985. private _displayGaze;
  40986. private _displayLaserPointer;
  40987. /**
  40988. * The mesh used to display where the user is going to teleport.
  40989. */
  40990. /**
  40991. * Sets the mesh to be used to display where the user is going to teleport.
  40992. */
  40993. teleportationTarget: Mesh;
  40994. /**
  40995. * 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
  40996. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40997. * See http://doc.babylonjs.com/resources/baking_transformations
  40998. */
  40999. gazeTrackerMesh: Mesh;
  41000. /**
  41001. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41002. */
  41003. updateGazeTrackerScale: boolean;
  41004. /**
  41005. * If the gaze trackers color should be updated when selecting meshes
  41006. */
  41007. updateGazeTrackerColor: boolean;
  41008. /**
  41009. * The gaze tracking mesh corresponding to the left controller
  41010. */
  41011. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41012. /**
  41013. * The gaze tracking mesh corresponding to the right controller
  41014. */
  41015. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41016. /**
  41017. * If the ray of the gaze should be displayed.
  41018. */
  41019. /**
  41020. * Sets if the ray of the gaze should be displayed.
  41021. */
  41022. displayGaze: boolean;
  41023. /**
  41024. * If the ray of the LaserPointer should be displayed.
  41025. */
  41026. /**
  41027. * Sets if the ray of the LaserPointer should be displayed.
  41028. */
  41029. displayLaserPointer: boolean;
  41030. /**
  41031. * The deviceOrientationCamera used as the camera when not in VR.
  41032. */
  41033. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41034. /**
  41035. * Based on the current WebVR support, returns the current VR camera used.
  41036. */
  41037. readonly currentVRCamera: Nullable<Camera>;
  41038. /**
  41039. * The webVRCamera which is used when in VR.
  41040. */
  41041. readonly webVRCamera: WebVRFreeCamera;
  41042. /**
  41043. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41044. */
  41045. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41046. /**
  41047. * The html button that is used to trigger entering into VR.
  41048. */
  41049. readonly vrButton: Nullable<HTMLButtonElement>;
  41050. private readonly _teleportationRequestInitiated;
  41051. /**
  41052. * Defines wether or not Pointer lock should be requested when switching to
  41053. * full screen.
  41054. */
  41055. requestPointerLockOnFullScreen: boolean;
  41056. /**
  41057. * Instantiates a VRExperienceHelper.
  41058. * Helps to quickly add VR support to an existing scene.
  41059. * @param scene The scene the VRExperienceHelper belongs to.
  41060. * @param webVROptions Options to modify the vr experience helper's behavior.
  41061. */
  41062. constructor(scene: Scene,
  41063. /** Options to modify the vr experience helper's behavior. */
  41064. webVROptions?: VRExperienceHelperOptions);
  41065. private _onDefaultMeshLoaded;
  41066. private _onResize;
  41067. private _onFullscreenChange;
  41068. /**
  41069. * Gets a value indicating if we are currently in VR mode.
  41070. */
  41071. readonly isInVRMode: boolean;
  41072. private onVrDisplayPresentChange;
  41073. private onVRDisplayChanged;
  41074. private moveButtonToBottomRight;
  41075. private displayVRButton;
  41076. private updateButtonVisibility;
  41077. private _cachedAngularSensibility;
  41078. /**
  41079. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41080. * Otherwise, will use the fullscreen API.
  41081. */
  41082. enterVR(): void;
  41083. /**
  41084. * Attempt to exit VR, or fullscreen.
  41085. */
  41086. exitVR(): void;
  41087. /**
  41088. * The position of the vr experience helper.
  41089. */
  41090. /**
  41091. * Sets the position of the vr experience helper.
  41092. */
  41093. position: Vector3;
  41094. /**
  41095. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41096. */
  41097. enableInteractions(): void;
  41098. private readonly _noControllerIsActive;
  41099. private beforeRender;
  41100. private _isTeleportationFloor;
  41101. /**
  41102. * Adds a floor mesh to be used for teleportation.
  41103. * @param floorMesh the mesh to be used for teleportation.
  41104. */
  41105. addFloorMesh(floorMesh: Mesh): void;
  41106. /**
  41107. * Removes a floor mesh from being used for teleportation.
  41108. * @param floorMesh the mesh to be removed.
  41109. */
  41110. removeFloorMesh(floorMesh: Mesh): void;
  41111. /**
  41112. * Enables interactions and teleportation using the VR controllers and gaze.
  41113. * @param vrTeleportationOptions options to modify teleportation behavior.
  41114. */
  41115. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41116. private _onNewGamepadConnected;
  41117. private _tryEnableInteractionOnController;
  41118. private _onNewGamepadDisconnected;
  41119. private _enableInteractionOnController;
  41120. private _checkTeleportWithRay;
  41121. private _checkRotate;
  41122. private _checkTeleportBackwards;
  41123. private _enableTeleportationOnController;
  41124. private _createTeleportationCircles;
  41125. private _displayTeleportationTarget;
  41126. private _hideTeleportationTarget;
  41127. private _rotateCamera;
  41128. private _moveTeleportationSelectorTo;
  41129. private _workingVector;
  41130. private _workingQuaternion;
  41131. private _workingMatrix;
  41132. /**
  41133. * Teleports the users feet to the desired location
  41134. * @param location The location where the user's feet should be placed
  41135. */
  41136. teleportCamera(location: Vector3): void;
  41137. private _convertNormalToDirectionOfRay;
  41138. private _castRayAndSelectObject;
  41139. private _notifySelectedMeshUnselected;
  41140. /**
  41141. * Sets the color of the laser ray from the vr controllers.
  41142. * @param color new color for the ray.
  41143. */
  41144. changeLaserColor(color: Color3): void;
  41145. /**
  41146. * Sets the color of the ray from the vr headsets gaze.
  41147. * @param color new color for the ray.
  41148. */
  41149. changeGazeColor(color: Color3): void;
  41150. /**
  41151. * Exits VR and disposes of the vr experience helper
  41152. */
  41153. dispose(): void;
  41154. /**
  41155. * Gets the name of the VRExperienceHelper class
  41156. * @returns "VRExperienceHelper"
  41157. */
  41158. getClassName(): string;
  41159. }
  41160. }
  41161. declare module BABYLON {
  41162. /**
  41163. * Manages an XRSession to work with Babylon's engine
  41164. * @see https://doc.babylonjs.com/how_to/webxr
  41165. */
  41166. export class WebXRSessionManager implements IDisposable {
  41167. private scene;
  41168. /**
  41169. * Fires every time a new xrFrame arrives which can be used to update the camera
  41170. */
  41171. onXRFrameObservable: Observable<any>;
  41172. /**
  41173. * Fires when the xr session is ended either by the device or manually done
  41174. */
  41175. onXRSessionEnded: Observable<any>;
  41176. /**
  41177. * Underlying xr session
  41178. */
  41179. session: XRSession;
  41180. /**
  41181. * Type of reference space used when creating the session
  41182. */
  41183. referenceSpace: XRReferenceSpace;
  41184. /** @hidden */
  41185. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41186. /**
  41187. * Current XR frame
  41188. */
  41189. currentFrame: Nullable<XRFrame>;
  41190. private _xrNavigator;
  41191. private baseLayer;
  41192. /**
  41193. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41194. * @param scene The scene which the session should be created for
  41195. */
  41196. constructor(scene: Scene);
  41197. /**
  41198. * Initializes the manager
  41199. * After initialization enterXR can be called to start an XR session
  41200. * @returns Promise which resolves after it is initialized
  41201. */
  41202. initializeAsync(): Promise<void>;
  41203. /**
  41204. * Initializes an xr session
  41205. * @param xrSessionMode mode to initialize
  41206. * @returns a promise which will resolve once the session has been initialized
  41207. */
  41208. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41209. /**
  41210. * Sets the reference space on the xr session
  41211. * @param referenceSpace space to set
  41212. * @returns a promise that will resolve once the reference space has been set
  41213. */
  41214. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41215. /**
  41216. * Updates the render state of the session
  41217. * @param state state to set
  41218. * @returns a promise that resolves once the render state has been updated
  41219. */
  41220. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41221. /**
  41222. * Starts rendering to the xr layer
  41223. * @returns a promise that will resolve once rendering has started
  41224. */
  41225. startRenderingToXRAsync(): Promise<void>;
  41226. /**
  41227. * Stops the xrSession and restores the renderloop
  41228. * @returns Promise which resolves after it exits XR
  41229. */
  41230. exitXRAsync(): Promise<unknown>;
  41231. /**
  41232. * Checks if a session would be supported for the creation options specified
  41233. * @param sessionMode session mode to check if supported eg. immersive-vr
  41234. * @returns true if supported
  41235. */
  41236. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41237. /**
  41238. * @hidden
  41239. * Converts the render layer of xrSession to a render target
  41240. * @param session session to create render target for
  41241. * @param scene scene the new render target should be created for
  41242. */
  41243. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41244. /**
  41245. * Disposes of the session manager
  41246. */
  41247. dispose(): void;
  41248. }
  41249. }
  41250. declare module BABYLON {
  41251. /**
  41252. * WebXR Camera which holds the views for the xrSession
  41253. * @see https://doc.babylonjs.com/how_to/webxr
  41254. */
  41255. export class WebXRCamera extends FreeCamera {
  41256. private static _TmpMatrix;
  41257. /**
  41258. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41259. * @param name the name of the camera
  41260. * @param scene the scene to add the camera to
  41261. */
  41262. constructor(name: string, scene: Scene);
  41263. private _updateNumberOfRigCameras;
  41264. /** @hidden */
  41265. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41266. /**
  41267. * Updates the cameras position from the current pose information of the XR session
  41268. * @param xrSessionManager the session containing pose information
  41269. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41270. */
  41271. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41272. }
  41273. }
  41274. declare module BABYLON {
  41275. /**
  41276. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41277. */
  41278. export class WebXRManagedOutputCanvas implements IDisposable {
  41279. private helper;
  41280. private _canvas;
  41281. /**
  41282. * xrpresent context of the canvas which can be used to display/mirror xr content
  41283. */
  41284. canvasContext: WebGLRenderingContext;
  41285. /**
  41286. * xr layer for the canvas
  41287. */
  41288. xrLayer: Nullable<XRWebGLLayer>;
  41289. /**
  41290. * Initializes the xr layer for the session
  41291. * @param xrSession xr session
  41292. * @returns a promise that will resolve once the XR Layer has been created
  41293. */
  41294. initializeXRLayerAsync(xrSession: any): any;
  41295. /**
  41296. * Initializes the canvas to be added/removed upon entering/exiting xr
  41297. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41298. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41299. */
  41300. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41301. /**
  41302. * Disposes of the object
  41303. */
  41304. dispose(): void;
  41305. private _setManagedOutputCanvas;
  41306. private _addCanvas;
  41307. private _removeCanvas;
  41308. }
  41309. }
  41310. declare module BABYLON {
  41311. /**
  41312. * States of the webXR experience
  41313. */
  41314. export enum WebXRState {
  41315. /**
  41316. * Transitioning to being in XR mode
  41317. */
  41318. ENTERING_XR = 0,
  41319. /**
  41320. * Transitioning to non XR mode
  41321. */
  41322. EXITING_XR = 1,
  41323. /**
  41324. * In XR mode and presenting
  41325. */
  41326. IN_XR = 2,
  41327. /**
  41328. * Not entered XR mode
  41329. */
  41330. NOT_IN_XR = 3
  41331. }
  41332. /**
  41333. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41334. * @see https://doc.babylonjs.com/how_to/webxr
  41335. */
  41336. export class WebXRExperienceHelper implements IDisposable {
  41337. private scene;
  41338. /**
  41339. * 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
  41340. */
  41341. container: AbstractMesh;
  41342. /**
  41343. * Camera used to render xr content
  41344. */
  41345. camera: WebXRCamera;
  41346. /**
  41347. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41348. */
  41349. state: WebXRState;
  41350. private _setState;
  41351. private static _TmpVector;
  41352. /**
  41353. * Fires when the state of the experience helper has changed
  41354. */
  41355. onStateChangedObservable: Observable<WebXRState>;
  41356. /** Session manager used to keep track of xr session */
  41357. sessionManager: WebXRSessionManager;
  41358. private _nonVRCamera;
  41359. private _originalSceneAutoClear;
  41360. private _supported;
  41361. /**
  41362. * Creates the experience helper
  41363. * @param scene the scene to attach the experience helper to
  41364. * @returns a promise for the experience helper
  41365. */
  41366. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41367. /**
  41368. * Creates a WebXRExperienceHelper
  41369. * @param scene The scene the helper should be created in
  41370. */
  41371. private constructor();
  41372. /**
  41373. * Exits XR mode and returns the scene to its original state
  41374. * @returns promise that resolves after xr mode has exited
  41375. */
  41376. exitXRAsync(): Promise<unknown>;
  41377. /**
  41378. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41379. * @param sessionCreationOptions options for the XR session
  41380. * @param referenceSpaceType frame of reference of the XR session
  41381. * @param outputCanvas the output canvas that will be used to enter XR mode
  41382. * @returns promise that resolves after xr mode has entered
  41383. */
  41384. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41385. /**
  41386. * Updates the global position of the camera by moving the camera's container
  41387. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41388. * @param position The desired global position of the camera
  41389. */
  41390. setPositionOfCameraUsingContainer(position: Vector3): void;
  41391. /**
  41392. * Rotates the xr camera by rotating the camera's container around the camera's position
  41393. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41394. * @param rotation the desired quaternion rotation to apply to the camera
  41395. */
  41396. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41397. /**
  41398. * Disposes of the experience helper
  41399. */
  41400. dispose(): void;
  41401. }
  41402. }
  41403. declare module BABYLON {
  41404. /**
  41405. * Button which can be used to enter a different mode of XR
  41406. */
  41407. export class WebXREnterExitUIButton {
  41408. /** button element */
  41409. element: HTMLElement;
  41410. /** XR initialization options for the button */
  41411. sessionMode: XRSessionMode;
  41412. /** Reference space type */
  41413. referenceSpaceType: XRReferenceSpaceType;
  41414. /**
  41415. * Creates a WebXREnterExitUIButton
  41416. * @param element button element
  41417. * @param sessionMode XR initialization session mode
  41418. * @param referenceSpaceType the type of reference space to be used
  41419. */
  41420. constructor(
  41421. /** button element */
  41422. element: HTMLElement,
  41423. /** XR initialization options for the button */
  41424. sessionMode: XRSessionMode,
  41425. /** Reference space type */
  41426. referenceSpaceType: XRReferenceSpaceType);
  41427. /**
  41428. * Overwritable function which can be used to update the button's visuals when the state changes
  41429. * @param activeButton the current active button in the UI
  41430. */
  41431. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41432. }
  41433. /**
  41434. * Options to create the webXR UI
  41435. */
  41436. export class WebXREnterExitUIOptions {
  41437. /**
  41438. * Context to enter xr with
  41439. */
  41440. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41441. /**
  41442. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41443. */
  41444. customButtons?: Array<WebXREnterExitUIButton>;
  41445. }
  41446. /**
  41447. * UI to allow the user to enter/exit XR mode
  41448. */
  41449. export class WebXREnterExitUI implements IDisposable {
  41450. private scene;
  41451. private _overlay;
  41452. private _buttons;
  41453. private _activeButton;
  41454. /**
  41455. * Fired every time the active button is changed.
  41456. *
  41457. * When xr is entered via a button that launches xr that button will be the callback parameter
  41458. *
  41459. * When exiting xr the callback parameter will be null)
  41460. */
  41461. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41462. /**
  41463. * Creates UI to allow the user to enter/exit XR mode
  41464. * @param scene the scene to add the ui to
  41465. * @param helper the xr experience helper to enter/exit xr with
  41466. * @param options options to configure the UI
  41467. * @returns the created ui
  41468. */
  41469. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41470. private constructor();
  41471. private _updateButtons;
  41472. /**
  41473. * Disposes of the object
  41474. */
  41475. dispose(): void;
  41476. }
  41477. }
  41478. declare module BABYLON {
  41479. /**
  41480. * Represents an XR input
  41481. */
  41482. export class WebXRController {
  41483. private scene;
  41484. /** The underlying input source for the controller */
  41485. inputSource: XRInputSource;
  41486. private parentContainer;
  41487. /**
  41488. * 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
  41489. */
  41490. grip?: AbstractMesh;
  41491. /**
  41492. * Pointer which can be used to select objects or attach a visible laser to
  41493. */
  41494. pointer: AbstractMesh;
  41495. /**
  41496. * Event that fires when the controller is removed/disposed
  41497. */
  41498. onDisposeObservable: Observable<{}>;
  41499. private _tmpMatrix;
  41500. private _tmpQuaternion;
  41501. private _tmpVector;
  41502. /**
  41503. * Creates the controller
  41504. * @see https://doc.babylonjs.com/how_to/webxr
  41505. * @param scene the scene which the controller should be associated to
  41506. * @param inputSource the underlying input source for the controller
  41507. * @param parentContainer parent that the controller meshes should be children of
  41508. */
  41509. constructor(scene: Scene,
  41510. /** The underlying input source for the controller */
  41511. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41512. /**
  41513. * Updates the controller pose based on the given XRFrame
  41514. * @param xrFrame xr frame to update the pose with
  41515. * @param referenceSpace reference space to use
  41516. */
  41517. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41518. /**
  41519. * Gets a world space ray coming from the controller
  41520. * @param result the resulting ray
  41521. */
  41522. getWorldPointerRayToRef(result: Ray): void;
  41523. /**
  41524. * Disposes of the object
  41525. */
  41526. dispose(): void;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * XR input used to track XR inputs such as controllers/rays
  41532. */
  41533. export class WebXRInput implements IDisposable {
  41534. /**
  41535. * Base experience the input listens to
  41536. */
  41537. baseExperience: WebXRExperienceHelper;
  41538. /**
  41539. * XR controllers being tracked
  41540. */
  41541. controllers: Array<WebXRController>;
  41542. private _frameObserver;
  41543. private _stateObserver;
  41544. /**
  41545. * Event when a controller has been connected/added
  41546. */
  41547. onControllerAddedObservable: Observable<WebXRController>;
  41548. /**
  41549. * Event when a controller has been removed/disconnected
  41550. */
  41551. onControllerRemovedObservable: Observable<WebXRController>;
  41552. /**
  41553. * Initializes the WebXRInput
  41554. * @param baseExperience experience helper which the input should be created for
  41555. */
  41556. constructor(
  41557. /**
  41558. * Base experience the input listens to
  41559. */
  41560. baseExperience: WebXRExperienceHelper);
  41561. private _onInputSourcesChange;
  41562. private _addAndRemoveControllers;
  41563. /**
  41564. * Disposes of the object
  41565. */
  41566. dispose(): void;
  41567. }
  41568. }
  41569. declare module BABYLON {
  41570. /**
  41571. * Enables teleportation
  41572. */
  41573. export class WebXRControllerTeleportation {
  41574. private _teleportationFillColor;
  41575. private _teleportationBorderColor;
  41576. private _tmpRay;
  41577. private _tmpVector;
  41578. /**
  41579. * Creates a WebXRControllerTeleportation
  41580. * @param input input manager to add teleportation to
  41581. * @param floorMeshes floormeshes which can be teleported to
  41582. */
  41583. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41584. }
  41585. }
  41586. declare module BABYLON {
  41587. /**
  41588. * Handles pointer input automatically for the pointer of XR controllers
  41589. */
  41590. export class WebXRControllerPointerSelection {
  41591. private static _idCounter;
  41592. private _tmpRay;
  41593. /**
  41594. * Creates a WebXRControllerPointerSelection
  41595. * @param input input manager to setup pointer selection
  41596. */
  41597. constructor(input: WebXRInput);
  41598. private _convertNormalToDirectionOfRay;
  41599. private _updatePointerDistance;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Class used to represent data loading progression
  41605. */
  41606. export class SceneLoaderProgressEvent {
  41607. /** defines if data length to load can be evaluated */
  41608. readonly lengthComputable: boolean;
  41609. /** defines the loaded data length */
  41610. readonly loaded: number;
  41611. /** defines the data length to load */
  41612. readonly total: number;
  41613. /**
  41614. * Create a new progress event
  41615. * @param lengthComputable defines if data length to load can be evaluated
  41616. * @param loaded defines the loaded data length
  41617. * @param total defines the data length to load
  41618. */
  41619. constructor(
  41620. /** defines if data length to load can be evaluated */
  41621. lengthComputable: boolean,
  41622. /** defines the loaded data length */
  41623. loaded: number,
  41624. /** defines the data length to load */
  41625. total: number);
  41626. /**
  41627. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41628. * @param event defines the source event
  41629. * @returns a new SceneLoaderProgressEvent
  41630. */
  41631. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41632. }
  41633. /**
  41634. * Interface used by SceneLoader plugins to define supported file extensions
  41635. */
  41636. export interface ISceneLoaderPluginExtensions {
  41637. /**
  41638. * Defines the list of supported extensions
  41639. */
  41640. [extension: string]: {
  41641. isBinary: boolean;
  41642. };
  41643. }
  41644. /**
  41645. * Interface used by SceneLoader plugin factory
  41646. */
  41647. export interface ISceneLoaderPluginFactory {
  41648. /**
  41649. * Defines the name of the factory
  41650. */
  41651. name: string;
  41652. /**
  41653. * Function called to create a new plugin
  41654. * @return the new plugin
  41655. */
  41656. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41657. /**
  41658. * Boolean indicating if the plugin can direct load specific data
  41659. */
  41660. canDirectLoad?: (data: string) => boolean;
  41661. }
  41662. /**
  41663. * Interface used to define a SceneLoader plugin
  41664. */
  41665. export interface ISceneLoaderPlugin {
  41666. /**
  41667. * The friendly name of this plugin.
  41668. */
  41669. name: string;
  41670. /**
  41671. * The file extensions supported by this plugin.
  41672. */
  41673. extensions: string | ISceneLoaderPluginExtensions;
  41674. /**
  41675. * Import meshes into a scene.
  41676. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41677. * @param scene The scene to import into
  41678. * @param data The data to import
  41679. * @param rootUrl The root url for scene and resources
  41680. * @param meshes The meshes array to import into
  41681. * @param particleSystems The particle systems array to import into
  41682. * @param skeletons The skeletons array to import into
  41683. * @param onError The callback when import fails
  41684. * @returns True if successful or false otherwise
  41685. */
  41686. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41687. /**
  41688. * Load into a scene.
  41689. * @param scene The scene to load into
  41690. * @param data The data to import
  41691. * @param rootUrl The root url for scene and resources
  41692. * @param onError The callback when import fails
  41693. * @returns true if successful or false otherwise
  41694. */
  41695. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41696. /**
  41697. * The callback that returns true if the data can be directly loaded.
  41698. */
  41699. canDirectLoad?: (data: string) => boolean;
  41700. /**
  41701. * The callback that allows custom handling of the root url based on the response url.
  41702. */
  41703. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41704. /**
  41705. * Load into an asset container.
  41706. * @param scene The scene to load into
  41707. * @param data The data to import
  41708. * @param rootUrl The root url for scene and resources
  41709. * @param onError The callback when import fails
  41710. * @returns The loaded asset container
  41711. */
  41712. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41713. }
  41714. /**
  41715. * Interface used to define an async SceneLoader plugin
  41716. */
  41717. export interface ISceneLoaderPluginAsync {
  41718. /**
  41719. * The friendly name of this plugin.
  41720. */
  41721. name: string;
  41722. /**
  41723. * The file extensions supported by this plugin.
  41724. */
  41725. extensions: string | ISceneLoaderPluginExtensions;
  41726. /**
  41727. * Import meshes into a scene.
  41728. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41729. * @param scene The scene to import into
  41730. * @param data The data to import
  41731. * @param rootUrl The root url for scene and resources
  41732. * @param onProgress The callback when the load progresses
  41733. * @param fileName Defines the name of the file to load
  41734. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41735. */
  41736. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41737. meshes: AbstractMesh[];
  41738. particleSystems: IParticleSystem[];
  41739. skeletons: Skeleton[];
  41740. animationGroups: AnimationGroup[];
  41741. }>;
  41742. /**
  41743. * Load into a scene.
  41744. * @param scene The scene to load into
  41745. * @param data The data to import
  41746. * @param rootUrl The root url for scene and resources
  41747. * @param onProgress The callback when the load progresses
  41748. * @param fileName Defines the name of the file to load
  41749. * @returns Nothing
  41750. */
  41751. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41752. /**
  41753. * The callback that returns true if the data can be directly loaded.
  41754. */
  41755. canDirectLoad?: (data: string) => boolean;
  41756. /**
  41757. * The callback that allows custom handling of the root url based on the response url.
  41758. */
  41759. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41760. /**
  41761. * Load into an asset container.
  41762. * @param scene The scene to load into
  41763. * @param data The data to import
  41764. * @param rootUrl The root url for scene and resources
  41765. * @param onProgress The callback when the load progresses
  41766. * @param fileName Defines the name of the file to load
  41767. * @returns The loaded asset container
  41768. */
  41769. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41770. }
  41771. /**
  41772. * Class used to load scene from various file formats using registered plugins
  41773. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41774. */
  41775. export class SceneLoader {
  41776. /**
  41777. * No logging while loading
  41778. */
  41779. static readonly NO_LOGGING: number;
  41780. /**
  41781. * Minimal logging while loading
  41782. */
  41783. static readonly MINIMAL_LOGGING: number;
  41784. /**
  41785. * Summary logging while loading
  41786. */
  41787. static readonly SUMMARY_LOGGING: number;
  41788. /**
  41789. * Detailled logging while loading
  41790. */
  41791. static readonly DETAILED_LOGGING: number;
  41792. /**
  41793. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41794. */
  41795. static ForceFullSceneLoadingForIncremental: boolean;
  41796. /**
  41797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41798. */
  41799. static ShowLoadingScreen: boolean;
  41800. /**
  41801. * Defines the current logging level (while loading the scene)
  41802. * @ignorenaming
  41803. */
  41804. static loggingLevel: number;
  41805. /**
  41806. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41807. */
  41808. static CleanBoneMatrixWeights: boolean;
  41809. /**
  41810. * Event raised when a plugin is used to load a scene
  41811. */
  41812. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41813. private static _registeredPlugins;
  41814. private static _getDefaultPlugin;
  41815. private static _getPluginForExtension;
  41816. private static _getPluginForDirectLoad;
  41817. private static _getPluginForFilename;
  41818. private static _getDirectLoad;
  41819. private static _loadData;
  41820. private static _getFileInfo;
  41821. /**
  41822. * Gets a plugin that can load the given extension
  41823. * @param extension defines the extension to load
  41824. * @returns a plugin or null if none works
  41825. */
  41826. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41827. /**
  41828. * Gets a boolean indicating that the given extension can be loaded
  41829. * @param extension defines the extension to load
  41830. * @returns true if the extension is supported
  41831. */
  41832. static IsPluginForExtensionAvailable(extension: string): boolean;
  41833. /**
  41834. * Adds a new plugin to the list of registered plugins
  41835. * @param plugin defines the plugin to add
  41836. */
  41837. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41838. /**
  41839. * Import meshes into a scene
  41840. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41841. * @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)
  41842. * @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)
  41843. * @param scene the instance of BABYLON.Scene to append to
  41844. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41845. * @param onProgress a callback with a progress event for each file being loaded
  41846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41847. * @param pluginExtension the extension used to determine the plugin
  41848. * @returns The loaded plugin
  41849. */
  41850. 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>;
  41851. /**
  41852. * Import meshes into a scene
  41853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41854. * @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)
  41855. * @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)
  41856. * @param scene the instance of BABYLON.Scene to append to
  41857. * @param onProgress a callback with a progress event for each file being loaded
  41858. * @param pluginExtension the extension used to determine the plugin
  41859. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41860. */
  41861. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41862. meshes: AbstractMesh[];
  41863. particleSystems: IParticleSystem[];
  41864. skeletons: Skeleton[];
  41865. animationGroups: AnimationGroup[];
  41866. }>;
  41867. /**
  41868. * Load a scene
  41869. * @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)
  41870. * @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)
  41871. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41872. * @param onSuccess a callback with the scene when import succeeds
  41873. * @param onProgress a callback with a progress event for each file being loaded
  41874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41875. * @param pluginExtension the extension used to determine the plugin
  41876. * @returns The loaded plugin
  41877. */
  41878. 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>;
  41879. /**
  41880. * Load a scene
  41881. * @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)
  41882. * @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)
  41883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41884. * @param onProgress a callback with a progress event for each file being loaded
  41885. * @param pluginExtension the extension used to determine the plugin
  41886. * @returns The loaded scene
  41887. */
  41888. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41889. /**
  41890. * Append a scene
  41891. * @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)
  41892. * @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)
  41893. * @param scene is the instance of BABYLON.Scene to append to
  41894. * @param onSuccess a callback with the scene when import succeeds
  41895. * @param onProgress a callback with a progress event for each file being loaded
  41896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41897. * @param pluginExtension the extension used to determine the plugin
  41898. * @returns The loaded plugin
  41899. */
  41900. 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>;
  41901. /**
  41902. * Append a scene
  41903. * @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)
  41904. * @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)
  41905. * @param scene is the instance of BABYLON.Scene to append to
  41906. * @param onProgress a callback with a progress event for each file being loaded
  41907. * @param pluginExtension the extension used to determine the plugin
  41908. * @returns The given scene
  41909. */
  41910. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41911. /**
  41912. * Load a scene into an asset container
  41913. * @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)
  41914. * @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)
  41915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41916. * @param onSuccess a callback with the scene when import succeeds
  41917. * @param onProgress a callback with a progress event for each file being loaded
  41918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41919. * @param pluginExtension the extension used to determine the plugin
  41920. * @returns The loaded plugin
  41921. */
  41922. 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>;
  41923. /**
  41924. * Load a scene into an asset container
  41925. * @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)
  41926. * @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)
  41927. * @param scene is the instance of Scene to append to
  41928. * @param onProgress a callback with a progress event for each file being loaded
  41929. * @param pluginExtension the extension used to determine the plugin
  41930. * @returns The loaded asset container
  41931. */
  41932. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41933. }
  41934. }
  41935. declare module BABYLON {
  41936. /**
  41937. * Generic Controller
  41938. */
  41939. export class GenericController extends WebVRController {
  41940. /**
  41941. * Base Url for the controller model.
  41942. */
  41943. static readonly MODEL_BASE_URL: string;
  41944. /**
  41945. * File name for the controller model.
  41946. */
  41947. static readonly MODEL_FILENAME: string;
  41948. /**
  41949. * Creates a new GenericController from a gamepad
  41950. * @param vrGamepad the gamepad that the controller should be created from
  41951. */
  41952. constructor(vrGamepad: any);
  41953. /**
  41954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41955. * @param scene scene in which to add meshes
  41956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41957. */
  41958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41959. /**
  41960. * Called once for each button that changed state since the last frame
  41961. * @param buttonIdx Which button index changed
  41962. * @param state New state of the button
  41963. * @param changes Which properties on the state changed since last frame
  41964. */
  41965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41966. }
  41967. }
  41968. declare module BABYLON {
  41969. /**
  41970. * Defines the WindowsMotionController object that the state of the windows motion controller
  41971. */
  41972. export class WindowsMotionController extends WebVRController {
  41973. /**
  41974. * The base url used to load the left and right controller models
  41975. */
  41976. static MODEL_BASE_URL: string;
  41977. /**
  41978. * The name of the left controller model file
  41979. */
  41980. static MODEL_LEFT_FILENAME: string;
  41981. /**
  41982. * The name of the right controller model file
  41983. */
  41984. static MODEL_RIGHT_FILENAME: string;
  41985. /**
  41986. * The controller name prefix for this controller type
  41987. */
  41988. static readonly GAMEPAD_ID_PREFIX: string;
  41989. /**
  41990. * The controller id pattern for this controller type
  41991. */
  41992. private static readonly GAMEPAD_ID_PATTERN;
  41993. private _loadedMeshInfo;
  41994. private readonly _mapping;
  41995. /**
  41996. * Fired when the trackpad on this controller is clicked
  41997. */
  41998. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41999. /**
  42000. * Fired when the trackpad on this controller is modified
  42001. */
  42002. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42003. /**
  42004. * The current x and y values of this controller's trackpad
  42005. */
  42006. trackpad: StickValues;
  42007. /**
  42008. * Creates a new WindowsMotionController from a gamepad
  42009. * @param vrGamepad the gamepad that the controller should be created from
  42010. */
  42011. constructor(vrGamepad: any);
  42012. /**
  42013. * Fired when the trigger on this controller is modified
  42014. */
  42015. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42016. /**
  42017. * Fired when the menu button on this controller is modified
  42018. */
  42019. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42020. /**
  42021. * Fired when the grip button on this controller is modified
  42022. */
  42023. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42024. /**
  42025. * Fired when the thumbstick button on this controller is modified
  42026. */
  42027. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42028. /**
  42029. * Fired when the touchpad button on this controller is modified
  42030. */
  42031. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42032. /**
  42033. * Fired when the touchpad values on this controller are modified
  42034. */
  42035. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42036. private _updateTrackpad;
  42037. /**
  42038. * Called once per frame by the engine.
  42039. */
  42040. update(): void;
  42041. /**
  42042. * Called once for each button that changed state since the last frame
  42043. * @param buttonIdx Which button index changed
  42044. * @param state New state of the button
  42045. * @param changes Which properties on the state changed since last frame
  42046. */
  42047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42048. /**
  42049. * Moves the buttons on the controller mesh based on their current state
  42050. * @param buttonName the name of the button to move
  42051. * @param buttonValue the value of the button which determines the buttons new position
  42052. */
  42053. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42054. /**
  42055. * Moves the axis on the controller mesh based on its current state
  42056. * @param axis the index of the axis
  42057. * @param axisValue the value of the axis which determines the meshes new position
  42058. * @hidden
  42059. */
  42060. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42061. /**
  42062. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42063. * @param scene scene in which to add meshes
  42064. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42065. */
  42066. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42067. /**
  42068. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42069. * can be transformed by button presses and axes values, based on this._mapping.
  42070. *
  42071. * @param scene scene in which the meshes exist
  42072. * @param meshes list of meshes that make up the controller model to process
  42073. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42074. */
  42075. private processModel;
  42076. private createMeshInfo;
  42077. /**
  42078. * Gets the ray of the controller in the direction the controller is pointing
  42079. * @param length the length the resulting ray should be
  42080. * @returns a ray in the direction the controller is pointing
  42081. */
  42082. getForwardRay(length?: number): Ray;
  42083. /**
  42084. * Disposes of the controller
  42085. */
  42086. dispose(): void;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Oculus Touch Controller
  42092. */
  42093. export class OculusTouchController extends WebVRController {
  42094. /**
  42095. * Base Url for the controller model.
  42096. */
  42097. static MODEL_BASE_URL: string;
  42098. /**
  42099. * File name for the left controller model.
  42100. */
  42101. static MODEL_LEFT_FILENAME: string;
  42102. /**
  42103. * File name for the right controller model.
  42104. */
  42105. static MODEL_RIGHT_FILENAME: string;
  42106. /**
  42107. * Base Url for the Quest controller model.
  42108. */
  42109. static QUEST_MODEL_BASE_URL: string;
  42110. /**
  42111. * @hidden
  42112. * If the controllers are running on a device that needs the updated Quest controller models
  42113. */
  42114. static _IsQuest: boolean;
  42115. /**
  42116. * Fired when the secondary trigger on this controller is modified
  42117. */
  42118. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42119. /**
  42120. * Fired when the thumb rest on this controller is modified
  42121. */
  42122. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42123. /**
  42124. * Creates a new OculusTouchController from a gamepad
  42125. * @param vrGamepad the gamepad that the controller should be created from
  42126. */
  42127. constructor(vrGamepad: any);
  42128. /**
  42129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42130. * @param scene scene in which to add meshes
  42131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42132. */
  42133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42134. /**
  42135. * Fired when the A button on this controller is modified
  42136. */
  42137. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42138. /**
  42139. * Fired when the B button on this controller is modified
  42140. */
  42141. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42142. /**
  42143. * Fired when the X button on this controller is modified
  42144. */
  42145. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42146. /**
  42147. * Fired when the Y button on this controller is modified
  42148. */
  42149. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42150. /**
  42151. * Called once for each button that changed state since the last frame
  42152. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42153. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42154. * 2) secondary trigger (same)
  42155. * 3) A (right) X (left), touch, pressed = value
  42156. * 4) B / Y
  42157. * 5) thumb rest
  42158. * @param buttonIdx Which button index changed
  42159. * @param state New state of the button
  42160. * @param changes Which properties on the state changed since last frame
  42161. */
  42162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42163. }
  42164. }
  42165. declare module BABYLON {
  42166. /**
  42167. * Vive Controller
  42168. */
  42169. export class ViveController extends WebVRController {
  42170. /**
  42171. * Base Url for the controller model.
  42172. */
  42173. static MODEL_BASE_URL: string;
  42174. /**
  42175. * File name for the controller model.
  42176. */
  42177. static MODEL_FILENAME: string;
  42178. /**
  42179. * Creates a new ViveController from a gamepad
  42180. * @param vrGamepad the gamepad that the controller should be created from
  42181. */
  42182. constructor(vrGamepad: any);
  42183. /**
  42184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42185. * @param scene scene in which to add meshes
  42186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42187. */
  42188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42189. /**
  42190. * Fired when the left button on this controller is modified
  42191. */
  42192. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42193. /**
  42194. * Fired when the right button on this controller is modified
  42195. */
  42196. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42197. /**
  42198. * Fired when the menu button on this controller is modified
  42199. */
  42200. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42201. /**
  42202. * Called once for each button that changed state since the last frame
  42203. * Vive mapping:
  42204. * 0: touchpad
  42205. * 1: trigger
  42206. * 2: left AND right buttons
  42207. * 3: menu button
  42208. * @param buttonIdx Which button index changed
  42209. * @param state New state of the button
  42210. * @param changes Which properties on the state changed since last frame
  42211. */
  42212. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42213. }
  42214. }
  42215. declare module BABYLON {
  42216. /**
  42217. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42218. */
  42219. export class WebXRControllerModelLoader {
  42220. /**
  42221. * Creates the WebXRControllerModelLoader
  42222. * @param input xr input that creates the controllers
  42223. */
  42224. constructor(input: WebXRInput);
  42225. }
  42226. }
  42227. declare module BABYLON {
  42228. /**
  42229. * Contains an array of blocks representing the octree
  42230. */
  42231. export interface IOctreeContainer<T> {
  42232. /**
  42233. * Blocks within the octree
  42234. */
  42235. blocks: Array<OctreeBlock<T>>;
  42236. }
  42237. /**
  42238. * Class used to store a cell in an octree
  42239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42240. */
  42241. export class OctreeBlock<T> {
  42242. /**
  42243. * Gets the content of the current block
  42244. */
  42245. entries: T[];
  42246. /**
  42247. * Gets the list of block children
  42248. */
  42249. blocks: Array<OctreeBlock<T>>;
  42250. private _depth;
  42251. private _maxDepth;
  42252. private _capacity;
  42253. private _minPoint;
  42254. private _maxPoint;
  42255. private _boundingVectors;
  42256. private _creationFunc;
  42257. /**
  42258. * Creates a new block
  42259. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42260. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42261. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42262. * @param depth defines the current depth of this block in the octree
  42263. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42264. * @param creationFunc defines a callback to call when an element is added to the block
  42265. */
  42266. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42267. /**
  42268. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42269. */
  42270. readonly capacity: number;
  42271. /**
  42272. * Gets the minimum vector (in world space) of the block's bounding box
  42273. */
  42274. readonly minPoint: Vector3;
  42275. /**
  42276. * Gets the maximum vector (in world space) of the block's bounding box
  42277. */
  42278. readonly maxPoint: Vector3;
  42279. /**
  42280. * Add a new element to this block
  42281. * @param entry defines the element to add
  42282. */
  42283. addEntry(entry: T): void;
  42284. /**
  42285. * Remove an element from this block
  42286. * @param entry defines the element to remove
  42287. */
  42288. removeEntry(entry: T): void;
  42289. /**
  42290. * Add an array of elements to this block
  42291. * @param entries defines the array of elements to add
  42292. */
  42293. addEntries(entries: T[]): void;
  42294. /**
  42295. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42296. * @param frustumPlanes defines the frustum planes to test
  42297. * @param selection defines the array to store current content if selection is positive
  42298. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42299. */
  42300. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42301. /**
  42302. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42303. * @param sphereCenter defines the bounding sphere center
  42304. * @param sphereRadius defines the bounding sphere radius
  42305. * @param selection defines the array to store current content if selection is positive
  42306. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42307. */
  42308. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42309. /**
  42310. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42311. * @param ray defines the ray to test with
  42312. * @param selection defines the array to store current content if selection is positive
  42313. */
  42314. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42315. /**
  42316. * Subdivide the content into child blocks (this block will then be empty)
  42317. */
  42318. createInnerBlocks(): void;
  42319. /**
  42320. * @hidden
  42321. */
  42322. 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;
  42323. }
  42324. }
  42325. declare module BABYLON {
  42326. /**
  42327. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42328. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42329. */
  42330. export class Octree<T> {
  42331. /** 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.) */
  42332. maxDepth: number;
  42333. /**
  42334. * Blocks within the octree containing objects
  42335. */
  42336. blocks: Array<OctreeBlock<T>>;
  42337. /**
  42338. * Content stored in the octree
  42339. */
  42340. dynamicContent: T[];
  42341. private _maxBlockCapacity;
  42342. private _selectionContent;
  42343. private _creationFunc;
  42344. /**
  42345. * Creates a octree
  42346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42347. * @param creationFunc function to be used to instatiate the octree
  42348. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42349. * @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.)
  42350. */
  42351. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42352. /** 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.) */
  42353. maxDepth?: number);
  42354. /**
  42355. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42356. * @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);
  42357. * @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);
  42358. * @param entries meshes to be added to the octree blocks
  42359. */
  42360. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42361. /**
  42362. * Adds a mesh to the octree
  42363. * @param entry Mesh to add to the octree
  42364. */
  42365. addMesh(entry: T): void;
  42366. /**
  42367. * Remove an element from the octree
  42368. * @param entry defines the element to remove
  42369. */
  42370. removeMesh(entry: T): void;
  42371. /**
  42372. * Selects an array of meshes within the frustum
  42373. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42374. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42375. * @returns array of meshes within the frustum
  42376. */
  42377. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42378. /**
  42379. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42380. * @param sphereCenter defines the bounding sphere center
  42381. * @param sphereRadius defines the bounding sphere radius
  42382. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42383. * @returns an array of objects that intersect the sphere
  42384. */
  42385. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42386. /**
  42387. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42388. * @param ray defines the ray to test with
  42389. * @returns array of intersected objects
  42390. */
  42391. intersectsRay(ray: Ray): SmartArray<T>;
  42392. /**
  42393. * Adds a mesh into the octree block if it intersects the block
  42394. */
  42395. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42396. /**
  42397. * Adds a submesh into the octree block if it intersects the block
  42398. */
  42399. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42400. }
  42401. }
  42402. declare module BABYLON {
  42403. interface Scene {
  42404. /**
  42405. * @hidden
  42406. * Backing Filed
  42407. */
  42408. _selectionOctree: Octree<AbstractMesh>;
  42409. /**
  42410. * Gets the octree used to boost mesh selection (picking)
  42411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42412. */
  42413. selectionOctree: Octree<AbstractMesh>;
  42414. /**
  42415. * Creates or updates the octree used to boost selection (picking)
  42416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42417. * @param maxCapacity defines the maximum capacity per leaf
  42418. * @param maxDepth defines the maximum depth of the octree
  42419. * @returns an octree of AbstractMesh
  42420. */
  42421. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42422. }
  42423. interface AbstractMesh {
  42424. /**
  42425. * @hidden
  42426. * Backing Field
  42427. */
  42428. _submeshesOctree: Octree<SubMesh>;
  42429. /**
  42430. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42431. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42432. * @param maxCapacity defines the maximum size of each block (64 by default)
  42433. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42434. * @returns the new octree
  42435. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42437. */
  42438. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42439. }
  42440. /**
  42441. * Defines the octree scene component responsible to manage any octrees
  42442. * in a given scene.
  42443. */
  42444. export class OctreeSceneComponent {
  42445. /**
  42446. * The component name help to identify the component in the list of scene components.
  42447. */
  42448. readonly name: string;
  42449. /**
  42450. * The scene the component belongs to.
  42451. */
  42452. scene: Scene;
  42453. /**
  42454. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42455. */
  42456. readonly checksIsEnabled: boolean;
  42457. /**
  42458. * Creates a new instance of the component for the given scene
  42459. * @param scene Defines the scene to register the component in
  42460. */
  42461. constructor(scene: Scene);
  42462. /**
  42463. * Registers the component in a given scene
  42464. */
  42465. register(): void;
  42466. /**
  42467. * Return the list of active meshes
  42468. * @returns the list of active meshes
  42469. */
  42470. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42471. /**
  42472. * Return the list of active sub meshes
  42473. * @param mesh The mesh to get the candidates sub meshes from
  42474. * @returns the list of active sub meshes
  42475. */
  42476. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42477. private _tempRay;
  42478. /**
  42479. * Return the list of sub meshes intersecting with a given local ray
  42480. * @param mesh defines the mesh to find the submesh for
  42481. * @param localRay defines the ray in local space
  42482. * @returns the list of intersecting sub meshes
  42483. */
  42484. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42485. /**
  42486. * Return the list of sub meshes colliding with a collider
  42487. * @param mesh defines the mesh to find the submesh for
  42488. * @param collider defines the collider to evaluate the collision against
  42489. * @returns the list of colliding sub meshes
  42490. */
  42491. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42492. /**
  42493. * Rebuilds the elements related to this component in case of
  42494. * context lost for instance.
  42495. */
  42496. rebuild(): void;
  42497. /**
  42498. * Disposes the component and the associated ressources.
  42499. */
  42500. dispose(): void;
  42501. }
  42502. }
  42503. declare module BABYLON {
  42504. /**
  42505. * Renders a layer on top of an existing scene
  42506. */
  42507. export class UtilityLayerRenderer implements IDisposable {
  42508. /** the original scene that will be rendered on top of */
  42509. originalScene: Scene;
  42510. private _pointerCaptures;
  42511. private _lastPointerEvents;
  42512. private static _DefaultUtilityLayer;
  42513. private static _DefaultKeepDepthUtilityLayer;
  42514. private _sharedGizmoLight;
  42515. private _renderCamera;
  42516. /**
  42517. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42518. * @returns the camera that is used when rendering the utility layer
  42519. */
  42520. getRenderCamera(): Nullable<Camera>;
  42521. /**
  42522. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42523. * @param cam the camera that should be used when rendering the utility layer
  42524. */
  42525. setRenderCamera(cam: Nullable<Camera>): void;
  42526. /**
  42527. * @hidden
  42528. * Light which used by gizmos to get light shading
  42529. */
  42530. _getSharedGizmoLight(): HemisphericLight;
  42531. /**
  42532. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42533. */
  42534. pickUtilitySceneFirst: boolean;
  42535. /**
  42536. * 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)
  42537. */
  42538. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42539. /**
  42540. * 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)
  42541. */
  42542. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42543. /**
  42544. * The scene that is rendered on top of the original scene
  42545. */
  42546. utilityLayerScene: Scene;
  42547. /**
  42548. * If the utility layer should automatically be rendered on top of existing scene
  42549. */
  42550. shouldRender: boolean;
  42551. /**
  42552. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42553. */
  42554. onlyCheckPointerDownEvents: boolean;
  42555. /**
  42556. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42557. */
  42558. processAllEvents: boolean;
  42559. /**
  42560. * Observable raised when the pointer move from the utility layer scene to the main scene
  42561. */
  42562. onPointerOutObservable: Observable<number>;
  42563. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42564. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42565. private _afterRenderObserver;
  42566. private _sceneDisposeObserver;
  42567. private _originalPointerObserver;
  42568. /**
  42569. * Instantiates a UtilityLayerRenderer
  42570. * @param originalScene the original scene that will be rendered on top of
  42571. * @param handleEvents boolean indicating if the utility layer should handle events
  42572. */
  42573. constructor(
  42574. /** the original scene that will be rendered on top of */
  42575. originalScene: Scene, handleEvents?: boolean);
  42576. private _notifyObservers;
  42577. /**
  42578. * Renders the utility layers scene on top of the original scene
  42579. */
  42580. render(): void;
  42581. /**
  42582. * Disposes of the renderer
  42583. */
  42584. dispose(): void;
  42585. private _updateCamera;
  42586. }
  42587. }
  42588. declare module BABYLON {
  42589. /**
  42590. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42591. */
  42592. export class Gizmo implements IDisposable {
  42593. /** The utility layer the gizmo will be added to */
  42594. gizmoLayer: UtilityLayerRenderer;
  42595. /**
  42596. * The root mesh of the gizmo
  42597. */
  42598. _rootMesh: Mesh;
  42599. private _attachedMesh;
  42600. /**
  42601. * Ratio for the scale of the gizmo (Default: 1)
  42602. */
  42603. scaleRatio: number;
  42604. /**
  42605. * If a custom mesh has been set (Default: false)
  42606. */
  42607. protected _customMeshSet: boolean;
  42608. /**
  42609. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42610. * * When set, interactions will be enabled
  42611. */
  42612. attachedMesh: Nullable<AbstractMesh>;
  42613. /**
  42614. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42615. * @param mesh The mesh to replace the default mesh of the gizmo
  42616. */
  42617. setCustomMesh(mesh: Mesh): void;
  42618. /**
  42619. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42620. */
  42621. updateGizmoRotationToMatchAttachedMesh: boolean;
  42622. /**
  42623. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42624. */
  42625. updateGizmoPositionToMatchAttachedMesh: boolean;
  42626. /**
  42627. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42628. */
  42629. updateScale: boolean;
  42630. protected _interactionsEnabled: boolean;
  42631. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42632. private _beforeRenderObserver;
  42633. private _tempVector;
  42634. /**
  42635. * Creates a gizmo
  42636. * @param gizmoLayer The utility layer the gizmo will be added to
  42637. */
  42638. constructor(
  42639. /** The utility layer the gizmo will be added to */
  42640. gizmoLayer?: UtilityLayerRenderer);
  42641. /**
  42642. * Updates the gizmo to match the attached mesh's position/rotation
  42643. */
  42644. protected _update(): void;
  42645. /**
  42646. * Disposes of the gizmo
  42647. */
  42648. dispose(): void;
  42649. }
  42650. }
  42651. declare module BABYLON {
  42652. /**
  42653. * Single plane drag gizmo
  42654. */
  42655. export class PlaneDragGizmo extends Gizmo {
  42656. /**
  42657. * Drag behavior responsible for the gizmos dragging interactions
  42658. */
  42659. dragBehavior: PointerDragBehavior;
  42660. private _pointerObserver;
  42661. /**
  42662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42663. */
  42664. snapDistance: number;
  42665. /**
  42666. * Event that fires each time the gizmo snaps to a new location.
  42667. * * snapDistance is the the change in distance
  42668. */
  42669. onSnapObservable: Observable<{
  42670. snapDistance: number;
  42671. }>;
  42672. private _plane;
  42673. private _coloredMaterial;
  42674. private _hoverMaterial;
  42675. private _isEnabled;
  42676. private _parent;
  42677. /** @hidden */
  42678. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42679. /** @hidden */
  42680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42681. /**
  42682. * Creates a PlaneDragGizmo
  42683. * @param gizmoLayer The utility layer the gizmo will be added to
  42684. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42685. * @param color The color of the gizmo
  42686. */
  42687. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42689. /**
  42690. * If the gizmo is enabled
  42691. */
  42692. isEnabled: boolean;
  42693. /**
  42694. * Disposes of the gizmo
  42695. */
  42696. dispose(): void;
  42697. }
  42698. }
  42699. declare module BABYLON {
  42700. /**
  42701. * Gizmo that enables dragging a mesh along 3 axis
  42702. */
  42703. export class PositionGizmo extends Gizmo {
  42704. /**
  42705. * Internal gizmo used for interactions on the x axis
  42706. */
  42707. xGizmo: AxisDragGizmo;
  42708. /**
  42709. * Internal gizmo used for interactions on the y axis
  42710. */
  42711. yGizmo: AxisDragGizmo;
  42712. /**
  42713. * Internal gizmo used for interactions on the z axis
  42714. */
  42715. zGizmo: AxisDragGizmo;
  42716. /**
  42717. * Internal gizmo used for interactions on the yz plane
  42718. */
  42719. xPlaneGizmo: PlaneDragGizmo;
  42720. /**
  42721. * Internal gizmo used for interactions on the xz plane
  42722. */
  42723. yPlaneGizmo: PlaneDragGizmo;
  42724. /**
  42725. * Internal gizmo used for interactions on the xy plane
  42726. */
  42727. zPlaneGizmo: PlaneDragGizmo;
  42728. /**
  42729. * private variables
  42730. */
  42731. private _meshAttached;
  42732. private _updateGizmoRotationToMatchAttachedMesh;
  42733. private _snapDistance;
  42734. private _scaleRatio;
  42735. /** Fires an event when any of it's sub gizmos are dragged */
  42736. onDragStartObservable: Observable<unknown>;
  42737. /** Fires an event when any of it's sub gizmos are released from dragging */
  42738. onDragEndObservable: Observable<unknown>;
  42739. /**
  42740. * If set to true, planar drag is enabled
  42741. */
  42742. private _planarGizmoEnabled;
  42743. attachedMesh: Nullable<AbstractMesh>;
  42744. /**
  42745. * Creates a PositionGizmo
  42746. * @param gizmoLayer The utility layer the gizmo will be added to
  42747. */
  42748. constructor(gizmoLayer?: UtilityLayerRenderer);
  42749. /**
  42750. * If the planar drag gizmo is enabled
  42751. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42752. */
  42753. planarGizmoEnabled: boolean;
  42754. updateGizmoRotationToMatchAttachedMesh: boolean;
  42755. /**
  42756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42757. */
  42758. snapDistance: number;
  42759. /**
  42760. * Ratio for the scale of the gizmo (Default: 1)
  42761. */
  42762. scaleRatio: number;
  42763. /**
  42764. * Disposes of the gizmo
  42765. */
  42766. dispose(): void;
  42767. /**
  42768. * CustomMeshes are not supported by this gizmo
  42769. * @param mesh The mesh to replace the default mesh of the gizmo
  42770. */
  42771. setCustomMesh(mesh: Mesh): void;
  42772. }
  42773. }
  42774. declare module BABYLON {
  42775. /**
  42776. * Single axis drag gizmo
  42777. */
  42778. export class AxisDragGizmo extends Gizmo {
  42779. /**
  42780. * Drag behavior responsible for the gizmos dragging interactions
  42781. */
  42782. dragBehavior: PointerDragBehavior;
  42783. private _pointerObserver;
  42784. /**
  42785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42786. */
  42787. snapDistance: number;
  42788. /**
  42789. * Event that fires each time the gizmo snaps to a new location.
  42790. * * snapDistance is the the change in distance
  42791. */
  42792. onSnapObservable: Observable<{
  42793. snapDistance: number;
  42794. }>;
  42795. private _isEnabled;
  42796. private _parent;
  42797. private _arrow;
  42798. private _coloredMaterial;
  42799. private _hoverMaterial;
  42800. /** @hidden */
  42801. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42802. /** @hidden */
  42803. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42804. /**
  42805. * Creates an AxisDragGizmo
  42806. * @param gizmoLayer The utility layer the gizmo will be added to
  42807. * @param dragAxis The axis which the gizmo will be able to drag on
  42808. * @param color The color of the gizmo
  42809. */
  42810. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42812. /**
  42813. * If the gizmo is enabled
  42814. */
  42815. isEnabled: boolean;
  42816. /**
  42817. * Disposes of the gizmo
  42818. */
  42819. dispose(): void;
  42820. }
  42821. }
  42822. declare module BABYLON.Debug {
  42823. /**
  42824. * The Axes viewer will show 3 axes in a specific point in space
  42825. */
  42826. export class AxesViewer {
  42827. private _xAxis;
  42828. private _yAxis;
  42829. private _zAxis;
  42830. private _scaleLinesFactor;
  42831. private _instanced;
  42832. /**
  42833. * Gets the hosting scene
  42834. */
  42835. scene: Scene;
  42836. /**
  42837. * Gets or sets a number used to scale line length
  42838. */
  42839. scaleLines: number;
  42840. /** Gets the node hierarchy used to render x-axis */
  42841. readonly xAxis: TransformNode;
  42842. /** Gets the node hierarchy used to render y-axis */
  42843. readonly yAxis: TransformNode;
  42844. /** Gets the node hierarchy used to render z-axis */
  42845. readonly zAxis: TransformNode;
  42846. /**
  42847. * Creates a new AxesViewer
  42848. * @param scene defines the hosting scene
  42849. * @param scaleLines defines a number used to scale line length (1 by default)
  42850. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42851. * @param xAxis defines the node hierarchy used to render the x-axis
  42852. * @param yAxis defines the node hierarchy used to render the y-axis
  42853. * @param zAxis defines the node hierarchy used to render the z-axis
  42854. */
  42855. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42856. /**
  42857. * Force the viewer to update
  42858. * @param position defines the position of the viewer
  42859. * @param xaxis defines the x axis of the viewer
  42860. * @param yaxis defines the y axis of the viewer
  42861. * @param zaxis defines the z axis of the viewer
  42862. */
  42863. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42864. /**
  42865. * Creates an instance of this axes viewer.
  42866. * @returns a new axes viewer with instanced meshes
  42867. */
  42868. createInstance(): AxesViewer;
  42869. /** Releases resources */
  42870. dispose(): void;
  42871. private static _SetRenderingGroupId;
  42872. }
  42873. }
  42874. declare module BABYLON.Debug {
  42875. /**
  42876. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42877. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42878. */
  42879. export class BoneAxesViewer extends AxesViewer {
  42880. /**
  42881. * Gets or sets the target mesh where to display the axes viewer
  42882. */
  42883. mesh: Nullable<Mesh>;
  42884. /**
  42885. * Gets or sets the target bone where to display the axes viewer
  42886. */
  42887. bone: Nullable<Bone>;
  42888. /** Gets current position */
  42889. pos: Vector3;
  42890. /** Gets direction of X axis */
  42891. xaxis: Vector3;
  42892. /** Gets direction of Y axis */
  42893. yaxis: Vector3;
  42894. /** Gets direction of Z axis */
  42895. zaxis: Vector3;
  42896. /**
  42897. * Creates a new BoneAxesViewer
  42898. * @param scene defines the hosting scene
  42899. * @param bone defines the target bone
  42900. * @param mesh defines the target mesh
  42901. * @param scaleLines defines a scaling factor for line length (1 by default)
  42902. */
  42903. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42904. /**
  42905. * Force the viewer to update
  42906. */
  42907. update(): void;
  42908. /** Releases resources */
  42909. dispose(): void;
  42910. }
  42911. }
  42912. declare module BABYLON {
  42913. /**
  42914. * Interface used to define scene explorer extensibility option
  42915. */
  42916. export interface IExplorerExtensibilityOption {
  42917. /**
  42918. * Define the option label
  42919. */
  42920. label: string;
  42921. /**
  42922. * Defines the action to execute on click
  42923. */
  42924. action: (entity: any) => void;
  42925. }
  42926. /**
  42927. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42928. */
  42929. export interface IExplorerExtensibilityGroup {
  42930. /**
  42931. * Defines a predicate to test if a given type mut be extended
  42932. */
  42933. predicate: (entity: any) => boolean;
  42934. /**
  42935. * Gets the list of options added to a type
  42936. */
  42937. entries: IExplorerExtensibilityOption[];
  42938. }
  42939. /**
  42940. * Interface used to define the options to use to create the Inspector
  42941. */
  42942. export interface IInspectorOptions {
  42943. /**
  42944. * Display in overlay mode (default: false)
  42945. */
  42946. overlay?: boolean;
  42947. /**
  42948. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42949. */
  42950. globalRoot?: HTMLElement;
  42951. /**
  42952. * Display the Scene explorer
  42953. */
  42954. showExplorer?: boolean;
  42955. /**
  42956. * Display the property inspector
  42957. */
  42958. showInspector?: boolean;
  42959. /**
  42960. * Display in embed mode (both panes on the right)
  42961. */
  42962. embedMode?: boolean;
  42963. /**
  42964. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42965. */
  42966. handleResize?: boolean;
  42967. /**
  42968. * Allow the panes to popup (default: true)
  42969. */
  42970. enablePopup?: boolean;
  42971. /**
  42972. * Allow the panes to be closed by users (default: true)
  42973. */
  42974. enableClose?: boolean;
  42975. /**
  42976. * Optional list of extensibility entries
  42977. */
  42978. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42979. /**
  42980. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42981. */
  42982. inspectorURL?: string;
  42983. }
  42984. interface Scene {
  42985. /**
  42986. * @hidden
  42987. * Backing field
  42988. */
  42989. _debugLayer: DebugLayer;
  42990. /**
  42991. * Gets the debug layer (aka Inspector) associated with the scene
  42992. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42993. */
  42994. debugLayer: DebugLayer;
  42995. }
  42996. /**
  42997. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42998. * what is happening in your scene
  42999. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43000. */
  43001. export class DebugLayer {
  43002. /**
  43003. * Define the url to get the inspector script from.
  43004. * By default it uses the babylonjs CDN.
  43005. * @ignoreNaming
  43006. */
  43007. static InspectorURL: string;
  43008. private _scene;
  43009. private BJSINSPECTOR;
  43010. private _onPropertyChangedObservable?;
  43011. /**
  43012. * Observable triggered when a property is changed through the inspector.
  43013. */
  43014. readonly onPropertyChangedObservable: any;
  43015. /**
  43016. * Instantiates a new debug layer.
  43017. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43018. * what is happening in your scene
  43019. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43020. * @param scene Defines the scene to inspect
  43021. */
  43022. constructor(scene: Scene);
  43023. /** Creates the inspector window. */
  43024. private _createInspector;
  43025. /**
  43026. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43027. * @param entity defines the entity to select
  43028. * @param lineContainerTitle defines the specific block to highlight
  43029. */
  43030. select(entity: any, lineContainerTitle?: string): void;
  43031. /** Get the inspector from bundle or global */
  43032. private _getGlobalInspector;
  43033. /**
  43034. * Get if the inspector is visible or not.
  43035. * @returns true if visible otherwise, false
  43036. */
  43037. isVisible(): boolean;
  43038. /**
  43039. * Hide the inspector and close its window.
  43040. */
  43041. hide(): void;
  43042. /**
  43043. * Launch the debugLayer.
  43044. * @param config Define the configuration of the inspector
  43045. * @return a promise fulfilled when the debug layer is visible
  43046. */
  43047. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43048. }
  43049. }
  43050. declare module BABYLON {
  43051. /**
  43052. * Class containing static functions to help procedurally build meshes
  43053. */
  43054. export class BoxBuilder {
  43055. /**
  43056. * Creates a box mesh
  43057. * * The parameter `size` sets the size (float) of each box side (default 1)
  43058. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43059. * * 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)
  43060. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43062. * * 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
  43063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43064. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43065. * @param name defines the name of the mesh
  43066. * @param options defines the options used to create the mesh
  43067. * @param scene defines the hosting scene
  43068. * @returns the box mesh
  43069. */
  43070. static CreateBox(name: string, options: {
  43071. size?: number;
  43072. width?: number;
  43073. height?: number;
  43074. depth?: number;
  43075. faceUV?: Vector4[];
  43076. faceColors?: Color4[];
  43077. sideOrientation?: number;
  43078. frontUVs?: Vector4;
  43079. backUVs?: Vector4;
  43080. wrap?: boolean;
  43081. topBaseAt?: number;
  43082. bottomBaseAt?: number;
  43083. updatable?: boolean;
  43084. }, scene?: Nullable<Scene>): Mesh;
  43085. }
  43086. }
  43087. declare module BABYLON {
  43088. /**
  43089. * Class containing static functions to help procedurally build meshes
  43090. */
  43091. export class SphereBuilder {
  43092. /**
  43093. * Creates a sphere mesh
  43094. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43095. * * 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`)
  43096. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43097. * * 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
  43098. * * 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)
  43099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43100. * * 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
  43101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43102. * @param name defines the name of the mesh
  43103. * @param options defines the options used to create the mesh
  43104. * @param scene defines the hosting scene
  43105. * @returns the sphere mesh
  43106. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43107. */
  43108. static CreateSphere(name: string, options: {
  43109. segments?: number;
  43110. diameter?: number;
  43111. diameterX?: number;
  43112. diameterY?: number;
  43113. diameterZ?: number;
  43114. arc?: number;
  43115. slice?: number;
  43116. sideOrientation?: number;
  43117. frontUVs?: Vector4;
  43118. backUVs?: Vector4;
  43119. updatable?: boolean;
  43120. }, scene?: Nullable<Scene>): Mesh;
  43121. }
  43122. }
  43123. declare module BABYLON.Debug {
  43124. /**
  43125. * Used to show the physics impostor around the specific mesh
  43126. */
  43127. export class PhysicsViewer {
  43128. /** @hidden */
  43129. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43130. /** @hidden */
  43131. protected _meshes: Array<Nullable<AbstractMesh>>;
  43132. /** @hidden */
  43133. protected _scene: Nullable<Scene>;
  43134. /** @hidden */
  43135. protected _numMeshes: number;
  43136. /** @hidden */
  43137. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43138. private _renderFunction;
  43139. private _utilityLayer;
  43140. private _debugBoxMesh;
  43141. private _debugSphereMesh;
  43142. private _debugCylinderMesh;
  43143. private _debugMaterial;
  43144. private _debugMeshMeshes;
  43145. /**
  43146. * Creates a new PhysicsViewer
  43147. * @param scene defines the hosting scene
  43148. */
  43149. constructor(scene: Scene);
  43150. /** @hidden */
  43151. protected _updateDebugMeshes(): void;
  43152. /**
  43153. * Renders a specified physic impostor
  43154. * @param impostor defines the impostor to render
  43155. * @param targetMesh defines the mesh represented by the impostor
  43156. * @returns the new debug mesh used to render the impostor
  43157. */
  43158. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43159. /**
  43160. * Hides a specified physic impostor
  43161. * @param impostor defines the impostor to hide
  43162. */
  43163. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43164. private _getDebugMaterial;
  43165. private _getDebugBoxMesh;
  43166. private _getDebugSphereMesh;
  43167. private _getDebugCylinderMesh;
  43168. private _getDebugMeshMesh;
  43169. private _getDebugMesh;
  43170. /** Releases all resources */
  43171. dispose(): void;
  43172. }
  43173. }
  43174. declare module BABYLON {
  43175. /**
  43176. * Class containing static functions to help procedurally build meshes
  43177. */
  43178. export class LinesBuilder {
  43179. /**
  43180. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43181. * * 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
  43182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43183. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43184. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43185. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43187. * * 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
  43188. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43191. * @param name defines the name of the new line system
  43192. * @param options defines the options used to create the line system
  43193. * @param scene defines the hosting scene
  43194. * @returns a new line system mesh
  43195. */
  43196. static CreateLineSystem(name: string, options: {
  43197. lines: Vector3[][];
  43198. updatable?: boolean;
  43199. instance?: Nullable<LinesMesh>;
  43200. colors?: Nullable<Color4[][]>;
  43201. useVertexAlpha?: boolean;
  43202. }, scene: Nullable<Scene>): LinesMesh;
  43203. /**
  43204. * Creates a line mesh
  43205. * 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
  43206. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43207. * * The parameter `points` is an array successive Vector3
  43208. * * 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
  43209. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43210. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43211. * * When updating an instance, remember that only point positions can change, not the number of points
  43212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43214. * @param name defines the name of the new line system
  43215. * @param options defines the options used to create the line system
  43216. * @param scene defines the hosting scene
  43217. * @returns a new line mesh
  43218. */
  43219. static CreateLines(name: string, options: {
  43220. points: Vector3[];
  43221. updatable?: boolean;
  43222. instance?: Nullable<LinesMesh>;
  43223. colors?: Color4[];
  43224. useVertexAlpha?: boolean;
  43225. }, scene?: Nullable<Scene>): LinesMesh;
  43226. /**
  43227. * Creates a dashed line mesh
  43228. * * 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
  43229. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43230. * * The parameter `points` is an array successive Vector3
  43231. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43232. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43233. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43234. * * 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
  43235. * * When updating an instance, remember that only point positions can change, not the number of points
  43236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43237. * @param name defines the name of the mesh
  43238. * @param options defines the options used to create the mesh
  43239. * @param scene defines the hosting scene
  43240. * @returns the dashed line mesh
  43241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43242. */
  43243. static CreateDashedLines(name: string, options: {
  43244. points: Vector3[];
  43245. dashSize?: number;
  43246. gapSize?: number;
  43247. dashNb?: number;
  43248. updatable?: boolean;
  43249. instance?: LinesMesh;
  43250. }, scene?: Nullable<Scene>): LinesMesh;
  43251. }
  43252. }
  43253. declare module BABYLON {
  43254. /**
  43255. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43256. * in order to better appreciate the issue one might have.
  43257. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43258. */
  43259. export class RayHelper {
  43260. /**
  43261. * Defines the ray we are currently tryin to visualize.
  43262. */
  43263. ray: Nullable<Ray>;
  43264. private _renderPoints;
  43265. private _renderLine;
  43266. private _renderFunction;
  43267. private _scene;
  43268. private _updateToMeshFunction;
  43269. private _attachedToMesh;
  43270. private _meshSpaceDirection;
  43271. private _meshSpaceOrigin;
  43272. /**
  43273. * Helper function to create a colored helper in a scene in one line.
  43274. * @param ray Defines the ray we are currently tryin to visualize
  43275. * @param scene Defines the scene the ray is used in
  43276. * @param color Defines the color we want to see the ray in
  43277. * @returns The newly created ray helper.
  43278. */
  43279. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43280. /**
  43281. * Instantiate a new ray helper.
  43282. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43283. * in order to better appreciate the issue one might have.
  43284. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43285. * @param ray Defines the ray we are currently tryin to visualize
  43286. */
  43287. constructor(ray: Ray);
  43288. /**
  43289. * Shows the ray we are willing to debug.
  43290. * @param scene Defines the scene the ray needs to be rendered in
  43291. * @param color Defines the color the ray needs to be rendered in
  43292. */
  43293. show(scene: Scene, color?: Color3): void;
  43294. /**
  43295. * Hides the ray we are debugging.
  43296. */
  43297. hide(): void;
  43298. private _render;
  43299. /**
  43300. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43301. * @param mesh Defines the mesh we want the helper attached to
  43302. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43303. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43304. * @param length Defines the length of the ray
  43305. */
  43306. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43307. /**
  43308. * Detach the ray helper from the mesh it has previously been attached to.
  43309. */
  43310. detachFromMesh(): void;
  43311. private _updateToMesh;
  43312. /**
  43313. * Dispose the helper and release its associated resources.
  43314. */
  43315. dispose(): void;
  43316. }
  43317. }
  43318. declare module BABYLON.Debug {
  43319. /**
  43320. * Class used to render a debug view of a given skeleton
  43321. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43322. */
  43323. export class SkeletonViewer {
  43324. /** defines the skeleton to render */
  43325. skeleton: Skeleton;
  43326. /** defines the mesh attached to the skeleton */
  43327. mesh: AbstractMesh;
  43328. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43329. autoUpdateBonesMatrices: boolean;
  43330. /** defines the rendering group id to use with the viewer */
  43331. renderingGroupId: number;
  43332. /** Gets or sets the color used to render the skeleton */
  43333. color: Color3;
  43334. private _scene;
  43335. private _debugLines;
  43336. private _debugMesh;
  43337. private _isEnabled;
  43338. private _renderFunction;
  43339. private _utilityLayer;
  43340. /**
  43341. * Returns the mesh used to render the bones
  43342. */
  43343. readonly debugMesh: Nullable<LinesMesh>;
  43344. /**
  43345. * Creates a new SkeletonViewer
  43346. * @param skeleton defines the skeleton to render
  43347. * @param mesh defines the mesh attached to the skeleton
  43348. * @param scene defines the hosting scene
  43349. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43350. * @param renderingGroupId defines the rendering group id to use with the viewer
  43351. */
  43352. constructor(
  43353. /** defines the skeleton to render */
  43354. skeleton: Skeleton,
  43355. /** defines the mesh attached to the skeleton */
  43356. mesh: AbstractMesh, scene: Scene,
  43357. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43358. autoUpdateBonesMatrices?: boolean,
  43359. /** defines the rendering group id to use with the viewer */
  43360. renderingGroupId?: number);
  43361. /** Gets or sets a boolean indicating if the viewer is enabled */
  43362. isEnabled: boolean;
  43363. private _getBonePosition;
  43364. private _getLinesForBonesWithLength;
  43365. private _getLinesForBonesNoLength;
  43366. /** Update the viewer to sync with current skeleton state */
  43367. update(): void;
  43368. /** Release associated resources */
  43369. dispose(): void;
  43370. }
  43371. }
  43372. declare module BABYLON {
  43373. /**
  43374. * Options to create the null engine
  43375. */
  43376. export class NullEngineOptions {
  43377. /**
  43378. * Render width (Default: 512)
  43379. */
  43380. renderWidth: number;
  43381. /**
  43382. * Render height (Default: 256)
  43383. */
  43384. renderHeight: number;
  43385. /**
  43386. * Texture size (Default: 512)
  43387. */
  43388. textureSize: number;
  43389. /**
  43390. * If delta time between frames should be constant
  43391. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43392. */
  43393. deterministicLockstep: boolean;
  43394. /**
  43395. * Maximum about of steps between frames (Default: 4)
  43396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43397. */
  43398. lockstepMaxSteps: number;
  43399. }
  43400. /**
  43401. * The null engine class provides support for headless version of babylon.js.
  43402. * This can be used in server side scenario or for testing purposes
  43403. */
  43404. export class NullEngine extends Engine {
  43405. private _options;
  43406. /**
  43407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43408. */
  43409. isDeterministicLockStep(): boolean;
  43410. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43411. getLockstepMaxSteps(): number;
  43412. /**
  43413. * Sets hardware scaling, used to save performance if needed
  43414. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43415. */
  43416. getHardwareScalingLevel(): number;
  43417. constructor(options?: NullEngineOptions);
  43418. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43419. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43420. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43421. getRenderWidth(useScreen?: boolean): number;
  43422. getRenderHeight(useScreen?: boolean): number;
  43423. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43424. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43425. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43426. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43427. bindSamplers(effect: Effect): void;
  43428. enableEffect(effect: Effect): void;
  43429. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43430. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43431. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43432. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43433. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43434. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43435. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43436. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43437. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43438. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43439. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43440. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43441. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43442. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43443. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43444. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43445. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43446. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43447. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43448. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43449. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43450. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43451. bindBuffers(vertexBuffers: {
  43452. [key: string]: VertexBuffer;
  43453. }, indexBuffer: DataBuffer, effect: Effect): void;
  43454. wipeCaches(bruteForce?: boolean): void;
  43455. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43456. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43457. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43458. /** @hidden */
  43459. _createTexture(): WebGLTexture;
  43460. /** @hidden */
  43461. _releaseTexture(texture: InternalTexture): void;
  43462. 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;
  43463. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43464. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43465. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43466. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43467. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43468. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43469. areAllEffectsReady(): boolean;
  43470. /**
  43471. * @hidden
  43472. * Get the current error code of the webGL context
  43473. * @returns the error code
  43474. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43475. */
  43476. getError(): number;
  43477. /** @hidden */
  43478. _getUnpackAlignement(): number;
  43479. /** @hidden */
  43480. _unpackFlipY(value: boolean): void;
  43481. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43482. /**
  43483. * Updates a dynamic vertex buffer.
  43484. * @param vertexBuffer the vertex buffer to update
  43485. * @param data the data used to update the vertex buffer
  43486. * @param byteOffset the byte offset of the data (optional)
  43487. * @param byteLength the byte length of the data (optional)
  43488. */
  43489. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43490. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43491. /** @hidden */
  43492. _bindTexture(channel: number, texture: InternalTexture): void;
  43493. /** @hidden */
  43494. _releaseBuffer(buffer: DataBuffer): boolean;
  43495. releaseEffects(): void;
  43496. displayLoadingUI(): void;
  43497. hideLoadingUI(): void;
  43498. /** @hidden */
  43499. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43500. /** @hidden */
  43501. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43502. /** @hidden */
  43503. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43504. /** @hidden */
  43505. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43506. }
  43507. }
  43508. declare module BABYLON {
  43509. /** @hidden */
  43510. export class _OcclusionDataStorage {
  43511. /** @hidden */
  43512. occlusionInternalRetryCounter: number;
  43513. /** @hidden */
  43514. isOcclusionQueryInProgress: boolean;
  43515. /** @hidden */
  43516. isOccluded: boolean;
  43517. /** @hidden */
  43518. occlusionRetryCount: number;
  43519. /** @hidden */
  43520. occlusionType: number;
  43521. /** @hidden */
  43522. occlusionQueryAlgorithmType: number;
  43523. }
  43524. interface Engine {
  43525. /**
  43526. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43527. * @return the new query
  43528. */
  43529. createQuery(): WebGLQuery;
  43530. /**
  43531. * Delete and release a webGL query
  43532. * @param query defines the query to delete
  43533. * @return the current engine
  43534. */
  43535. deleteQuery(query: WebGLQuery): Engine;
  43536. /**
  43537. * Check if a given query has resolved and got its value
  43538. * @param query defines the query to check
  43539. * @returns true if the query got its value
  43540. */
  43541. isQueryResultAvailable(query: WebGLQuery): boolean;
  43542. /**
  43543. * Gets the value of a given query
  43544. * @param query defines the query to check
  43545. * @returns the value of the query
  43546. */
  43547. getQueryResult(query: WebGLQuery): number;
  43548. /**
  43549. * Initiates an occlusion query
  43550. * @param algorithmType defines the algorithm to use
  43551. * @param query defines the query to use
  43552. * @returns the current engine
  43553. * @see http://doc.babylonjs.com/features/occlusionquery
  43554. */
  43555. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43556. /**
  43557. * Ends an occlusion query
  43558. * @see http://doc.babylonjs.com/features/occlusionquery
  43559. * @param algorithmType defines the algorithm to use
  43560. * @returns the current engine
  43561. */
  43562. endOcclusionQuery(algorithmType: number): Engine;
  43563. /**
  43564. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43565. * Please note that only one query can be issued at a time
  43566. * @returns a time token used to track the time span
  43567. */
  43568. startTimeQuery(): Nullable<_TimeToken>;
  43569. /**
  43570. * Ends a time query
  43571. * @param token defines the token used to measure the time span
  43572. * @returns the time spent (in ns)
  43573. */
  43574. endTimeQuery(token: _TimeToken): int;
  43575. /** @hidden */
  43576. _currentNonTimestampToken: Nullable<_TimeToken>;
  43577. /** @hidden */
  43578. _createTimeQuery(): WebGLQuery;
  43579. /** @hidden */
  43580. _deleteTimeQuery(query: WebGLQuery): void;
  43581. /** @hidden */
  43582. _getGlAlgorithmType(algorithmType: number): number;
  43583. /** @hidden */
  43584. _getTimeQueryResult(query: WebGLQuery): any;
  43585. /** @hidden */
  43586. _getTimeQueryAvailability(query: WebGLQuery): any;
  43587. }
  43588. interface AbstractMesh {
  43589. /**
  43590. * Backing filed
  43591. * @hidden
  43592. */
  43593. __occlusionDataStorage: _OcclusionDataStorage;
  43594. /**
  43595. * Access property
  43596. * @hidden
  43597. */
  43598. _occlusionDataStorage: _OcclusionDataStorage;
  43599. /**
  43600. * 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.
  43601. * The default value is -1 which means don't break the query and wait till the result
  43602. * @see http://doc.babylonjs.com/features/occlusionquery
  43603. */
  43604. occlusionRetryCount: number;
  43605. /**
  43606. * 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:
  43607. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43608. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43609. * * 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.
  43610. * @see http://doc.babylonjs.com/features/occlusionquery
  43611. */
  43612. occlusionType: number;
  43613. /**
  43614. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43615. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43616. * * 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.
  43617. * @see http://doc.babylonjs.com/features/occlusionquery
  43618. */
  43619. occlusionQueryAlgorithmType: number;
  43620. /**
  43621. * 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
  43622. * @see http://doc.babylonjs.com/features/occlusionquery
  43623. */
  43624. isOccluded: boolean;
  43625. /**
  43626. * Flag to check the progress status of the query
  43627. * @see http://doc.babylonjs.com/features/occlusionquery
  43628. */
  43629. isOcclusionQueryInProgress: boolean;
  43630. }
  43631. }
  43632. declare module BABYLON {
  43633. /** @hidden */
  43634. export var _forceTransformFeedbackToBundle: boolean;
  43635. interface Engine {
  43636. /**
  43637. * Creates a webGL transform feedback object
  43638. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43639. * @returns the webGL transform feedback object
  43640. */
  43641. createTransformFeedback(): WebGLTransformFeedback;
  43642. /**
  43643. * Delete a webGL transform feedback object
  43644. * @param value defines the webGL transform feedback object to delete
  43645. */
  43646. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43647. /**
  43648. * Bind a webGL transform feedback object to the webgl context
  43649. * @param value defines the webGL transform feedback object to bind
  43650. */
  43651. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43652. /**
  43653. * Begins a transform feedback operation
  43654. * @param usePoints defines if points or triangles must be used
  43655. */
  43656. beginTransformFeedback(usePoints: boolean): void;
  43657. /**
  43658. * Ends a transform feedback operation
  43659. */
  43660. endTransformFeedback(): void;
  43661. /**
  43662. * Specify the varyings to use with transform feedback
  43663. * @param program defines the associated webGL program
  43664. * @param value defines the list of strings representing the varying names
  43665. */
  43666. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43667. /**
  43668. * Bind a webGL buffer for a transform feedback operation
  43669. * @param value defines the webGL buffer to bind
  43670. */
  43671. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43672. }
  43673. }
  43674. declare module BABYLON {
  43675. /**
  43676. * Creation options of the multi render target texture.
  43677. */
  43678. export interface IMultiRenderTargetOptions {
  43679. /**
  43680. * Define if the texture needs to create mip maps after render.
  43681. */
  43682. generateMipMaps?: boolean;
  43683. /**
  43684. * Define the types of all the draw buffers we want to create
  43685. */
  43686. types?: number[];
  43687. /**
  43688. * Define the sampling modes of all the draw buffers we want to create
  43689. */
  43690. samplingModes?: number[];
  43691. /**
  43692. * Define if a depth buffer is required
  43693. */
  43694. generateDepthBuffer?: boolean;
  43695. /**
  43696. * Define if a stencil buffer is required
  43697. */
  43698. generateStencilBuffer?: boolean;
  43699. /**
  43700. * Define if a depth texture is required instead of a depth buffer
  43701. */
  43702. generateDepthTexture?: boolean;
  43703. /**
  43704. * Define the number of desired draw buffers
  43705. */
  43706. textureCount?: number;
  43707. /**
  43708. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43709. */
  43710. doNotChangeAspectRatio?: boolean;
  43711. /**
  43712. * Define the default type of the buffers we are creating
  43713. */
  43714. defaultType?: number;
  43715. }
  43716. /**
  43717. * A multi render target, like a render target provides the ability to render to a texture.
  43718. * Unlike the render target, it can render to several draw buffers in one draw.
  43719. * This is specially interesting in deferred rendering or for any effects requiring more than
  43720. * just one color from a single pass.
  43721. */
  43722. export class MultiRenderTarget extends RenderTargetTexture {
  43723. private _internalTextures;
  43724. private _textures;
  43725. private _multiRenderTargetOptions;
  43726. /**
  43727. * Get if draw buffers are currently supported by the used hardware and browser.
  43728. */
  43729. readonly isSupported: boolean;
  43730. /**
  43731. * Get the list of textures generated by the multi render target.
  43732. */
  43733. readonly textures: Texture[];
  43734. /**
  43735. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43736. */
  43737. readonly depthTexture: Texture;
  43738. /**
  43739. * Set the wrapping mode on U of all the textures we are rendering to.
  43740. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43741. */
  43742. wrapU: number;
  43743. /**
  43744. * Set the wrapping mode on V of all the textures we are rendering to.
  43745. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43746. */
  43747. wrapV: number;
  43748. /**
  43749. * Instantiate a new multi render target texture.
  43750. * A multi render target, like a render target provides the ability to render to a texture.
  43751. * Unlike the render target, it can render to several draw buffers in one draw.
  43752. * This is specially interesting in deferred rendering or for any effects requiring more than
  43753. * just one color from a single pass.
  43754. * @param name Define the name of the texture
  43755. * @param size Define the size of the buffers to render to
  43756. * @param count Define the number of target we are rendering into
  43757. * @param scene Define the scene the texture belongs to
  43758. * @param options Define the options used to create the multi render target
  43759. */
  43760. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43761. /** @hidden */
  43762. _rebuild(): void;
  43763. private _createInternalTextures;
  43764. private _createTextures;
  43765. /**
  43766. * Define the number of samples used if MSAA is enabled.
  43767. */
  43768. samples: number;
  43769. /**
  43770. * Resize all the textures in the multi render target.
  43771. * Be carrefull as it will recreate all the data in the new texture.
  43772. * @param size Define the new size
  43773. */
  43774. resize(size: any): void;
  43775. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43776. /**
  43777. * Dispose the render targets and their associated resources
  43778. */
  43779. dispose(): void;
  43780. /**
  43781. * Release all the underlying texture used as draw buffers.
  43782. */
  43783. releaseInternalTextures(): void;
  43784. }
  43785. }
  43786. declare module BABYLON {
  43787. interface Engine {
  43788. /**
  43789. * Unbind a list of render target textures from the webGL context
  43790. * This is used only when drawBuffer extension or webGL2 are active
  43791. * @param textures defines the render target textures to unbind
  43792. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43793. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43794. */
  43795. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43796. /**
  43797. * Create a multi render target texture
  43798. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43799. * @param size defines the size of the texture
  43800. * @param options defines the creation options
  43801. * @returns the cube texture as an InternalTexture
  43802. */
  43803. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43804. /**
  43805. * Update the sample count for a given multiple render target texture
  43806. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43807. * @param textures defines the textures to update
  43808. * @param samples defines the sample count to set
  43809. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43810. */
  43811. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43812. }
  43813. }
  43814. declare module BABYLON {
  43815. /**
  43816. * Gather the list of clipboard event types as constants.
  43817. */
  43818. export class ClipboardEventTypes {
  43819. /**
  43820. * The clipboard event is fired when a copy command is active (pressed).
  43821. */
  43822. static readonly COPY: number;
  43823. /**
  43824. * The clipboard event is fired when a cut command is active (pressed).
  43825. */
  43826. static readonly CUT: number;
  43827. /**
  43828. * The clipboard event is fired when a paste command is active (pressed).
  43829. */
  43830. static readonly PASTE: number;
  43831. }
  43832. /**
  43833. * This class is used to store clipboard related info for the onClipboardObservable event.
  43834. */
  43835. export class ClipboardInfo {
  43836. /**
  43837. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43838. */
  43839. type: number;
  43840. /**
  43841. * Defines the related dom event
  43842. */
  43843. event: ClipboardEvent;
  43844. /**
  43845. *Creates an instance of ClipboardInfo.
  43846. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43847. * @param event Defines the related dom event
  43848. */
  43849. constructor(
  43850. /**
  43851. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43852. */
  43853. type: number,
  43854. /**
  43855. * Defines the related dom event
  43856. */
  43857. event: ClipboardEvent);
  43858. /**
  43859. * Get the clipboard event's type from the keycode.
  43860. * @param keyCode Defines the keyCode for the current keyboard event.
  43861. * @return {number}
  43862. */
  43863. static GetTypeFromCharacter(keyCode: number): number;
  43864. }
  43865. }
  43866. declare module BABYLON {
  43867. /**
  43868. * Google Daydream controller
  43869. */
  43870. export class DaydreamController extends WebVRController {
  43871. /**
  43872. * Base Url for the controller model.
  43873. */
  43874. static MODEL_BASE_URL: string;
  43875. /**
  43876. * File name for the controller model.
  43877. */
  43878. static MODEL_FILENAME: string;
  43879. /**
  43880. * Gamepad Id prefix used to identify Daydream Controller.
  43881. */
  43882. static readonly GAMEPAD_ID_PREFIX: string;
  43883. /**
  43884. * Creates a new DaydreamController from a gamepad
  43885. * @param vrGamepad the gamepad that the controller should be created from
  43886. */
  43887. constructor(vrGamepad: any);
  43888. /**
  43889. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43890. * @param scene scene in which to add meshes
  43891. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43892. */
  43893. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43894. /**
  43895. * Called once for each button that changed state since the last frame
  43896. * @param buttonIdx Which button index changed
  43897. * @param state New state of the button
  43898. * @param changes Which properties on the state changed since last frame
  43899. */
  43900. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43901. }
  43902. }
  43903. declare module BABYLON {
  43904. /**
  43905. * Gear VR Controller
  43906. */
  43907. export class GearVRController extends WebVRController {
  43908. /**
  43909. * Base Url for the controller model.
  43910. */
  43911. static MODEL_BASE_URL: string;
  43912. /**
  43913. * File name for the controller model.
  43914. */
  43915. static MODEL_FILENAME: string;
  43916. /**
  43917. * Gamepad Id prefix used to identify this controller.
  43918. */
  43919. static readonly GAMEPAD_ID_PREFIX: string;
  43920. private readonly _buttonIndexToObservableNameMap;
  43921. /**
  43922. * Creates a new GearVRController from a gamepad
  43923. * @param vrGamepad the gamepad that the controller should be created from
  43924. */
  43925. constructor(vrGamepad: any);
  43926. /**
  43927. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43928. * @param scene scene in which to add meshes
  43929. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43930. */
  43931. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43932. /**
  43933. * Called once for each button that changed state since the last frame
  43934. * @param buttonIdx Which button index changed
  43935. * @param state New state of the button
  43936. * @param changes Which properties on the state changed since last frame
  43937. */
  43938. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43939. }
  43940. }
  43941. declare module BABYLON {
  43942. /**
  43943. * Class containing static functions to help procedurally build meshes
  43944. */
  43945. export class PolyhedronBuilder {
  43946. /**
  43947. * Creates a polyhedron mesh
  43948. * * 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
  43949. * * The parameter `size` (positive float, default 1) sets the polygon size
  43950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43951. * * 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`
  43952. * * 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
  43953. * * 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)`)
  43954. * * 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
  43955. * * 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
  43956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43957. * * 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
  43958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43959. * @param name defines the name of the mesh
  43960. * @param options defines the options used to create the mesh
  43961. * @param scene defines the hosting scene
  43962. * @returns the polyhedron mesh
  43963. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43964. */
  43965. static CreatePolyhedron(name: string, options: {
  43966. type?: number;
  43967. size?: number;
  43968. sizeX?: number;
  43969. sizeY?: number;
  43970. sizeZ?: number;
  43971. custom?: any;
  43972. faceUV?: Vector4[];
  43973. faceColors?: Color4[];
  43974. flat?: boolean;
  43975. updatable?: boolean;
  43976. sideOrientation?: number;
  43977. frontUVs?: Vector4;
  43978. backUVs?: Vector4;
  43979. }, scene?: Nullable<Scene>): Mesh;
  43980. }
  43981. }
  43982. declare module BABYLON {
  43983. /**
  43984. * Gizmo that enables scaling a mesh along 3 axis
  43985. */
  43986. export class ScaleGizmo extends Gizmo {
  43987. /**
  43988. * Internal gizmo used for interactions on the x axis
  43989. */
  43990. xGizmo: AxisScaleGizmo;
  43991. /**
  43992. * Internal gizmo used for interactions on the y axis
  43993. */
  43994. yGizmo: AxisScaleGizmo;
  43995. /**
  43996. * Internal gizmo used for interactions on the z axis
  43997. */
  43998. zGizmo: AxisScaleGizmo;
  43999. /**
  44000. * Internal gizmo used to scale all axis equally
  44001. */
  44002. uniformScaleGizmo: AxisScaleGizmo;
  44003. private _meshAttached;
  44004. private _updateGizmoRotationToMatchAttachedMesh;
  44005. private _snapDistance;
  44006. private _scaleRatio;
  44007. private _uniformScalingMesh;
  44008. private _octahedron;
  44009. /** Fires an event when any of it's sub gizmos are dragged */
  44010. onDragStartObservable: Observable<unknown>;
  44011. /** Fires an event when any of it's sub gizmos are released from dragging */
  44012. onDragEndObservable: Observable<unknown>;
  44013. attachedMesh: Nullable<AbstractMesh>;
  44014. /**
  44015. * Creates a ScaleGizmo
  44016. * @param gizmoLayer The utility layer the gizmo will be added to
  44017. */
  44018. constructor(gizmoLayer?: UtilityLayerRenderer);
  44019. updateGizmoRotationToMatchAttachedMesh: boolean;
  44020. /**
  44021. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44022. */
  44023. snapDistance: number;
  44024. /**
  44025. * Ratio for the scale of the gizmo (Default: 1)
  44026. */
  44027. scaleRatio: number;
  44028. /**
  44029. * Disposes of the gizmo
  44030. */
  44031. dispose(): void;
  44032. }
  44033. }
  44034. declare module BABYLON {
  44035. /**
  44036. * Single axis scale gizmo
  44037. */
  44038. export class AxisScaleGizmo extends Gizmo {
  44039. /**
  44040. * Drag behavior responsible for the gizmos dragging interactions
  44041. */
  44042. dragBehavior: PointerDragBehavior;
  44043. private _pointerObserver;
  44044. /**
  44045. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44046. */
  44047. snapDistance: number;
  44048. /**
  44049. * Event that fires each time the gizmo snaps to a new location.
  44050. * * snapDistance is the the change in distance
  44051. */
  44052. onSnapObservable: Observable<{
  44053. snapDistance: number;
  44054. }>;
  44055. /**
  44056. * If the scaling operation should be done on all axis (default: false)
  44057. */
  44058. uniformScaling: boolean;
  44059. private _isEnabled;
  44060. private _parent;
  44061. private _arrow;
  44062. private _coloredMaterial;
  44063. private _hoverMaterial;
  44064. /**
  44065. * Creates an AxisScaleGizmo
  44066. * @param gizmoLayer The utility layer the gizmo will be added to
  44067. * @param dragAxis The axis which the gizmo will be able to scale on
  44068. * @param color The color of the gizmo
  44069. */
  44070. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44072. /**
  44073. * If the gizmo is enabled
  44074. */
  44075. isEnabled: boolean;
  44076. /**
  44077. * Disposes of the gizmo
  44078. */
  44079. dispose(): void;
  44080. /**
  44081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44082. * @param mesh The mesh to replace the default mesh of the gizmo
  44083. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44084. */
  44085. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44086. }
  44087. }
  44088. declare module BABYLON {
  44089. /**
  44090. * Bounding box gizmo
  44091. */
  44092. export class BoundingBoxGizmo extends Gizmo {
  44093. private _lineBoundingBox;
  44094. private _rotateSpheresParent;
  44095. private _scaleBoxesParent;
  44096. private _boundingDimensions;
  44097. private _renderObserver;
  44098. private _pointerObserver;
  44099. private _scaleDragSpeed;
  44100. private _tmpQuaternion;
  44101. private _tmpVector;
  44102. private _tmpRotationMatrix;
  44103. /**
  44104. * 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)
  44105. */
  44106. ignoreChildren: boolean;
  44107. /**
  44108. * 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)
  44109. */
  44110. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44111. /**
  44112. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44113. */
  44114. rotationSphereSize: number;
  44115. /**
  44116. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44117. */
  44118. scaleBoxSize: number;
  44119. /**
  44120. * 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)
  44121. */
  44122. fixedDragMeshScreenSize: boolean;
  44123. /**
  44124. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44125. */
  44126. fixedDragMeshScreenSizeDistanceFactor: number;
  44127. /**
  44128. * Fired when a rotation sphere or scale box is dragged
  44129. */
  44130. onDragStartObservable: Observable<{}>;
  44131. /**
  44132. * Fired when a scale box is dragged
  44133. */
  44134. onScaleBoxDragObservable: Observable<{}>;
  44135. /**
  44136. * Fired when a scale box drag is ended
  44137. */
  44138. onScaleBoxDragEndObservable: Observable<{}>;
  44139. /**
  44140. * Fired when a rotation sphere is dragged
  44141. */
  44142. onRotationSphereDragObservable: Observable<{}>;
  44143. /**
  44144. * Fired when a rotation sphere drag is ended
  44145. */
  44146. onRotationSphereDragEndObservable: Observable<{}>;
  44147. /**
  44148. * 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)
  44149. */
  44150. scalePivot: Nullable<Vector3>;
  44151. /**
  44152. * Mesh used as a pivot to rotate the attached mesh
  44153. */
  44154. private _anchorMesh;
  44155. private _existingMeshScale;
  44156. private _dragMesh;
  44157. private pointerDragBehavior;
  44158. private coloredMaterial;
  44159. private hoverColoredMaterial;
  44160. /**
  44161. * Sets the color of the bounding box gizmo
  44162. * @param color the color to set
  44163. */
  44164. setColor(color: Color3): void;
  44165. /**
  44166. * Creates an BoundingBoxGizmo
  44167. * @param gizmoLayer The utility layer the gizmo will be added to
  44168. * @param color The color of the gizmo
  44169. */
  44170. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44171. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44172. private _selectNode;
  44173. /**
  44174. * Updates the bounding box information for the Gizmo
  44175. */
  44176. updateBoundingBox(): void;
  44177. private _updateRotationSpheres;
  44178. private _updateScaleBoxes;
  44179. /**
  44180. * Enables rotation on the specified axis and disables rotation on the others
  44181. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44182. */
  44183. setEnabledRotationAxis(axis: string): void;
  44184. /**
  44185. * Enables/disables scaling
  44186. * @param enable if scaling should be enabled
  44187. */
  44188. setEnabledScaling(enable: boolean): void;
  44189. private _updateDummy;
  44190. /**
  44191. * Enables a pointer drag behavior on the bounding box of the gizmo
  44192. */
  44193. enableDragBehavior(): void;
  44194. /**
  44195. * Disposes of the gizmo
  44196. */
  44197. dispose(): void;
  44198. /**
  44199. * 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)
  44200. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44201. * @returns the bounding box mesh with the passed in mesh as a child
  44202. */
  44203. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44204. /**
  44205. * CustomMeshes are not supported by this gizmo
  44206. * @param mesh The mesh to replace the default mesh of the gizmo
  44207. */
  44208. setCustomMesh(mesh: Mesh): void;
  44209. }
  44210. }
  44211. declare module BABYLON {
  44212. /**
  44213. * Single plane rotation gizmo
  44214. */
  44215. export class PlaneRotationGizmo extends Gizmo {
  44216. /**
  44217. * Drag behavior responsible for the gizmos dragging interactions
  44218. */
  44219. dragBehavior: PointerDragBehavior;
  44220. private _pointerObserver;
  44221. /**
  44222. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44223. */
  44224. snapDistance: number;
  44225. /**
  44226. * Event that fires each time the gizmo snaps to a new location.
  44227. * * snapDistance is the the change in distance
  44228. */
  44229. onSnapObservable: Observable<{
  44230. snapDistance: number;
  44231. }>;
  44232. private _isEnabled;
  44233. private _parent;
  44234. /**
  44235. * Creates a PlaneRotationGizmo
  44236. * @param gizmoLayer The utility layer the gizmo will be added to
  44237. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44238. * @param color The color of the gizmo
  44239. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44240. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44241. */
  44242. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44243. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44244. /**
  44245. * If the gizmo is enabled
  44246. */
  44247. isEnabled: boolean;
  44248. /**
  44249. * Disposes of the gizmo
  44250. */
  44251. dispose(): void;
  44252. }
  44253. }
  44254. declare module BABYLON {
  44255. /**
  44256. * Gizmo that enables rotating a mesh along 3 axis
  44257. */
  44258. export class RotationGizmo extends Gizmo {
  44259. /**
  44260. * Internal gizmo used for interactions on the x axis
  44261. */
  44262. xGizmo: PlaneRotationGizmo;
  44263. /**
  44264. * Internal gizmo used for interactions on the y axis
  44265. */
  44266. yGizmo: PlaneRotationGizmo;
  44267. /**
  44268. * Internal gizmo used for interactions on the z axis
  44269. */
  44270. zGizmo: PlaneRotationGizmo;
  44271. /** Fires an event when any of it's sub gizmos are dragged */
  44272. onDragStartObservable: Observable<unknown>;
  44273. /** Fires an event when any of it's sub gizmos are released from dragging */
  44274. onDragEndObservable: Observable<unknown>;
  44275. private _meshAttached;
  44276. attachedMesh: Nullable<AbstractMesh>;
  44277. /**
  44278. * Creates a RotationGizmo
  44279. * @param gizmoLayer The utility layer the gizmo will be added to
  44280. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44281. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44282. */
  44283. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44284. updateGizmoRotationToMatchAttachedMesh: boolean;
  44285. /**
  44286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44287. */
  44288. snapDistance: number;
  44289. /**
  44290. * Ratio for the scale of the gizmo (Default: 1)
  44291. */
  44292. scaleRatio: number;
  44293. /**
  44294. * Disposes of the gizmo
  44295. */
  44296. dispose(): void;
  44297. /**
  44298. * CustomMeshes are not supported by this gizmo
  44299. * @param mesh The mesh to replace the default mesh of the gizmo
  44300. */
  44301. setCustomMesh(mesh: Mesh): void;
  44302. }
  44303. }
  44304. declare module BABYLON {
  44305. /**
  44306. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44307. */
  44308. export class GizmoManager implements IDisposable {
  44309. private scene;
  44310. /**
  44311. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44312. */
  44313. gizmos: {
  44314. positionGizmo: Nullable<PositionGizmo>;
  44315. rotationGizmo: Nullable<RotationGizmo>;
  44316. scaleGizmo: Nullable<ScaleGizmo>;
  44317. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44318. };
  44319. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44320. clearGizmoOnEmptyPointerEvent: boolean;
  44321. /** Fires an event when the manager is attached to a mesh */
  44322. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44323. private _gizmosEnabled;
  44324. private _pointerObserver;
  44325. private _attachedMesh;
  44326. private _boundingBoxColor;
  44327. private _defaultUtilityLayer;
  44328. private _defaultKeepDepthUtilityLayer;
  44329. /**
  44330. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44331. */
  44332. boundingBoxDragBehavior: SixDofDragBehavior;
  44333. /**
  44334. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44335. */
  44336. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44337. /**
  44338. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44339. */
  44340. usePointerToAttachGizmos: boolean;
  44341. /**
  44342. * Utility layer that the bounding box gizmo belongs to
  44343. */
  44344. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44345. /**
  44346. * Utility layer that all gizmos besides bounding box belong to
  44347. */
  44348. readonly utilityLayer: UtilityLayerRenderer;
  44349. /**
  44350. * Instatiates a gizmo manager
  44351. * @param scene the scene to overlay the gizmos on top of
  44352. */
  44353. constructor(scene: Scene);
  44354. /**
  44355. * Attaches a set of gizmos to the specified mesh
  44356. * @param mesh The mesh the gizmo's should be attached to
  44357. */
  44358. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44359. /**
  44360. * If the position gizmo is enabled
  44361. */
  44362. positionGizmoEnabled: boolean;
  44363. /**
  44364. * If the rotation gizmo is enabled
  44365. */
  44366. rotationGizmoEnabled: boolean;
  44367. /**
  44368. * If the scale gizmo is enabled
  44369. */
  44370. scaleGizmoEnabled: boolean;
  44371. /**
  44372. * If the boundingBox gizmo is enabled
  44373. */
  44374. boundingBoxGizmoEnabled: boolean;
  44375. /**
  44376. * Disposes of the gizmo manager
  44377. */
  44378. dispose(): void;
  44379. }
  44380. }
  44381. declare module BABYLON {
  44382. /**
  44383. * A directional light is defined by a direction (what a surprise!).
  44384. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44385. * 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.
  44386. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44387. */
  44388. export class DirectionalLight extends ShadowLight {
  44389. private _shadowFrustumSize;
  44390. /**
  44391. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44392. */
  44393. /**
  44394. * Specifies a fix frustum size for the shadow generation.
  44395. */
  44396. shadowFrustumSize: number;
  44397. private _shadowOrthoScale;
  44398. /**
  44399. * Gets the shadow projection scale against the optimal computed one.
  44400. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44401. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44402. */
  44403. /**
  44404. * Sets the shadow projection scale against the optimal computed one.
  44405. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44406. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44407. */
  44408. shadowOrthoScale: number;
  44409. /**
  44410. * Automatically compute the projection matrix to best fit (including all the casters)
  44411. * on each frame.
  44412. */
  44413. autoUpdateExtends: boolean;
  44414. private _orthoLeft;
  44415. private _orthoRight;
  44416. private _orthoTop;
  44417. private _orthoBottom;
  44418. /**
  44419. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44420. * The directional light is emitted from everywhere in the given direction.
  44421. * It can cast shadows.
  44422. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44423. * @param name The friendly name of the light
  44424. * @param direction The direction of the light
  44425. * @param scene The scene the light belongs to
  44426. */
  44427. constructor(name: string, direction: Vector3, scene: Scene);
  44428. /**
  44429. * Returns the string "DirectionalLight".
  44430. * @return The class name
  44431. */
  44432. getClassName(): string;
  44433. /**
  44434. * Returns the integer 1.
  44435. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44436. */
  44437. getTypeID(): number;
  44438. /**
  44439. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44440. * Returns the DirectionalLight Shadow projection matrix.
  44441. */
  44442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44443. /**
  44444. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44445. * Returns the DirectionalLight Shadow projection matrix.
  44446. */
  44447. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44448. /**
  44449. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44450. * Returns the DirectionalLight Shadow projection matrix.
  44451. */
  44452. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44453. protected _buildUniformLayout(): void;
  44454. /**
  44455. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44456. * @param effect The effect to update
  44457. * @param lightIndex The index of the light in the effect to update
  44458. * @returns The directional light
  44459. */
  44460. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44461. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44462. /**
  44463. * Gets the minZ used for shadow according to both the scene and the light.
  44464. *
  44465. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44466. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44467. * @param activeCamera The camera we are returning the min for
  44468. * @returns the depth min z
  44469. */
  44470. getDepthMinZ(activeCamera: Camera): number;
  44471. /**
  44472. * Gets the maxZ used for shadow according to both the scene and the light.
  44473. *
  44474. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44475. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44476. * @param activeCamera The camera we are returning the max for
  44477. * @returns the depth max z
  44478. */
  44479. getDepthMaxZ(activeCamera: Camera): number;
  44480. /**
  44481. * Prepares the list of defines specific to the light type.
  44482. * @param defines the list of defines
  44483. * @param lightIndex defines the index of the light for the effect
  44484. */
  44485. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44486. }
  44487. }
  44488. declare module BABYLON {
  44489. /**
  44490. * Class containing static functions to help procedurally build meshes
  44491. */
  44492. export class HemisphereBuilder {
  44493. /**
  44494. * Creates a hemisphere mesh
  44495. * @param name defines the name of the mesh
  44496. * @param options defines the options used to create the mesh
  44497. * @param scene defines the hosting scene
  44498. * @returns the hemisphere mesh
  44499. */
  44500. static CreateHemisphere(name: string, options: {
  44501. segments?: number;
  44502. diameter?: number;
  44503. sideOrientation?: number;
  44504. }, scene: any): Mesh;
  44505. }
  44506. }
  44507. declare module BABYLON {
  44508. /**
  44509. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44510. * These values define a cone of light starting from the position, emitting toward the direction.
  44511. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44512. * and the exponent defines the speed of the decay of the light with distance (reach).
  44513. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44514. */
  44515. export class SpotLight extends ShadowLight {
  44516. private _angle;
  44517. private _innerAngle;
  44518. private _cosHalfAngle;
  44519. private _lightAngleScale;
  44520. private _lightAngleOffset;
  44521. /**
  44522. * Gets the cone angle of the spot light in Radians.
  44523. */
  44524. /**
  44525. * Sets the cone angle of the spot light in Radians.
  44526. */
  44527. angle: number;
  44528. /**
  44529. * Only used in gltf falloff mode, this defines the angle where
  44530. * the directional falloff will start before cutting at angle which could be seen
  44531. * as outer angle.
  44532. */
  44533. /**
  44534. * Only used in gltf falloff mode, this defines the angle where
  44535. * the directional falloff will start before cutting at angle which could be seen
  44536. * as outer angle.
  44537. */
  44538. innerAngle: number;
  44539. private _shadowAngleScale;
  44540. /**
  44541. * Allows scaling the angle of the light for shadow generation only.
  44542. */
  44543. /**
  44544. * Allows scaling the angle of the light for shadow generation only.
  44545. */
  44546. shadowAngleScale: number;
  44547. /**
  44548. * The light decay speed with the distance from the emission spot.
  44549. */
  44550. exponent: number;
  44551. private _projectionTextureMatrix;
  44552. /**
  44553. * Allows reading the projecton texture
  44554. */
  44555. readonly projectionTextureMatrix: Matrix;
  44556. protected _projectionTextureLightNear: number;
  44557. /**
  44558. * Gets the near clip of the Spotlight for texture projection.
  44559. */
  44560. /**
  44561. * Sets the near clip of the Spotlight for texture projection.
  44562. */
  44563. projectionTextureLightNear: number;
  44564. protected _projectionTextureLightFar: number;
  44565. /**
  44566. * Gets the far clip of the Spotlight for texture projection.
  44567. */
  44568. /**
  44569. * Sets the far clip of the Spotlight for texture projection.
  44570. */
  44571. projectionTextureLightFar: number;
  44572. protected _projectionTextureUpDirection: Vector3;
  44573. /**
  44574. * Gets the Up vector of the Spotlight for texture projection.
  44575. */
  44576. /**
  44577. * Sets the Up vector of the Spotlight for texture projection.
  44578. */
  44579. projectionTextureUpDirection: Vector3;
  44580. private _projectionTexture;
  44581. /**
  44582. * Gets the projection texture of the light.
  44583. */
  44584. /**
  44585. * Sets the projection texture of the light.
  44586. */
  44587. projectionTexture: Nullable<BaseTexture>;
  44588. private _projectionTextureViewLightDirty;
  44589. private _projectionTextureProjectionLightDirty;
  44590. private _projectionTextureDirty;
  44591. private _projectionTextureViewTargetVector;
  44592. private _projectionTextureViewLightMatrix;
  44593. private _projectionTextureProjectionLightMatrix;
  44594. private _projectionTextureScalingMatrix;
  44595. /**
  44596. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44597. * It can cast shadows.
  44598. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44599. * @param name The light friendly name
  44600. * @param position The position of the spot light in the scene
  44601. * @param direction The direction of the light in the scene
  44602. * @param angle The cone angle of the light in Radians
  44603. * @param exponent The light decay speed with the distance from the emission spot
  44604. * @param scene The scene the lights belongs to
  44605. */
  44606. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44607. /**
  44608. * Returns the string "SpotLight".
  44609. * @returns the class name
  44610. */
  44611. getClassName(): string;
  44612. /**
  44613. * Returns the integer 2.
  44614. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44615. */
  44616. getTypeID(): number;
  44617. /**
  44618. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44619. */
  44620. protected _setDirection(value: Vector3): void;
  44621. /**
  44622. * Overrides the position setter to recompute the projection texture view light Matrix.
  44623. */
  44624. protected _setPosition(value: Vector3): void;
  44625. /**
  44626. * 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.
  44627. * Returns the SpotLight.
  44628. */
  44629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44630. protected _computeProjectionTextureViewLightMatrix(): void;
  44631. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44632. /**
  44633. * Main function for light texture projection matrix computing.
  44634. */
  44635. protected _computeProjectionTextureMatrix(): void;
  44636. protected _buildUniformLayout(): void;
  44637. private _computeAngleValues;
  44638. /**
  44639. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44640. * @param effect The effect to update
  44641. * @param lightIndex The index of the light in the effect to update
  44642. * @returns The spot light
  44643. */
  44644. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44645. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44646. /**
  44647. * Disposes the light and the associated resources.
  44648. */
  44649. dispose(): void;
  44650. /**
  44651. * Prepares the list of defines specific to the light type.
  44652. * @param defines the list of defines
  44653. * @param lightIndex defines the index of the light for the effect
  44654. */
  44655. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44656. }
  44657. }
  44658. declare module BABYLON {
  44659. /**
  44660. * Gizmo that enables viewing a light
  44661. */
  44662. export class LightGizmo extends Gizmo {
  44663. private _lightMesh;
  44664. private _material;
  44665. private cachedPosition;
  44666. private cachedForward;
  44667. /**
  44668. * Creates a LightGizmo
  44669. * @param gizmoLayer The utility layer the gizmo will be added to
  44670. */
  44671. constructor(gizmoLayer?: UtilityLayerRenderer);
  44672. private _light;
  44673. /**
  44674. * The light that the gizmo is attached to
  44675. */
  44676. light: Nullable<Light>;
  44677. /**
  44678. * Gets the material used to render the light gizmo
  44679. */
  44680. readonly material: StandardMaterial;
  44681. /**
  44682. * @hidden
  44683. * Updates the gizmo to match the attached mesh's position/rotation
  44684. */
  44685. protected _update(): void;
  44686. private static _Scale;
  44687. /**
  44688. * Creates the lines for a light mesh
  44689. */
  44690. private static _createLightLines;
  44691. /**
  44692. * Disposes of the light gizmo
  44693. */
  44694. dispose(): void;
  44695. private static _CreateHemisphericLightMesh;
  44696. private static _CreatePointLightMesh;
  44697. private static _CreateSpotLightMesh;
  44698. private static _CreateDirectionalLightMesh;
  44699. }
  44700. }
  44701. declare module BABYLON {
  44702. /** @hidden */
  44703. export var backgroundFragmentDeclaration: {
  44704. name: string;
  44705. shader: string;
  44706. };
  44707. }
  44708. declare module BABYLON {
  44709. /** @hidden */
  44710. export var backgroundUboDeclaration: {
  44711. name: string;
  44712. shader: string;
  44713. };
  44714. }
  44715. declare module BABYLON {
  44716. /** @hidden */
  44717. export var backgroundPixelShader: {
  44718. name: string;
  44719. shader: string;
  44720. };
  44721. }
  44722. declare module BABYLON {
  44723. /** @hidden */
  44724. export var backgroundVertexDeclaration: {
  44725. name: string;
  44726. shader: string;
  44727. };
  44728. }
  44729. declare module BABYLON {
  44730. /** @hidden */
  44731. export var backgroundVertexShader: {
  44732. name: string;
  44733. shader: string;
  44734. };
  44735. }
  44736. declare module BABYLON {
  44737. /**
  44738. * Background material used to create an efficient environement around your scene.
  44739. */
  44740. export class BackgroundMaterial extends PushMaterial {
  44741. /**
  44742. * Standard reflectance value at parallel view angle.
  44743. */
  44744. static StandardReflectance0: number;
  44745. /**
  44746. * Standard reflectance value at grazing angle.
  44747. */
  44748. static StandardReflectance90: number;
  44749. protected _primaryColor: Color3;
  44750. /**
  44751. * Key light Color (multiply against the environement texture)
  44752. */
  44753. primaryColor: Color3;
  44754. protected __perceptualColor: Nullable<Color3>;
  44755. /**
  44756. * Experimental Internal Use Only.
  44757. *
  44758. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44759. * This acts as a helper to set the primary color to a more "human friendly" value.
  44760. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44761. * output color as close as possible from the chosen value.
  44762. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44763. * part of lighting setup.)
  44764. */
  44765. _perceptualColor: Nullable<Color3>;
  44766. protected _primaryColorShadowLevel: float;
  44767. /**
  44768. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44769. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44770. */
  44771. primaryColorShadowLevel: float;
  44772. protected _primaryColorHighlightLevel: float;
  44773. /**
  44774. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44775. * The primary color is used at the level chosen to define what the white area would look.
  44776. */
  44777. primaryColorHighlightLevel: float;
  44778. protected _reflectionTexture: Nullable<BaseTexture>;
  44779. /**
  44780. * Reflection Texture used in the material.
  44781. * Should be author in a specific way for the best result (refer to the documentation).
  44782. */
  44783. reflectionTexture: Nullable<BaseTexture>;
  44784. protected _reflectionBlur: float;
  44785. /**
  44786. * Reflection Texture level of blur.
  44787. *
  44788. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44789. * texture twice.
  44790. */
  44791. reflectionBlur: float;
  44792. protected _diffuseTexture: Nullable<BaseTexture>;
  44793. /**
  44794. * Diffuse Texture used in the material.
  44795. * Should be author in a specific way for the best result (refer to the documentation).
  44796. */
  44797. diffuseTexture: Nullable<BaseTexture>;
  44798. protected _shadowLights: Nullable<IShadowLight[]>;
  44799. /**
  44800. * Specify the list of lights casting shadow on the material.
  44801. * All scene shadow lights will be included if null.
  44802. */
  44803. shadowLights: Nullable<IShadowLight[]>;
  44804. protected _shadowLevel: float;
  44805. /**
  44806. * Helps adjusting the shadow to a softer level if required.
  44807. * 0 means black shadows and 1 means no shadows.
  44808. */
  44809. shadowLevel: float;
  44810. protected _sceneCenter: Vector3;
  44811. /**
  44812. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44813. * It is usually zero but might be interesting to modify according to your setup.
  44814. */
  44815. sceneCenter: Vector3;
  44816. protected _opacityFresnel: boolean;
  44817. /**
  44818. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44819. * This helps ensuring a nice transition when the camera goes under the ground.
  44820. */
  44821. opacityFresnel: boolean;
  44822. protected _reflectionFresnel: boolean;
  44823. /**
  44824. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44825. * This helps adding a mirror texture on the ground.
  44826. */
  44827. reflectionFresnel: boolean;
  44828. protected _reflectionFalloffDistance: number;
  44829. /**
  44830. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44831. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44832. */
  44833. reflectionFalloffDistance: number;
  44834. protected _reflectionAmount: number;
  44835. /**
  44836. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44837. */
  44838. reflectionAmount: number;
  44839. protected _reflectionReflectance0: number;
  44840. /**
  44841. * This specifies the weight of the reflection at grazing angle.
  44842. */
  44843. reflectionReflectance0: number;
  44844. protected _reflectionReflectance90: number;
  44845. /**
  44846. * This specifies the weight of the reflection at a perpendicular point of view.
  44847. */
  44848. reflectionReflectance90: number;
  44849. /**
  44850. * Sets the reflection reflectance fresnel values according to the default standard
  44851. * empirically know to work well :-)
  44852. */
  44853. reflectionStandardFresnelWeight: number;
  44854. protected _useRGBColor: boolean;
  44855. /**
  44856. * Helps to directly use the maps channels instead of their level.
  44857. */
  44858. useRGBColor: boolean;
  44859. protected _enableNoise: boolean;
  44860. /**
  44861. * This helps reducing the banding effect that could occur on the background.
  44862. */
  44863. enableNoise: boolean;
  44864. /**
  44865. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44866. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44867. * Recommended to be keep at 1.0 except for special cases.
  44868. */
  44869. fovMultiplier: number;
  44870. private _fovMultiplier;
  44871. /**
  44872. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44873. */
  44874. useEquirectangularFOV: boolean;
  44875. private _maxSimultaneousLights;
  44876. /**
  44877. * Number of Simultaneous lights allowed on the material.
  44878. */
  44879. maxSimultaneousLights: int;
  44880. /**
  44881. * Default configuration related to image processing available in the Background Material.
  44882. */
  44883. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44884. /**
  44885. * Keep track of the image processing observer to allow dispose and replace.
  44886. */
  44887. private _imageProcessingObserver;
  44888. /**
  44889. * Attaches a new image processing configuration to the PBR Material.
  44890. * @param configuration (if null the scene configuration will be use)
  44891. */
  44892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44893. /**
  44894. * Gets the image processing configuration used either in this material.
  44895. */
  44896. /**
  44897. * Sets the Default image processing configuration used either in the this material.
  44898. *
  44899. * If sets to null, the scene one is in use.
  44900. */
  44901. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44902. /**
  44903. * Gets wether the color curves effect is enabled.
  44904. */
  44905. /**
  44906. * Sets wether the color curves effect is enabled.
  44907. */
  44908. cameraColorCurvesEnabled: boolean;
  44909. /**
  44910. * Gets wether the color grading effect is enabled.
  44911. */
  44912. /**
  44913. * Gets wether the color grading effect is enabled.
  44914. */
  44915. cameraColorGradingEnabled: boolean;
  44916. /**
  44917. * Gets wether tonemapping is enabled or not.
  44918. */
  44919. /**
  44920. * Sets wether tonemapping is enabled or not
  44921. */
  44922. cameraToneMappingEnabled: boolean;
  44923. /**
  44924. * The camera exposure used on this material.
  44925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44926. * This corresponds to a photographic exposure.
  44927. */
  44928. /**
  44929. * The camera exposure used on this material.
  44930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44931. * This corresponds to a photographic exposure.
  44932. */
  44933. cameraExposure: float;
  44934. /**
  44935. * Gets The camera contrast used on this material.
  44936. */
  44937. /**
  44938. * Sets The camera contrast used on this material.
  44939. */
  44940. cameraContrast: float;
  44941. /**
  44942. * Gets the Color Grading 2D Lookup Texture.
  44943. */
  44944. /**
  44945. * Sets the Color Grading 2D Lookup Texture.
  44946. */
  44947. cameraColorGradingTexture: Nullable<BaseTexture>;
  44948. /**
  44949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44951. * 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;
  44952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44953. */
  44954. /**
  44955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44957. * 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;
  44958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44959. */
  44960. cameraColorCurves: Nullable<ColorCurves>;
  44961. /**
  44962. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44963. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44964. */
  44965. switchToBGR: boolean;
  44966. private _renderTargets;
  44967. private _reflectionControls;
  44968. private _white;
  44969. private _primaryShadowColor;
  44970. private _primaryHighlightColor;
  44971. /**
  44972. * Instantiates a Background Material in the given scene
  44973. * @param name The friendly name of the material
  44974. * @param scene The scene to add the material to
  44975. */
  44976. constructor(name: string, scene: Scene);
  44977. /**
  44978. * Gets a boolean indicating that current material needs to register RTT
  44979. */
  44980. readonly hasRenderTargetTextures: boolean;
  44981. /**
  44982. * The entire material has been created in order to prevent overdraw.
  44983. * @returns false
  44984. */
  44985. needAlphaTesting(): boolean;
  44986. /**
  44987. * The entire material has been created in order to prevent overdraw.
  44988. * @returns true if blending is enable
  44989. */
  44990. needAlphaBlending(): boolean;
  44991. /**
  44992. * Checks wether the material is ready to be rendered for a given mesh.
  44993. * @param mesh The mesh to render
  44994. * @param subMesh The submesh to check against
  44995. * @param useInstances Specify wether or not the material is used with instances
  44996. * @returns true if all the dependencies are ready (Textures, Effects...)
  44997. */
  44998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44999. /**
  45000. * Compute the primary color according to the chosen perceptual color.
  45001. */
  45002. private _computePrimaryColorFromPerceptualColor;
  45003. /**
  45004. * Compute the highlights and shadow colors according to their chosen levels.
  45005. */
  45006. private _computePrimaryColors;
  45007. /**
  45008. * Build the uniform buffer used in the material.
  45009. */
  45010. buildUniformLayout(): void;
  45011. /**
  45012. * Unbind the material.
  45013. */
  45014. unbind(): void;
  45015. /**
  45016. * Bind only the world matrix to the material.
  45017. * @param world The world matrix to bind.
  45018. */
  45019. bindOnlyWorldMatrix(world: Matrix): void;
  45020. /**
  45021. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45022. * @param world The world matrix to bind.
  45023. * @param subMesh The submesh to bind for.
  45024. */
  45025. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45026. /**
  45027. * Checks to see if a texture is used in the material.
  45028. * @param texture - Base texture to use.
  45029. * @returns - Boolean specifying if a texture is used in the material.
  45030. */
  45031. hasTexture(texture: BaseTexture): boolean;
  45032. /**
  45033. * Dispose the material.
  45034. * @param forceDisposeEffect Force disposal of the associated effect.
  45035. * @param forceDisposeTextures Force disposal of the associated textures.
  45036. */
  45037. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45038. /**
  45039. * Clones the material.
  45040. * @param name The cloned name.
  45041. * @returns The cloned material.
  45042. */
  45043. clone(name: string): BackgroundMaterial;
  45044. /**
  45045. * Serializes the current material to its JSON representation.
  45046. * @returns The JSON representation.
  45047. */
  45048. serialize(): any;
  45049. /**
  45050. * Gets the class name of the material
  45051. * @returns "BackgroundMaterial"
  45052. */
  45053. getClassName(): string;
  45054. /**
  45055. * Parse a JSON input to create back a background material.
  45056. * @param source The JSON data to parse
  45057. * @param scene The scene to create the parsed material in
  45058. * @param rootUrl The root url of the assets the material depends upon
  45059. * @returns the instantiated BackgroundMaterial.
  45060. */
  45061. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45062. }
  45063. }
  45064. declare module BABYLON {
  45065. /**
  45066. * Represents the different options available during the creation of
  45067. * a Environment helper.
  45068. *
  45069. * This can control the default ground, skybox and image processing setup of your scene.
  45070. */
  45071. export interface IEnvironmentHelperOptions {
  45072. /**
  45073. * Specifies wether or not to create a ground.
  45074. * True by default.
  45075. */
  45076. createGround: boolean;
  45077. /**
  45078. * Specifies the ground size.
  45079. * 15 by default.
  45080. */
  45081. groundSize: number;
  45082. /**
  45083. * The texture used on the ground for the main color.
  45084. * Comes from the BabylonJS CDN by default.
  45085. *
  45086. * Remarks: Can be either a texture or a url.
  45087. */
  45088. groundTexture: string | BaseTexture;
  45089. /**
  45090. * The color mixed in the ground texture by default.
  45091. * BabylonJS clearColor by default.
  45092. */
  45093. groundColor: Color3;
  45094. /**
  45095. * Specifies the ground opacity.
  45096. * 1 by default.
  45097. */
  45098. groundOpacity: number;
  45099. /**
  45100. * Enables the ground to receive shadows.
  45101. * True by default.
  45102. */
  45103. enableGroundShadow: boolean;
  45104. /**
  45105. * Helps preventing the shadow to be fully black on the ground.
  45106. * 0.5 by default.
  45107. */
  45108. groundShadowLevel: number;
  45109. /**
  45110. * Creates a mirror texture attach to the ground.
  45111. * false by default.
  45112. */
  45113. enableGroundMirror: boolean;
  45114. /**
  45115. * Specifies the ground mirror size ratio.
  45116. * 0.3 by default as the default kernel is 64.
  45117. */
  45118. groundMirrorSizeRatio: number;
  45119. /**
  45120. * Specifies the ground mirror blur kernel size.
  45121. * 64 by default.
  45122. */
  45123. groundMirrorBlurKernel: number;
  45124. /**
  45125. * Specifies the ground mirror visibility amount.
  45126. * 1 by default
  45127. */
  45128. groundMirrorAmount: number;
  45129. /**
  45130. * Specifies the ground mirror reflectance weight.
  45131. * This uses the standard weight of the background material to setup the fresnel effect
  45132. * of the mirror.
  45133. * 1 by default.
  45134. */
  45135. groundMirrorFresnelWeight: number;
  45136. /**
  45137. * Specifies the ground mirror Falloff distance.
  45138. * This can helps reducing the size of the reflection.
  45139. * 0 by Default.
  45140. */
  45141. groundMirrorFallOffDistance: number;
  45142. /**
  45143. * Specifies the ground mirror texture type.
  45144. * Unsigned Int by Default.
  45145. */
  45146. groundMirrorTextureType: number;
  45147. /**
  45148. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45149. * the shown objects.
  45150. */
  45151. groundYBias: number;
  45152. /**
  45153. * Specifies wether or not to create a skybox.
  45154. * True by default.
  45155. */
  45156. createSkybox: boolean;
  45157. /**
  45158. * Specifies the skybox size.
  45159. * 20 by default.
  45160. */
  45161. skyboxSize: number;
  45162. /**
  45163. * The texture used on the skybox for the main color.
  45164. * Comes from the BabylonJS CDN by default.
  45165. *
  45166. * Remarks: Can be either a texture or a url.
  45167. */
  45168. skyboxTexture: string | BaseTexture;
  45169. /**
  45170. * The color mixed in the skybox texture by default.
  45171. * BabylonJS clearColor by default.
  45172. */
  45173. skyboxColor: Color3;
  45174. /**
  45175. * The background rotation around the Y axis of the scene.
  45176. * This helps aligning the key lights of your scene with the background.
  45177. * 0 by default.
  45178. */
  45179. backgroundYRotation: number;
  45180. /**
  45181. * Compute automatically the size of the elements to best fit with the scene.
  45182. */
  45183. sizeAuto: boolean;
  45184. /**
  45185. * Default position of the rootMesh if autoSize is not true.
  45186. */
  45187. rootPosition: Vector3;
  45188. /**
  45189. * Sets up the image processing in the scene.
  45190. * true by default.
  45191. */
  45192. setupImageProcessing: boolean;
  45193. /**
  45194. * The texture used as your environment texture in the scene.
  45195. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45196. *
  45197. * Remarks: Can be either a texture or a url.
  45198. */
  45199. environmentTexture: string | BaseTexture;
  45200. /**
  45201. * The value of the exposure to apply to the scene.
  45202. * 0.6 by default if setupImageProcessing is true.
  45203. */
  45204. cameraExposure: number;
  45205. /**
  45206. * The value of the contrast to apply to the scene.
  45207. * 1.6 by default if setupImageProcessing is true.
  45208. */
  45209. cameraContrast: number;
  45210. /**
  45211. * Specifies wether or not tonemapping should be enabled in the scene.
  45212. * true by default if setupImageProcessing is true.
  45213. */
  45214. toneMappingEnabled: boolean;
  45215. }
  45216. /**
  45217. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45218. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45219. * It also helps with the default setup of your imageProcessing configuration.
  45220. */
  45221. export class EnvironmentHelper {
  45222. /**
  45223. * Default ground texture URL.
  45224. */
  45225. private static _groundTextureCDNUrl;
  45226. /**
  45227. * Default skybox texture URL.
  45228. */
  45229. private static _skyboxTextureCDNUrl;
  45230. /**
  45231. * Default environment texture URL.
  45232. */
  45233. private static _environmentTextureCDNUrl;
  45234. /**
  45235. * Creates the default options for the helper.
  45236. */
  45237. private static _getDefaultOptions;
  45238. private _rootMesh;
  45239. /**
  45240. * Gets the root mesh created by the helper.
  45241. */
  45242. readonly rootMesh: Mesh;
  45243. private _skybox;
  45244. /**
  45245. * Gets the skybox created by the helper.
  45246. */
  45247. readonly skybox: Nullable<Mesh>;
  45248. private _skyboxTexture;
  45249. /**
  45250. * Gets the skybox texture created by the helper.
  45251. */
  45252. readonly skyboxTexture: Nullable<BaseTexture>;
  45253. private _skyboxMaterial;
  45254. /**
  45255. * Gets the skybox material created by the helper.
  45256. */
  45257. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45258. private _ground;
  45259. /**
  45260. * Gets the ground mesh created by the helper.
  45261. */
  45262. readonly ground: Nullable<Mesh>;
  45263. private _groundTexture;
  45264. /**
  45265. * Gets the ground texture created by the helper.
  45266. */
  45267. readonly groundTexture: Nullable<BaseTexture>;
  45268. private _groundMirror;
  45269. /**
  45270. * Gets the ground mirror created by the helper.
  45271. */
  45272. readonly groundMirror: Nullable<MirrorTexture>;
  45273. /**
  45274. * Gets the ground mirror render list to helps pushing the meshes
  45275. * you wish in the ground reflection.
  45276. */
  45277. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45278. private _groundMaterial;
  45279. /**
  45280. * Gets the ground material created by the helper.
  45281. */
  45282. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45283. /**
  45284. * Stores the creation options.
  45285. */
  45286. private readonly _scene;
  45287. private _options;
  45288. /**
  45289. * This observable will be notified with any error during the creation of the environment,
  45290. * mainly texture creation errors.
  45291. */
  45292. onErrorObservable: Observable<{
  45293. message?: string;
  45294. exception?: any;
  45295. }>;
  45296. /**
  45297. * constructor
  45298. * @param options Defines the options we want to customize the helper
  45299. * @param scene The scene to add the material to
  45300. */
  45301. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45302. /**
  45303. * Updates the background according to the new options
  45304. * @param options
  45305. */
  45306. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45307. /**
  45308. * Sets the primary color of all the available elements.
  45309. * @param color the main color to affect to the ground and the background
  45310. */
  45311. setMainColor(color: Color3): void;
  45312. /**
  45313. * Setup the image processing according to the specified options.
  45314. */
  45315. private _setupImageProcessing;
  45316. /**
  45317. * Setup the environment texture according to the specified options.
  45318. */
  45319. private _setupEnvironmentTexture;
  45320. /**
  45321. * Setup the background according to the specified options.
  45322. */
  45323. private _setupBackground;
  45324. /**
  45325. * Get the scene sizes according to the setup.
  45326. */
  45327. private _getSceneSize;
  45328. /**
  45329. * Setup the ground according to the specified options.
  45330. */
  45331. private _setupGround;
  45332. /**
  45333. * Setup the ground material according to the specified options.
  45334. */
  45335. private _setupGroundMaterial;
  45336. /**
  45337. * Setup the ground diffuse texture according to the specified options.
  45338. */
  45339. private _setupGroundDiffuseTexture;
  45340. /**
  45341. * Setup the ground mirror texture according to the specified options.
  45342. */
  45343. private _setupGroundMirrorTexture;
  45344. /**
  45345. * Setup the ground to receive the mirror texture.
  45346. */
  45347. private _setupMirrorInGroundMaterial;
  45348. /**
  45349. * Setup the skybox according to the specified options.
  45350. */
  45351. private _setupSkybox;
  45352. /**
  45353. * Setup the skybox material according to the specified options.
  45354. */
  45355. private _setupSkyboxMaterial;
  45356. /**
  45357. * Setup the skybox reflection texture according to the specified options.
  45358. */
  45359. private _setupSkyboxReflectionTexture;
  45360. private _errorHandler;
  45361. /**
  45362. * Dispose all the elements created by the Helper.
  45363. */
  45364. dispose(): void;
  45365. }
  45366. }
  45367. declare module BABYLON {
  45368. /**
  45369. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45370. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45371. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45372. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45373. */
  45374. export class PhotoDome extends TransformNode {
  45375. /**
  45376. * Define the image as a Monoscopic panoramic 360 image.
  45377. */
  45378. static readonly MODE_MONOSCOPIC: number;
  45379. /**
  45380. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45381. */
  45382. static readonly MODE_TOPBOTTOM: number;
  45383. /**
  45384. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45385. */
  45386. static readonly MODE_SIDEBYSIDE: number;
  45387. private _useDirectMapping;
  45388. /**
  45389. * The texture being displayed on the sphere
  45390. */
  45391. protected _photoTexture: Texture;
  45392. /**
  45393. * Gets or sets the texture being displayed on the sphere
  45394. */
  45395. photoTexture: Texture;
  45396. /**
  45397. * Observable raised when an error occured while loading the 360 image
  45398. */
  45399. onLoadErrorObservable: Observable<string>;
  45400. /**
  45401. * The skybox material
  45402. */
  45403. protected _material: BackgroundMaterial;
  45404. /**
  45405. * The surface used for the skybox
  45406. */
  45407. protected _mesh: Mesh;
  45408. /**
  45409. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45410. * Also see the options.resolution property.
  45411. */
  45412. fovMultiplier: number;
  45413. private _imageMode;
  45414. /**
  45415. * Gets or set the current video mode for the video. It can be:
  45416. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45417. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45418. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45419. */
  45420. imageMode: number;
  45421. /**
  45422. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45423. * @param name Element's name, child elements will append suffixes for their own names.
  45424. * @param urlsOfPhoto defines the url of the photo to display
  45425. * @param options defines an object containing optional or exposed sub element properties
  45426. * @param onError defines a callback called when an error occured while loading the texture
  45427. */
  45428. constructor(name: string, urlOfPhoto: string, options: {
  45429. resolution?: number;
  45430. size?: number;
  45431. useDirectMapping?: boolean;
  45432. faceForward?: boolean;
  45433. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45434. private _onBeforeCameraRenderObserver;
  45435. private _changeImageMode;
  45436. /**
  45437. * Releases resources associated with this node.
  45438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45440. */
  45441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45442. }
  45443. }
  45444. declare module BABYLON {
  45445. /** @hidden */
  45446. export var rgbdDecodePixelShader: {
  45447. name: string;
  45448. shader: string;
  45449. };
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * Class used to host texture specific utilities
  45454. */
  45455. export class BRDFTextureTools {
  45456. /**
  45457. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45458. * @param texture the texture to expand.
  45459. */
  45460. private static _ExpandDefaultBRDFTexture;
  45461. /**
  45462. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45463. * @param scene defines the hosting scene
  45464. * @returns the environment BRDF texture
  45465. */
  45466. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45467. private static _environmentBRDFBase64Texture;
  45468. }
  45469. }
  45470. declare module BABYLON {
  45471. /**
  45472. * @hidden
  45473. */
  45474. export interface IMaterialClearCoatDefines {
  45475. CLEARCOAT: boolean;
  45476. CLEARCOAT_DEFAULTIOR: boolean;
  45477. CLEARCOAT_TEXTURE: boolean;
  45478. CLEARCOAT_TEXTUREDIRECTUV: number;
  45479. CLEARCOAT_BUMP: boolean;
  45480. CLEARCOAT_BUMPDIRECTUV: number;
  45481. CLEARCOAT_TINT: boolean;
  45482. CLEARCOAT_TINT_TEXTURE: boolean;
  45483. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45484. /** @hidden */
  45485. _areTexturesDirty: boolean;
  45486. }
  45487. /**
  45488. * Define the code related to the clear coat parameters of the pbr material.
  45489. */
  45490. export class PBRClearCoatConfiguration {
  45491. /**
  45492. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45493. * The default fits with a polyurethane material.
  45494. */
  45495. private static readonly _DefaultIndexOfRefraction;
  45496. private _isEnabled;
  45497. /**
  45498. * Defines if the clear coat is enabled in the material.
  45499. */
  45500. isEnabled: boolean;
  45501. /**
  45502. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45503. */
  45504. intensity: number;
  45505. /**
  45506. * Defines the clear coat layer roughness.
  45507. */
  45508. roughness: number;
  45509. private _indexOfRefraction;
  45510. /**
  45511. * Defines the index of refraction of the clear coat.
  45512. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45513. * The default fits with a polyurethane material.
  45514. * Changing the default value is more performance intensive.
  45515. */
  45516. indexOfRefraction: number;
  45517. private _texture;
  45518. /**
  45519. * Stores the clear coat values in a texture.
  45520. */
  45521. texture: Nullable<BaseTexture>;
  45522. private _bumpTexture;
  45523. /**
  45524. * Define the clear coat specific bump texture.
  45525. */
  45526. bumpTexture: Nullable<BaseTexture>;
  45527. private _isTintEnabled;
  45528. /**
  45529. * Defines if the clear coat tint is enabled in the material.
  45530. */
  45531. isTintEnabled: boolean;
  45532. /**
  45533. * Defines the clear coat tint of the material.
  45534. * This is only use if tint is enabled
  45535. */
  45536. tintColor: Color3;
  45537. /**
  45538. * Defines the distance at which the tint color should be found in the
  45539. * clear coat media.
  45540. * This is only use if tint is enabled
  45541. */
  45542. tintColorAtDistance: number;
  45543. /**
  45544. * Defines the clear coat layer thickness.
  45545. * This is only use if tint is enabled
  45546. */
  45547. tintThickness: number;
  45548. private _tintTexture;
  45549. /**
  45550. * Stores the clear tint values in a texture.
  45551. * rgb is tint
  45552. * a is a thickness factor
  45553. */
  45554. tintTexture: Nullable<BaseTexture>;
  45555. /** @hidden */
  45556. private _internalMarkAllSubMeshesAsTexturesDirty;
  45557. /** @hidden */
  45558. _markAllSubMeshesAsTexturesDirty(): void;
  45559. /**
  45560. * Instantiate a new istance of clear coat configuration.
  45561. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45562. */
  45563. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45564. /**
  45565. * Gets wehter the submesh is ready to be used or not.
  45566. * @param defines the list of "defines" to update.
  45567. * @param scene defines the scene the material belongs to.
  45568. * @param engine defines the engine the material belongs to.
  45569. * @param disableBumpMap defines wether the material disables bump or not.
  45570. * @returns - boolean indicating that the submesh is ready or not.
  45571. */
  45572. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45573. /**
  45574. * Checks to see if a texture is used in the material.
  45575. * @param defines the list of "defines" to update.
  45576. * @param scene defines the scene to the material belongs to.
  45577. */
  45578. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45579. /**
  45580. * Binds the material data.
  45581. * @param uniformBuffer defines the Uniform buffer to fill in.
  45582. * @param scene defines the scene the material belongs to.
  45583. * @param engine defines the engine the material belongs to.
  45584. * @param disableBumpMap defines wether the material disables bump or not.
  45585. * @param isFrozen defines wether the material is frozen or not.
  45586. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45587. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45588. */
  45589. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45590. /**
  45591. * Checks to see if a texture is used in the material.
  45592. * @param texture - Base texture to use.
  45593. * @returns - Boolean specifying if a texture is used in the material.
  45594. */
  45595. hasTexture(texture: BaseTexture): boolean;
  45596. /**
  45597. * Returns an array of the actively used textures.
  45598. * @param activeTextures Array of BaseTextures
  45599. */
  45600. getActiveTextures(activeTextures: BaseTexture[]): void;
  45601. /**
  45602. * Returns the animatable textures.
  45603. * @param animatables Array of animatable textures.
  45604. */
  45605. getAnimatables(animatables: IAnimatable[]): void;
  45606. /**
  45607. * Disposes the resources of the material.
  45608. * @param forceDisposeTextures - Forces the disposal of all textures.
  45609. */
  45610. dispose(forceDisposeTextures?: boolean): void;
  45611. /**
  45612. * Get the current class name of the texture useful for serialization or dynamic coding.
  45613. * @returns "PBRClearCoatConfiguration"
  45614. */
  45615. getClassName(): string;
  45616. /**
  45617. * Add fallbacks to the effect fallbacks list.
  45618. * @param defines defines the Base texture to use.
  45619. * @param fallbacks defines the current fallback list.
  45620. * @param currentRank defines the current fallback rank.
  45621. * @returns the new fallback rank.
  45622. */
  45623. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45624. /**
  45625. * Add the required uniforms to the current list.
  45626. * @param uniforms defines the current uniform list.
  45627. */
  45628. static AddUniforms(uniforms: string[]): void;
  45629. /**
  45630. * Add the required samplers to the current list.
  45631. * @param samplers defines the current sampler list.
  45632. */
  45633. static AddSamplers(samplers: string[]): void;
  45634. /**
  45635. * Add the required uniforms to the current buffer.
  45636. * @param uniformBuffer defines the current uniform buffer.
  45637. */
  45638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45639. /**
  45640. * Makes a duplicate of the current configuration into another one.
  45641. * @param clearCoatConfiguration define the config where to copy the info
  45642. */
  45643. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45644. /**
  45645. * Serializes this clear coat configuration.
  45646. * @returns - An object with the serialized config.
  45647. */
  45648. serialize(): any;
  45649. /**
  45650. * Parses a anisotropy Configuration from a serialized object.
  45651. * @param source - Serialized object.
  45652. * @param scene Defines the scene we are parsing for
  45653. * @param rootUrl Defines the rootUrl to load from
  45654. */
  45655. parse(source: any, scene: Scene, rootUrl: string): void;
  45656. }
  45657. }
  45658. declare module BABYLON {
  45659. /**
  45660. * @hidden
  45661. */
  45662. export interface IMaterialAnisotropicDefines {
  45663. ANISOTROPIC: boolean;
  45664. ANISOTROPIC_TEXTURE: boolean;
  45665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45666. MAINUV1: boolean;
  45667. _areTexturesDirty: boolean;
  45668. _needUVs: boolean;
  45669. }
  45670. /**
  45671. * Define the code related to the anisotropic parameters of the pbr material.
  45672. */
  45673. export class PBRAnisotropicConfiguration {
  45674. private _isEnabled;
  45675. /**
  45676. * Defines if the anisotropy is enabled in the material.
  45677. */
  45678. isEnabled: boolean;
  45679. /**
  45680. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45681. */
  45682. intensity: number;
  45683. /**
  45684. * Defines if the effect is along the tangents, bitangents or in between.
  45685. * By default, the effect is "strectching" the highlights along the tangents.
  45686. */
  45687. direction: Vector2;
  45688. private _texture;
  45689. /**
  45690. * Stores the anisotropy values in a texture.
  45691. * rg is direction (like normal from -1 to 1)
  45692. * b is a intensity
  45693. */
  45694. texture: Nullable<BaseTexture>;
  45695. /** @hidden */
  45696. private _internalMarkAllSubMeshesAsTexturesDirty;
  45697. /** @hidden */
  45698. _markAllSubMeshesAsTexturesDirty(): void;
  45699. /**
  45700. * Instantiate a new istance of anisotropy configuration.
  45701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45702. */
  45703. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45704. /**
  45705. * Specifies that the submesh is ready to be used.
  45706. * @param defines the list of "defines" to update.
  45707. * @param scene defines the scene the material belongs to.
  45708. * @returns - boolean indicating that the submesh is ready or not.
  45709. */
  45710. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45711. /**
  45712. * Checks to see if a texture is used in the material.
  45713. * @param defines the list of "defines" to update.
  45714. * @param mesh the mesh we are preparing the defines for.
  45715. * @param scene defines the scene the material belongs to.
  45716. */
  45717. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45718. /**
  45719. * Binds the material data.
  45720. * @param uniformBuffer defines the Uniform buffer to fill in.
  45721. * @param scene defines the scene the material belongs to.
  45722. * @param isFrozen defines wether the material is frozen or not.
  45723. */
  45724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45725. /**
  45726. * Checks to see if a texture is used in the material.
  45727. * @param texture - Base texture to use.
  45728. * @returns - Boolean specifying if a texture is used in the material.
  45729. */
  45730. hasTexture(texture: BaseTexture): boolean;
  45731. /**
  45732. * Returns an array of the actively used textures.
  45733. * @param activeTextures Array of BaseTextures
  45734. */
  45735. getActiveTextures(activeTextures: BaseTexture[]): void;
  45736. /**
  45737. * Returns the animatable textures.
  45738. * @param animatables Array of animatable textures.
  45739. */
  45740. getAnimatables(animatables: IAnimatable[]): void;
  45741. /**
  45742. * Disposes the resources of the material.
  45743. * @param forceDisposeTextures - Forces the disposal of all textures.
  45744. */
  45745. dispose(forceDisposeTextures?: boolean): void;
  45746. /**
  45747. * Get the current class name of the texture useful for serialization or dynamic coding.
  45748. * @returns "PBRAnisotropicConfiguration"
  45749. */
  45750. getClassName(): string;
  45751. /**
  45752. * Add fallbacks to the effect fallbacks list.
  45753. * @param defines defines the Base texture to use.
  45754. * @param fallbacks defines the current fallback list.
  45755. * @param currentRank defines the current fallback rank.
  45756. * @returns the new fallback rank.
  45757. */
  45758. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45759. /**
  45760. * Add the required uniforms to the current list.
  45761. * @param uniforms defines the current uniform list.
  45762. */
  45763. static AddUniforms(uniforms: string[]): void;
  45764. /**
  45765. * Add the required uniforms to the current buffer.
  45766. * @param uniformBuffer defines the current uniform buffer.
  45767. */
  45768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45769. /**
  45770. * Add the required samplers to the current list.
  45771. * @param samplers defines the current sampler list.
  45772. */
  45773. static AddSamplers(samplers: string[]): void;
  45774. /**
  45775. * Makes a duplicate of the current configuration into another one.
  45776. * @param anisotropicConfiguration define the config where to copy the info
  45777. */
  45778. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45779. /**
  45780. * Serializes this anisotropy configuration.
  45781. * @returns - An object with the serialized config.
  45782. */
  45783. serialize(): any;
  45784. /**
  45785. * Parses a anisotropy Configuration from a serialized object.
  45786. * @param source - Serialized object.
  45787. * @param scene Defines the scene we are parsing for
  45788. * @param rootUrl Defines the rootUrl to load from
  45789. */
  45790. parse(source: any, scene: Scene, rootUrl: string): void;
  45791. }
  45792. }
  45793. declare module BABYLON {
  45794. /**
  45795. * @hidden
  45796. */
  45797. export interface IMaterialBRDFDefines {
  45798. BRDF_V_HEIGHT_CORRELATED: boolean;
  45799. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45800. SPHERICAL_HARMONICS: boolean;
  45801. /** @hidden */
  45802. _areMiscDirty: boolean;
  45803. }
  45804. /**
  45805. * Define the code related to the BRDF parameters of the pbr material.
  45806. */
  45807. export class PBRBRDFConfiguration {
  45808. /**
  45809. * Default value used for the energy conservation.
  45810. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45811. */
  45812. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45813. /**
  45814. * Default value used for the Smith Visibility Height Correlated mode.
  45815. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45816. */
  45817. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45818. /**
  45819. * Default value used for the IBL diffuse part.
  45820. * This can help switching back to the polynomials mode globally which is a tiny bit
  45821. * less GPU intensive at the drawback of a lower quality.
  45822. */
  45823. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45824. private _useEnergyConservation;
  45825. /**
  45826. * Defines if the material uses energy conservation.
  45827. */
  45828. useEnergyConservation: boolean;
  45829. private _useSmithVisibilityHeightCorrelated;
  45830. /**
  45831. * LEGACY Mode set to false
  45832. * Defines if the material uses height smith correlated visibility term.
  45833. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45834. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45835. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45836. * Not relying on height correlated will also disable energy conservation.
  45837. */
  45838. useSmithVisibilityHeightCorrelated: boolean;
  45839. private _useSphericalHarmonics;
  45840. /**
  45841. * LEGACY Mode set to false
  45842. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45843. * diffuse part of the IBL.
  45844. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45845. * to the ground truth.
  45846. */
  45847. useSphericalHarmonics: boolean;
  45848. /** @hidden */
  45849. private _internalMarkAllSubMeshesAsMiscDirty;
  45850. /** @hidden */
  45851. _markAllSubMeshesAsMiscDirty(): void;
  45852. /**
  45853. * Instantiate a new istance of clear coat configuration.
  45854. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45855. */
  45856. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45857. /**
  45858. * Checks to see if a texture is used in the material.
  45859. * @param defines the list of "defines" to update.
  45860. */
  45861. prepareDefines(defines: IMaterialBRDFDefines): void;
  45862. /**
  45863. * Get the current class name of the texture useful for serialization or dynamic coding.
  45864. * @returns "PBRClearCoatConfiguration"
  45865. */
  45866. getClassName(): string;
  45867. /**
  45868. * Makes a duplicate of the current configuration into another one.
  45869. * @param brdfConfiguration define the config where to copy the info
  45870. */
  45871. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45872. /**
  45873. * Serializes this BRDF configuration.
  45874. * @returns - An object with the serialized config.
  45875. */
  45876. serialize(): any;
  45877. /**
  45878. * Parses a anisotropy Configuration from a serialized object.
  45879. * @param source - Serialized object.
  45880. * @param scene Defines the scene we are parsing for
  45881. * @param rootUrl Defines the rootUrl to load from
  45882. */
  45883. parse(source: any, scene: Scene, rootUrl: string): void;
  45884. }
  45885. }
  45886. declare module BABYLON {
  45887. /**
  45888. * @hidden
  45889. */
  45890. export interface IMaterialSheenDefines {
  45891. SHEEN: boolean;
  45892. SHEEN_TEXTURE: boolean;
  45893. SHEEN_TEXTUREDIRECTUV: number;
  45894. SHEEN_LINKWITHALBEDO: boolean;
  45895. /** @hidden */
  45896. _areTexturesDirty: boolean;
  45897. }
  45898. /**
  45899. * Define the code related to the Sheen parameters of the pbr material.
  45900. */
  45901. export class PBRSheenConfiguration {
  45902. private _isEnabled;
  45903. /**
  45904. * Defines if the material uses sheen.
  45905. */
  45906. isEnabled: boolean;
  45907. private _linkSheenWithAlbedo;
  45908. /**
  45909. * Defines if the sheen is linked to the sheen color.
  45910. */
  45911. linkSheenWithAlbedo: boolean;
  45912. /**
  45913. * Defines the sheen intensity.
  45914. */
  45915. intensity: number;
  45916. /**
  45917. * Defines the sheen color.
  45918. */
  45919. color: Color3;
  45920. private _texture;
  45921. /**
  45922. * Stores the sheen tint values in a texture.
  45923. * rgb is tint
  45924. * a is a intensity
  45925. */
  45926. texture: Nullable<BaseTexture>;
  45927. /** @hidden */
  45928. private _internalMarkAllSubMeshesAsTexturesDirty;
  45929. /** @hidden */
  45930. _markAllSubMeshesAsTexturesDirty(): void;
  45931. /**
  45932. * Instantiate a new istance of clear coat configuration.
  45933. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45934. */
  45935. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45936. /**
  45937. * Specifies that the submesh is ready to be used.
  45938. * @param defines the list of "defines" to update.
  45939. * @param scene defines the scene the material belongs to.
  45940. * @returns - boolean indicating that the submesh is ready or not.
  45941. */
  45942. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45943. /**
  45944. * Checks to see if a texture is used in the material.
  45945. * @param defines the list of "defines" to update.
  45946. * @param scene defines the scene the material belongs to.
  45947. */
  45948. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45949. /**
  45950. * Binds the material data.
  45951. * @param uniformBuffer defines the Uniform buffer to fill in.
  45952. * @param scene defines the scene the material belongs to.
  45953. * @param isFrozen defines wether the material is frozen or not.
  45954. */
  45955. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45956. /**
  45957. * Checks to see if a texture is used in the material.
  45958. * @param texture - Base texture to use.
  45959. * @returns - Boolean specifying if a texture is used in the material.
  45960. */
  45961. hasTexture(texture: BaseTexture): boolean;
  45962. /**
  45963. * Returns an array of the actively used textures.
  45964. * @param activeTextures Array of BaseTextures
  45965. */
  45966. getActiveTextures(activeTextures: BaseTexture[]): void;
  45967. /**
  45968. * Returns the animatable textures.
  45969. * @param animatables Array of animatable textures.
  45970. */
  45971. getAnimatables(animatables: IAnimatable[]): void;
  45972. /**
  45973. * Disposes the resources of the material.
  45974. * @param forceDisposeTextures - Forces the disposal of all textures.
  45975. */
  45976. dispose(forceDisposeTextures?: boolean): void;
  45977. /**
  45978. * Get the current class name of the texture useful for serialization or dynamic coding.
  45979. * @returns "PBRSheenConfiguration"
  45980. */
  45981. getClassName(): string;
  45982. /**
  45983. * Add fallbacks to the effect fallbacks list.
  45984. * @param defines defines the Base texture to use.
  45985. * @param fallbacks defines the current fallback list.
  45986. * @param currentRank defines the current fallback rank.
  45987. * @returns the new fallback rank.
  45988. */
  45989. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45990. /**
  45991. * Add the required uniforms to the current list.
  45992. * @param uniforms defines the current uniform list.
  45993. */
  45994. static AddUniforms(uniforms: string[]): void;
  45995. /**
  45996. * Add the required uniforms to the current buffer.
  45997. * @param uniformBuffer defines the current uniform buffer.
  45998. */
  45999. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46000. /**
  46001. * Add the required samplers to the current list.
  46002. * @param samplers defines the current sampler list.
  46003. */
  46004. static AddSamplers(samplers: string[]): void;
  46005. /**
  46006. * Makes a duplicate of the current configuration into another one.
  46007. * @param sheenConfiguration define the config where to copy the info
  46008. */
  46009. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46010. /**
  46011. * Serializes this BRDF configuration.
  46012. * @returns - An object with the serialized config.
  46013. */
  46014. serialize(): any;
  46015. /**
  46016. * Parses a anisotropy Configuration from a serialized object.
  46017. * @param source - Serialized object.
  46018. * @param scene Defines the scene we are parsing for
  46019. * @param rootUrl Defines the rootUrl to load from
  46020. */
  46021. parse(source: any, scene: Scene, rootUrl: string): void;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /**
  46026. * @hidden
  46027. */
  46028. export interface IMaterialSubSurfaceDefines {
  46029. SUBSURFACE: boolean;
  46030. SS_REFRACTION: boolean;
  46031. SS_TRANSLUCENCY: boolean;
  46032. SS_SCATERRING: boolean;
  46033. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46034. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46035. SS_REFRACTIONMAP_3D: boolean;
  46036. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46037. SS_LODINREFRACTIONALPHA: boolean;
  46038. SS_GAMMAREFRACTION: boolean;
  46039. SS_RGBDREFRACTION: boolean;
  46040. SS_LINEARSPECULARREFRACTION: boolean;
  46041. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46042. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46043. /** @hidden */
  46044. _areTexturesDirty: boolean;
  46045. }
  46046. /**
  46047. * Define the code related to the sub surface parameters of the pbr material.
  46048. */
  46049. export class PBRSubSurfaceConfiguration {
  46050. private _isRefractionEnabled;
  46051. /**
  46052. * Defines if the refraction is enabled in the material.
  46053. */
  46054. isRefractionEnabled: boolean;
  46055. private _isTranslucencyEnabled;
  46056. /**
  46057. * Defines if the translucency is enabled in the material.
  46058. */
  46059. isTranslucencyEnabled: boolean;
  46060. private _isScatteringEnabled;
  46061. /**
  46062. * Defines the refraction intensity of the material.
  46063. * The refraction when enabled replaces the Diffuse part of the material.
  46064. * The intensity helps transitionning between diffuse and refraction.
  46065. */
  46066. refractionIntensity: number;
  46067. /**
  46068. * Defines the translucency intensity of the material.
  46069. * When translucency has been enabled, this defines how much of the "translucency"
  46070. * is addded to the diffuse part of the material.
  46071. */
  46072. translucencyIntensity: number;
  46073. /**
  46074. * Defines the scattering intensity of the material.
  46075. * When scattering has been enabled, this defines how much of the "scattered light"
  46076. * is addded to the diffuse part of the material.
  46077. */
  46078. scatteringIntensity: number;
  46079. private _thicknessTexture;
  46080. /**
  46081. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46082. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46083. * 0 would mean minimumThickness
  46084. * 1 would mean maximumThickness
  46085. * The other channels might be use as a mask to vary the different effects intensity.
  46086. */
  46087. thicknessTexture: Nullable<BaseTexture>;
  46088. private _refractionTexture;
  46089. /**
  46090. * Defines the texture to use for refraction.
  46091. */
  46092. refractionTexture: Nullable<BaseTexture>;
  46093. private _indexOfRefraction;
  46094. /**
  46095. * Defines the index of refraction used in the material.
  46096. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46097. */
  46098. indexOfRefraction: number;
  46099. private _invertRefractionY;
  46100. /**
  46101. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46102. */
  46103. invertRefractionY: boolean;
  46104. private _linkRefractionWithTransparency;
  46105. /**
  46106. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46107. * Materials half opaque for instance using refraction could benefit from this control.
  46108. */
  46109. linkRefractionWithTransparency: boolean;
  46110. /**
  46111. * Defines the minimum thickness stored in the thickness map.
  46112. * If no thickness map is defined, this value will be used to simulate thickness.
  46113. */
  46114. minimumThickness: number;
  46115. /**
  46116. * Defines the maximum thickness stored in the thickness map.
  46117. */
  46118. maximumThickness: number;
  46119. /**
  46120. * Defines the volume tint of the material.
  46121. * This is used for both translucency and scattering.
  46122. */
  46123. tintColor: Color3;
  46124. /**
  46125. * Defines the distance at which the tint color should be found in the media.
  46126. * This is used for refraction only.
  46127. */
  46128. tintColorAtDistance: number;
  46129. /**
  46130. * Defines how far each channel transmit through the media.
  46131. * It is defined as a color to simplify it selection.
  46132. */
  46133. diffusionDistance: Color3;
  46134. private _useMaskFromThicknessTexture;
  46135. /**
  46136. * Stores the intensity of the different subsurface effects in the thickness texture.
  46137. * * the green channel is the translucency intensity.
  46138. * * the blue channel is the scattering intensity.
  46139. * * the alpha channel is the refraction intensity.
  46140. */
  46141. useMaskFromThicknessTexture: boolean;
  46142. /** @hidden */
  46143. private _internalMarkAllSubMeshesAsTexturesDirty;
  46144. /** @hidden */
  46145. _markAllSubMeshesAsTexturesDirty(): void;
  46146. /**
  46147. * Instantiate a new istance of sub surface configuration.
  46148. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46149. */
  46150. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46151. /**
  46152. * Gets wehter the submesh is ready to be used or not.
  46153. * @param defines the list of "defines" to update.
  46154. * @param scene defines the scene the material belongs to.
  46155. * @returns - boolean indicating that the submesh is ready or not.
  46156. */
  46157. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46158. /**
  46159. * Checks to see if a texture is used in the material.
  46160. * @param defines the list of "defines" to update.
  46161. * @param scene defines the scene to the material belongs to.
  46162. */
  46163. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46164. /**
  46165. * Binds the material data.
  46166. * @param uniformBuffer defines the Uniform buffer to fill in.
  46167. * @param scene defines the scene the material belongs to.
  46168. * @param engine defines the engine the material belongs to.
  46169. * @param isFrozen defines wether the material is frozen or not.
  46170. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46171. */
  46172. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46173. /**
  46174. * Unbinds the material from the mesh.
  46175. * @param activeEffect defines the effect that should be unbound from.
  46176. * @returns true if unbound, otherwise false
  46177. */
  46178. unbind(activeEffect: Effect): boolean;
  46179. /**
  46180. * Returns the texture used for refraction or null if none is used.
  46181. * @param scene defines the scene the material belongs to.
  46182. * @returns - Refraction texture if present. If no refraction texture and refraction
  46183. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46184. */
  46185. private _getRefractionTexture;
  46186. /**
  46187. * Returns true if alpha blending should be disabled.
  46188. */
  46189. readonly disableAlphaBlending: boolean;
  46190. /**
  46191. * Fills the list of render target textures.
  46192. * @param renderTargets the list of render targets to update
  46193. */
  46194. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46195. /**
  46196. * Checks to see if a texture is used in the material.
  46197. * @param texture - Base texture to use.
  46198. * @returns - Boolean specifying if a texture is used in the material.
  46199. */
  46200. hasTexture(texture: BaseTexture): boolean;
  46201. /**
  46202. * Gets a boolean indicating that current material needs to register RTT
  46203. * @returns true if this uses a render target otherwise false.
  46204. */
  46205. hasRenderTargetTextures(): boolean;
  46206. /**
  46207. * Returns an array of the actively used textures.
  46208. * @param activeTextures Array of BaseTextures
  46209. */
  46210. getActiveTextures(activeTextures: BaseTexture[]): void;
  46211. /**
  46212. * Returns the animatable textures.
  46213. * @param animatables Array of animatable textures.
  46214. */
  46215. getAnimatables(animatables: IAnimatable[]): void;
  46216. /**
  46217. * Disposes the resources of the material.
  46218. * @param forceDisposeTextures - Forces the disposal of all textures.
  46219. */
  46220. dispose(forceDisposeTextures?: boolean): void;
  46221. /**
  46222. * Get the current class name of the texture useful for serialization or dynamic coding.
  46223. * @returns "PBRSubSurfaceConfiguration"
  46224. */
  46225. getClassName(): string;
  46226. /**
  46227. * Add fallbacks to the effect fallbacks list.
  46228. * @param defines defines the Base texture to use.
  46229. * @param fallbacks defines the current fallback list.
  46230. * @param currentRank defines the current fallback rank.
  46231. * @returns the new fallback rank.
  46232. */
  46233. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46234. /**
  46235. * Add the required uniforms to the current list.
  46236. * @param uniforms defines the current uniform list.
  46237. */
  46238. static AddUniforms(uniforms: string[]): void;
  46239. /**
  46240. * Add the required samplers to the current list.
  46241. * @param samplers defines the current sampler list.
  46242. */
  46243. static AddSamplers(samplers: string[]): void;
  46244. /**
  46245. * Add the required uniforms to the current buffer.
  46246. * @param uniformBuffer defines the current uniform buffer.
  46247. */
  46248. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46249. /**
  46250. * Makes a duplicate of the current configuration into another one.
  46251. * @param configuration define the config where to copy the info
  46252. */
  46253. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46254. /**
  46255. * Serializes this Sub Surface configuration.
  46256. * @returns - An object with the serialized config.
  46257. */
  46258. serialize(): any;
  46259. /**
  46260. * Parses a anisotropy Configuration from a serialized object.
  46261. * @param source - Serialized object.
  46262. * @param scene Defines the scene we are parsing for
  46263. * @param rootUrl Defines the rootUrl to load from
  46264. */
  46265. parse(source: any, scene: Scene, rootUrl: string): void;
  46266. }
  46267. }
  46268. declare module BABYLON {
  46269. /** @hidden */
  46270. export var pbrFragmentDeclaration: {
  46271. name: string;
  46272. shader: string;
  46273. };
  46274. }
  46275. declare module BABYLON {
  46276. /** @hidden */
  46277. export var pbrUboDeclaration: {
  46278. name: string;
  46279. shader: string;
  46280. };
  46281. }
  46282. declare module BABYLON {
  46283. /** @hidden */
  46284. export var pbrFragmentExtraDeclaration: {
  46285. name: string;
  46286. shader: string;
  46287. };
  46288. }
  46289. declare module BABYLON {
  46290. /** @hidden */
  46291. export var pbrFragmentSamplersDeclaration: {
  46292. name: string;
  46293. shader: string;
  46294. };
  46295. }
  46296. declare module BABYLON {
  46297. /** @hidden */
  46298. export var pbrHelperFunctions: {
  46299. name: string;
  46300. shader: string;
  46301. };
  46302. }
  46303. declare module BABYLON {
  46304. /** @hidden */
  46305. export var harmonicsFunctions: {
  46306. name: string;
  46307. shader: string;
  46308. };
  46309. }
  46310. declare module BABYLON {
  46311. /** @hidden */
  46312. export var pbrDirectLightingSetupFunctions: {
  46313. name: string;
  46314. shader: string;
  46315. };
  46316. }
  46317. declare module BABYLON {
  46318. /** @hidden */
  46319. export var pbrDirectLightingFalloffFunctions: {
  46320. name: string;
  46321. shader: string;
  46322. };
  46323. }
  46324. declare module BABYLON {
  46325. /** @hidden */
  46326. export var pbrBRDFFunctions: {
  46327. name: string;
  46328. shader: string;
  46329. };
  46330. }
  46331. declare module BABYLON {
  46332. /** @hidden */
  46333. export var pbrDirectLightingFunctions: {
  46334. name: string;
  46335. shader: string;
  46336. };
  46337. }
  46338. declare module BABYLON {
  46339. /** @hidden */
  46340. export var pbrIBLFunctions: {
  46341. name: string;
  46342. shader: string;
  46343. };
  46344. }
  46345. declare module BABYLON {
  46346. /** @hidden */
  46347. export var pbrDebug: {
  46348. name: string;
  46349. shader: string;
  46350. };
  46351. }
  46352. declare module BABYLON {
  46353. /** @hidden */
  46354. export var pbrPixelShader: {
  46355. name: string;
  46356. shader: string;
  46357. };
  46358. }
  46359. declare module BABYLON {
  46360. /** @hidden */
  46361. export var pbrVertexDeclaration: {
  46362. name: string;
  46363. shader: string;
  46364. };
  46365. }
  46366. declare module BABYLON {
  46367. /** @hidden */
  46368. export var pbrVertexShader: {
  46369. name: string;
  46370. shader: string;
  46371. };
  46372. }
  46373. declare module BABYLON {
  46374. /**
  46375. * Manages the defines for the PBR Material.
  46376. * @hidden
  46377. */
  46378. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46379. PBR: boolean;
  46380. MAINUV1: boolean;
  46381. MAINUV2: boolean;
  46382. UV1: boolean;
  46383. UV2: boolean;
  46384. ALBEDO: boolean;
  46385. ALBEDODIRECTUV: number;
  46386. VERTEXCOLOR: boolean;
  46387. AMBIENT: boolean;
  46388. AMBIENTDIRECTUV: number;
  46389. AMBIENTINGRAYSCALE: boolean;
  46390. OPACITY: boolean;
  46391. VERTEXALPHA: boolean;
  46392. OPACITYDIRECTUV: number;
  46393. OPACITYRGB: boolean;
  46394. ALPHATEST: boolean;
  46395. DEPTHPREPASS: boolean;
  46396. ALPHABLEND: boolean;
  46397. ALPHAFROMALBEDO: boolean;
  46398. ALPHATESTVALUE: string;
  46399. SPECULAROVERALPHA: boolean;
  46400. RADIANCEOVERALPHA: boolean;
  46401. ALPHAFRESNEL: boolean;
  46402. LINEARALPHAFRESNEL: boolean;
  46403. PREMULTIPLYALPHA: boolean;
  46404. EMISSIVE: boolean;
  46405. EMISSIVEDIRECTUV: number;
  46406. REFLECTIVITY: boolean;
  46407. REFLECTIVITYDIRECTUV: number;
  46408. SPECULARTERM: boolean;
  46409. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46410. MICROSURFACEAUTOMATIC: boolean;
  46411. LODBASEDMICROSFURACE: boolean;
  46412. MICROSURFACEMAP: boolean;
  46413. MICROSURFACEMAPDIRECTUV: number;
  46414. METALLICWORKFLOW: boolean;
  46415. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46416. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46417. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46418. AOSTOREINMETALMAPRED: boolean;
  46419. ENVIRONMENTBRDF: boolean;
  46420. ENVIRONMENTBRDF_RGBD: boolean;
  46421. NORMAL: boolean;
  46422. TANGENT: boolean;
  46423. BUMP: boolean;
  46424. BUMPDIRECTUV: number;
  46425. OBJECTSPACE_NORMALMAP: boolean;
  46426. PARALLAX: boolean;
  46427. PARALLAXOCCLUSION: boolean;
  46428. NORMALXYSCALE: boolean;
  46429. LIGHTMAP: boolean;
  46430. LIGHTMAPDIRECTUV: number;
  46431. USELIGHTMAPASSHADOWMAP: boolean;
  46432. GAMMALIGHTMAP: boolean;
  46433. REFLECTION: boolean;
  46434. REFLECTIONMAP_3D: boolean;
  46435. REFLECTIONMAP_SPHERICAL: boolean;
  46436. REFLECTIONMAP_PLANAR: boolean;
  46437. REFLECTIONMAP_CUBIC: boolean;
  46438. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46439. REFLECTIONMAP_PROJECTION: boolean;
  46440. REFLECTIONMAP_SKYBOX: boolean;
  46441. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46442. REFLECTIONMAP_EXPLICIT: boolean;
  46443. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46444. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46445. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46446. INVERTCUBICMAP: boolean;
  46447. USESPHERICALFROMREFLECTIONMAP: boolean;
  46448. USEIRRADIANCEMAP: boolean;
  46449. SPHERICAL_HARMONICS: boolean;
  46450. USESPHERICALINVERTEX: boolean;
  46451. REFLECTIONMAP_OPPOSITEZ: boolean;
  46452. LODINREFLECTIONALPHA: boolean;
  46453. GAMMAREFLECTION: boolean;
  46454. RGBDREFLECTION: boolean;
  46455. LINEARSPECULARREFLECTION: boolean;
  46456. RADIANCEOCCLUSION: boolean;
  46457. HORIZONOCCLUSION: boolean;
  46458. INSTANCES: boolean;
  46459. NUM_BONE_INFLUENCERS: number;
  46460. BonesPerMesh: number;
  46461. BONETEXTURE: boolean;
  46462. NONUNIFORMSCALING: boolean;
  46463. MORPHTARGETS: boolean;
  46464. MORPHTARGETS_NORMAL: boolean;
  46465. MORPHTARGETS_TANGENT: boolean;
  46466. MORPHTARGETS_UV: boolean;
  46467. NUM_MORPH_INFLUENCERS: number;
  46468. IMAGEPROCESSING: boolean;
  46469. VIGNETTE: boolean;
  46470. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46471. VIGNETTEBLENDMODEOPAQUE: boolean;
  46472. TONEMAPPING: boolean;
  46473. TONEMAPPING_ACES: boolean;
  46474. CONTRAST: boolean;
  46475. COLORCURVES: boolean;
  46476. COLORGRADING: boolean;
  46477. COLORGRADING3D: boolean;
  46478. SAMPLER3DGREENDEPTH: boolean;
  46479. SAMPLER3DBGRMAP: boolean;
  46480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46481. EXPOSURE: boolean;
  46482. MULTIVIEW: boolean;
  46483. USEPHYSICALLIGHTFALLOFF: boolean;
  46484. USEGLTFLIGHTFALLOFF: boolean;
  46485. TWOSIDEDLIGHTING: boolean;
  46486. SHADOWFLOAT: boolean;
  46487. CLIPPLANE: boolean;
  46488. CLIPPLANE2: boolean;
  46489. CLIPPLANE3: boolean;
  46490. CLIPPLANE4: boolean;
  46491. POINTSIZE: boolean;
  46492. FOG: boolean;
  46493. LOGARITHMICDEPTH: boolean;
  46494. FORCENORMALFORWARD: boolean;
  46495. SPECULARAA: boolean;
  46496. CLEARCOAT: boolean;
  46497. CLEARCOAT_DEFAULTIOR: boolean;
  46498. CLEARCOAT_TEXTURE: boolean;
  46499. CLEARCOAT_TEXTUREDIRECTUV: number;
  46500. CLEARCOAT_BUMP: boolean;
  46501. CLEARCOAT_BUMPDIRECTUV: number;
  46502. CLEARCOAT_TINT: boolean;
  46503. CLEARCOAT_TINT_TEXTURE: boolean;
  46504. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46505. ANISOTROPIC: boolean;
  46506. ANISOTROPIC_TEXTURE: boolean;
  46507. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46508. BRDF_V_HEIGHT_CORRELATED: boolean;
  46509. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46510. SHEEN: boolean;
  46511. SHEEN_TEXTURE: boolean;
  46512. SHEEN_TEXTUREDIRECTUV: number;
  46513. SHEEN_LINKWITHALBEDO: boolean;
  46514. SUBSURFACE: boolean;
  46515. SS_REFRACTION: boolean;
  46516. SS_TRANSLUCENCY: boolean;
  46517. SS_SCATERRING: boolean;
  46518. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46519. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46520. SS_REFRACTIONMAP_3D: boolean;
  46521. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46522. SS_LODINREFRACTIONALPHA: boolean;
  46523. SS_GAMMAREFRACTION: boolean;
  46524. SS_RGBDREFRACTION: boolean;
  46525. SS_LINEARSPECULARREFRACTION: boolean;
  46526. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46527. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46528. UNLIT: boolean;
  46529. DEBUGMODE: number;
  46530. /**
  46531. * Initializes the PBR Material defines.
  46532. */
  46533. constructor();
  46534. /**
  46535. * Resets the PBR Material defines.
  46536. */
  46537. reset(): void;
  46538. }
  46539. /**
  46540. * The Physically based material base class of BJS.
  46541. *
  46542. * This offers the main features of a standard PBR material.
  46543. * For more information, please refer to the documentation :
  46544. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46545. */
  46546. export abstract class PBRBaseMaterial extends PushMaterial {
  46547. /**
  46548. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46549. */
  46550. static readonly PBRMATERIAL_OPAQUE: number;
  46551. /**
  46552. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46553. */
  46554. static readonly PBRMATERIAL_ALPHATEST: number;
  46555. /**
  46556. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46557. */
  46558. static readonly PBRMATERIAL_ALPHABLEND: number;
  46559. /**
  46560. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46561. * They are also discarded below the alpha cutoff threshold to improve performances.
  46562. */
  46563. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46564. /**
  46565. * Defines the default value of how much AO map is occluding the analytical lights
  46566. * (point spot...).
  46567. */
  46568. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46569. /**
  46570. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46571. */
  46572. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46573. /**
  46574. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46575. * to enhance interoperability with other engines.
  46576. */
  46577. static readonly LIGHTFALLOFF_GLTF: number;
  46578. /**
  46579. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46580. * to enhance interoperability with other materials.
  46581. */
  46582. static readonly LIGHTFALLOFF_STANDARD: number;
  46583. /**
  46584. * Intensity of the direct lights e.g. the four lights available in your scene.
  46585. * This impacts both the direct diffuse and specular highlights.
  46586. */
  46587. protected _directIntensity: number;
  46588. /**
  46589. * Intensity of the emissive part of the material.
  46590. * This helps controlling the emissive effect without modifying the emissive color.
  46591. */
  46592. protected _emissiveIntensity: number;
  46593. /**
  46594. * Intensity of the environment e.g. how much the environment will light the object
  46595. * either through harmonics for rough material or through the refelction for shiny ones.
  46596. */
  46597. protected _environmentIntensity: number;
  46598. /**
  46599. * This is a special control allowing the reduction of the specular highlights coming from the
  46600. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46601. */
  46602. protected _specularIntensity: number;
  46603. /**
  46604. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46605. */
  46606. private _lightingInfos;
  46607. /**
  46608. * Debug Control allowing disabling the bump map on this material.
  46609. */
  46610. protected _disableBumpMap: boolean;
  46611. /**
  46612. * AKA Diffuse Texture in standard nomenclature.
  46613. */
  46614. protected _albedoTexture: Nullable<BaseTexture>;
  46615. /**
  46616. * AKA Occlusion Texture in other nomenclature.
  46617. */
  46618. protected _ambientTexture: Nullable<BaseTexture>;
  46619. /**
  46620. * AKA Occlusion Texture Intensity in other nomenclature.
  46621. */
  46622. protected _ambientTextureStrength: number;
  46623. /**
  46624. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46625. * 1 means it completely occludes it
  46626. * 0 mean it has no impact
  46627. */
  46628. protected _ambientTextureImpactOnAnalyticalLights: number;
  46629. /**
  46630. * Stores the alpha values in a texture.
  46631. */
  46632. protected _opacityTexture: Nullable<BaseTexture>;
  46633. /**
  46634. * Stores the reflection values in a texture.
  46635. */
  46636. protected _reflectionTexture: Nullable<BaseTexture>;
  46637. /**
  46638. * Stores the emissive values in a texture.
  46639. */
  46640. protected _emissiveTexture: Nullable<BaseTexture>;
  46641. /**
  46642. * AKA Specular texture in other nomenclature.
  46643. */
  46644. protected _reflectivityTexture: Nullable<BaseTexture>;
  46645. /**
  46646. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46647. */
  46648. protected _metallicTexture: Nullable<BaseTexture>;
  46649. /**
  46650. * Specifies the metallic scalar of the metallic/roughness workflow.
  46651. * Can also be used to scale the metalness values of the metallic texture.
  46652. */
  46653. protected _metallic: Nullable<number>;
  46654. /**
  46655. * Specifies the roughness scalar of the metallic/roughness workflow.
  46656. * Can also be used to scale the roughness values of the metallic texture.
  46657. */
  46658. protected _roughness: Nullable<number>;
  46659. /**
  46660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46662. */
  46663. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46664. /**
  46665. * Stores surface normal data used to displace a mesh in a texture.
  46666. */
  46667. protected _bumpTexture: Nullable<BaseTexture>;
  46668. /**
  46669. * Stores the pre-calculated light information of a mesh in a texture.
  46670. */
  46671. protected _lightmapTexture: Nullable<BaseTexture>;
  46672. /**
  46673. * The color of a material in ambient lighting.
  46674. */
  46675. protected _ambientColor: Color3;
  46676. /**
  46677. * AKA Diffuse Color in other nomenclature.
  46678. */
  46679. protected _albedoColor: Color3;
  46680. /**
  46681. * AKA Specular Color in other nomenclature.
  46682. */
  46683. protected _reflectivityColor: Color3;
  46684. /**
  46685. * The color applied when light is reflected from a material.
  46686. */
  46687. protected _reflectionColor: Color3;
  46688. /**
  46689. * The color applied when light is emitted from a material.
  46690. */
  46691. protected _emissiveColor: Color3;
  46692. /**
  46693. * AKA Glossiness in other nomenclature.
  46694. */
  46695. protected _microSurface: number;
  46696. /**
  46697. * Specifies that the material will use the light map as a show map.
  46698. */
  46699. protected _useLightmapAsShadowmap: boolean;
  46700. /**
  46701. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46702. * makes the reflect vector face the model (under horizon).
  46703. */
  46704. protected _useHorizonOcclusion: boolean;
  46705. /**
  46706. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46707. * too much the area relying on ambient texture to define their ambient occlusion.
  46708. */
  46709. protected _useRadianceOcclusion: boolean;
  46710. /**
  46711. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46712. */
  46713. protected _useAlphaFromAlbedoTexture: boolean;
  46714. /**
  46715. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46716. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46717. */
  46718. protected _useSpecularOverAlpha: boolean;
  46719. /**
  46720. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46721. */
  46722. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46723. /**
  46724. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46725. */
  46726. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46727. /**
  46728. * Specifies if the metallic texture contains the roughness information in its green channel.
  46729. */
  46730. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46731. /**
  46732. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46733. */
  46734. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46735. /**
  46736. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46737. */
  46738. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46739. /**
  46740. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46741. */
  46742. protected _useAmbientInGrayScale: boolean;
  46743. /**
  46744. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46745. * The material will try to infer what glossiness each pixel should be.
  46746. */
  46747. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46748. /**
  46749. * Defines the falloff type used in this material.
  46750. * It by default is Physical.
  46751. */
  46752. protected _lightFalloff: number;
  46753. /**
  46754. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46755. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46756. */
  46757. protected _useRadianceOverAlpha: boolean;
  46758. /**
  46759. * Allows using an object space normal map (instead of tangent space).
  46760. */
  46761. protected _useObjectSpaceNormalMap: boolean;
  46762. /**
  46763. * Allows using the bump map in parallax mode.
  46764. */
  46765. protected _useParallax: boolean;
  46766. /**
  46767. * Allows using the bump map in parallax occlusion mode.
  46768. */
  46769. protected _useParallaxOcclusion: boolean;
  46770. /**
  46771. * Controls the scale bias of the parallax mode.
  46772. */
  46773. protected _parallaxScaleBias: number;
  46774. /**
  46775. * If sets to true, disables all the lights affecting the material.
  46776. */
  46777. protected _disableLighting: boolean;
  46778. /**
  46779. * Number of Simultaneous lights allowed on the material.
  46780. */
  46781. protected _maxSimultaneousLights: number;
  46782. /**
  46783. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46784. */
  46785. protected _invertNormalMapX: boolean;
  46786. /**
  46787. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46788. */
  46789. protected _invertNormalMapY: boolean;
  46790. /**
  46791. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46792. */
  46793. protected _twoSidedLighting: boolean;
  46794. /**
  46795. * Defines the alpha limits in alpha test mode.
  46796. */
  46797. protected _alphaCutOff: number;
  46798. /**
  46799. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46800. */
  46801. protected _forceAlphaTest: boolean;
  46802. /**
  46803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46804. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46805. */
  46806. protected _useAlphaFresnel: boolean;
  46807. /**
  46808. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46809. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46810. */
  46811. protected _useLinearAlphaFresnel: boolean;
  46812. /**
  46813. * The transparency mode of the material.
  46814. */
  46815. protected _transparencyMode: Nullable<number>;
  46816. /**
  46817. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46818. * from cos thetav and roughness:
  46819. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46820. */
  46821. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46822. /**
  46823. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46824. */
  46825. protected _forceIrradianceInFragment: boolean;
  46826. /**
  46827. * Force normal to face away from face.
  46828. */
  46829. protected _forceNormalForward: boolean;
  46830. /**
  46831. * Enables specular anti aliasing in the PBR shader.
  46832. * It will both interacts on the Geometry for analytical and IBL lighting.
  46833. * It also prefilter the roughness map based on the bump values.
  46834. */
  46835. protected _enableSpecularAntiAliasing: boolean;
  46836. /**
  46837. * Default configuration related to image processing available in the PBR Material.
  46838. */
  46839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46840. /**
  46841. * Keep track of the image processing observer to allow dispose and replace.
  46842. */
  46843. private _imageProcessingObserver;
  46844. /**
  46845. * Attaches a new image processing configuration to the PBR Material.
  46846. * @param configuration
  46847. */
  46848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46849. /**
  46850. * Stores the available render targets.
  46851. */
  46852. private _renderTargets;
  46853. /**
  46854. * Sets the global ambient color for the material used in lighting calculations.
  46855. */
  46856. private _globalAmbientColor;
  46857. /**
  46858. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46859. */
  46860. private _useLogarithmicDepth;
  46861. /**
  46862. * If set to true, no lighting calculations will be applied.
  46863. */
  46864. private _unlit;
  46865. private _debugMode;
  46866. /**
  46867. * @hidden
  46868. * This is reserved for the inspector.
  46869. * Defines the material debug mode.
  46870. * It helps seeing only some components of the material while troubleshooting.
  46871. */
  46872. debugMode: number;
  46873. /**
  46874. * @hidden
  46875. * This is reserved for the inspector.
  46876. * Specify from where on screen the debug mode should start.
  46877. * The value goes from -1 (full screen) to 1 (not visible)
  46878. * It helps with side by side comparison against the final render
  46879. * This defaults to -1
  46880. */
  46881. private debugLimit;
  46882. /**
  46883. * @hidden
  46884. * This is reserved for the inspector.
  46885. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46886. * You can use the factor to better multiply the final value.
  46887. */
  46888. private debugFactor;
  46889. /**
  46890. * Defines the clear coat layer parameters for the material.
  46891. */
  46892. readonly clearCoat: PBRClearCoatConfiguration;
  46893. /**
  46894. * Defines the anisotropic parameters for the material.
  46895. */
  46896. readonly anisotropy: PBRAnisotropicConfiguration;
  46897. /**
  46898. * Defines the BRDF parameters for the material.
  46899. */
  46900. readonly brdf: PBRBRDFConfiguration;
  46901. /**
  46902. * Defines the Sheen parameters for the material.
  46903. */
  46904. readonly sheen: PBRSheenConfiguration;
  46905. /**
  46906. * Defines the SubSurface parameters for the material.
  46907. */
  46908. readonly subSurface: PBRSubSurfaceConfiguration;
  46909. /**
  46910. * Custom callback helping to override the default shader used in the material.
  46911. */
  46912. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46913. protected _rebuildInParallel: boolean;
  46914. /**
  46915. * Instantiates a new PBRMaterial instance.
  46916. *
  46917. * @param name The material name
  46918. * @param scene The scene the material will be use in.
  46919. */
  46920. constructor(name: string, scene: Scene);
  46921. /**
  46922. * Gets a boolean indicating that current material needs to register RTT
  46923. */
  46924. readonly hasRenderTargetTextures: boolean;
  46925. /**
  46926. * Gets the name of the material class.
  46927. */
  46928. getClassName(): string;
  46929. /**
  46930. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46931. */
  46932. /**
  46933. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46934. */
  46935. useLogarithmicDepth: boolean;
  46936. /**
  46937. * Gets the current transparency mode.
  46938. */
  46939. /**
  46940. * Sets the transparency mode of the material.
  46941. *
  46942. * | Value | Type | Description |
  46943. * | ----- | ----------------------------------- | ----------- |
  46944. * | 0 | OPAQUE | |
  46945. * | 1 | ALPHATEST | |
  46946. * | 2 | ALPHABLEND | |
  46947. * | 3 | ALPHATESTANDBLEND | |
  46948. *
  46949. */
  46950. transparencyMode: Nullable<number>;
  46951. /**
  46952. * Returns true if alpha blending should be disabled.
  46953. */
  46954. private readonly _disableAlphaBlending;
  46955. /**
  46956. * Specifies whether or not this material should be rendered in alpha blend mode.
  46957. */
  46958. needAlphaBlending(): boolean;
  46959. /**
  46960. * Specifies if the mesh will require alpha blending.
  46961. * @param mesh - BJS mesh.
  46962. */
  46963. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46964. /**
  46965. * Specifies whether or not this material should be rendered in alpha test mode.
  46966. */
  46967. needAlphaTesting(): boolean;
  46968. /**
  46969. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46970. */
  46971. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46972. /**
  46973. * Gets the texture used for the alpha test.
  46974. */
  46975. getAlphaTestTexture(): Nullable<BaseTexture>;
  46976. /**
  46977. * Specifies that the submesh is ready to be used.
  46978. * @param mesh - BJS mesh.
  46979. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46980. * @param useInstances - Specifies that instances should be used.
  46981. * @returns - boolean indicating that the submesh is ready or not.
  46982. */
  46983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46984. /**
  46985. * Specifies if the material uses metallic roughness workflow.
  46986. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46987. */
  46988. isMetallicWorkflow(): boolean;
  46989. private _prepareEffect;
  46990. private _prepareDefines;
  46991. /**
  46992. * Force shader compilation
  46993. */
  46994. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46995. clipPlane: boolean;
  46996. }>): void;
  46997. /**
  46998. * Initializes the uniform buffer layout for the shader.
  46999. */
  47000. buildUniformLayout(): void;
  47001. /**
  47002. * Unbinds the material from the mesh
  47003. */
  47004. unbind(): void;
  47005. /**
  47006. * Binds the submesh data.
  47007. * @param world - The world matrix.
  47008. * @param mesh - The BJS mesh.
  47009. * @param subMesh - A submesh of the BJS mesh.
  47010. */
  47011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47012. /**
  47013. * Returns the animatable textures.
  47014. * @returns - Array of animatable textures.
  47015. */
  47016. getAnimatables(): IAnimatable[];
  47017. /**
  47018. * Returns the texture used for reflections.
  47019. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47020. */
  47021. private _getReflectionTexture;
  47022. /**
  47023. * Returns an array of the actively used textures.
  47024. * @returns - Array of BaseTextures
  47025. */
  47026. getActiveTextures(): BaseTexture[];
  47027. /**
  47028. * Checks to see if a texture is used in the material.
  47029. * @param texture - Base texture to use.
  47030. * @returns - Boolean specifying if a texture is used in the material.
  47031. */
  47032. hasTexture(texture: BaseTexture): boolean;
  47033. /**
  47034. * Disposes the resources of the material.
  47035. * @param forceDisposeEffect - Forces the disposal of effects.
  47036. * @param forceDisposeTextures - Forces the disposal of all textures.
  47037. */
  47038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47039. }
  47040. }
  47041. declare module BABYLON {
  47042. /**
  47043. * The Physically based material of BJS.
  47044. *
  47045. * This offers the main features of a standard PBR material.
  47046. * For more information, please refer to the documentation :
  47047. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47048. */
  47049. export class PBRMaterial extends PBRBaseMaterial {
  47050. /**
  47051. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47052. */
  47053. static readonly PBRMATERIAL_OPAQUE: number;
  47054. /**
  47055. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47056. */
  47057. static readonly PBRMATERIAL_ALPHATEST: number;
  47058. /**
  47059. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47060. */
  47061. static readonly PBRMATERIAL_ALPHABLEND: number;
  47062. /**
  47063. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47064. * They are also discarded below the alpha cutoff threshold to improve performances.
  47065. */
  47066. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47067. /**
  47068. * Defines the default value of how much AO map is occluding the analytical lights
  47069. * (point spot...).
  47070. */
  47071. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47072. /**
  47073. * Intensity of the direct lights e.g. the four lights available in your scene.
  47074. * This impacts both the direct diffuse and specular highlights.
  47075. */
  47076. directIntensity: number;
  47077. /**
  47078. * Intensity of the emissive part of the material.
  47079. * This helps controlling the emissive effect without modifying the emissive color.
  47080. */
  47081. emissiveIntensity: number;
  47082. /**
  47083. * Intensity of the environment e.g. how much the environment will light the object
  47084. * either through harmonics for rough material or through the refelction for shiny ones.
  47085. */
  47086. environmentIntensity: number;
  47087. /**
  47088. * This is a special control allowing the reduction of the specular highlights coming from the
  47089. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47090. */
  47091. specularIntensity: number;
  47092. /**
  47093. * Debug Control allowing disabling the bump map on this material.
  47094. */
  47095. disableBumpMap: boolean;
  47096. /**
  47097. * AKA Diffuse Texture in standard nomenclature.
  47098. */
  47099. albedoTexture: BaseTexture;
  47100. /**
  47101. * AKA Occlusion Texture in other nomenclature.
  47102. */
  47103. ambientTexture: BaseTexture;
  47104. /**
  47105. * AKA Occlusion Texture Intensity in other nomenclature.
  47106. */
  47107. ambientTextureStrength: number;
  47108. /**
  47109. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47110. * 1 means it completely occludes it
  47111. * 0 mean it has no impact
  47112. */
  47113. ambientTextureImpactOnAnalyticalLights: number;
  47114. /**
  47115. * Stores the alpha values in a texture.
  47116. */
  47117. opacityTexture: BaseTexture;
  47118. /**
  47119. * Stores the reflection values in a texture.
  47120. */
  47121. reflectionTexture: Nullable<BaseTexture>;
  47122. /**
  47123. * Stores the emissive values in a texture.
  47124. */
  47125. emissiveTexture: BaseTexture;
  47126. /**
  47127. * AKA Specular texture in other nomenclature.
  47128. */
  47129. reflectivityTexture: BaseTexture;
  47130. /**
  47131. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47132. */
  47133. metallicTexture: BaseTexture;
  47134. /**
  47135. * Specifies the metallic scalar of the metallic/roughness workflow.
  47136. * Can also be used to scale the metalness values of the metallic texture.
  47137. */
  47138. metallic: Nullable<number>;
  47139. /**
  47140. * Specifies the roughness scalar of the metallic/roughness workflow.
  47141. * Can also be used to scale the roughness values of the metallic texture.
  47142. */
  47143. roughness: Nullable<number>;
  47144. /**
  47145. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47146. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47147. */
  47148. microSurfaceTexture: BaseTexture;
  47149. /**
  47150. * Stores surface normal data used to displace a mesh in a texture.
  47151. */
  47152. bumpTexture: BaseTexture;
  47153. /**
  47154. * Stores the pre-calculated light information of a mesh in a texture.
  47155. */
  47156. lightmapTexture: BaseTexture;
  47157. /**
  47158. * Stores the refracted light information in a texture.
  47159. */
  47160. refractionTexture: Nullable<BaseTexture>;
  47161. /**
  47162. * The color of a material in ambient lighting.
  47163. */
  47164. ambientColor: Color3;
  47165. /**
  47166. * AKA Diffuse Color in other nomenclature.
  47167. */
  47168. albedoColor: Color3;
  47169. /**
  47170. * AKA Specular Color in other nomenclature.
  47171. */
  47172. reflectivityColor: Color3;
  47173. /**
  47174. * The color reflected from the material.
  47175. */
  47176. reflectionColor: Color3;
  47177. /**
  47178. * The color emitted from the material.
  47179. */
  47180. emissiveColor: Color3;
  47181. /**
  47182. * AKA Glossiness in other nomenclature.
  47183. */
  47184. microSurface: number;
  47185. /**
  47186. * source material index of refraction (IOR)' / 'destination material IOR.
  47187. */
  47188. indexOfRefraction: number;
  47189. /**
  47190. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47191. */
  47192. invertRefractionY: boolean;
  47193. /**
  47194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47195. * Materials half opaque for instance using refraction could benefit from this control.
  47196. */
  47197. linkRefractionWithTransparency: boolean;
  47198. /**
  47199. * If true, the light map contains occlusion information instead of lighting info.
  47200. */
  47201. useLightmapAsShadowmap: boolean;
  47202. /**
  47203. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47204. */
  47205. useAlphaFromAlbedoTexture: boolean;
  47206. /**
  47207. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47208. */
  47209. forceAlphaTest: boolean;
  47210. /**
  47211. * Defines the alpha limits in alpha test mode.
  47212. */
  47213. alphaCutOff: number;
  47214. /**
  47215. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47216. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47217. */
  47218. useSpecularOverAlpha: boolean;
  47219. /**
  47220. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47221. */
  47222. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47223. /**
  47224. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47225. */
  47226. useRoughnessFromMetallicTextureAlpha: boolean;
  47227. /**
  47228. * Specifies if the metallic texture contains the roughness information in its green channel.
  47229. */
  47230. useRoughnessFromMetallicTextureGreen: boolean;
  47231. /**
  47232. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47233. */
  47234. useMetallnessFromMetallicTextureBlue: boolean;
  47235. /**
  47236. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47237. */
  47238. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47239. /**
  47240. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47241. */
  47242. useAmbientInGrayScale: boolean;
  47243. /**
  47244. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47245. * The material will try to infer what glossiness each pixel should be.
  47246. */
  47247. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47248. /**
  47249. * BJS is using an harcoded light falloff based on a manually sets up range.
  47250. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47251. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47252. */
  47253. /**
  47254. * BJS is using an harcoded light falloff based on a manually sets up range.
  47255. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47256. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47257. */
  47258. usePhysicalLightFalloff: boolean;
  47259. /**
  47260. * In order to support the falloff compatibility with gltf, a special mode has been added
  47261. * to reproduce the gltf light falloff.
  47262. */
  47263. /**
  47264. * In order to support the falloff compatibility with gltf, a special mode has been added
  47265. * to reproduce the gltf light falloff.
  47266. */
  47267. useGLTFLightFalloff: boolean;
  47268. /**
  47269. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47270. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47271. */
  47272. useRadianceOverAlpha: boolean;
  47273. /**
  47274. * Allows using an object space normal map (instead of tangent space).
  47275. */
  47276. useObjectSpaceNormalMap: boolean;
  47277. /**
  47278. * Allows using the bump map in parallax mode.
  47279. */
  47280. useParallax: boolean;
  47281. /**
  47282. * Allows using the bump map in parallax occlusion mode.
  47283. */
  47284. useParallaxOcclusion: boolean;
  47285. /**
  47286. * Controls the scale bias of the parallax mode.
  47287. */
  47288. parallaxScaleBias: number;
  47289. /**
  47290. * If sets to true, disables all the lights affecting the material.
  47291. */
  47292. disableLighting: boolean;
  47293. /**
  47294. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47295. */
  47296. forceIrradianceInFragment: boolean;
  47297. /**
  47298. * Number of Simultaneous lights allowed on the material.
  47299. */
  47300. maxSimultaneousLights: number;
  47301. /**
  47302. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47303. */
  47304. invertNormalMapX: boolean;
  47305. /**
  47306. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47307. */
  47308. invertNormalMapY: boolean;
  47309. /**
  47310. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47311. */
  47312. twoSidedLighting: boolean;
  47313. /**
  47314. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47315. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47316. */
  47317. useAlphaFresnel: boolean;
  47318. /**
  47319. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47320. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47321. */
  47322. useLinearAlphaFresnel: boolean;
  47323. /**
  47324. * Let user defines the brdf lookup texture used for IBL.
  47325. * A default 8bit version is embedded but you could point at :
  47326. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47327. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47328. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47329. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47330. */
  47331. environmentBRDFTexture: Nullable<BaseTexture>;
  47332. /**
  47333. * Force normal to face away from face.
  47334. */
  47335. forceNormalForward: boolean;
  47336. /**
  47337. * Enables specular anti aliasing in the PBR shader.
  47338. * It will both interacts on the Geometry for analytical and IBL lighting.
  47339. * It also prefilter the roughness map based on the bump values.
  47340. */
  47341. enableSpecularAntiAliasing: boolean;
  47342. /**
  47343. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47344. * makes the reflect vector face the model (under horizon).
  47345. */
  47346. useHorizonOcclusion: boolean;
  47347. /**
  47348. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47349. * too much the area relying on ambient texture to define their ambient occlusion.
  47350. */
  47351. useRadianceOcclusion: boolean;
  47352. /**
  47353. * If set to true, no lighting calculations will be applied.
  47354. */
  47355. unlit: boolean;
  47356. /**
  47357. * Gets the image processing configuration used either in this material.
  47358. */
  47359. /**
  47360. * Sets the Default image processing configuration used either in the this material.
  47361. *
  47362. * If sets to null, the scene one is in use.
  47363. */
  47364. imageProcessingConfiguration: ImageProcessingConfiguration;
  47365. /**
  47366. * Gets wether the color curves effect is enabled.
  47367. */
  47368. /**
  47369. * Sets wether the color curves effect is enabled.
  47370. */
  47371. cameraColorCurvesEnabled: boolean;
  47372. /**
  47373. * Gets wether the color grading effect is enabled.
  47374. */
  47375. /**
  47376. * Gets wether the color grading effect is enabled.
  47377. */
  47378. cameraColorGradingEnabled: boolean;
  47379. /**
  47380. * Gets wether tonemapping is enabled or not.
  47381. */
  47382. /**
  47383. * Sets wether tonemapping is enabled or not
  47384. */
  47385. cameraToneMappingEnabled: boolean;
  47386. /**
  47387. * The camera exposure used on this material.
  47388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47389. * This corresponds to a photographic exposure.
  47390. */
  47391. /**
  47392. * The camera exposure used on this material.
  47393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47394. * This corresponds to a photographic exposure.
  47395. */
  47396. cameraExposure: number;
  47397. /**
  47398. * Gets The camera contrast used on this material.
  47399. */
  47400. /**
  47401. * Sets The camera contrast used on this material.
  47402. */
  47403. cameraContrast: number;
  47404. /**
  47405. * Gets the Color Grading 2D Lookup Texture.
  47406. */
  47407. /**
  47408. * Sets the Color Grading 2D Lookup Texture.
  47409. */
  47410. cameraColorGradingTexture: Nullable<BaseTexture>;
  47411. /**
  47412. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47413. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47414. * 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;
  47415. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47416. */
  47417. /**
  47418. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47419. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47420. * 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;
  47421. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47422. */
  47423. cameraColorCurves: Nullable<ColorCurves>;
  47424. /**
  47425. * Instantiates a new PBRMaterial instance.
  47426. *
  47427. * @param name The material name
  47428. * @param scene The scene the material will be use in.
  47429. */
  47430. constructor(name: string, scene: Scene);
  47431. /**
  47432. * Returns the name of this material class.
  47433. */
  47434. getClassName(): string;
  47435. /**
  47436. * Makes a duplicate of the current material.
  47437. * @param name - name to use for the new material.
  47438. */
  47439. clone(name: string): PBRMaterial;
  47440. /**
  47441. * Serializes this PBR Material.
  47442. * @returns - An object with the serialized material.
  47443. */
  47444. serialize(): any;
  47445. /**
  47446. * Parses a PBR Material from a serialized object.
  47447. * @param source - Serialized object.
  47448. * @param scene - BJS scene instance.
  47449. * @param rootUrl - url for the scene object
  47450. * @returns - PBRMaterial
  47451. */
  47452. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47453. }
  47454. }
  47455. declare module BABYLON {
  47456. /**
  47457. * Direct draw surface info
  47458. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47459. */
  47460. export interface DDSInfo {
  47461. /**
  47462. * Width of the texture
  47463. */
  47464. width: number;
  47465. /**
  47466. * Width of the texture
  47467. */
  47468. height: number;
  47469. /**
  47470. * Number of Mipmaps for the texture
  47471. * @see https://en.wikipedia.org/wiki/Mipmap
  47472. */
  47473. mipmapCount: number;
  47474. /**
  47475. * If the textures format is a known fourCC format
  47476. * @see https://www.fourcc.org/
  47477. */
  47478. isFourCC: boolean;
  47479. /**
  47480. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47481. */
  47482. isRGB: boolean;
  47483. /**
  47484. * If the texture is a lumincance format
  47485. */
  47486. isLuminance: boolean;
  47487. /**
  47488. * If this is a cube texture
  47489. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47490. */
  47491. isCube: boolean;
  47492. /**
  47493. * If the texture is a compressed format eg. FOURCC_DXT1
  47494. */
  47495. isCompressed: boolean;
  47496. /**
  47497. * The dxgiFormat of the texture
  47498. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47499. */
  47500. dxgiFormat: number;
  47501. /**
  47502. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47503. */
  47504. textureType: number;
  47505. /**
  47506. * Sphericle polynomial created for the dds texture
  47507. */
  47508. sphericalPolynomial?: SphericalPolynomial;
  47509. }
  47510. /**
  47511. * Class used to provide DDS decompression tools
  47512. */
  47513. export class DDSTools {
  47514. /**
  47515. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47516. */
  47517. static StoreLODInAlphaChannel: boolean;
  47518. /**
  47519. * Gets DDS information from an array buffer
  47520. * @param arrayBuffer defines the array buffer to read data from
  47521. * @returns the DDS information
  47522. */
  47523. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47524. private static _FloatView;
  47525. private static _Int32View;
  47526. private static _ToHalfFloat;
  47527. private static _FromHalfFloat;
  47528. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47529. private static _GetHalfFloatRGBAArrayBuffer;
  47530. private static _GetFloatRGBAArrayBuffer;
  47531. private static _GetFloatAsUIntRGBAArrayBuffer;
  47532. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47533. private static _GetRGBAArrayBuffer;
  47534. private static _ExtractLongWordOrder;
  47535. private static _GetRGBArrayBuffer;
  47536. private static _GetLuminanceArrayBuffer;
  47537. /**
  47538. * Uploads DDS Levels to a Babylon Texture
  47539. * @hidden
  47540. */
  47541. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47542. }
  47543. interface Engine {
  47544. /**
  47545. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47546. * @param rootUrl defines the url where the file to load is located
  47547. * @param scene defines the current scene
  47548. * @param lodScale defines scale to apply to the mip map selection
  47549. * @param lodOffset defines offset to apply to the mip map selection
  47550. * @param onLoad defines an optional callback raised when the texture is loaded
  47551. * @param onError defines an optional callback raised if there is an issue to load the texture
  47552. * @param format defines the format of the data
  47553. * @param forcedExtension defines the extension to use to pick the right loader
  47554. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47555. * @returns the cube texture as an InternalTexture
  47556. */
  47557. 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;
  47558. }
  47559. }
  47560. declare module BABYLON {
  47561. /**
  47562. * Implementation of the DDS Texture Loader.
  47563. * @hidden
  47564. */
  47565. export class _DDSTextureLoader implements IInternalTextureLoader {
  47566. /**
  47567. * Defines wether the loader supports cascade loading the different faces.
  47568. */
  47569. readonly supportCascades: boolean;
  47570. /**
  47571. * This returns if the loader support the current file information.
  47572. * @param extension defines the file extension of the file being loaded
  47573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47574. * @param fallback defines the fallback internal texture if any
  47575. * @param isBase64 defines whether the texture is encoded as a base64
  47576. * @param isBuffer defines whether the texture data are stored as a buffer
  47577. * @returns true if the loader can load the specified file
  47578. */
  47579. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47580. /**
  47581. * Transform the url before loading if required.
  47582. * @param rootUrl the url of the texture
  47583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47584. * @returns the transformed texture
  47585. */
  47586. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47587. /**
  47588. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47589. * @param rootUrl the url of the texture
  47590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47591. * @returns the fallback texture
  47592. */
  47593. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47594. /**
  47595. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47596. * @param data contains the texture data
  47597. * @param texture defines the BabylonJS internal texture
  47598. * @param createPolynomials will be true if polynomials have been requested
  47599. * @param onLoad defines the callback to trigger once the texture is ready
  47600. * @param onError defines the callback to trigger in case of error
  47601. */
  47602. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47603. /**
  47604. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47605. * @param data contains the texture data
  47606. * @param texture defines the BabylonJS internal texture
  47607. * @param callback defines the method to call once ready to upload
  47608. */
  47609. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47610. }
  47611. }
  47612. declare module BABYLON {
  47613. /** @hidden */
  47614. export var rgbdEncodePixelShader: {
  47615. name: string;
  47616. shader: string;
  47617. };
  47618. }
  47619. declare module BABYLON {
  47620. /**
  47621. * Raw texture data and descriptor sufficient for WebGL texture upload
  47622. */
  47623. export interface EnvironmentTextureInfo {
  47624. /**
  47625. * Version of the environment map
  47626. */
  47627. version: number;
  47628. /**
  47629. * Width of image
  47630. */
  47631. width: number;
  47632. /**
  47633. * Irradiance information stored in the file.
  47634. */
  47635. irradiance: any;
  47636. /**
  47637. * Specular information stored in the file.
  47638. */
  47639. specular: any;
  47640. }
  47641. /**
  47642. * Sets of helpers addressing the serialization and deserialization of environment texture
  47643. * stored in a BabylonJS env file.
  47644. * Those files are usually stored as .env files.
  47645. */
  47646. export class EnvironmentTextureTools {
  47647. /**
  47648. * Magic number identifying the env file.
  47649. */
  47650. private static _MagicBytes;
  47651. /**
  47652. * Gets the environment info from an env file.
  47653. * @param data The array buffer containing the .env bytes.
  47654. * @returns the environment file info (the json header) if successfully parsed.
  47655. */
  47656. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47657. /**
  47658. * Creates an environment texture from a loaded cube texture.
  47659. * @param texture defines the cube texture to convert in env file
  47660. * @return a promise containing the environment data if succesfull.
  47661. */
  47662. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47663. /**
  47664. * Creates a JSON representation of the spherical data.
  47665. * @param texture defines the texture containing the polynomials
  47666. * @return the JSON representation of the spherical info
  47667. */
  47668. private static _CreateEnvTextureIrradiance;
  47669. /**
  47670. * Uploads the texture info contained in the env file to the GPU.
  47671. * @param texture defines the internal texture to upload to
  47672. * @param arrayBuffer defines the buffer cotaining the data to load
  47673. * @param info defines the texture info retrieved through the GetEnvInfo method
  47674. * @returns a promise
  47675. */
  47676. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47677. /**
  47678. * Uploads the levels of image data to the GPU.
  47679. * @param texture defines the internal texture to upload to
  47680. * @param imageData defines the array buffer views of image data [mipmap][face]
  47681. * @returns a promise
  47682. */
  47683. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47684. /**
  47685. * Uploads spherical polynomials information to the texture.
  47686. * @param texture defines the texture we are trying to upload the information to
  47687. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47688. */
  47689. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47690. /** @hidden */
  47691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47692. }
  47693. }
  47694. declare module BABYLON {
  47695. /**
  47696. * Implementation of the ENV Texture Loader.
  47697. * @hidden
  47698. */
  47699. export class _ENVTextureLoader implements IInternalTextureLoader {
  47700. /**
  47701. * Defines wether the loader supports cascade loading the different faces.
  47702. */
  47703. readonly supportCascades: boolean;
  47704. /**
  47705. * This returns if the loader support the current file information.
  47706. * @param extension defines the file extension of the file being loaded
  47707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47708. * @param fallback defines the fallback internal texture if any
  47709. * @param isBase64 defines whether the texture is encoded as a base64
  47710. * @param isBuffer defines whether the texture data are stored as a buffer
  47711. * @returns true if the loader can load the specified file
  47712. */
  47713. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47714. /**
  47715. * Transform the url before loading if required.
  47716. * @param rootUrl the url of the texture
  47717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47718. * @returns the transformed texture
  47719. */
  47720. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47721. /**
  47722. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47723. * @param rootUrl the url of the texture
  47724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47725. * @returns the fallback texture
  47726. */
  47727. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47728. /**
  47729. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47730. * @param data contains the texture data
  47731. * @param texture defines the BabylonJS internal texture
  47732. * @param createPolynomials will be true if polynomials have been requested
  47733. * @param onLoad defines the callback to trigger once the texture is ready
  47734. * @param onError defines the callback to trigger in case of error
  47735. */
  47736. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47737. /**
  47738. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47739. * @param data contains the texture data
  47740. * @param texture defines the BabylonJS internal texture
  47741. * @param callback defines the method to call once ready to upload
  47742. */
  47743. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47749. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47750. */
  47751. export class KhronosTextureContainer {
  47752. /** contents of the KTX container file */
  47753. arrayBuffer: any;
  47754. private static HEADER_LEN;
  47755. private static COMPRESSED_2D;
  47756. private static COMPRESSED_3D;
  47757. private static TEX_2D;
  47758. private static TEX_3D;
  47759. /**
  47760. * Gets the openGL type
  47761. */
  47762. glType: number;
  47763. /**
  47764. * Gets the openGL type size
  47765. */
  47766. glTypeSize: number;
  47767. /**
  47768. * Gets the openGL format
  47769. */
  47770. glFormat: number;
  47771. /**
  47772. * Gets the openGL internal format
  47773. */
  47774. glInternalFormat: number;
  47775. /**
  47776. * Gets the base internal format
  47777. */
  47778. glBaseInternalFormat: number;
  47779. /**
  47780. * Gets image width in pixel
  47781. */
  47782. pixelWidth: number;
  47783. /**
  47784. * Gets image height in pixel
  47785. */
  47786. pixelHeight: number;
  47787. /**
  47788. * Gets image depth in pixels
  47789. */
  47790. pixelDepth: number;
  47791. /**
  47792. * Gets the number of array elements
  47793. */
  47794. numberOfArrayElements: number;
  47795. /**
  47796. * Gets the number of faces
  47797. */
  47798. numberOfFaces: number;
  47799. /**
  47800. * Gets the number of mipmap levels
  47801. */
  47802. numberOfMipmapLevels: number;
  47803. /**
  47804. * Gets the bytes of key value data
  47805. */
  47806. bytesOfKeyValueData: number;
  47807. /**
  47808. * Gets the load type
  47809. */
  47810. loadType: number;
  47811. /**
  47812. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47813. */
  47814. isInvalid: boolean;
  47815. /**
  47816. * Creates a new KhronosTextureContainer
  47817. * @param arrayBuffer contents of the KTX container file
  47818. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47819. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47820. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47821. */
  47822. constructor(
  47823. /** contents of the KTX container file */
  47824. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47825. /**
  47826. * Uploads KTX content to a Babylon Texture.
  47827. * It is assumed that the texture has already been created & is currently bound
  47828. * @hidden
  47829. */
  47830. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47831. private _upload2DCompressedLevels;
  47832. }
  47833. }
  47834. declare module BABYLON {
  47835. /**
  47836. * Implementation of the KTX Texture Loader.
  47837. * @hidden
  47838. */
  47839. export class _KTXTextureLoader implements IInternalTextureLoader {
  47840. /**
  47841. * Defines wether the loader supports cascade loading the different faces.
  47842. */
  47843. readonly supportCascades: boolean;
  47844. /**
  47845. * This returns if the loader support the current file information.
  47846. * @param extension defines the file extension of the file being loaded
  47847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47848. * @param fallback defines the fallback internal texture if any
  47849. * @param isBase64 defines whether the texture is encoded as a base64
  47850. * @param isBuffer defines whether the texture data are stored as a buffer
  47851. * @returns true if the loader can load the specified file
  47852. */
  47853. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47854. /**
  47855. * Transform the url before loading if required.
  47856. * @param rootUrl the url of the texture
  47857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47858. * @returns the transformed texture
  47859. */
  47860. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47861. /**
  47862. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47863. * @param rootUrl the url of the texture
  47864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47865. * @returns the fallback texture
  47866. */
  47867. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47868. /**
  47869. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47870. * @param data contains the texture data
  47871. * @param texture defines the BabylonJS internal texture
  47872. * @param createPolynomials will be true if polynomials have been requested
  47873. * @param onLoad defines the callback to trigger once the texture is ready
  47874. * @param onError defines the callback to trigger in case of error
  47875. */
  47876. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47877. /**
  47878. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47879. * @param data contains the texture data
  47880. * @param texture defines the BabylonJS internal texture
  47881. * @param callback defines the method to call once ready to upload
  47882. */
  47883. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47884. }
  47885. }
  47886. declare module BABYLON {
  47887. /**
  47888. * Options for the default xr helper
  47889. */
  47890. export class WebXRDefaultExperienceOptions {
  47891. /**
  47892. * Floor meshes that should be used for teleporting
  47893. */
  47894. floorMeshes: Array<AbstractMesh>;
  47895. }
  47896. /**
  47897. * Default experience which provides a similar setup to the previous webVRExperience
  47898. */
  47899. export class WebXRDefaultExperience {
  47900. /**
  47901. * Base experience
  47902. */
  47903. baseExperience: WebXRExperienceHelper;
  47904. /**
  47905. * Input experience extension
  47906. */
  47907. input: WebXRInput;
  47908. /**
  47909. * Loads the controller models
  47910. */
  47911. controllerModelLoader: WebXRControllerModelLoader;
  47912. /**
  47913. * Enables laser pointer and selection
  47914. */
  47915. pointerSelection: WebXRControllerPointerSelection;
  47916. /**
  47917. * Enables teleportation
  47918. */
  47919. teleportation: WebXRControllerTeleportation;
  47920. /**
  47921. * Enables ui for enetering/exiting xr
  47922. */
  47923. enterExitUI: WebXREnterExitUI;
  47924. /**
  47925. * Default output canvas xr should render to
  47926. */
  47927. outputCanvas: WebXRManagedOutputCanvas;
  47928. /**
  47929. * Creates the default xr experience
  47930. * @param scene scene
  47931. * @param options options for basic configuration
  47932. * @returns resulting WebXRDefaultExperience
  47933. */
  47934. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47935. private constructor();
  47936. /**
  47937. * DIsposes of the experience helper
  47938. */
  47939. dispose(): void;
  47940. }
  47941. }
  47942. declare module BABYLON {
  47943. /** @hidden */
  47944. export var _forceSceneHelpersToBundle: boolean;
  47945. interface Scene {
  47946. /**
  47947. * Creates a default light for the scene.
  47948. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47949. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47950. */
  47951. createDefaultLight(replace?: boolean): void;
  47952. /**
  47953. * Creates a default camera for the scene.
  47954. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47955. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47956. * @param replace has default false, when true replaces the active camera in the scene
  47957. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47958. */
  47959. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47960. /**
  47961. * Creates a default camera and a default light.
  47962. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47963. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47964. * @param replace has the default false, when true replaces the active camera/light in the scene
  47965. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47966. */
  47967. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47968. /**
  47969. * Creates a new sky box
  47970. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47971. * @param environmentTexture defines the texture to use as environment texture
  47972. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47973. * @param scale defines the overall scale of the skybox
  47974. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47975. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47976. * @returns a new mesh holding the sky box
  47977. */
  47978. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47979. /**
  47980. * Creates a new environment
  47981. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47982. * @param options defines the options you can use to configure the environment
  47983. * @returns the new EnvironmentHelper
  47984. */
  47985. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47986. /**
  47987. * Creates a new VREXperienceHelper
  47988. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47989. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47990. * @returns a new VREXperienceHelper
  47991. */
  47992. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47993. /**
  47994. * Creates a new WebXRDefaultExperience
  47995. * @see http://doc.babylonjs.com/how_to/webxr
  47996. * @param options experience options
  47997. * @returns a promise for a new WebXRDefaultExperience
  47998. */
  47999. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48000. }
  48001. }
  48002. declare module BABYLON {
  48003. /**
  48004. * Contains position and normal vectors for a vertex
  48005. */
  48006. export class PositionNormalVertex {
  48007. /** the position of the vertex (defaut: 0,0,0) */
  48008. position: Vector3;
  48009. /** the normal of the vertex (defaut: 0,1,0) */
  48010. normal: Vector3;
  48011. /**
  48012. * Creates a PositionNormalVertex
  48013. * @param position the position of the vertex (defaut: 0,0,0)
  48014. * @param normal the normal of the vertex (defaut: 0,1,0)
  48015. */
  48016. constructor(
  48017. /** the position of the vertex (defaut: 0,0,0) */
  48018. position?: Vector3,
  48019. /** the normal of the vertex (defaut: 0,1,0) */
  48020. normal?: Vector3);
  48021. /**
  48022. * Clones the PositionNormalVertex
  48023. * @returns the cloned PositionNormalVertex
  48024. */
  48025. clone(): PositionNormalVertex;
  48026. }
  48027. /**
  48028. * Contains position, normal and uv vectors for a vertex
  48029. */
  48030. export class PositionNormalTextureVertex {
  48031. /** the position of the vertex (defaut: 0,0,0) */
  48032. position: Vector3;
  48033. /** the normal of the vertex (defaut: 0,1,0) */
  48034. normal: Vector3;
  48035. /** the uv of the vertex (default: 0,0) */
  48036. uv: Vector2;
  48037. /**
  48038. * Creates a PositionNormalTextureVertex
  48039. * @param position the position of the vertex (defaut: 0,0,0)
  48040. * @param normal the normal of the vertex (defaut: 0,1,0)
  48041. * @param uv the uv of the vertex (default: 0,0)
  48042. */
  48043. constructor(
  48044. /** the position of the vertex (defaut: 0,0,0) */
  48045. position?: Vector3,
  48046. /** the normal of the vertex (defaut: 0,1,0) */
  48047. normal?: Vector3,
  48048. /** the uv of the vertex (default: 0,0) */
  48049. uv?: Vector2);
  48050. /**
  48051. * Clones the PositionNormalTextureVertex
  48052. * @returns the cloned PositionNormalTextureVertex
  48053. */
  48054. clone(): PositionNormalTextureVertex;
  48055. }
  48056. }
  48057. declare module BABYLON {
  48058. /**
  48059. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48060. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48061. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48062. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48063. */
  48064. export class VideoDome extends TransformNode {
  48065. /**
  48066. * Define the video source as a Monoscopic panoramic 360 video.
  48067. */
  48068. static readonly MODE_MONOSCOPIC: number;
  48069. /**
  48070. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48071. */
  48072. static readonly MODE_TOPBOTTOM: number;
  48073. /**
  48074. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48075. */
  48076. static readonly MODE_SIDEBYSIDE: number;
  48077. private _halfDome;
  48078. private _useDirectMapping;
  48079. /**
  48080. * The video texture being displayed on the sphere
  48081. */
  48082. protected _videoTexture: VideoTexture;
  48083. /**
  48084. * Gets the video texture being displayed on the sphere
  48085. */
  48086. readonly videoTexture: VideoTexture;
  48087. /**
  48088. * The skybox material
  48089. */
  48090. protected _material: BackgroundMaterial;
  48091. /**
  48092. * The surface used for the skybox
  48093. */
  48094. protected _mesh: Mesh;
  48095. /**
  48096. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48097. */
  48098. private _halfDomeMask;
  48099. /**
  48100. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48101. * Also see the options.resolution property.
  48102. */
  48103. fovMultiplier: number;
  48104. private _videoMode;
  48105. /**
  48106. * Gets or set the current video mode for the video. It can be:
  48107. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48108. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48109. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48110. */
  48111. videoMode: number;
  48112. /**
  48113. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48114. *
  48115. */
  48116. /**
  48117. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48118. */
  48119. halfDome: boolean;
  48120. /**
  48121. * Oberserver used in Stereoscopic VR Mode.
  48122. */
  48123. private _onBeforeCameraRenderObserver;
  48124. /**
  48125. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48126. * @param name Element's name, child elements will append suffixes for their own names.
  48127. * @param urlsOrVideo defines the url(s) or the video element to use
  48128. * @param options An object containing optional or exposed sub element properties
  48129. */
  48130. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48131. resolution?: number;
  48132. clickToPlay?: boolean;
  48133. autoPlay?: boolean;
  48134. loop?: boolean;
  48135. size?: number;
  48136. poster?: string;
  48137. faceForward?: boolean;
  48138. useDirectMapping?: boolean;
  48139. halfDomeMode?: boolean;
  48140. }, scene: Scene);
  48141. private _changeVideoMode;
  48142. /**
  48143. * Releases resources associated with this node.
  48144. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48145. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48146. */
  48147. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48148. }
  48149. }
  48150. declare module BABYLON {
  48151. /**
  48152. * This class can be used to get instrumentation data from a Babylon engine
  48153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48154. */
  48155. export class EngineInstrumentation implements IDisposable {
  48156. /**
  48157. * Define the instrumented engine.
  48158. */
  48159. engine: Engine;
  48160. private _captureGPUFrameTime;
  48161. private _gpuFrameTimeToken;
  48162. private _gpuFrameTime;
  48163. private _captureShaderCompilationTime;
  48164. private _shaderCompilationTime;
  48165. private _onBeginFrameObserver;
  48166. private _onEndFrameObserver;
  48167. private _onBeforeShaderCompilationObserver;
  48168. private _onAfterShaderCompilationObserver;
  48169. /**
  48170. * Gets the perf counter used for GPU frame time
  48171. */
  48172. readonly gpuFrameTimeCounter: PerfCounter;
  48173. /**
  48174. * Gets the GPU frame time capture status
  48175. */
  48176. /**
  48177. * Enable or disable the GPU frame time capture
  48178. */
  48179. captureGPUFrameTime: boolean;
  48180. /**
  48181. * Gets the perf counter used for shader compilation time
  48182. */
  48183. readonly shaderCompilationTimeCounter: PerfCounter;
  48184. /**
  48185. * Gets the shader compilation time capture status
  48186. */
  48187. /**
  48188. * Enable or disable the shader compilation time capture
  48189. */
  48190. captureShaderCompilationTime: boolean;
  48191. /**
  48192. * Instantiates a new engine instrumentation.
  48193. * This class can be used to get instrumentation data from a Babylon engine
  48194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48195. * @param engine Defines the engine to instrument
  48196. */
  48197. constructor(
  48198. /**
  48199. * Define the instrumented engine.
  48200. */
  48201. engine: Engine);
  48202. /**
  48203. * Dispose and release associated resources.
  48204. */
  48205. dispose(): void;
  48206. }
  48207. }
  48208. declare module BABYLON {
  48209. /**
  48210. * This class can be used to get instrumentation data from a Babylon engine
  48211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48212. */
  48213. export class SceneInstrumentation implements IDisposable {
  48214. /**
  48215. * Defines the scene to instrument
  48216. */
  48217. scene: Scene;
  48218. private _captureActiveMeshesEvaluationTime;
  48219. private _activeMeshesEvaluationTime;
  48220. private _captureRenderTargetsRenderTime;
  48221. private _renderTargetsRenderTime;
  48222. private _captureFrameTime;
  48223. private _frameTime;
  48224. private _captureRenderTime;
  48225. private _renderTime;
  48226. private _captureInterFrameTime;
  48227. private _interFrameTime;
  48228. private _captureParticlesRenderTime;
  48229. private _particlesRenderTime;
  48230. private _captureSpritesRenderTime;
  48231. private _spritesRenderTime;
  48232. private _capturePhysicsTime;
  48233. private _physicsTime;
  48234. private _captureAnimationsTime;
  48235. private _animationsTime;
  48236. private _captureCameraRenderTime;
  48237. private _cameraRenderTime;
  48238. private _onBeforeActiveMeshesEvaluationObserver;
  48239. private _onAfterActiveMeshesEvaluationObserver;
  48240. private _onBeforeRenderTargetsRenderObserver;
  48241. private _onAfterRenderTargetsRenderObserver;
  48242. private _onAfterRenderObserver;
  48243. private _onBeforeDrawPhaseObserver;
  48244. private _onAfterDrawPhaseObserver;
  48245. private _onBeforeAnimationsObserver;
  48246. private _onBeforeParticlesRenderingObserver;
  48247. private _onAfterParticlesRenderingObserver;
  48248. private _onBeforeSpritesRenderingObserver;
  48249. private _onAfterSpritesRenderingObserver;
  48250. private _onBeforePhysicsObserver;
  48251. private _onAfterPhysicsObserver;
  48252. private _onAfterAnimationsObserver;
  48253. private _onBeforeCameraRenderObserver;
  48254. private _onAfterCameraRenderObserver;
  48255. /**
  48256. * Gets the perf counter used for active meshes evaluation time
  48257. */
  48258. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48259. /**
  48260. * Gets the active meshes evaluation time capture status
  48261. */
  48262. /**
  48263. * Enable or disable the active meshes evaluation time capture
  48264. */
  48265. captureActiveMeshesEvaluationTime: boolean;
  48266. /**
  48267. * Gets the perf counter used for render targets render time
  48268. */
  48269. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48270. /**
  48271. * Gets the render targets render time capture status
  48272. */
  48273. /**
  48274. * Enable or disable the render targets render time capture
  48275. */
  48276. captureRenderTargetsRenderTime: boolean;
  48277. /**
  48278. * Gets the perf counter used for particles render time
  48279. */
  48280. readonly particlesRenderTimeCounter: PerfCounter;
  48281. /**
  48282. * Gets the particles render time capture status
  48283. */
  48284. /**
  48285. * Enable or disable the particles render time capture
  48286. */
  48287. captureParticlesRenderTime: boolean;
  48288. /**
  48289. * Gets the perf counter used for sprites render time
  48290. */
  48291. readonly spritesRenderTimeCounter: PerfCounter;
  48292. /**
  48293. * Gets the sprites render time capture status
  48294. */
  48295. /**
  48296. * Enable or disable the sprites render time capture
  48297. */
  48298. captureSpritesRenderTime: boolean;
  48299. /**
  48300. * Gets the perf counter used for physics time
  48301. */
  48302. readonly physicsTimeCounter: PerfCounter;
  48303. /**
  48304. * Gets the physics time capture status
  48305. */
  48306. /**
  48307. * Enable or disable the physics time capture
  48308. */
  48309. capturePhysicsTime: boolean;
  48310. /**
  48311. * Gets the perf counter used for animations time
  48312. */
  48313. readonly animationsTimeCounter: PerfCounter;
  48314. /**
  48315. * Gets the animations time capture status
  48316. */
  48317. /**
  48318. * Enable or disable the animations time capture
  48319. */
  48320. captureAnimationsTime: boolean;
  48321. /**
  48322. * Gets the perf counter used for frame time capture
  48323. */
  48324. readonly frameTimeCounter: PerfCounter;
  48325. /**
  48326. * Gets the frame time capture status
  48327. */
  48328. /**
  48329. * Enable or disable the frame time capture
  48330. */
  48331. captureFrameTime: boolean;
  48332. /**
  48333. * Gets the perf counter used for inter-frames time capture
  48334. */
  48335. readonly interFrameTimeCounter: PerfCounter;
  48336. /**
  48337. * Gets the inter-frames time capture status
  48338. */
  48339. /**
  48340. * Enable or disable the inter-frames time capture
  48341. */
  48342. captureInterFrameTime: boolean;
  48343. /**
  48344. * Gets the perf counter used for render time capture
  48345. */
  48346. readonly renderTimeCounter: PerfCounter;
  48347. /**
  48348. * Gets the render time capture status
  48349. */
  48350. /**
  48351. * Enable or disable the render time capture
  48352. */
  48353. captureRenderTime: boolean;
  48354. /**
  48355. * Gets the perf counter used for camera render time capture
  48356. */
  48357. readonly cameraRenderTimeCounter: PerfCounter;
  48358. /**
  48359. * Gets the camera render time capture status
  48360. */
  48361. /**
  48362. * Enable or disable the camera render time capture
  48363. */
  48364. captureCameraRenderTime: boolean;
  48365. /**
  48366. * Gets the perf counter used for draw calls
  48367. */
  48368. readonly drawCallsCounter: PerfCounter;
  48369. /**
  48370. * Instantiates a new scene instrumentation.
  48371. * This class can be used to get instrumentation data from a Babylon engine
  48372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48373. * @param scene Defines the scene to instrument
  48374. */
  48375. constructor(
  48376. /**
  48377. * Defines the scene to instrument
  48378. */
  48379. scene: Scene);
  48380. /**
  48381. * Dispose and release associated resources.
  48382. */
  48383. dispose(): void;
  48384. }
  48385. }
  48386. declare module BABYLON {
  48387. /** @hidden */
  48388. export var glowMapGenerationPixelShader: {
  48389. name: string;
  48390. shader: string;
  48391. };
  48392. }
  48393. declare module BABYLON {
  48394. /** @hidden */
  48395. export var glowMapGenerationVertexShader: {
  48396. name: string;
  48397. shader: string;
  48398. };
  48399. }
  48400. declare module BABYLON {
  48401. /**
  48402. * Effect layer options. This helps customizing the behaviour
  48403. * of the effect layer.
  48404. */
  48405. export interface IEffectLayerOptions {
  48406. /**
  48407. * Multiplication factor apply to the canvas size to compute the render target size
  48408. * used to generated the objects (the smaller the faster).
  48409. */
  48410. mainTextureRatio: number;
  48411. /**
  48412. * Enforces a fixed size texture to ensure effect stability across devices.
  48413. */
  48414. mainTextureFixedSize?: number;
  48415. /**
  48416. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48417. */
  48418. alphaBlendingMode: number;
  48419. /**
  48420. * The camera attached to the layer.
  48421. */
  48422. camera: Nullable<Camera>;
  48423. /**
  48424. * The rendering group to draw the layer in.
  48425. */
  48426. renderingGroupId: number;
  48427. }
  48428. /**
  48429. * The effect layer Helps adding post process effect blended with the main pass.
  48430. *
  48431. * This can be for instance use to generate glow or higlight effects on the scene.
  48432. *
  48433. * The effect layer class can not be used directly and is intented to inherited from to be
  48434. * customized per effects.
  48435. */
  48436. export abstract class EffectLayer {
  48437. private _vertexBuffers;
  48438. private _indexBuffer;
  48439. private _cachedDefines;
  48440. private _effectLayerMapGenerationEffect;
  48441. private _effectLayerOptions;
  48442. private _mergeEffect;
  48443. protected _scene: Scene;
  48444. protected _engine: Engine;
  48445. protected _maxSize: number;
  48446. protected _mainTextureDesiredSize: ISize;
  48447. protected _mainTexture: RenderTargetTexture;
  48448. protected _shouldRender: boolean;
  48449. protected _postProcesses: PostProcess[];
  48450. protected _textures: BaseTexture[];
  48451. protected _emissiveTextureAndColor: {
  48452. texture: Nullable<BaseTexture>;
  48453. color: Color4;
  48454. };
  48455. /**
  48456. * The name of the layer
  48457. */
  48458. name: string;
  48459. /**
  48460. * The clear color of the texture used to generate the glow map.
  48461. */
  48462. neutralColor: Color4;
  48463. /**
  48464. * Specifies wether the highlight layer is enabled or not.
  48465. */
  48466. isEnabled: boolean;
  48467. /**
  48468. * Gets the camera attached to the layer.
  48469. */
  48470. readonly camera: Nullable<Camera>;
  48471. /**
  48472. * Gets the rendering group id the layer should render in.
  48473. */
  48474. renderingGroupId: number;
  48475. /**
  48476. * An event triggered when the effect layer has been disposed.
  48477. */
  48478. onDisposeObservable: Observable<EffectLayer>;
  48479. /**
  48480. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48481. */
  48482. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48483. /**
  48484. * An event triggered when the generated texture is being merged in the scene.
  48485. */
  48486. onBeforeComposeObservable: Observable<EffectLayer>;
  48487. /**
  48488. * An event triggered when the generated texture has been merged in the scene.
  48489. */
  48490. onAfterComposeObservable: Observable<EffectLayer>;
  48491. /**
  48492. * An event triggered when the efffect layer changes its size.
  48493. */
  48494. onSizeChangedObservable: Observable<EffectLayer>;
  48495. /** @hidden */
  48496. static _SceneComponentInitialization: (scene: Scene) => void;
  48497. /**
  48498. * Instantiates a new effect Layer and references it in the scene.
  48499. * @param name The name of the layer
  48500. * @param scene The scene to use the layer in
  48501. */
  48502. constructor(
  48503. /** The Friendly of the effect in the scene */
  48504. name: string, scene: Scene);
  48505. /**
  48506. * Get the effect name of the layer.
  48507. * @return The effect name
  48508. */
  48509. abstract getEffectName(): string;
  48510. /**
  48511. * Checks for the readiness of the element composing the layer.
  48512. * @param subMesh the mesh to check for
  48513. * @param useInstances specify wether or not to use instances to render the mesh
  48514. * @return true if ready otherwise, false
  48515. */
  48516. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48517. /**
  48518. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48519. * @returns true if the effect requires stencil during the main canvas render pass.
  48520. */
  48521. abstract needStencil(): boolean;
  48522. /**
  48523. * Create the merge effect. This is the shader use to blit the information back
  48524. * to the main canvas at the end of the scene rendering.
  48525. * @returns The effect containing the shader used to merge the effect on the main canvas
  48526. */
  48527. protected abstract _createMergeEffect(): Effect;
  48528. /**
  48529. * Creates the render target textures and post processes used in the effect layer.
  48530. */
  48531. protected abstract _createTextureAndPostProcesses(): void;
  48532. /**
  48533. * Implementation specific of rendering the generating effect on the main canvas.
  48534. * @param effect The effect used to render through
  48535. */
  48536. protected abstract _internalRender(effect: Effect): void;
  48537. /**
  48538. * Sets the required values for both the emissive texture and and the main color.
  48539. */
  48540. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48541. /**
  48542. * Free any resources and references associated to a mesh.
  48543. * Internal use
  48544. * @param mesh The mesh to free.
  48545. */
  48546. abstract _disposeMesh(mesh: Mesh): void;
  48547. /**
  48548. * Serializes this layer (Glow or Highlight for example)
  48549. * @returns a serialized layer object
  48550. */
  48551. abstract serialize?(): any;
  48552. /**
  48553. * Initializes the effect layer with the required options.
  48554. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48555. */
  48556. protected _init(options: Partial<IEffectLayerOptions>): void;
  48557. /**
  48558. * Generates the index buffer of the full screen quad blending to the main canvas.
  48559. */
  48560. private _generateIndexBuffer;
  48561. /**
  48562. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48563. */
  48564. private _generateVertexBuffer;
  48565. /**
  48566. * Sets the main texture desired size which is the closest power of two
  48567. * of the engine canvas size.
  48568. */
  48569. private _setMainTextureSize;
  48570. /**
  48571. * Creates the main texture for the effect layer.
  48572. */
  48573. protected _createMainTexture(): void;
  48574. /**
  48575. * Adds specific effects defines.
  48576. * @param defines The defines to add specifics to.
  48577. */
  48578. protected _addCustomEffectDefines(defines: string[]): void;
  48579. /**
  48580. * Checks for the readiness of the element composing the layer.
  48581. * @param subMesh the mesh to check for
  48582. * @param useInstances specify wether or not to use instances to render the mesh
  48583. * @param emissiveTexture the associated emissive texture used to generate the glow
  48584. * @return true if ready otherwise, false
  48585. */
  48586. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48587. /**
  48588. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48589. */
  48590. render(): void;
  48591. /**
  48592. * Determine if a given mesh will be used in the current effect.
  48593. * @param mesh mesh to test
  48594. * @returns true if the mesh will be used
  48595. */
  48596. hasMesh(mesh: AbstractMesh): boolean;
  48597. /**
  48598. * Returns true if the layer contains information to display, otherwise false.
  48599. * @returns true if the glow layer should be rendered
  48600. */
  48601. shouldRender(): boolean;
  48602. /**
  48603. * Returns true if the mesh should render, otherwise false.
  48604. * @param mesh The mesh to render
  48605. * @returns true if it should render otherwise false
  48606. */
  48607. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48608. /**
  48609. * Returns true if the mesh can be rendered, otherwise false.
  48610. * @param mesh The mesh to render
  48611. * @param material The material used on the mesh
  48612. * @returns true if it can be rendered otherwise false
  48613. */
  48614. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48615. /**
  48616. * Returns true if the mesh should render, otherwise false.
  48617. * @param mesh The mesh to render
  48618. * @returns true if it should render otherwise false
  48619. */
  48620. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48621. /**
  48622. * Renders the submesh passed in parameter to the generation map.
  48623. */
  48624. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48625. /**
  48626. * Rebuild the required buffers.
  48627. * @hidden Internal use only.
  48628. */
  48629. _rebuild(): void;
  48630. /**
  48631. * Dispose only the render target textures and post process.
  48632. */
  48633. private _disposeTextureAndPostProcesses;
  48634. /**
  48635. * Dispose the highlight layer and free resources.
  48636. */
  48637. dispose(): void;
  48638. /**
  48639. * Gets the class name of the effect layer
  48640. * @returns the string with the class name of the effect layer
  48641. */
  48642. getClassName(): string;
  48643. /**
  48644. * Creates an effect layer from parsed effect layer data
  48645. * @param parsedEffectLayer defines effect layer data
  48646. * @param scene defines the current scene
  48647. * @param rootUrl defines the root URL containing the effect layer information
  48648. * @returns a parsed effect Layer
  48649. */
  48650. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48651. }
  48652. }
  48653. declare module BABYLON {
  48654. interface AbstractScene {
  48655. /**
  48656. * The list of effect layers (highlights/glow) added to the scene
  48657. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48658. * @see http://doc.babylonjs.com/how_to/glow_layer
  48659. */
  48660. effectLayers: Array<EffectLayer>;
  48661. /**
  48662. * Removes the given effect layer from this scene.
  48663. * @param toRemove defines the effect layer to remove
  48664. * @returns the index of the removed effect layer
  48665. */
  48666. removeEffectLayer(toRemove: EffectLayer): number;
  48667. /**
  48668. * Adds the given effect layer to this scene
  48669. * @param newEffectLayer defines the effect layer to add
  48670. */
  48671. addEffectLayer(newEffectLayer: EffectLayer): void;
  48672. }
  48673. /**
  48674. * Defines the layer scene component responsible to manage any effect layers
  48675. * in a given scene.
  48676. */
  48677. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48678. /**
  48679. * The component name helpfull to identify the component in the list of scene components.
  48680. */
  48681. readonly name: string;
  48682. /**
  48683. * The scene the component belongs to.
  48684. */
  48685. scene: Scene;
  48686. private _engine;
  48687. private _renderEffects;
  48688. private _needStencil;
  48689. private _previousStencilState;
  48690. /**
  48691. * Creates a new instance of the component for the given scene
  48692. * @param scene Defines the scene to register the component in
  48693. */
  48694. constructor(scene: Scene);
  48695. /**
  48696. * Registers the component in a given scene
  48697. */
  48698. register(): void;
  48699. /**
  48700. * Rebuilds the elements related to this component in case of
  48701. * context lost for instance.
  48702. */
  48703. rebuild(): void;
  48704. /**
  48705. * Serializes the component data to the specified json object
  48706. * @param serializationObject The object to serialize to
  48707. */
  48708. serialize(serializationObject: any): void;
  48709. /**
  48710. * Adds all the elements from the container to the scene
  48711. * @param container the container holding the elements
  48712. */
  48713. addFromContainer(container: AbstractScene): void;
  48714. /**
  48715. * Removes all the elements in the container from the scene
  48716. * @param container contains the elements to remove
  48717. * @param dispose if the removed element should be disposed (default: false)
  48718. */
  48719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48720. /**
  48721. * Disposes the component and the associated ressources.
  48722. */
  48723. dispose(): void;
  48724. private _isReadyForMesh;
  48725. private _renderMainTexture;
  48726. private _setStencil;
  48727. private _setStencilBack;
  48728. private _draw;
  48729. private _drawCamera;
  48730. private _drawRenderingGroup;
  48731. }
  48732. }
  48733. declare module BABYLON {
  48734. /** @hidden */
  48735. export var glowMapMergePixelShader: {
  48736. name: string;
  48737. shader: string;
  48738. };
  48739. }
  48740. declare module BABYLON {
  48741. /** @hidden */
  48742. export var glowMapMergeVertexShader: {
  48743. name: string;
  48744. shader: string;
  48745. };
  48746. }
  48747. declare module BABYLON {
  48748. interface AbstractScene {
  48749. /**
  48750. * Return a the first highlight layer of the scene with a given name.
  48751. * @param name The name of the highlight layer to look for.
  48752. * @return The highlight layer if found otherwise null.
  48753. */
  48754. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48755. }
  48756. /**
  48757. * Glow layer options. This helps customizing the behaviour
  48758. * of the glow layer.
  48759. */
  48760. export interface IGlowLayerOptions {
  48761. /**
  48762. * Multiplication factor apply to the canvas size to compute the render target size
  48763. * used to generated the glowing objects (the smaller the faster).
  48764. */
  48765. mainTextureRatio: number;
  48766. /**
  48767. * Enforces a fixed size texture to ensure resize independant blur.
  48768. */
  48769. mainTextureFixedSize?: number;
  48770. /**
  48771. * How big is the kernel of the blur texture.
  48772. */
  48773. blurKernelSize: number;
  48774. /**
  48775. * The camera attached to the layer.
  48776. */
  48777. camera: Nullable<Camera>;
  48778. /**
  48779. * Enable MSAA by chosing the number of samples.
  48780. */
  48781. mainTextureSamples?: number;
  48782. /**
  48783. * The rendering group to draw the layer in.
  48784. */
  48785. renderingGroupId: number;
  48786. }
  48787. /**
  48788. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48789. *
  48790. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48791. * glowy meshes to your scene.
  48792. *
  48793. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48794. */
  48795. export class GlowLayer extends EffectLayer {
  48796. /**
  48797. * Effect Name of the layer.
  48798. */
  48799. static readonly EffectName: string;
  48800. /**
  48801. * The default blur kernel size used for the glow.
  48802. */
  48803. static DefaultBlurKernelSize: number;
  48804. /**
  48805. * The default texture size ratio used for the glow.
  48806. */
  48807. static DefaultTextureRatio: number;
  48808. /**
  48809. * Sets the kernel size of the blur.
  48810. */
  48811. /**
  48812. * Gets the kernel size of the blur.
  48813. */
  48814. blurKernelSize: number;
  48815. /**
  48816. * Sets the glow intensity.
  48817. */
  48818. /**
  48819. * Gets the glow intensity.
  48820. */
  48821. intensity: number;
  48822. private _options;
  48823. private _intensity;
  48824. private _horizontalBlurPostprocess1;
  48825. private _verticalBlurPostprocess1;
  48826. private _horizontalBlurPostprocess2;
  48827. private _verticalBlurPostprocess2;
  48828. private _blurTexture1;
  48829. private _blurTexture2;
  48830. private _postProcesses1;
  48831. private _postProcesses2;
  48832. private _includedOnlyMeshes;
  48833. private _excludedMeshes;
  48834. /**
  48835. * Callback used to let the user override the color selection on a per mesh basis
  48836. */
  48837. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48838. /**
  48839. * Callback used to let the user override the texture selection on a per mesh basis
  48840. */
  48841. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48842. /**
  48843. * Instantiates a new glow Layer and references it to the scene.
  48844. * @param name The name of the layer
  48845. * @param scene The scene to use the layer in
  48846. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48847. */
  48848. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48849. /**
  48850. * Get the effect name of the layer.
  48851. * @return The effect name
  48852. */
  48853. getEffectName(): string;
  48854. /**
  48855. * Create the merge effect. This is the shader use to blit the information back
  48856. * to the main canvas at the end of the scene rendering.
  48857. */
  48858. protected _createMergeEffect(): Effect;
  48859. /**
  48860. * Creates the render target textures and post processes used in the glow layer.
  48861. */
  48862. protected _createTextureAndPostProcesses(): void;
  48863. /**
  48864. * Checks for the readiness of the element composing the layer.
  48865. * @param subMesh the mesh to check for
  48866. * @param useInstances specify wether or not to use instances to render the mesh
  48867. * @param emissiveTexture the associated emissive texture used to generate the glow
  48868. * @return true if ready otherwise, false
  48869. */
  48870. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48871. /**
  48872. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48873. */
  48874. needStencil(): boolean;
  48875. /**
  48876. * Returns true if the mesh can be rendered, otherwise false.
  48877. * @param mesh The mesh to render
  48878. * @param material The material used on the mesh
  48879. * @returns true if it can be rendered otherwise false
  48880. */
  48881. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48882. /**
  48883. * Implementation specific of rendering the generating effect on the main canvas.
  48884. * @param effect The effect used to render through
  48885. */
  48886. protected _internalRender(effect: Effect): void;
  48887. /**
  48888. * Sets the required values for both the emissive texture and and the main color.
  48889. */
  48890. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48891. /**
  48892. * Returns true if the mesh should render, otherwise false.
  48893. * @param mesh The mesh to render
  48894. * @returns true if it should render otherwise false
  48895. */
  48896. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48897. /**
  48898. * Adds specific effects defines.
  48899. * @param defines The defines to add specifics to.
  48900. */
  48901. protected _addCustomEffectDefines(defines: string[]): void;
  48902. /**
  48903. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48904. * @param mesh The mesh to exclude from the glow layer
  48905. */
  48906. addExcludedMesh(mesh: Mesh): void;
  48907. /**
  48908. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48909. * @param mesh The mesh to remove
  48910. */
  48911. removeExcludedMesh(mesh: Mesh): void;
  48912. /**
  48913. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48914. * @param mesh The mesh to include in the glow layer
  48915. */
  48916. addIncludedOnlyMesh(mesh: Mesh): void;
  48917. /**
  48918. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48919. * @param mesh The mesh to remove
  48920. */
  48921. removeIncludedOnlyMesh(mesh: Mesh): void;
  48922. /**
  48923. * Determine if a given mesh will be used in the glow layer
  48924. * @param mesh The mesh to test
  48925. * @returns true if the mesh will be highlighted by the current glow layer
  48926. */
  48927. hasMesh(mesh: AbstractMesh): boolean;
  48928. /**
  48929. * Free any resources and references associated to a mesh.
  48930. * Internal use
  48931. * @param mesh The mesh to free.
  48932. * @hidden
  48933. */
  48934. _disposeMesh(mesh: Mesh): void;
  48935. /**
  48936. * Gets the class name of the effect layer
  48937. * @returns the string with the class name of the effect layer
  48938. */
  48939. getClassName(): string;
  48940. /**
  48941. * Serializes this glow layer
  48942. * @returns a serialized glow layer object
  48943. */
  48944. serialize(): any;
  48945. /**
  48946. * Creates a Glow Layer from parsed glow layer data
  48947. * @param parsedGlowLayer defines glow layer data
  48948. * @param scene defines the current scene
  48949. * @param rootUrl defines the root URL containing the glow layer information
  48950. * @returns a parsed Glow Layer
  48951. */
  48952. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48953. }
  48954. }
  48955. declare module BABYLON {
  48956. /** @hidden */
  48957. export var glowBlurPostProcessPixelShader: {
  48958. name: string;
  48959. shader: string;
  48960. };
  48961. }
  48962. declare module BABYLON {
  48963. interface AbstractScene {
  48964. /**
  48965. * Return a the first highlight layer of the scene with a given name.
  48966. * @param name The name of the highlight layer to look for.
  48967. * @return The highlight layer if found otherwise null.
  48968. */
  48969. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48970. }
  48971. /**
  48972. * Highlight layer options. This helps customizing the behaviour
  48973. * of the highlight layer.
  48974. */
  48975. export interface IHighlightLayerOptions {
  48976. /**
  48977. * Multiplication factor apply to the canvas size to compute the render target size
  48978. * used to generated the glowing objects (the smaller the faster).
  48979. */
  48980. mainTextureRatio: number;
  48981. /**
  48982. * Enforces a fixed size texture to ensure resize independant blur.
  48983. */
  48984. mainTextureFixedSize?: number;
  48985. /**
  48986. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48987. * of the picture to blur (the smaller the faster).
  48988. */
  48989. blurTextureSizeRatio: number;
  48990. /**
  48991. * How big in texel of the blur texture is the vertical blur.
  48992. */
  48993. blurVerticalSize: number;
  48994. /**
  48995. * How big in texel of the blur texture is the horizontal blur.
  48996. */
  48997. blurHorizontalSize: number;
  48998. /**
  48999. * Alpha blending mode used to apply the blur. Default is combine.
  49000. */
  49001. alphaBlendingMode: number;
  49002. /**
  49003. * The camera attached to the layer.
  49004. */
  49005. camera: Nullable<Camera>;
  49006. /**
  49007. * Should we display highlight as a solid stroke?
  49008. */
  49009. isStroke?: boolean;
  49010. /**
  49011. * The rendering group to draw the layer in.
  49012. */
  49013. renderingGroupId: number;
  49014. }
  49015. /**
  49016. * The highlight layer Helps adding a glow effect around a mesh.
  49017. *
  49018. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49019. * glowy meshes to your scene.
  49020. *
  49021. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49022. */
  49023. export class HighlightLayer extends EffectLayer {
  49024. name: string;
  49025. /**
  49026. * Effect Name of the highlight layer.
  49027. */
  49028. static readonly EffectName: string;
  49029. /**
  49030. * The neutral color used during the preparation of the glow effect.
  49031. * This is black by default as the blend operation is a blend operation.
  49032. */
  49033. static NeutralColor: Color4;
  49034. /**
  49035. * Stencil value used for glowing meshes.
  49036. */
  49037. static GlowingMeshStencilReference: number;
  49038. /**
  49039. * Stencil value used for the other meshes in the scene.
  49040. */
  49041. static NormalMeshStencilReference: number;
  49042. /**
  49043. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49044. */
  49045. innerGlow: boolean;
  49046. /**
  49047. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49048. */
  49049. outerGlow: boolean;
  49050. /**
  49051. * Specifies the horizontal size of the blur.
  49052. */
  49053. /**
  49054. * Gets the horizontal size of the blur.
  49055. */
  49056. blurHorizontalSize: number;
  49057. /**
  49058. * Specifies the vertical size of the blur.
  49059. */
  49060. /**
  49061. * Gets the vertical size of the blur.
  49062. */
  49063. blurVerticalSize: number;
  49064. /**
  49065. * An event triggered when the highlight layer is being blurred.
  49066. */
  49067. onBeforeBlurObservable: Observable<HighlightLayer>;
  49068. /**
  49069. * An event triggered when the highlight layer has been blurred.
  49070. */
  49071. onAfterBlurObservable: Observable<HighlightLayer>;
  49072. private _instanceGlowingMeshStencilReference;
  49073. private _options;
  49074. private _downSamplePostprocess;
  49075. private _horizontalBlurPostprocess;
  49076. private _verticalBlurPostprocess;
  49077. private _blurTexture;
  49078. private _meshes;
  49079. private _excludedMeshes;
  49080. /**
  49081. * Instantiates a new highlight Layer and references it to the scene..
  49082. * @param name The name of the layer
  49083. * @param scene The scene to use the layer in
  49084. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49085. */
  49086. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49087. /**
  49088. * Get the effect name of the layer.
  49089. * @return The effect name
  49090. */
  49091. getEffectName(): string;
  49092. /**
  49093. * Create the merge effect. This is the shader use to blit the information back
  49094. * to the main canvas at the end of the scene rendering.
  49095. */
  49096. protected _createMergeEffect(): Effect;
  49097. /**
  49098. * Creates the render target textures and post processes used in the highlight layer.
  49099. */
  49100. protected _createTextureAndPostProcesses(): void;
  49101. /**
  49102. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49103. */
  49104. needStencil(): boolean;
  49105. /**
  49106. * Checks for the readiness of the element composing the layer.
  49107. * @param subMesh the mesh to check for
  49108. * @param useInstances specify wether or not to use instances to render the mesh
  49109. * @param emissiveTexture the associated emissive texture used to generate the glow
  49110. * @return true if ready otherwise, false
  49111. */
  49112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49113. /**
  49114. * Implementation specific of rendering the generating effect on the main canvas.
  49115. * @param effect The effect used to render through
  49116. */
  49117. protected _internalRender(effect: Effect): void;
  49118. /**
  49119. * Returns true if the layer contains information to display, otherwise false.
  49120. */
  49121. shouldRender(): boolean;
  49122. /**
  49123. * Returns true if the mesh should render, otherwise false.
  49124. * @param mesh The mesh to render
  49125. * @returns true if it should render otherwise false
  49126. */
  49127. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49128. /**
  49129. * Sets the required values for both the emissive texture and and the main color.
  49130. */
  49131. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49132. /**
  49133. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49134. * @param mesh The mesh to exclude from the highlight layer
  49135. */
  49136. addExcludedMesh(mesh: Mesh): void;
  49137. /**
  49138. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49139. * @param mesh The mesh to highlight
  49140. */
  49141. removeExcludedMesh(mesh: Mesh): void;
  49142. /**
  49143. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49144. * @param mesh mesh to test
  49145. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49146. */
  49147. hasMesh(mesh: AbstractMesh): boolean;
  49148. /**
  49149. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49150. * @param mesh The mesh to highlight
  49151. * @param color The color of the highlight
  49152. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49153. */
  49154. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49155. /**
  49156. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49157. * @param mesh The mesh to highlight
  49158. */
  49159. removeMesh(mesh: Mesh): void;
  49160. /**
  49161. * Force the stencil to the normal expected value for none glowing parts
  49162. */
  49163. private _defaultStencilReference;
  49164. /**
  49165. * Free any resources and references associated to a mesh.
  49166. * Internal use
  49167. * @param mesh The mesh to free.
  49168. * @hidden
  49169. */
  49170. _disposeMesh(mesh: Mesh): void;
  49171. /**
  49172. * Dispose the highlight layer and free resources.
  49173. */
  49174. dispose(): void;
  49175. /**
  49176. * Gets the class name of the effect layer
  49177. * @returns the string with the class name of the effect layer
  49178. */
  49179. getClassName(): string;
  49180. /**
  49181. * Serializes this Highlight layer
  49182. * @returns a serialized Highlight layer object
  49183. */
  49184. serialize(): any;
  49185. /**
  49186. * Creates a Highlight layer from parsed Highlight layer data
  49187. * @param parsedHightlightLayer defines the Highlight layer data
  49188. * @param scene defines the current scene
  49189. * @param rootUrl defines the root URL containing the Highlight layer information
  49190. * @returns a parsed Highlight layer
  49191. */
  49192. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. interface AbstractScene {
  49197. /**
  49198. * The list of layers (background and foreground) of the scene
  49199. */
  49200. layers: Array<Layer>;
  49201. }
  49202. /**
  49203. * Defines the layer scene component responsible to manage any layers
  49204. * in a given scene.
  49205. */
  49206. export class LayerSceneComponent implements ISceneComponent {
  49207. /**
  49208. * The component name helpfull to identify the component in the list of scene components.
  49209. */
  49210. readonly name: string;
  49211. /**
  49212. * The scene the component belongs to.
  49213. */
  49214. scene: Scene;
  49215. private _engine;
  49216. /**
  49217. * Creates a new instance of the component for the given scene
  49218. * @param scene Defines the scene to register the component in
  49219. */
  49220. constructor(scene: Scene);
  49221. /**
  49222. * Registers the component in a given scene
  49223. */
  49224. register(): void;
  49225. /**
  49226. * Rebuilds the elements related to this component in case of
  49227. * context lost for instance.
  49228. */
  49229. rebuild(): void;
  49230. /**
  49231. * Disposes the component and the associated ressources.
  49232. */
  49233. dispose(): void;
  49234. private _draw;
  49235. private _drawCameraPredicate;
  49236. private _drawCameraBackground;
  49237. private _drawCameraForeground;
  49238. private _drawRenderTargetPredicate;
  49239. private _drawRenderTargetBackground;
  49240. private _drawRenderTargetForeground;
  49241. /**
  49242. * Adds all the elements from the container to the scene
  49243. * @param container the container holding the elements
  49244. */
  49245. addFromContainer(container: AbstractScene): void;
  49246. /**
  49247. * Removes all the elements in the container from the scene
  49248. * @param container contains the elements to remove
  49249. * @param dispose if the removed element should be disposed (default: false)
  49250. */
  49251. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49252. }
  49253. }
  49254. declare module BABYLON {
  49255. /** @hidden */
  49256. export var layerPixelShader: {
  49257. name: string;
  49258. shader: string;
  49259. };
  49260. }
  49261. declare module BABYLON {
  49262. /** @hidden */
  49263. export var layerVertexShader: {
  49264. name: string;
  49265. shader: string;
  49266. };
  49267. }
  49268. declare module BABYLON {
  49269. /**
  49270. * This represents a full screen 2d layer.
  49271. * This can be useful to display a picture in the background of your scene for instance.
  49272. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49273. */
  49274. export class Layer {
  49275. /**
  49276. * Define the name of the layer.
  49277. */
  49278. name: string;
  49279. /**
  49280. * Define the texture the layer should display.
  49281. */
  49282. texture: Nullable<Texture>;
  49283. /**
  49284. * Is the layer in background or foreground.
  49285. */
  49286. isBackground: boolean;
  49287. /**
  49288. * Define the color of the layer (instead of texture).
  49289. */
  49290. color: Color4;
  49291. /**
  49292. * Define the scale of the layer in order to zoom in out of the texture.
  49293. */
  49294. scale: Vector2;
  49295. /**
  49296. * Define an offset for the layer in order to shift the texture.
  49297. */
  49298. offset: Vector2;
  49299. /**
  49300. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49301. */
  49302. alphaBlendingMode: number;
  49303. /**
  49304. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49305. * Alpha test will not mix with the background color in case of transparency.
  49306. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49307. */
  49308. alphaTest: boolean;
  49309. /**
  49310. * Define a mask to restrict the layer to only some of the scene cameras.
  49311. */
  49312. layerMask: number;
  49313. /**
  49314. * Define the list of render target the layer is visible into.
  49315. */
  49316. renderTargetTextures: RenderTargetTexture[];
  49317. /**
  49318. * Define if the layer is only used in renderTarget or if it also
  49319. * renders in the main frame buffer of the canvas.
  49320. */
  49321. renderOnlyInRenderTargetTextures: boolean;
  49322. private _scene;
  49323. private _vertexBuffers;
  49324. private _indexBuffer;
  49325. private _effect;
  49326. private _alphaTestEffect;
  49327. /**
  49328. * An event triggered when the layer is disposed.
  49329. */
  49330. onDisposeObservable: Observable<Layer>;
  49331. private _onDisposeObserver;
  49332. /**
  49333. * Back compatibility with callback before the onDisposeObservable existed.
  49334. * The set callback will be triggered when the layer has been disposed.
  49335. */
  49336. onDispose: () => void;
  49337. /**
  49338. * An event triggered before rendering the scene
  49339. */
  49340. onBeforeRenderObservable: Observable<Layer>;
  49341. private _onBeforeRenderObserver;
  49342. /**
  49343. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49344. * The set callback will be triggered just before rendering the layer.
  49345. */
  49346. onBeforeRender: () => void;
  49347. /**
  49348. * An event triggered after rendering the scene
  49349. */
  49350. onAfterRenderObservable: Observable<Layer>;
  49351. private _onAfterRenderObserver;
  49352. /**
  49353. * Back compatibility with callback before the onAfterRenderObservable existed.
  49354. * The set callback will be triggered just after rendering the layer.
  49355. */
  49356. onAfterRender: () => void;
  49357. /**
  49358. * Instantiates a new layer.
  49359. * This represents a full screen 2d layer.
  49360. * This can be useful to display a picture in the background of your scene for instance.
  49361. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49362. * @param name Define the name of the layer in the scene
  49363. * @param imgUrl Define the url of the texture to display in the layer
  49364. * @param scene Define the scene the layer belongs to
  49365. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49366. * @param color Defines a color for the layer
  49367. */
  49368. constructor(
  49369. /**
  49370. * Define the name of the layer.
  49371. */
  49372. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49373. private _createIndexBuffer;
  49374. /** @hidden */
  49375. _rebuild(): void;
  49376. /**
  49377. * Renders the layer in the scene.
  49378. */
  49379. render(): void;
  49380. /**
  49381. * Disposes and releases the associated ressources.
  49382. */
  49383. dispose(): void;
  49384. }
  49385. }
  49386. declare module BABYLON {
  49387. /** @hidden */
  49388. export var lensFlarePixelShader: {
  49389. name: string;
  49390. shader: string;
  49391. };
  49392. }
  49393. declare module BABYLON {
  49394. /** @hidden */
  49395. export var lensFlareVertexShader: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module BABYLON {
  49401. /**
  49402. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49403. * It is usually composed of several `lensFlare`.
  49404. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49405. */
  49406. export class LensFlareSystem {
  49407. /**
  49408. * Define the name of the lens flare system
  49409. */
  49410. name: string;
  49411. /**
  49412. * List of lens flares used in this system.
  49413. */
  49414. lensFlares: LensFlare[];
  49415. /**
  49416. * Define a limit from the border the lens flare can be visible.
  49417. */
  49418. borderLimit: number;
  49419. /**
  49420. * Define a viewport border we do not want to see the lens flare in.
  49421. */
  49422. viewportBorder: number;
  49423. /**
  49424. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49425. */
  49426. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49427. /**
  49428. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49429. */
  49430. layerMask: number;
  49431. /**
  49432. * Define the id of the lens flare system in the scene.
  49433. * (equal to name by default)
  49434. */
  49435. id: string;
  49436. private _scene;
  49437. private _emitter;
  49438. private _vertexBuffers;
  49439. private _indexBuffer;
  49440. private _effect;
  49441. private _positionX;
  49442. private _positionY;
  49443. private _isEnabled;
  49444. /** @hidden */
  49445. static _SceneComponentInitialization: (scene: Scene) => void;
  49446. /**
  49447. * Instantiates a lens flare system.
  49448. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49449. * It is usually composed of several `lensFlare`.
  49450. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49451. * @param name Define the name of the lens flare system in the scene
  49452. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49453. * @param scene Define the scene the lens flare system belongs to
  49454. */
  49455. constructor(
  49456. /**
  49457. * Define the name of the lens flare system
  49458. */
  49459. name: string, emitter: any, scene: Scene);
  49460. /**
  49461. * Define if the lens flare system is enabled.
  49462. */
  49463. isEnabled: boolean;
  49464. /**
  49465. * Get the scene the effects belongs to.
  49466. * @returns the scene holding the lens flare system
  49467. */
  49468. getScene(): Scene;
  49469. /**
  49470. * Get the emitter of the lens flare system.
  49471. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49472. * @returns the emitter of the lens flare system
  49473. */
  49474. getEmitter(): any;
  49475. /**
  49476. * Set the emitter of the lens flare system.
  49477. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49478. * @param newEmitter Define the new emitter of the system
  49479. */
  49480. setEmitter(newEmitter: any): void;
  49481. /**
  49482. * Get the lens flare system emitter position.
  49483. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49484. * @returns the position
  49485. */
  49486. getEmitterPosition(): Vector3;
  49487. /**
  49488. * @hidden
  49489. */
  49490. computeEffectivePosition(globalViewport: Viewport): boolean;
  49491. /** @hidden */
  49492. _isVisible(): boolean;
  49493. /**
  49494. * @hidden
  49495. */
  49496. render(): boolean;
  49497. /**
  49498. * Dispose and release the lens flare with its associated resources.
  49499. */
  49500. dispose(): void;
  49501. /**
  49502. * Parse a lens flare system from a JSON repressentation
  49503. * @param parsedLensFlareSystem Define the JSON to parse
  49504. * @param scene Define the scene the parsed system should be instantiated in
  49505. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49506. * @returns the parsed system
  49507. */
  49508. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49509. /**
  49510. * Serialize the current Lens Flare System into a JSON representation.
  49511. * @returns the serialized JSON
  49512. */
  49513. serialize(): any;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * This represents one of the lens effect in a `lensFlareSystem`.
  49519. * It controls one of the indiviual texture used in the effect.
  49520. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49521. */
  49522. export class LensFlare {
  49523. /**
  49524. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49525. */
  49526. size: number;
  49527. /**
  49528. * 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.
  49529. */
  49530. position: number;
  49531. /**
  49532. * Define the lens color.
  49533. */
  49534. color: Color3;
  49535. /**
  49536. * Define the lens texture.
  49537. */
  49538. texture: Nullable<Texture>;
  49539. /**
  49540. * Define the alpha mode to render this particular lens.
  49541. */
  49542. alphaMode: number;
  49543. private _system;
  49544. /**
  49545. * Creates a new Lens Flare.
  49546. * This represents one of the lens effect in a `lensFlareSystem`.
  49547. * It controls one of the indiviual texture used in the effect.
  49548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49549. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49550. * @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.
  49551. * @param color Define the lens color
  49552. * @param imgUrl Define the lens texture url
  49553. * @param system Define the `lensFlareSystem` this flare is part of
  49554. * @returns The newly created Lens Flare
  49555. */
  49556. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49557. /**
  49558. * Instantiates a new Lens Flare.
  49559. * This represents one of the lens effect in a `lensFlareSystem`.
  49560. * It controls one of the indiviual texture used in the effect.
  49561. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49562. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49563. * @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.
  49564. * @param color Define the lens color
  49565. * @param imgUrl Define the lens texture url
  49566. * @param system Define the `lensFlareSystem` this flare is part of
  49567. */
  49568. constructor(
  49569. /**
  49570. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49571. */
  49572. size: number,
  49573. /**
  49574. * 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.
  49575. */
  49576. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49577. /**
  49578. * Dispose and release the lens flare with its associated resources.
  49579. */
  49580. dispose(): void;
  49581. }
  49582. }
  49583. declare module BABYLON {
  49584. interface AbstractScene {
  49585. /**
  49586. * The list of lens flare system added to the scene
  49587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49588. */
  49589. lensFlareSystems: Array<LensFlareSystem>;
  49590. /**
  49591. * Removes the given lens flare system from this scene.
  49592. * @param toRemove The lens flare system to remove
  49593. * @returns The index of the removed lens flare system
  49594. */
  49595. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49596. /**
  49597. * Adds the given lens flare system to this scene
  49598. * @param newLensFlareSystem The lens flare system to add
  49599. */
  49600. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49601. /**
  49602. * Gets a lens flare system using its name
  49603. * @param name defines the name to look for
  49604. * @returns the lens flare system or null if not found
  49605. */
  49606. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49607. /**
  49608. * Gets a lens flare system using its id
  49609. * @param id defines the id to look for
  49610. * @returns the lens flare system or null if not found
  49611. */
  49612. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49613. }
  49614. /**
  49615. * Defines the lens flare scene component responsible to manage any lens flares
  49616. * in a given scene.
  49617. */
  49618. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49619. /**
  49620. * The component name helpfull to identify the component in the list of scene components.
  49621. */
  49622. readonly name: string;
  49623. /**
  49624. * The scene the component belongs to.
  49625. */
  49626. scene: Scene;
  49627. /**
  49628. * Creates a new instance of the component for the given scene
  49629. * @param scene Defines the scene to register the component in
  49630. */
  49631. constructor(scene: Scene);
  49632. /**
  49633. * Registers the component in a given scene
  49634. */
  49635. register(): void;
  49636. /**
  49637. * Rebuilds the elements related to this component in case of
  49638. * context lost for instance.
  49639. */
  49640. rebuild(): void;
  49641. /**
  49642. * Adds all the elements from the container to the scene
  49643. * @param container the container holding the elements
  49644. */
  49645. addFromContainer(container: AbstractScene): void;
  49646. /**
  49647. * Removes all the elements in the container from the scene
  49648. * @param container contains the elements to remove
  49649. * @param dispose if the removed element should be disposed (default: false)
  49650. */
  49651. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49652. /**
  49653. * Serializes the component data to the specified json object
  49654. * @param serializationObject The object to serialize to
  49655. */
  49656. serialize(serializationObject: any): void;
  49657. /**
  49658. * Disposes the component and the associated ressources.
  49659. */
  49660. dispose(): void;
  49661. private _draw;
  49662. }
  49663. }
  49664. declare module BABYLON {
  49665. /**
  49666. * Defines the shadow generator component responsible to manage any shadow generators
  49667. * in a given scene.
  49668. */
  49669. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49670. /**
  49671. * The component name helpfull to identify the component in the list of scene components.
  49672. */
  49673. readonly name: string;
  49674. /**
  49675. * The scene the component belongs to.
  49676. */
  49677. scene: Scene;
  49678. /**
  49679. * Creates a new instance of the component for the given scene
  49680. * @param scene Defines the scene to register the component in
  49681. */
  49682. constructor(scene: Scene);
  49683. /**
  49684. * Registers the component in a given scene
  49685. */
  49686. register(): void;
  49687. /**
  49688. * Rebuilds the elements related to this component in case of
  49689. * context lost for instance.
  49690. */
  49691. rebuild(): void;
  49692. /**
  49693. * Serializes the component data to the specified json object
  49694. * @param serializationObject The object to serialize to
  49695. */
  49696. serialize(serializationObject: any): void;
  49697. /**
  49698. * Adds all the elements from the container to the scene
  49699. * @param container the container holding the elements
  49700. */
  49701. addFromContainer(container: AbstractScene): void;
  49702. /**
  49703. * Removes all the elements in the container from the scene
  49704. * @param container contains the elements to remove
  49705. * @param dispose if the removed element should be disposed (default: false)
  49706. */
  49707. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49708. /**
  49709. * Rebuilds the elements related to this component in case of
  49710. * context lost for instance.
  49711. */
  49712. dispose(): void;
  49713. private _gatherRenderTargets;
  49714. }
  49715. }
  49716. declare module BABYLON {
  49717. /**
  49718. * A point light is a light defined by an unique point in world space.
  49719. * The light is emitted in every direction from this point.
  49720. * A good example of a point light is a standard light bulb.
  49721. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49722. */
  49723. export class PointLight extends ShadowLight {
  49724. private _shadowAngle;
  49725. /**
  49726. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49727. * This specifies what angle the shadow will use to be created.
  49728. *
  49729. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49730. */
  49731. /**
  49732. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49733. * This specifies what angle the shadow will use to be created.
  49734. *
  49735. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49736. */
  49737. shadowAngle: number;
  49738. /**
  49739. * Gets the direction if it has been set.
  49740. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49741. */
  49742. /**
  49743. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49744. */
  49745. direction: Vector3;
  49746. /**
  49747. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49748. * A PointLight emits the light in every direction.
  49749. * It can cast shadows.
  49750. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49751. * ```javascript
  49752. * var pointLight = new PointLight("pl", camera.position, scene);
  49753. * ```
  49754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49755. * @param name The light friendly name
  49756. * @param position The position of the point light in the scene
  49757. * @param scene The scene the lights belongs to
  49758. */
  49759. constructor(name: string, position: Vector3, scene: Scene);
  49760. /**
  49761. * Returns the string "PointLight"
  49762. * @returns the class name
  49763. */
  49764. getClassName(): string;
  49765. /**
  49766. * Returns the integer 0.
  49767. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49768. */
  49769. getTypeID(): number;
  49770. /**
  49771. * Specifies wether or not the shadowmap should be a cube texture.
  49772. * @returns true if the shadowmap needs to be a cube texture.
  49773. */
  49774. needCube(): boolean;
  49775. /**
  49776. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49777. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49778. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49779. */
  49780. getShadowDirection(faceIndex?: number): Vector3;
  49781. /**
  49782. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49783. * - fov = PI / 2
  49784. * - aspect ratio : 1.0
  49785. * - z-near and far equal to the active camera minZ and maxZ.
  49786. * Returns the PointLight.
  49787. */
  49788. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49789. protected _buildUniformLayout(): void;
  49790. /**
  49791. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49792. * @param effect The effect to update
  49793. * @param lightIndex The index of the light in the effect to update
  49794. * @returns The point light
  49795. */
  49796. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49797. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49798. /**
  49799. * Prepares the list of defines specific to the light type.
  49800. * @param defines the list of defines
  49801. * @param lightIndex defines the index of the light for the effect
  49802. */
  49803. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49804. }
  49805. }
  49806. declare module BABYLON {
  49807. /**
  49808. * Header information of HDR texture files.
  49809. */
  49810. export interface HDRInfo {
  49811. /**
  49812. * The height of the texture in pixels.
  49813. */
  49814. height: number;
  49815. /**
  49816. * The width of the texture in pixels.
  49817. */
  49818. width: number;
  49819. /**
  49820. * The index of the beginning of the data in the binary file.
  49821. */
  49822. dataPosition: number;
  49823. }
  49824. /**
  49825. * This groups tools to convert HDR texture to native colors array.
  49826. */
  49827. export class HDRTools {
  49828. private static Ldexp;
  49829. private static Rgbe2float;
  49830. private static readStringLine;
  49831. /**
  49832. * Reads header information from an RGBE texture stored in a native array.
  49833. * More information on this format are available here:
  49834. * https://en.wikipedia.org/wiki/RGBE_image_format
  49835. *
  49836. * @param uint8array The binary file stored in native array.
  49837. * @return The header information.
  49838. */
  49839. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49840. /**
  49841. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49842. * This RGBE texture needs to store the information as a panorama.
  49843. *
  49844. * More information on this format are available here:
  49845. * https://en.wikipedia.org/wiki/RGBE_image_format
  49846. *
  49847. * @param buffer The binary file stored in an array buffer.
  49848. * @param size The expected size of the extracted cubemap.
  49849. * @return The Cube Map information.
  49850. */
  49851. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49852. /**
  49853. * Returns the pixels data extracted from an RGBE texture.
  49854. * This pixels will be stored left to right up to down in the R G B order in one array.
  49855. *
  49856. * More information on this format are available here:
  49857. * https://en.wikipedia.org/wiki/RGBE_image_format
  49858. *
  49859. * @param uint8array The binary file stored in an array buffer.
  49860. * @param hdrInfo The header information of the file.
  49861. * @return The pixels data in RGB right to left up to down order.
  49862. */
  49863. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49864. private static RGBE_ReadPixels_RLE;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * This represents a texture coming from an HDR input.
  49870. *
  49871. * The only supported format is currently panorama picture stored in RGBE format.
  49872. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49873. */
  49874. export class HDRCubeTexture extends BaseTexture {
  49875. private static _facesMapping;
  49876. private _generateHarmonics;
  49877. private _noMipmap;
  49878. private _textureMatrix;
  49879. private _size;
  49880. private _onLoad;
  49881. private _onError;
  49882. /**
  49883. * The texture URL.
  49884. */
  49885. url: string;
  49886. /**
  49887. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49888. */
  49889. coordinatesMode: number;
  49890. protected _isBlocking: boolean;
  49891. /**
  49892. * Sets wether or not the texture is blocking during loading.
  49893. */
  49894. /**
  49895. * Gets wether or not the texture is blocking during loading.
  49896. */
  49897. isBlocking: boolean;
  49898. protected _rotationY: number;
  49899. /**
  49900. * Sets texture matrix rotation angle around Y axis in radians.
  49901. */
  49902. /**
  49903. * Gets texture matrix rotation angle around Y axis radians.
  49904. */
  49905. rotationY: number;
  49906. /**
  49907. * Gets or sets the center of the bounding box associated with the cube texture
  49908. * It must define where the camera used to render the texture was set
  49909. */
  49910. boundingBoxPosition: Vector3;
  49911. private _boundingBoxSize;
  49912. /**
  49913. * Gets or sets the size of the bounding box associated with the cube texture
  49914. * When defined, the cubemap will switch to local mode
  49915. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49916. * @example https://www.babylonjs-playground.com/#RNASML
  49917. */
  49918. boundingBoxSize: Vector3;
  49919. /**
  49920. * Instantiates an HDRTexture from the following parameters.
  49921. *
  49922. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49923. * @param scene The scene the texture will be used in
  49924. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49925. * @param noMipmap Forces to not generate the mipmap if true
  49926. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49927. * @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)
  49928. * @param reserved Reserved flag for internal use.
  49929. */
  49930. 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>);
  49931. /**
  49932. * Get the current class name of the texture useful for serialization or dynamic coding.
  49933. * @returns "HDRCubeTexture"
  49934. */
  49935. getClassName(): string;
  49936. /**
  49937. * Occurs when the file is raw .hdr file.
  49938. */
  49939. private loadTexture;
  49940. clone(): HDRCubeTexture;
  49941. delayLoad(): void;
  49942. /**
  49943. * Get the texture reflection matrix used to rotate/transform the reflection.
  49944. * @returns the reflection matrix
  49945. */
  49946. getReflectionTextureMatrix(): Matrix;
  49947. /**
  49948. * Set the texture reflection matrix used to rotate/transform the reflection.
  49949. * @param value Define the reflection matrix to set
  49950. */
  49951. setReflectionTextureMatrix(value: Matrix): void;
  49952. /**
  49953. * Parses a JSON representation of an HDR Texture in order to create the texture
  49954. * @param parsedTexture Define the JSON representation
  49955. * @param scene Define the scene the texture should be created in
  49956. * @param rootUrl Define the root url in case we need to load relative dependencies
  49957. * @returns the newly created texture after parsing
  49958. */
  49959. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49960. serialize(): any;
  49961. }
  49962. }
  49963. declare module BABYLON {
  49964. /**
  49965. * Class used to control physics engine
  49966. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49967. */
  49968. export class PhysicsEngine implements IPhysicsEngine {
  49969. private _physicsPlugin;
  49970. /**
  49971. * Global value used to control the smallest number supported by the simulation
  49972. */
  49973. static Epsilon: number;
  49974. private _impostors;
  49975. private _joints;
  49976. /**
  49977. * Gets the gravity vector used by the simulation
  49978. */
  49979. gravity: Vector3;
  49980. /**
  49981. * Factory used to create the default physics plugin.
  49982. * @returns The default physics plugin
  49983. */
  49984. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49985. /**
  49986. * Creates a new Physics Engine
  49987. * @param gravity defines the gravity vector used by the simulation
  49988. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49989. */
  49990. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49991. /**
  49992. * Sets the gravity vector used by the simulation
  49993. * @param gravity defines the gravity vector to use
  49994. */
  49995. setGravity(gravity: Vector3): void;
  49996. /**
  49997. * Set the time step of the physics engine.
  49998. * Default is 1/60.
  49999. * To slow it down, enter 1/600 for example.
  50000. * To speed it up, 1/30
  50001. * @param newTimeStep defines the new timestep to apply to this world.
  50002. */
  50003. setTimeStep(newTimeStep?: number): void;
  50004. /**
  50005. * Get the time step of the physics engine.
  50006. * @returns the current time step
  50007. */
  50008. getTimeStep(): number;
  50009. /**
  50010. * Release all resources
  50011. */
  50012. dispose(): void;
  50013. /**
  50014. * Gets the name of the current physics plugin
  50015. * @returns the name of the plugin
  50016. */
  50017. getPhysicsPluginName(): string;
  50018. /**
  50019. * Adding a new impostor for the impostor tracking.
  50020. * This will be done by the impostor itself.
  50021. * @param impostor the impostor to add
  50022. */
  50023. addImpostor(impostor: PhysicsImpostor): void;
  50024. /**
  50025. * Remove an impostor from the engine.
  50026. * This impostor and its mesh will not longer be updated by the physics engine.
  50027. * @param impostor the impostor to remove
  50028. */
  50029. removeImpostor(impostor: PhysicsImpostor): void;
  50030. /**
  50031. * Add a joint to the physics engine
  50032. * @param mainImpostor defines the main impostor to which the joint is added.
  50033. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50034. * @param joint defines the joint that will connect both impostors.
  50035. */
  50036. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50037. /**
  50038. * Removes a joint from the simulation
  50039. * @param mainImpostor defines the impostor used with the joint
  50040. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50041. * @param joint defines the joint to remove
  50042. */
  50043. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50044. /**
  50045. * Called by the scene. No need to call it.
  50046. * @param delta defines the timespam between frames
  50047. */
  50048. _step(delta: number): void;
  50049. /**
  50050. * Gets the current plugin used to run the simulation
  50051. * @returns current plugin
  50052. */
  50053. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50054. /**
  50055. * Gets the list of physic impostors
  50056. * @returns an array of PhysicsImpostor
  50057. */
  50058. getImpostors(): Array<PhysicsImpostor>;
  50059. /**
  50060. * Gets the impostor for a physics enabled object
  50061. * @param object defines the object impersonated by the impostor
  50062. * @returns the PhysicsImpostor or null if not found
  50063. */
  50064. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50065. /**
  50066. * Gets the impostor for a physics body object
  50067. * @param body defines physics body used by the impostor
  50068. * @returns the PhysicsImpostor or null if not found
  50069. */
  50070. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50071. /**
  50072. * Does a raycast in the physics world
  50073. * @param from when should the ray start?
  50074. * @param to when should the ray end?
  50075. * @returns PhysicsRaycastResult
  50076. */
  50077. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50078. }
  50079. }
  50080. declare module BABYLON {
  50081. /** @hidden */
  50082. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50083. private _useDeltaForWorldStep;
  50084. world: any;
  50085. name: string;
  50086. private _physicsMaterials;
  50087. private _fixedTimeStep;
  50088. private _cannonRaycastResult;
  50089. private _raycastResult;
  50090. private _physicsBodysToRemoveAfterStep;
  50091. BJSCANNON: any;
  50092. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50093. setGravity(gravity: Vector3): void;
  50094. setTimeStep(timeStep: number): void;
  50095. getTimeStep(): number;
  50096. executeStep(delta: number): void;
  50097. private _removeMarkedPhysicsBodiesFromWorld;
  50098. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50099. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50100. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50101. private _processChildMeshes;
  50102. removePhysicsBody(impostor: PhysicsImpostor): void;
  50103. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50104. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50105. private _addMaterial;
  50106. private _checkWithEpsilon;
  50107. private _createShape;
  50108. private _createHeightmap;
  50109. private _minus90X;
  50110. private _plus90X;
  50111. private _tmpPosition;
  50112. private _tmpDeltaPosition;
  50113. private _tmpUnityRotation;
  50114. private _updatePhysicsBodyTransformation;
  50115. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50116. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50117. isSupported(): boolean;
  50118. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50119. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50120. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50121. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50122. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50123. getBodyMass(impostor: PhysicsImpostor): number;
  50124. getBodyFriction(impostor: PhysicsImpostor): number;
  50125. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50126. getBodyRestitution(impostor: PhysicsImpostor): number;
  50127. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50128. sleepBody(impostor: PhysicsImpostor): void;
  50129. wakeUpBody(impostor: PhysicsImpostor): void;
  50130. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50131. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50132. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50133. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50134. getRadius(impostor: PhysicsImpostor): number;
  50135. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50136. dispose(): void;
  50137. private _extendNamespace;
  50138. /**
  50139. * Does a raycast in the physics world
  50140. * @param from when should the ray start?
  50141. * @param to when should the ray end?
  50142. * @returns PhysicsRaycastResult
  50143. */
  50144. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50145. }
  50146. }
  50147. declare module BABYLON {
  50148. /** @hidden */
  50149. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50150. world: any;
  50151. name: string;
  50152. BJSOIMO: any;
  50153. private _raycastResult;
  50154. constructor(iterations?: number, oimoInjection?: any);
  50155. setGravity(gravity: Vector3): void;
  50156. setTimeStep(timeStep: number): void;
  50157. getTimeStep(): number;
  50158. private _tmpImpostorsArray;
  50159. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50160. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50161. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50162. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50163. private _tmpPositionVector;
  50164. removePhysicsBody(impostor: PhysicsImpostor): void;
  50165. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50166. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50167. isSupported(): boolean;
  50168. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50169. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50170. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50171. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50172. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50173. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50174. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50175. getBodyMass(impostor: PhysicsImpostor): number;
  50176. getBodyFriction(impostor: PhysicsImpostor): number;
  50177. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50178. getBodyRestitution(impostor: PhysicsImpostor): number;
  50179. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50180. sleepBody(impostor: PhysicsImpostor): void;
  50181. wakeUpBody(impostor: PhysicsImpostor): void;
  50182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50183. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50184. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50185. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50186. getRadius(impostor: PhysicsImpostor): number;
  50187. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50188. dispose(): void;
  50189. /**
  50190. * Does a raycast in the physics world
  50191. * @param from when should the ray start?
  50192. * @param to when should the ray end?
  50193. * @returns PhysicsRaycastResult
  50194. */
  50195. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50196. }
  50197. }
  50198. declare module BABYLON {
  50199. /**
  50200. * Class containing static functions to help procedurally build meshes
  50201. */
  50202. export class RibbonBuilder {
  50203. /**
  50204. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50205. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50206. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50207. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50208. * * 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
  50209. * * 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
  50210. * * 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
  50211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50212. * * 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
  50213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50214. * * 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
  50215. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50216. * * 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
  50217. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50219. * @param name defines the name of the mesh
  50220. * @param options defines the options used to create the mesh
  50221. * @param scene defines the hosting scene
  50222. * @returns the ribbon mesh
  50223. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50225. */
  50226. static CreateRibbon(name: string, options: {
  50227. pathArray: Vector3[][];
  50228. closeArray?: boolean;
  50229. closePath?: boolean;
  50230. offset?: number;
  50231. updatable?: boolean;
  50232. sideOrientation?: number;
  50233. frontUVs?: Vector4;
  50234. backUVs?: Vector4;
  50235. instance?: Mesh;
  50236. invertUV?: boolean;
  50237. uvs?: Vector2[];
  50238. colors?: Color4[];
  50239. }, scene?: Nullable<Scene>): Mesh;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * Class containing static functions to help procedurally build meshes
  50245. */
  50246. export class ShapeBuilder {
  50247. /**
  50248. * 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.
  50249. * * 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.
  50250. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50251. * * 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.
  50252. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50253. * * 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
  50254. * * 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
  50255. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50257. * * 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
  50258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50260. * @param name defines the name of the mesh
  50261. * @param options defines the options used to create the mesh
  50262. * @param scene defines the hosting scene
  50263. * @returns the extruded shape mesh
  50264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50266. */
  50267. static ExtrudeShape(name: string, options: {
  50268. shape: Vector3[];
  50269. path: Vector3[];
  50270. scale?: number;
  50271. rotation?: number;
  50272. cap?: number;
  50273. updatable?: boolean;
  50274. sideOrientation?: number;
  50275. frontUVs?: Vector4;
  50276. backUVs?: Vector4;
  50277. instance?: Mesh;
  50278. invertUV?: boolean;
  50279. }, scene?: Nullable<Scene>): Mesh;
  50280. /**
  50281. * Creates an custom extruded shape mesh.
  50282. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50283. * * 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.
  50284. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50285. * * 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
  50286. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50287. * * 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
  50288. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50289. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50290. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50291. * * 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
  50292. * * 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
  50293. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50295. * * 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
  50296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50298. * @param name defines the name of the mesh
  50299. * @param options defines the options used to create the mesh
  50300. * @param scene defines the hosting scene
  50301. * @returns the custom extruded shape mesh
  50302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50305. */
  50306. static ExtrudeShapeCustom(name: string, options: {
  50307. shape: Vector3[];
  50308. path: Vector3[];
  50309. scaleFunction?: any;
  50310. rotationFunction?: any;
  50311. ribbonCloseArray?: boolean;
  50312. ribbonClosePath?: boolean;
  50313. cap?: number;
  50314. updatable?: boolean;
  50315. sideOrientation?: number;
  50316. frontUVs?: Vector4;
  50317. backUVs?: Vector4;
  50318. instance?: Mesh;
  50319. invertUV?: boolean;
  50320. }, scene?: Nullable<Scene>): Mesh;
  50321. private static _ExtrudeShapeGeneric;
  50322. }
  50323. }
  50324. declare module BABYLON {
  50325. /**
  50326. * AmmoJS Physics plugin
  50327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50328. * @see https://github.com/kripken/ammo.js/
  50329. */
  50330. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50331. private _useDeltaForWorldStep;
  50332. /**
  50333. * Reference to the Ammo library
  50334. */
  50335. bjsAMMO: any;
  50336. /**
  50337. * Created ammoJS world which physics bodies are added to
  50338. */
  50339. world: any;
  50340. /**
  50341. * Name of the plugin
  50342. */
  50343. name: string;
  50344. private _timeStep;
  50345. private _fixedTimeStep;
  50346. private _maxSteps;
  50347. private _tmpQuaternion;
  50348. private _tmpAmmoTransform;
  50349. private _tmpAmmoQuaternion;
  50350. private _tmpAmmoConcreteContactResultCallback;
  50351. private _collisionConfiguration;
  50352. private _dispatcher;
  50353. private _overlappingPairCache;
  50354. private _solver;
  50355. private _softBodySolver;
  50356. private _tmpAmmoVectorA;
  50357. private _tmpAmmoVectorB;
  50358. private _tmpAmmoVectorC;
  50359. private _tmpAmmoVectorD;
  50360. private _tmpContactCallbackResult;
  50361. private _tmpAmmoVectorRCA;
  50362. private _tmpAmmoVectorRCB;
  50363. private _raycastResult;
  50364. private static readonly DISABLE_COLLISION_FLAG;
  50365. private static readonly KINEMATIC_FLAG;
  50366. private static readonly DISABLE_DEACTIVATION_FLAG;
  50367. /**
  50368. * Initializes the ammoJS plugin
  50369. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50370. * @param ammoInjection can be used to inject your own ammo reference
  50371. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50372. */
  50373. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50374. /**
  50375. * Sets the gravity of the physics world (m/(s^2))
  50376. * @param gravity Gravity to set
  50377. */
  50378. setGravity(gravity: Vector3): void;
  50379. /**
  50380. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50381. * @param timeStep timestep to use in seconds
  50382. */
  50383. setTimeStep(timeStep: number): void;
  50384. /**
  50385. * 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)
  50386. * @param fixedTimeStep fixedTimeStep to use in seconds
  50387. */
  50388. setFixedTimeStep(fixedTimeStep: number): void;
  50389. /**
  50390. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50391. * @param maxSteps the maximum number of steps by the physics engine per frame
  50392. */
  50393. setMaxSteps(maxSteps: number): void;
  50394. /**
  50395. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50396. * @returns the current timestep in seconds
  50397. */
  50398. getTimeStep(): number;
  50399. private _isImpostorInContact;
  50400. private _isImpostorPairInContact;
  50401. private _stepSimulation;
  50402. /**
  50403. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50404. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50405. * After the step the babylon meshes are set to the position of the physics imposters
  50406. * @param delta amount of time to step forward
  50407. * @param impostors array of imposters to update before/after the step
  50408. */
  50409. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50410. /**
  50411. * Update babylon mesh to match physics world object
  50412. * @param impostor imposter to match
  50413. */
  50414. private _afterSoftStep;
  50415. /**
  50416. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50417. * @param impostor imposter to match
  50418. */
  50419. private _ropeStep;
  50420. /**
  50421. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50422. * @param impostor imposter to match
  50423. */
  50424. private _softbodyOrClothStep;
  50425. private _tmpVector;
  50426. private _tmpMatrix;
  50427. /**
  50428. * Applies an impulse on the imposter
  50429. * @param impostor imposter to apply impulse to
  50430. * @param force amount of force to be applied to the imposter
  50431. * @param contactPoint the location to apply the impulse on the imposter
  50432. */
  50433. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50434. /**
  50435. * Applies a force on the imposter
  50436. * @param impostor imposter to apply force
  50437. * @param force amount of force to be applied to the imposter
  50438. * @param contactPoint the location to apply the force on the imposter
  50439. */
  50440. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50441. /**
  50442. * Creates a physics body using the plugin
  50443. * @param impostor the imposter to create the physics body on
  50444. */
  50445. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50446. /**
  50447. * Removes the physics body from the imposter and disposes of the body's memory
  50448. * @param impostor imposter to remove the physics body from
  50449. */
  50450. removePhysicsBody(impostor: PhysicsImpostor): void;
  50451. /**
  50452. * Generates a joint
  50453. * @param impostorJoint the imposter joint to create the joint with
  50454. */
  50455. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50456. /**
  50457. * Removes a joint
  50458. * @param impostorJoint the imposter joint to remove the joint from
  50459. */
  50460. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50461. private _addMeshVerts;
  50462. /**
  50463. * Initialise the soft body vertices to match its object's (mesh) vertices
  50464. * Softbody vertices (nodes) are in world space and to match this
  50465. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50466. * @param impostor to create the softbody for
  50467. */
  50468. private _softVertexData;
  50469. /**
  50470. * Create an impostor's soft body
  50471. * @param impostor to create the softbody for
  50472. */
  50473. private _createSoftbody;
  50474. /**
  50475. * Create cloth for an impostor
  50476. * @param impostor to create the softbody for
  50477. */
  50478. private _createCloth;
  50479. /**
  50480. * Create rope for an impostor
  50481. * @param impostor to create the softbody for
  50482. */
  50483. private _createRope;
  50484. private _addHullVerts;
  50485. private _createShape;
  50486. /**
  50487. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50488. * @param impostor imposter containing the physics body and babylon object
  50489. */
  50490. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50491. /**
  50492. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50493. * @param impostor imposter containing the physics body and babylon object
  50494. * @param newPosition new position
  50495. * @param newRotation new rotation
  50496. */
  50497. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50498. /**
  50499. * If this plugin is supported
  50500. * @returns true if its supported
  50501. */
  50502. isSupported(): boolean;
  50503. /**
  50504. * Sets the linear velocity of the physics body
  50505. * @param impostor imposter to set the velocity on
  50506. * @param velocity velocity to set
  50507. */
  50508. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50509. /**
  50510. * Sets the angular velocity of the physics body
  50511. * @param impostor imposter to set the velocity on
  50512. * @param velocity velocity to set
  50513. */
  50514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50515. /**
  50516. * gets the linear velocity
  50517. * @param impostor imposter to get linear velocity from
  50518. * @returns linear velocity
  50519. */
  50520. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50521. /**
  50522. * gets the angular velocity
  50523. * @param impostor imposter to get angular velocity from
  50524. * @returns angular velocity
  50525. */
  50526. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50527. /**
  50528. * Sets the mass of physics body
  50529. * @param impostor imposter to set the mass on
  50530. * @param mass mass to set
  50531. */
  50532. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50533. /**
  50534. * Gets the mass of the physics body
  50535. * @param impostor imposter to get the mass from
  50536. * @returns mass
  50537. */
  50538. getBodyMass(impostor: PhysicsImpostor): number;
  50539. /**
  50540. * Gets friction of the impostor
  50541. * @param impostor impostor to get friction from
  50542. * @returns friction value
  50543. */
  50544. getBodyFriction(impostor: PhysicsImpostor): number;
  50545. /**
  50546. * Sets friction of the impostor
  50547. * @param impostor impostor to set friction on
  50548. * @param friction friction value
  50549. */
  50550. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50551. /**
  50552. * Gets restitution of the impostor
  50553. * @param impostor impostor to get restitution from
  50554. * @returns restitution value
  50555. */
  50556. getBodyRestitution(impostor: PhysicsImpostor): number;
  50557. /**
  50558. * Sets resitution of the impostor
  50559. * @param impostor impostor to set resitution on
  50560. * @param restitution resitution value
  50561. */
  50562. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50563. /**
  50564. * Gets pressure inside the impostor
  50565. * @param impostor impostor to get pressure from
  50566. * @returns pressure value
  50567. */
  50568. getBodyPressure(impostor: PhysicsImpostor): number;
  50569. /**
  50570. * Sets pressure inside a soft body impostor
  50571. * Cloth and rope must remain 0 pressure
  50572. * @param impostor impostor to set pressure on
  50573. * @param pressure pressure value
  50574. */
  50575. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50576. /**
  50577. * Gets stiffness of the impostor
  50578. * @param impostor impostor to get stiffness from
  50579. * @returns pressure value
  50580. */
  50581. getBodyStiffness(impostor: PhysicsImpostor): number;
  50582. /**
  50583. * Sets stiffness of the impostor
  50584. * @param impostor impostor to set stiffness on
  50585. * @param stiffness stiffness value from 0 to 1
  50586. */
  50587. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50588. /**
  50589. * Gets velocityIterations of the impostor
  50590. * @param impostor impostor to get velocity iterations from
  50591. * @returns velocityIterations value
  50592. */
  50593. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50594. /**
  50595. * Sets velocityIterations of the impostor
  50596. * @param impostor impostor to set velocity iterations on
  50597. * @param velocityIterations velocityIterations value
  50598. */
  50599. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50600. /**
  50601. * Gets positionIterations of the impostor
  50602. * @param impostor impostor to get position iterations from
  50603. * @returns positionIterations value
  50604. */
  50605. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50606. /**
  50607. * Sets positionIterations of the impostor
  50608. * @param impostor impostor to set position on
  50609. * @param positionIterations positionIterations value
  50610. */
  50611. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50612. /**
  50613. * Append an anchor to a cloth object
  50614. * @param impostor is the cloth impostor to add anchor to
  50615. * @param otherImpostor is the rigid impostor to anchor to
  50616. * @param width ratio across width from 0 to 1
  50617. * @param height ratio up height from 0 to 1
  50618. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50620. */
  50621. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50622. /**
  50623. * Append an hook to a rope object
  50624. * @param impostor is the rope impostor to add hook to
  50625. * @param otherImpostor is the rigid impostor to hook to
  50626. * @param length ratio along the rope from 0 to 1
  50627. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50628. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50629. */
  50630. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50631. /**
  50632. * Sleeps the physics body and stops it from being active
  50633. * @param impostor impostor to sleep
  50634. */
  50635. sleepBody(impostor: PhysicsImpostor): void;
  50636. /**
  50637. * Activates the physics body
  50638. * @param impostor impostor to activate
  50639. */
  50640. wakeUpBody(impostor: PhysicsImpostor): void;
  50641. /**
  50642. * Updates the distance parameters of the joint
  50643. * @param joint joint to update
  50644. * @param maxDistance maximum distance of the joint
  50645. * @param minDistance minimum distance of the joint
  50646. */
  50647. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50648. /**
  50649. * Sets a motor on the joint
  50650. * @param joint joint to set motor on
  50651. * @param speed speed of the motor
  50652. * @param maxForce maximum force of the motor
  50653. * @param motorIndex index of the motor
  50654. */
  50655. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50656. /**
  50657. * Sets the motors limit
  50658. * @param joint joint to set limit on
  50659. * @param upperLimit upper limit
  50660. * @param lowerLimit lower limit
  50661. */
  50662. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50663. /**
  50664. * Syncs the position and rotation of a mesh with the impostor
  50665. * @param mesh mesh to sync
  50666. * @param impostor impostor to update the mesh with
  50667. */
  50668. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50669. /**
  50670. * Gets the radius of the impostor
  50671. * @param impostor impostor to get radius from
  50672. * @returns the radius
  50673. */
  50674. getRadius(impostor: PhysicsImpostor): number;
  50675. /**
  50676. * Gets the box size of the impostor
  50677. * @param impostor impostor to get box size from
  50678. * @param result the resulting box size
  50679. */
  50680. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50681. /**
  50682. * Disposes of the impostor
  50683. */
  50684. dispose(): void;
  50685. /**
  50686. * Does a raycast in the physics world
  50687. * @param from when should the ray start?
  50688. * @param to when should the ray end?
  50689. * @returns PhysicsRaycastResult
  50690. */
  50691. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50692. }
  50693. }
  50694. declare module BABYLON {
  50695. interface AbstractScene {
  50696. /**
  50697. * The list of reflection probes added to the scene
  50698. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50699. */
  50700. reflectionProbes: Array<ReflectionProbe>;
  50701. /**
  50702. * Removes the given reflection probe from this scene.
  50703. * @param toRemove The reflection probe to remove
  50704. * @returns The index of the removed reflection probe
  50705. */
  50706. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50707. /**
  50708. * Adds the given reflection probe to this scene.
  50709. * @param newReflectionProbe The reflection probe to add
  50710. */
  50711. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50712. }
  50713. /**
  50714. * Class used to generate realtime reflection / refraction cube textures
  50715. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50716. */
  50717. export class ReflectionProbe {
  50718. /** defines the name of the probe */
  50719. name: string;
  50720. private _scene;
  50721. private _renderTargetTexture;
  50722. private _projectionMatrix;
  50723. private _viewMatrix;
  50724. private _target;
  50725. private _add;
  50726. private _attachedMesh;
  50727. private _invertYAxis;
  50728. /** Gets or sets probe position (center of the cube map) */
  50729. position: Vector3;
  50730. /**
  50731. * Creates a new reflection probe
  50732. * @param name defines the name of the probe
  50733. * @param size defines the texture resolution (for each face)
  50734. * @param scene defines the hosting scene
  50735. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50736. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50737. */
  50738. constructor(
  50739. /** defines the name of the probe */
  50740. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50741. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50742. samples: number;
  50743. /** Gets or sets the refresh rate to use (on every frame by default) */
  50744. refreshRate: number;
  50745. /**
  50746. * Gets the hosting scene
  50747. * @returns a Scene
  50748. */
  50749. getScene(): Scene;
  50750. /** Gets the internal CubeTexture used to render to */
  50751. readonly cubeTexture: RenderTargetTexture;
  50752. /** Gets the list of meshes to render */
  50753. readonly renderList: Nullable<AbstractMesh[]>;
  50754. /**
  50755. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50756. * @param mesh defines the mesh to attach to
  50757. */
  50758. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50759. /**
  50760. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50761. * @param renderingGroupId The rendering group id corresponding to its index
  50762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50763. */
  50764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50765. /**
  50766. * Clean all associated resources
  50767. */
  50768. dispose(): void;
  50769. /**
  50770. * Converts the reflection probe information to a readable string for debug purpose.
  50771. * @param fullDetails Supports for multiple levels of logging within scene loading
  50772. * @returns the human readable reflection probe info
  50773. */
  50774. toString(fullDetails?: boolean): string;
  50775. /**
  50776. * Get the class name of the relfection probe.
  50777. * @returns "ReflectionProbe"
  50778. */
  50779. getClassName(): string;
  50780. /**
  50781. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50782. * @returns The JSON representation of the texture
  50783. */
  50784. serialize(): any;
  50785. /**
  50786. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50787. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50788. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50789. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50790. * @returns The parsed reflection probe if successful
  50791. */
  50792. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50793. }
  50794. }
  50795. declare module BABYLON {
  50796. /** @hidden */
  50797. export var _BabylonLoaderRegistered: boolean;
  50798. }
  50799. declare module BABYLON {
  50800. /**
  50801. * The Physically based simple base material of BJS.
  50802. *
  50803. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50804. * It is used as the base class for both the specGloss and metalRough conventions.
  50805. */
  50806. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50807. /**
  50808. * Number of Simultaneous lights allowed on the material.
  50809. */
  50810. maxSimultaneousLights: number;
  50811. /**
  50812. * If sets to true, disables all the lights affecting the material.
  50813. */
  50814. disableLighting: boolean;
  50815. /**
  50816. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50817. */
  50818. environmentTexture: BaseTexture;
  50819. /**
  50820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50821. */
  50822. invertNormalMapX: boolean;
  50823. /**
  50824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50825. */
  50826. invertNormalMapY: boolean;
  50827. /**
  50828. * Normal map used in the model.
  50829. */
  50830. normalTexture: BaseTexture;
  50831. /**
  50832. * Emissivie color used to self-illuminate the model.
  50833. */
  50834. emissiveColor: Color3;
  50835. /**
  50836. * Emissivie texture used to self-illuminate the model.
  50837. */
  50838. emissiveTexture: BaseTexture;
  50839. /**
  50840. * Occlusion Channel Strenght.
  50841. */
  50842. occlusionStrength: number;
  50843. /**
  50844. * Occlusion Texture of the material (adding extra occlusion effects).
  50845. */
  50846. occlusionTexture: BaseTexture;
  50847. /**
  50848. * Defines the alpha limits in alpha test mode.
  50849. */
  50850. alphaCutOff: number;
  50851. /**
  50852. * Gets the current double sided mode.
  50853. */
  50854. /**
  50855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50856. */
  50857. doubleSided: boolean;
  50858. /**
  50859. * Stores the pre-calculated light information of a mesh in a texture.
  50860. */
  50861. lightmapTexture: BaseTexture;
  50862. /**
  50863. * If true, the light map contains occlusion information instead of lighting info.
  50864. */
  50865. useLightmapAsShadowmap: boolean;
  50866. /**
  50867. * Instantiates a new PBRMaterial instance.
  50868. *
  50869. * @param name The material name
  50870. * @param scene The scene the material will be use in.
  50871. */
  50872. constructor(name: string, scene: Scene);
  50873. getClassName(): string;
  50874. }
  50875. }
  50876. declare module BABYLON {
  50877. /**
  50878. * The PBR material of BJS following the metal roughness convention.
  50879. *
  50880. * This fits to the PBR convention in the GLTF definition:
  50881. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50882. */
  50883. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50884. /**
  50885. * The base color has two different interpretations depending on the value of metalness.
  50886. * When the material is a metal, the base color is the specific measured reflectance value
  50887. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50888. * of the material.
  50889. */
  50890. baseColor: Color3;
  50891. /**
  50892. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50893. * well as opacity information in the alpha channel.
  50894. */
  50895. baseTexture: BaseTexture;
  50896. /**
  50897. * Specifies the metallic scalar value of the material.
  50898. * Can also be used to scale the metalness values of the metallic texture.
  50899. */
  50900. metallic: number;
  50901. /**
  50902. * Specifies the roughness scalar value of the material.
  50903. * Can also be used to scale the roughness values of the metallic texture.
  50904. */
  50905. roughness: number;
  50906. /**
  50907. * Texture containing both the metallic value in the B channel and the
  50908. * roughness value in the G channel to keep better precision.
  50909. */
  50910. metallicRoughnessTexture: BaseTexture;
  50911. /**
  50912. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50913. *
  50914. * @param name The material name
  50915. * @param scene The scene the material will be use in.
  50916. */
  50917. constructor(name: string, scene: Scene);
  50918. /**
  50919. * Return the currrent class name of the material.
  50920. */
  50921. getClassName(): string;
  50922. /**
  50923. * Makes a duplicate of the current material.
  50924. * @param name - name to use for the new material.
  50925. */
  50926. clone(name: string): PBRMetallicRoughnessMaterial;
  50927. /**
  50928. * Serialize the material to a parsable JSON object.
  50929. */
  50930. serialize(): any;
  50931. /**
  50932. * Parses a JSON object correponding to the serialize function.
  50933. */
  50934. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50935. }
  50936. }
  50937. declare module BABYLON {
  50938. /**
  50939. * The PBR material of BJS following the specular glossiness convention.
  50940. *
  50941. * This fits to the PBR convention in the GLTF definition:
  50942. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50943. */
  50944. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50945. /**
  50946. * Specifies the diffuse color of the material.
  50947. */
  50948. diffuseColor: Color3;
  50949. /**
  50950. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50951. * channel.
  50952. */
  50953. diffuseTexture: BaseTexture;
  50954. /**
  50955. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50956. */
  50957. specularColor: Color3;
  50958. /**
  50959. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50960. */
  50961. glossiness: number;
  50962. /**
  50963. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50964. */
  50965. specularGlossinessTexture: BaseTexture;
  50966. /**
  50967. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50968. *
  50969. * @param name The material name
  50970. * @param scene The scene the material will be use in.
  50971. */
  50972. constructor(name: string, scene: Scene);
  50973. /**
  50974. * Return the currrent class name of the material.
  50975. */
  50976. getClassName(): string;
  50977. /**
  50978. * Makes a duplicate of the current material.
  50979. * @param name - name to use for the new material.
  50980. */
  50981. clone(name: string): PBRSpecularGlossinessMaterial;
  50982. /**
  50983. * Serialize the material to a parsable JSON object.
  50984. */
  50985. serialize(): any;
  50986. /**
  50987. * Parses a JSON object correponding to the serialize function.
  50988. */
  50989. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50990. }
  50991. }
  50992. declare module BABYLON {
  50993. /**
  50994. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50995. * It can help converting any input color in a desired output one. This can then be used to create effects
  50996. * from sepia, black and white to sixties or futuristic rendering...
  50997. *
  50998. * The only supported format is currently 3dl.
  50999. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51000. */
  51001. export class ColorGradingTexture extends BaseTexture {
  51002. /**
  51003. * The current texture matrix. (will always be identity in color grading texture)
  51004. */
  51005. private _textureMatrix;
  51006. /**
  51007. * The texture URL.
  51008. */
  51009. url: string;
  51010. /**
  51011. * Empty line regex stored for GC.
  51012. */
  51013. private static _noneEmptyLineRegex;
  51014. private _engine;
  51015. /**
  51016. * Instantiates a ColorGradingTexture from the following parameters.
  51017. *
  51018. * @param url The location of the color gradind data (currently only supporting 3dl)
  51019. * @param scene The scene the texture will be used in
  51020. */
  51021. constructor(url: string, scene: Scene);
  51022. /**
  51023. * Returns the texture matrix used in most of the material.
  51024. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51025. */
  51026. getTextureMatrix(): Matrix;
  51027. /**
  51028. * Occurs when the file being loaded is a .3dl LUT file.
  51029. */
  51030. private load3dlTexture;
  51031. /**
  51032. * Starts the loading process of the texture.
  51033. */
  51034. private loadTexture;
  51035. /**
  51036. * Clones the color gradind texture.
  51037. */
  51038. clone(): ColorGradingTexture;
  51039. /**
  51040. * Called during delayed load for textures.
  51041. */
  51042. delayLoad(): void;
  51043. /**
  51044. * Parses a color grading texture serialized by Babylon.
  51045. * @param parsedTexture The texture information being parsedTexture
  51046. * @param scene The scene to load the texture in
  51047. * @param rootUrl The root url of the data assets to load
  51048. * @return A color gradind texture
  51049. */
  51050. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51051. /**
  51052. * Serializes the LUT texture to json format.
  51053. */
  51054. serialize(): any;
  51055. }
  51056. }
  51057. declare module BABYLON {
  51058. /**
  51059. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51060. */
  51061. export class EquiRectangularCubeTexture extends BaseTexture {
  51062. /** The six faces of the cube. */
  51063. private static _FacesMapping;
  51064. private _noMipmap;
  51065. private _onLoad;
  51066. private _onError;
  51067. /** The size of the cubemap. */
  51068. private _size;
  51069. /** The buffer of the image. */
  51070. private _buffer;
  51071. /** The width of the input image. */
  51072. private _width;
  51073. /** The height of the input image. */
  51074. private _height;
  51075. /** The URL to the image. */
  51076. url: string;
  51077. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51078. coordinatesMode: number;
  51079. /**
  51080. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51081. * @param url The location of the image
  51082. * @param scene The scene the texture will be used in
  51083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51084. * @param noMipmap Forces to not generate the mipmap if true
  51085. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51086. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51087. * @param onLoad — defines a callback called when texture is loaded
  51088. * @param onError — defines a callback called if there is an error
  51089. */
  51090. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51091. /**
  51092. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51093. */
  51094. private loadImage;
  51095. /**
  51096. * Convert the image buffer into a cubemap and create a CubeTexture.
  51097. */
  51098. private loadTexture;
  51099. /**
  51100. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51101. * @param buffer The ArrayBuffer that should be converted.
  51102. * @returns The buffer as Float32Array.
  51103. */
  51104. private getFloat32ArrayFromArrayBuffer;
  51105. /**
  51106. * Get the current class name of the texture useful for serialization or dynamic coding.
  51107. * @returns "EquiRectangularCubeTexture"
  51108. */
  51109. getClassName(): string;
  51110. /**
  51111. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51112. * @returns A clone of the current EquiRectangularCubeTexture.
  51113. */
  51114. clone(): EquiRectangularCubeTexture;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * Based on jsTGALoader - Javascript loader for TGA file
  51120. * By Vincent Thibault
  51121. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51122. */
  51123. export class TGATools {
  51124. private static _TYPE_INDEXED;
  51125. private static _TYPE_RGB;
  51126. private static _TYPE_GREY;
  51127. private static _TYPE_RLE_INDEXED;
  51128. private static _TYPE_RLE_RGB;
  51129. private static _TYPE_RLE_GREY;
  51130. private static _ORIGIN_MASK;
  51131. private static _ORIGIN_SHIFT;
  51132. private static _ORIGIN_BL;
  51133. private static _ORIGIN_BR;
  51134. private static _ORIGIN_UL;
  51135. private static _ORIGIN_UR;
  51136. /**
  51137. * Gets the header of a TGA file
  51138. * @param data defines the TGA data
  51139. * @returns the header
  51140. */
  51141. static GetTGAHeader(data: Uint8Array): any;
  51142. /**
  51143. * Uploads TGA content to a Babylon Texture
  51144. * @hidden
  51145. */
  51146. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51147. /** @hidden */
  51148. 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;
  51149. /** @hidden */
  51150. 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;
  51151. /** @hidden */
  51152. 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;
  51153. /** @hidden */
  51154. 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;
  51155. /** @hidden */
  51156. 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;
  51157. /** @hidden */
  51158. 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;
  51159. }
  51160. }
  51161. declare module BABYLON {
  51162. /**
  51163. * Implementation of the TGA Texture Loader.
  51164. * @hidden
  51165. */
  51166. export class _TGATextureLoader implements IInternalTextureLoader {
  51167. /**
  51168. * Defines wether the loader supports cascade loading the different faces.
  51169. */
  51170. readonly supportCascades: boolean;
  51171. /**
  51172. * This returns if the loader support the current file information.
  51173. * @param extension defines the file extension of the file being loaded
  51174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51175. * @param fallback defines the fallback internal texture if any
  51176. * @param isBase64 defines whether the texture is encoded as a base64
  51177. * @param isBuffer defines whether the texture data are stored as a buffer
  51178. * @returns true if the loader can load the specified file
  51179. */
  51180. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51181. /**
  51182. * Transform the url before loading if required.
  51183. * @param rootUrl the url of the texture
  51184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51185. * @returns the transformed texture
  51186. */
  51187. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51188. /**
  51189. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51190. * @param rootUrl the url of the texture
  51191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51192. * @returns the fallback texture
  51193. */
  51194. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51195. /**
  51196. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51197. * @param data contains the texture data
  51198. * @param texture defines the BabylonJS internal texture
  51199. * @param createPolynomials will be true if polynomials have been requested
  51200. * @param onLoad defines the callback to trigger once the texture is ready
  51201. * @param onError defines the callback to trigger in case of error
  51202. */
  51203. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51204. /**
  51205. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51206. * @param data contains the texture data
  51207. * @param texture defines the BabylonJS internal texture
  51208. * @param callback defines the method to call once ready to upload
  51209. */
  51210. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. /**
  51215. * Info about the .basis files
  51216. */
  51217. class BasisFileInfo {
  51218. /**
  51219. * If the file has alpha
  51220. */
  51221. hasAlpha: boolean;
  51222. /**
  51223. * Info about each image of the basis file
  51224. */
  51225. images: Array<{
  51226. levels: Array<{
  51227. width: number;
  51228. height: number;
  51229. transcodedPixels: ArrayBufferView;
  51230. }>;
  51231. }>;
  51232. }
  51233. /**
  51234. * Result of transcoding a basis file
  51235. */
  51236. class TranscodeResult {
  51237. /**
  51238. * Info about the .basis file
  51239. */
  51240. fileInfo: BasisFileInfo;
  51241. /**
  51242. * Format to use when loading the file
  51243. */
  51244. format: number;
  51245. }
  51246. /**
  51247. * Configuration options for the Basis transcoder
  51248. */
  51249. export class BasisTranscodeConfiguration {
  51250. /**
  51251. * Supported compression formats used to determine the supported output format of the transcoder
  51252. */
  51253. supportedCompressionFormats?: {
  51254. /**
  51255. * etc1 compression format
  51256. */
  51257. etc1?: boolean;
  51258. /**
  51259. * s3tc compression format
  51260. */
  51261. s3tc?: boolean;
  51262. /**
  51263. * pvrtc compression format
  51264. */
  51265. pvrtc?: boolean;
  51266. /**
  51267. * etc2 compression format
  51268. */
  51269. etc2?: boolean;
  51270. };
  51271. /**
  51272. * If mipmap levels should be loaded for transcoded images (Default: true)
  51273. */
  51274. loadMipmapLevels?: boolean;
  51275. /**
  51276. * Index of a single image to load (Default: all images)
  51277. */
  51278. loadSingleImage?: number;
  51279. }
  51280. /**
  51281. * Used to load .Basis files
  51282. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51283. */
  51284. export class BasisTools {
  51285. private static _IgnoreSupportedFormats;
  51286. /**
  51287. * URL to use when loading the basis transcoder
  51288. */
  51289. static JSModuleURL: string;
  51290. /**
  51291. * URL to use when loading the wasm module for the transcoder
  51292. */
  51293. static WasmModuleURL: string;
  51294. /**
  51295. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51296. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51297. * @returns internal format corresponding to the Basis format
  51298. */
  51299. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51300. private static _WorkerPromise;
  51301. private static _Worker;
  51302. private static _actionId;
  51303. private static _CreateWorkerAsync;
  51304. /**
  51305. * Transcodes a loaded image file to compressed pixel data
  51306. * @param imageData image data to transcode
  51307. * @param config configuration options for the transcoding
  51308. * @returns a promise resulting in the transcoded image
  51309. */
  51310. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51311. /**
  51312. * Loads a texture from the transcode result
  51313. * @param texture texture load to
  51314. * @param transcodeResult the result of transcoding the basis file to load from
  51315. */
  51316. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51317. }
  51318. }
  51319. declare module BABYLON {
  51320. /**
  51321. * Loader for .basis file format
  51322. */
  51323. export class _BasisTextureLoader implements IInternalTextureLoader {
  51324. /**
  51325. * Defines whether the loader supports cascade loading the different faces.
  51326. */
  51327. readonly supportCascades: boolean;
  51328. /**
  51329. * This returns if the loader support the current file information.
  51330. * @param extension defines the file extension of the file being loaded
  51331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51332. * @param fallback defines the fallback internal texture if any
  51333. * @param isBase64 defines whether the texture is encoded as a base64
  51334. * @param isBuffer defines whether the texture data are stored as a buffer
  51335. * @returns true if the loader can load the specified file
  51336. */
  51337. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51338. /**
  51339. * Transform the url before loading if required.
  51340. * @param rootUrl the url of the texture
  51341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51342. * @returns the transformed texture
  51343. */
  51344. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51345. /**
  51346. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51347. * @param rootUrl the url of the texture
  51348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51349. * @returns the fallback texture
  51350. */
  51351. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51352. /**
  51353. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51354. * @param data contains the texture data
  51355. * @param texture defines the BabylonJS internal texture
  51356. * @param createPolynomials will be true if polynomials have been requested
  51357. * @param onLoad defines the callback to trigger once the texture is ready
  51358. * @param onError defines the callback to trigger in case of error
  51359. */
  51360. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51361. /**
  51362. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51363. * @param data contains the texture data
  51364. * @param texture defines the BabylonJS internal texture
  51365. * @param callback defines the method to call once ready to upload
  51366. */
  51367. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51368. }
  51369. }
  51370. declare module BABYLON {
  51371. /**
  51372. * 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.
  51373. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51374. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51375. */
  51376. export class CustomProceduralTexture extends ProceduralTexture {
  51377. private _animate;
  51378. private _time;
  51379. private _config;
  51380. private _texturePath;
  51381. /**
  51382. * Instantiates a new Custom Procedural Texture.
  51383. * 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.
  51384. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51385. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51386. * @param name Define the name of the texture
  51387. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51388. * @param size Define the size of the texture to create
  51389. * @param scene Define the scene the texture belongs to
  51390. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51391. * @param generateMipMaps Define if the texture should creates mip maps or not
  51392. */
  51393. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51394. private _loadJson;
  51395. /**
  51396. * Is the texture ready to be used ? (rendered at least once)
  51397. * @returns true if ready, otherwise, false.
  51398. */
  51399. isReady(): boolean;
  51400. /**
  51401. * Render the texture to its associated render target.
  51402. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51403. */
  51404. render(useCameraPostProcess?: boolean): void;
  51405. /**
  51406. * Update the list of dependant textures samplers in the shader.
  51407. */
  51408. updateTextures(): void;
  51409. /**
  51410. * Update the uniform values of the procedural texture in the shader.
  51411. */
  51412. updateShaderUniforms(): void;
  51413. /**
  51414. * Define if the texture animates or not.
  51415. */
  51416. animate: boolean;
  51417. }
  51418. }
  51419. declare module BABYLON {
  51420. /** @hidden */
  51421. export var noisePixelShader: {
  51422. name: string;
  51423. shader: string;
  51424. };
  51425. }
  51426. declare module BABYLON {
  51427. /**
  51428. * Class used to generate noise procedural textures
  51429. */
  51430. export class NoiseProceduralTexture extends ProceduralTexture {
  51431. private _time;
  51432. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51433. brightness: number;
  51434. /** Defines the number of octaves to process */
  51435. octaves: number;
  51436. /** Defines the level of persistence (0.8 by default) */
  51437. persistence: number;
  51438. /** Gets or sets animation speed factor (default is 1) */
  51439. animationSpeedFactor: number;
  51440. /**
  51441. * Creates a new NoiseProceduralTexture
  51442. * @param name defines the name fo the texture
  51443. * @param size defines the size of the texture (default is 256)
  51444. * @param scene defines the hosting scene
  51445. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51446. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51447. */
  51448. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51449. private _updateShaderUniforms;
  51450. protected _getDefines(): string;
  51451. /** Generate the current state of the procedural texture */
  51452. render(useCameraPostProcess?: boolean): void;
  51453. /**
  51454. * Serializes this noise procedural texture
  51455. * @returns a serialized noise procedural texture object
  51456. */
  51457. serialize(): any;
  51458. /**
  51459. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51460. * @param parsedTexture defines parsed texture data
  51461. * @param scene defines the current scene
  51462. * @param rootUrl defines the root URL containing noise procedural texture information
  51463. * @returns a parsed NoiseProceduralTexture
  51464. */
  51465. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51466. }
  51467. }
  51468. declare module BABYLON {
  51469. /**
  51470. * Raw cube texture where the raw buffers are passed in
  51471. */
  51472. export class RawCubeTexture extends CubeTexture {
  51473. /**
  51474. * Creates a cube texture where the raw buffers are passed in.
  51475. * @param scene defines the scene the texture is attached to
  51476. * @param data defines the array of data to use to create each face
  51477. * @param size defines the size of the textures
  51478. * @param format defines the format of the data
  51479. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51480. * @param generateMipMaps defines if the engine should generate the mip levels
  51481. * @param invertY defines if data must be stored with Y axis inverted
  51482. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51483. * @param compression defines the compression used (null by default)
  51484. */
  51485. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51486. /**
  51487. * Updates the raw cube texture.
  51488. * @param data defines the data to store
  51489. * @param format defines the data format
  51490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51491. * @param invertY defines if data must be stored with Y axis inverted
  51492. * @param compression defines the compression used (null by default)
  51493. * @param level defines which level of the texture to update
  51494. */
  51495. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51496. /**
  51497. * Updates a raw cube texture with RGBD encoded data.
  51498. * @param data defines the array of data [mipmap][face] to use to create each face
  51499. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51500. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51501. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51502. * @returns a promsie that resolves when the operation is complete
  51503. */
  51504. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51505. /**
  51506. * Clones the raw cube texture.
  51507. * @return a new cube texture
  51508. */
  51509. clone(): CubeTexture;
  51510. /** @hidden */
  51511. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51512. }
  51513. }
  51514. declare module BABYLON {
  51515. /**
  51516. * Class used to store 3D textures containing user data
  51517. */
  51518. export class RawTexture3D extends Texture {
  51519. /** Gets or sets the texture format to use */
  51520. format: number;
  51521. private _engine;
  51522. /**
  51523. * Create a new RawTexture3D
  51524. * @param data defines the data of the texture
  51525. * @param width defines the width of the texture
  51526. * @param height defines the height of the texture
  51527. * @param depth defines the depth of the texture
  51528. * @param format defines the texture format to use
  51529. * @param scene defines the hosting scene
  51530. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51531. * @param invertY defines if texture must be stored with Y axis inverted
  51532. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51533. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51534. */
  51535. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51536. /** Gets or sets the texture format to use */
  51537. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51538. /**
  51539. * Update the texture with new data
  51540. * @param data defines the data to store in the texture
  51541. */
  51542. update(data: ArrayBufferView): void;
  51543. }
  51544. }
  51545. declare module BABYLON {
  51546. /**
  51547. * Creates a refraction texture used by refraction channel of the standard material.
  51548. * It is like a mirror but to see through a material.
  51549. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51550. */
  51551. export class RefractionTexture extends RenderTargetTexture {
  51552. /**
  51553. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51554. * 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.
  51555. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51556. */
  51557. refractionPlane: Plane;
  51558. /**
  51559. * Define how deep under the surface we should see.
  51560. */
  51561. depth: number;
  51562. /**
  51563. * Creates a refraction texture used by refraction channel of the standard material.
  51564. * It is like a mirror but to see through a material.
  51565. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51566. * @param name Define the texture name
  51567. * @param size Define the size of the underlying texture
  51568. * @param scene Define the scene the refraction belongs to
  51569. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51570. */
  51571. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51572. /**
  51573. * Clone the refraction texture.
  51574. * @returns the cloned texture
  51575. */
  51576. clone(): RefractionTexture;
  51577. /**
  51578. * Serialize the texture to a JSON representation you could use in Parse later on
  51579. * @returns the serialized JSON representation
  51580. */
  51581. serialize(): any;
  51582. }
  51583. }
  51584. declare module BABYLON {
  51585. /**
  51586. * Defines the options related to the creation of an HtmlElementTexture
  51587. */
  51588. export interface IHtmlElementTextureOptions {
  51589. /**
  51590. * Defines wether mip maps should be created or not.
  51591. */
  51592. generateMipMaps?: boolean;
  51593. /**
  51594. * Defines the sampling mode of the texture.
  51595. */
  51596. samplingMode?: number;
  51597. /**
  51598. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51599. */
  51600. engine: Nullable<Engine>;
  51601. /**
  51602. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51603. */
  51604. scene: Nullable<Scene>;
  51605. }
  51606. /**
  51607. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51608. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51609. * is automatically managed.
  51610. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51611. * in your application.
  51612. *
  51613. * As the update is not automatic, you need to call them manually.
  51614. */
  51615. export class HtmlElementTexture extends BaseTexture {
  51616. /**
  51617. * The texture URL.
  51618. */
  51619. element: HTMLVideoElement | HTMLCanvasElement;
  51620. private static readonly DefaultOptions;
  51621. private _textureMatrix;
  51622. private _engine;
  51623. private _isVideo;
  51624. private _generateMipMaps;
  51625. private _samplingMode;
  51626. /**
  51627. * Instantiates a HtmlElementTexture from the following parameters.
  51628. *
  51629. * @param name Defines the name of the texture
  51630. * @param element Defines the video or canvas the texture is filled with
  51631. * @param options Defines the other none mandatory texture creation options
  51632. */
  51633. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51634. private _createInternalTexture;
  51635. /**
  51636. * Returns the texture matrix used in most of the material.
  51637. */
  51638. getTextureMatrix(): Matrix;
  51639. /**
  51640. * Updates the content of the texture.
  51641. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51642. */
  51643. update(invertY?: Nullable<boolean>): void;
  51644. }
  51645. }
  51646. declare module BABYLON {
  51647. /**
  51648. * Enum used to define the target of a block
  51649. */
  51650. export enum NodeMaterialBlockTargets {
  51651. /** Vertex shader */
  51652. Vertex = 1,
  51653. /** Fragment shader */
  51654. Fragment = 2,
  51655. /** Neutral */
  51656. Neutral = 4,
  51657. /** Vertex and Fragment */
  51658. VertexAndFragment = 3
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /**
  51663. * Defines the kind of connection point for node based material
  51664. */
  51665. export enum NodeMaterialBlockConnectionPointTypes {
  51666. /** Float */
  51667. Float = 1,
  51668. /** Int */
  51669. Int = 2,
  51670. /** Vector2 */
  51671. Vector2 = 4,
  51672. /** Vector3 */
  51673. Vector3 = 8,
  51674. /** Vector4 */
  51675. Vector4 = 16,
  51676. /** Color3 */
  51677. Color3 = 32,
  51678. /** Color4 */
  51679. Color4 = 64,
  51680. /** Matrix */
  51681. Matrix = 128,
  51682. /** Detect type based on connection */
  51683. AutoDetect = 1024,
  51684. /** Output type that will be defined by input type */
  51685. BasedOnInput = 2048
  51686. }
  51687. }
  51688. declare module BABYLON {
  51689. /**
  51690. * Root class for all node material optimizers
  51691. */
  51692. export class NodeMaterialOptimizer {
  51693. /**
  51694. * Function used to optimize a NodeMaterial graph
  51695. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51696. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51697. */
  51698. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51704. */
  51705. export class TransformBlock extends NodeMaterialBlock {
  51706. /**
  51707. * Defines the value to use to complement W value to transform it to a Vector4
  51708. */
  51709. complementW: number;
  51710. /**
  51711. * Defines the value to use to complement z value to transform it to a Vector4
  51712. */
  51713. complementZ: number;
  51714. /**
  51715. * Creates a new TransformBlock
  51716. * @param name defines the block name
  51717. */
  51718. constructor(name: string);
  51719. /**
  51720. * Gets the current class name
  51721. * @returns the class name
  51722. */
  51723. getClassName(): string;
  51724. /**
  51725. * Gets the vector input
  51726. */
  51727. readonly vector: NodeMaterialConnectionPoint;
  51728. /**
  51729. * Gets the output component
  51730. */
  51731. readonly output: NodeMaterialConnectionPoint;
  51732. /**
  51733. * Gets the matrix transform input
  51734. */
  51735. readonly transform: NodeMaterialConnectionPoint;
  51736. protected _buildBlock(state: NodeMaterialBuildState): this;
  51737. serialize(): any;
  51738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51739. protected _dumpPropertiesCode(): string;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Block used to output the vertex position
  51745. */
  51746. export class VertexOutputBlock extends NodeMaterialBlock {
  51747. /**
  51748. * Creates a new VertexOutputBlock
  51749. * @param name defines the block name
  51750. */
  51751. constructor(name: string);
  51752. /**
  51753. * Gets the current class name
  51754. * @returns the class name
  51755. */
  51756. getClassName(): string;
  51757. /**
  51758. * Gets the vector input component
  51759. */
  51760. readonly vector: NodeMaterialConnectionPoint;
  51761. protected _buildBlock(state: NodeMaterialBuildState): this;
  51762. }
  51763. }
  51764. declare module BABYLON {
  51765. /**
  51766. * Block used to output the final color
  51767. */
  51768. export class FragmentOutputBlock extends NodeMaterialBlock {
  51769. /**
  51770. * Create a new FragmentOutputBlock
  51771. * @param name defines the block name
  51772. */
  51773. constructor(name: string);
  51774. /**
  51775. * Gets the current class name
  51776. * @returns the class name
  51777. */
  51778. getClassName(): string;
  51779. /**
  51780. * Gets the rgba input component
  51781. */
  51782. readonly rgba: NodeMaterialConnectionPoint;
  51783. /**
  51784. * Gets the rgb input component
  51785. */
  51786. readonly rgb: NodeMaterialConnectionPoint;
  51787. /**
  51788. * Gets the a input component
  51789. */
  51790. readonly a: NodeMaterialConnectionPoint;
  51791. protected _buildBlock(state: NodeMaterialBuildState): this;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * Enum used to define well known values e.g. values automatically provided by the system
  51797. */
  51798. export enum NodeMaterialWellKnownValues {
  51799. /** World */
  51800. World = 1,
  51801. /** View */
  51802. View = 2,
  51803. /** Projection */
  51804. Projection = 3,
  51805. /** ViewProjection */
  51806. ViewProjection = 4,
  51807. /** WorldView */
  51808. WorldView = 5,
  51809. /** WorldViewProjection */
  51810. WorldViewProjection = 6,
  51811. /** CameraPosition */
  51812. CameraPosition = 7,
  51813. /** Fog Color */
  51814. FogColor = 8
  51815. }
  51816. }
  51817. declare module BABYLON {
  51818. /**
  51819. * Block used to read a reflection texture from a sampler
  51820. */
  51821. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51822. private _define3DName;
  51823. private _defineCubicName;
  51824. private _defineExplicitName;
  51825. private _defineProjectionName;
  51826. private _defineLocalCubicName;
  51827. private _defineSphericalName;
  51828. private _definePlanarName;
  51829. private _defineEquirectangularName;
  51830. private _defineMirroredEquirectangularFixedName;
  51831. private _defineEquirectangularFixedName;
  51832. private _defineSkyboxName;
  51833. private _cubeSamplerName;
  51834. private _2DSamplerName;
  51835. private _positionUVWName;
  51836. private _directionWName;
  51837. private _reflectionCoordsName;
  51838. private _reflection2DCoordsName;
  51839. private _reflectionColorName;
  51840. private _reflectionMatrixName;
  51841. /**
  51842. * Gets or sets the texture associated with the node
  51843. */
  51844. texture: Nullable<BaseTexture>;
  51845. /**
  51846. * Create a new TextureBlock
  51847. * @param name defines the block name
  51848. */
  51849. constructor(name: string);
  51850. /**
  51851. * Gets the current class name
  51852. * @returns the class name
  51853. */
  51854. getClassName(): string;
  51855. /**
  51856. * Gets the world position input component
  51857. */
  51858. readonly position: NodeMaterialConnectionPoint;
  51859. /**
  51860. * Gets the world position input component
  51861. */
  51862. readonly worldPosition: NodeMaterialConnectionPoint;
  51863. /**
  51864. * Gets the world normal input component
  51865. */
  51866. readonly worldNormal: NodeMaterialConnectionPoint;
  51867. /**
  51868. * Gets the world input component
  51869. */
  51870. readonly world: NodeMaterialConnectionPoint;
  51871. /**
  51872. * Gets the camera (or eye) position component
  51873. */
  51874. readonly cameraPosition: NodeMaterialConnectionPoint;
  51875. /**
  51876. * Gets the view input component
  51877. */
  51878. readonly view: NodeMaterialConnectionPoint;
  51879. /**
  51880. * Gets the rgb output component
  51881. */
  51882. readonly rgb: NodeMaterialConnectionPoint;
  51883. /**
  51884. * Gets the r output component
  51885. */
  51886. readonly r: NodeMaterialConnectionPoint;
  51887. /**
  51888. * Gets the g output component
  51889. */
  51890. readonly g: NodeMaterialConnectionPoint;
  51891. /**
  51892. * Gets the b output component
  51893. */
  51894. readonly b: NodeMaterialConnectionPoint;
  51895. autoConfigure(material: NodeMaterial): void;
  51896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51897. isReady(): boolean;
  51898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51899. private _injectVertexCode;
  51900. private _writeOutput;
  51901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51902. serialize(): any;
  51903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. /**
  51908. * Interface used to configure the node material editor
  51909. */
  51910. export interface INodeMaterialEditorOptions {
  51911. /** Define the URl to load node editor script */
  51912. editorURL?: string;
  51913. }
  51914. /** @hidden */
  51915. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51916. /** BONES */
  51917. NUM_BONE_INFLUENCERS: number;
  51918. BonesPerMesh: number;
  51919. BONETEXTURE: boolean;
  51920. /** MORPH TARGETS */
  51921. MORPHTARGETS: boolean;
  51922. MORPHTARGETS_NORMAL: boolean;
  51923. MORPHTARGETS_TANGENT: boolean;
  51924. MORPHTARGETS_UV: boolean;
  51925. NUM_MORPH_INFLUENCERS: number;
  51926. /** IMAGE PROCESSING */
  51927. IMAGEPROCESSING: boolean;
  51928. VIGNETTE: boolean;
  51929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51930. VIGNETTEBLENDMODEOPAQUE: boolean;
  51931. TONEMAPPING: boolean;
  51932. TONEMAPPING_ACES: boolean;
  51933. CONTRAST: boolean;
  51934. EXPOSURE: boolean;
  51935. COLORCURVES: boolean;
  51936. COLORGRADING: boolean;
  51937. COLORGRADING3D: boolean;
  51938. SAMPLER3DGREENDEPTH: boolean;
  51939. SAMPLER3DBGRMAP: boolean;
  51940. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51941. constructor();
  51942. setValue(name: string, value: boolean): void;
  51943. }
  51944. /**
  51945. * Class used to configure NodeMaterial
  51946. */
  51947. export interface INodeMaterialOptions {
  51948. /**
  51949. * Defines if blocks should emit comments
  51950. */
  51951. emitComments: boolean;
  51952. }
  51953. /**
  51954. * Class used to create a node based material built by assembling shader blocks
  51955. */
  51956. export class NodeMaterial extends PushMaterial {
  51957. private static _BuildIdGenerator;
  51958. private _options;
  51959. private _vertexCompilationState;
  51960. private _fragmentCompilationState;
  51961. private _sharedData;
  51962. private _buildId;
  51963. private _buildWasSuccessful;
  51964. private _cachedWorldViewMatrix;
  51965. private _cachedWorldViewProjectionMatrix;
  51966. private _optimizers;
  51967. private _animationFrame;
  51968. /** Define the URl to load node editor script */
  51969. static EditorURL: string;
  51970. private BJSNODEMATERIALEDITOR;
  51971. /** Get the inspector from bundle or global */
  51972. private _getGlobalNodeMaterialEditor;
  51973. /**
  51974. * 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)
  51975. */
  51976. ignoreAlpha: boolean;
  51977. /**
  51978. * Defines the maximum number of lights that can be used in the material
  51979. */
  51980. maxSimultaneousLights: number;
  51981. /**
  51982. * Observable raised when the material is built
  51983. */
  51984. onBuildObservable: Observable<NodeMaterial>;
  51985. /**
  51986. * Gets or sets the root nodes of the material vertex shader
  51987. */
  51988. _vertexOutputNodes: NodeMaterialBlock[];
  51989. /**
  51990. * Gets or sets the root nodes of the material fragment (pixel) shader
  51991. */
  51992. _fragmentOutputNodes: NodeMaterialBlock[];
  51993. /** Gets or sets options to control the node material overall behavior */
  51994. options: INodeMaterialOptions;
  51995. /**
  51996. * Default configuration related to image processing available in the standard Material.
  51997. */
  51998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51999. /**
  52000. * Gets the image processing configuration used either in this material.
  52001. */
  52002. /**
  52003. * Sets the Default image processing configuration used either in the this material.
  52004. *
  52005. * If sets to null, the scene one is in use.
  52006. */
  52007. imageProcessingConfiguration: ImageProcessingConfiguration;
  52008. /**
  52009. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52010. */
  52011. attachedBlocks: NodeMaterialBlock[];
  52012. /**
  52013. * Create a new node based material
  52014. * @param name defines the material name
  52015. * @param scene defines the hosting scene
  52016. * @param options defines creation option
  52017. */
  52018. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52019. /**
  52020. * Gets the current class name of the material e.g. "NodeMaterial"
  52021. * @returns the class name
  52022. */
  52023. getClassName(): string;
  52024. /**
  52025. * Keep track of the image processing observer to allow dispose and replace.
  52026. */
  52027. private _imageProcessingObserver;
  52028. /**
  52029. * Attaches a new image processing configuration to the Standard Material.
  52030. * @param configuration
  52031. */
  52032. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52033. /**
  52034. * Get a block by its name
  52035. * @param name defines the name of the block to retrieve
  52036. * @returns the required block or null if not found
  52037. */
  52038. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52039. /**
  52040. * Get a block by its name
  52041. * @param predicate defines the predicate used to find the good candidate
  52042. * @returns the required block or null if not found
  52043. */
  52044. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52045. /**
  52046. * Get an input block by its name
  52047. * @param predicate defines the predicate used to find the good candidate
  52048. * @returns the required input block or null if not found
  52049. */
  52050. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52051. /**
  52052. * Gets the list of input blocks attached to this material
  52053. * @returns an array of InputBlocks
  52054. */
  52055. getInputBlocks(): InputBlock[];
  52056. /**
  52057. * Adds a new optimizer to the list of optimizers
  52058. * @param optimizer defines the optimizers to add
  52059. * @returns the current material
  52060. */
  52061. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52062. /**
  52063. * Remove an optimizer from the list of optimizers
  52064. * @param optimizer defines the optimizers to remove
  52065. * @returns the current material
  52066. */
  52067. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52068. /**
  52069. * Add a new block to the list of output nodes
  52070. * @param node defines the node to add
  52071. * @returns the current material
  52072. */
  52073. addOutputNode(node: NodeMaterialBlock): this;
  52074. /**
  52075. * Remove a block from the list of root nodes
  52076. * @param node defines the node to remove
  52077. * @returns the current material
  52078. */
  52079. removeOutputNode(node: NodeMaterialBlock): this;
  52080. private _addVertexOutputNode;
  52081. private _removeVertexOutputNode;
  52082. private _addFragmentOutputNode;
  52083. private _removeFragmentOutputNode;
  52084. /**
  52085. * Specifies if the material will require alpha blending
  52086. * @returns a boolean specifying if alpha blending is needed
  52087. */
  52088. needAlphaBlending(): boolean;
  52089. /**
  52090. * Specifies if this material should be rendered in alpha test mode
  52091. * @returns a boolean specifying if an alpha test is needed.
  52092. */
  52093. needAlphaTesting(): boolean;
  52094. private _initializeBlock;
  52095. private _resetDualBlocks;
  52096. /**
  52097. * Build the material and generates the inner effect
  52098. * @param verbose defines if the build should log activity
  52099. */
  52100. build(verbose?: boolean): void;
  52101. /**
  52102. * Runs an otpimization phase to try to improve the shader code
  52103. */
  52104. optimize(): void;
  52105. private _prepareDefinesForAttributes;
  52106. /**
  52107. * Get if the submesh is ready to be used and all its information available.
  52108. * Child classes can use it to update shaders
  52109. * @param mesh defines the mesh to check
  52110. * @param subMesh defines which submesh to check
  52111. * @param useInstances specifies that instances should be used
  52112. * @returns a boolean indicating that the submesh is ready or not
  52113. */
  52114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52115. /**
  52116. * Get a string representing the shaders built by the current node graph
  52117. */
  52118. readonly compiledShaders: string;
  52119. /**
  52120. * Binds the world matrix to the material
  52121. * @param world defines the world transformation matrix
  52122. */
  52123. bindOnlyWorldMatrix(world: Matrix): void;
  52124. /**
  52125. * Binds the submesh to this material by preparing the effect and shader to draw
  52126. * @param world defines the world transformation matrix
  52127. * @param mesh defines the mesh containing the submesh
  52128. * @param subMesh defines the submesh to bind the material to
  52129. */
  52130. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52131. /**
  52132. * Gets the active textures from the material
  52133. * @returns an array of textures
  52134. */
  52135. getActiveTextures(): BaseTexture[];
  52136. /**
  52137. * Gets the list of texture blocks
  52138. * @returns an array of texture blocks
  52139. */
  52140. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52141. /**
  52142. * Specifies if the material uses a texture
  52143. * @param texture defines the texture to check against the material
  52144. * @returns a boolean specifying if the material uses the texture
  52145. */
  52146. hasTexture(texture: BaseTexture): boolean;
  52147. /**
  52148. * Disposes the material
  52149. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52150. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52151. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52152. */
  52153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52154. /** Creates the node editor window. */
  52155. private _createNodeEditor;
  52156. /**
  52157. * Launch the node material editor
  52158. * @param config Define the configuration of the editor
  52159. * @return a promise fulfilled when the node editor is visible
  52160. */
  52161. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52162. /**
  52163. * Clear the current material
  52164. */
  52165. clear(): void;
  52166. /**
  52167. * Clear the current material and set it to a default state
  52168. */
  52169. setToDefault(): void;
  52170. /**
  52171. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52172. * @param url defines the url to load from
  52173. * @returns a promise that will fullfil when the material is fully loaded
  52174. */
  52175. loadAsync(url: string): Promise<unknown>;
  52176. private _gatherBlocks;
  52177. /**
  52178. * Generate a string containing the code declaration required to create an equivalent of this material
  52179. * @returns a string
  52180. */
  52181. generateCode(): string;
  52182. /**
  52183. * Serializes this material in a JSON representation
  52184. * @returns the serialized material object
  52185. */
  52186. serialize(): any;
  52187. private _restoreConnections;
  52188. /**
  52189. * Clear the current graph and load a new one from a serialization object
  52190. * @param source defines the JSON representation of the material
  52191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52192. */
  52193. loadFromSerialization(source: any, rootUrl?: string): void;
  52194. /**
  52195. * Creates a node material from parsed material data
  52196. * @param source defines the JSON representation of the material
  52197. * @param scene defines the hosting scene
  52198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52199. * @returns a new node material
  52200. */
  52201. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52202. /**
  52203. * Creates a new node material set to default basic configuration
  52204. * @param name defines the name of the material
  52205. * @param scene defines the hosting scene
  52206. * @returns a new NodeMaterial
  52207. */
  52208. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52209. }
  52210. }
  52211. declare module BABYLON {
  52212. /**
  52213. * Block used to read a texture from a sampler
  52214. */
  52215. export class TextureBlock extends NodeMaterialBlock {
  52216. private _defineName;
  52217. private _samplerName;
  52218. private _transformedUVName;
  52219. private _textureTransformName;
  52220. private _textureInfoName;
  52221. private _mainUVName;
  52222. private _mainUVDefineName;
  52223. /**
  52224. * Gets or sets the texture associated with the node
  52225. */
  52226. texture: Nullable<BaseTexture>;
  52227. /**
  52228. * Create a new TextureBlock
  52229. * @param name defines the block name
  52230. */
  52231. constructor(name: string);
  52232. /**
  52233. * Gets the current class name
  52234. * @returns the class name
  52235. */
  52236. getClassName(): string;
  52237. /**
  52238. * Gets the uv input component
  52239. */
  52240. readonly uv: NodeMaterialConnectionPoint;
  52241. /**
  52242. * Gets the rgba output component
  52243. */
  52244. readonly rgba: NodeMaterialConnectionPoint;
  52245. /**
  52246. * Gets the rgb output component
  52247. */
  52248. readonly rgb: NodeMaterialConnectionPoint;
  52249. /**
  52250. * Gets the r output component
  52251. */
  52252. readonly r: NodeMaterialConnectionPoint;
  52253. /**
  52254. * Gets the g output component
  52255. */
  52256. readonly g: NodeMaterialConnectionPoint;
  52257. /**
  52258. * Gets the b output component
  52259. */
  52260. readonly b: NodeMaterialConnectionPoint;
  52261. /**
  52262. * Gets the a output component
  52263. */
  52264. readonly a: NodeMaterialConnectionPoint;
  52265. readonly target: NodeMaterialBlockTargets;
  52266. autoConfigure(material: NodeMaterial): void;
  52267. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52269. isReady(): boolean;
  52270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52271. private readonly _isMixed;
  52272. private _injectVertexCode;
  52273. private _writeOutput;
  52274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52275. protected _dumpPropertiesCode(): string;
  52276. serialize(): any;
  52277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52278. }
  52279. }
  52280. declare module BABYLON {
  52281. /**
  52282. * Class used to store shared data between 2 NodeMaterialBuildState
  52283. */
  52284. export class NodeMaterialBuildStateSharedData {
  52285. /**
  52286. * Gets the list of emitted varyings
  52287. */
  52288. temps: string[];
  52289. /**
  52290. * Gets the list of emitted varyings
  52291. */
  52292. varyings: string[];
  52293. /**
  52294. * Gets the varying declaration string
  52295. */
  52296. varyingDeclaration: string;
  52297. /**
  52298. * Input blocks
  52299. */
  52300. inputBlocks: InputBlock[];
  52301. /**
  52302. * Input blocks
  52303. */
  52304. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52305. /**
  52306. * Bindable blocks (Blocks that need to set data to the effect)
  52307. */
  52308. bindableBlocks: NodeMaterialBlock[];
  52309. /**
  52310. * List of blocks that can provide a compilation fallback
  52311. */
  52312. blocksWithFallbacks: NodeMaterialBlock[];
  52313. /**
  52314. * List of blocks that can provide a define update
  52315. */
  52316. blocksWithDefines: NodeMaterialBlock[];
  52317. /**
  52318. * List of blocks that can provide a repeatable content
  52319. */
  52320. repeatableContentBlocks: NodeMaterialBlock[];
  52321. /**
  52322. * List of blocks that can provide a dynamic list of uniforms
  52323. */
  52324. dynamicUniformBlocks: NodeMaterialBlock[];
  52325. /**
  52326. * List of blocks that can block the isReady function for the material
  52327. */
  52328. blockingBlocks: NodeMaterialBlock[];
  52329. /**
  52330. * Gets the list of animated inputs
  52331. */
  52332. animatedInputs: InputBlock[];
  52333. /**
  52334. * Build Id used to avoid multiple recompilations
  52335. */
  52336. buildId: number;
  52337. /** List of emitted variables */
  52338. variableNames: {
  52339. [key: string]: number;
  52340. };
  52341. /** List of emitted defines */
  52342. defineNames: {
  52343. [key: string]: number;
  52344. };
  52345. /** Should emit comments? */
  52346. emitComments: boolean;
  52347. /** Emit build activity */
  52348. verbose: boolean;
  52349. /**
  52350. * Gets the compilation hints emitted at compilation time
  52351. */
  52352. hints: {
  52353. needWorldViewMatrix: boolean;
  52354. needWorldViewProjectionMatrix: boolean;
  52355. needAlphaBlending: boolean;
  52356. needAlphaTesting: boolean;
  52357. };
  52358. /**
  52359. * List of compilation checks
  52360. */
  52361. checks: {
  52362. emitVertex: boolean;
  52363. emitFragment: boolean;
  52364. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52365. };
  52366. /** Creates a new shared data */
  52367. constructor();
  52368. /**
  52369. * Emits console errors and exceptions if there is a failing check
  52370. */
  52371. emitErrors(): void;
  52372. }
  52373. }
  52374. declare module BABYLON {
  52375. /**
  52376. * Class used to store node based material build state
  52377. */
  52378. export class NodeMaterialBuildState {
  52379. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52380. supportUniformBuffers: boolean;
  52381. /**
  52382. * Gets the list of emitted attributes
  52383. */
  52384. attributes: string[];
  52385. /**
  52386. * Gets the list of emitted uniforms
  52387. */
  52388. uniforms: string[];
  52389. /**
  52390. * Gets the list of emitted uniform buffers
  52391. */
  52392. uniformBuffers: string[];
  52393. /**
  52394. * Gets the list of emitted samplers
  52395. */
  52396. samplers: string[];
  52397. /**
  52398. * Gets the list of emitted functions
  52399. */
  52400. functions: {
  52401. [key: string]: string;
  52402. };
  52403. /**
  52404. * Gets the target of the compilation state
  52405. */
  52406. target: NodeMaterialBlockTargets;
  52407. /**
  52408. * Gets the list of emitted counters
  52409. */
  52410. counters: {
  52411. [key: string]: number;
  52412. };
  52413. /**
  52414. * Shared data between multiple NodeMaterialBuildState instances
  52415. */
  52416. sharedData: NodeMaterialBuildStateSharedData;
  52417. /** @hidden */
  52418. _vertexState: NodeMaterialBuildState;
  52419. /** @hidden */
  52420. _attributeDeclaration: string;
  52421. /** @hidden */
  52422. _uniformDeclaration: string;
  52423. /** @hidden */
  52424. _samplerDeclaration: string;
  52425. /** @hidden */
  52426. _varyingTransfer: string;
  52427. private _repeatableContentAnchorIndex;
  52428. /** @hidden */
  52429. _builtCompilationString: string;
  52430. /**
  52431. * Gets the emitted compilation strings
  52432. */
  52433. compilationString: string;
  52434. /**
  52435. * Finalize the compilation strings
  52436. * @param state defines the current compilation state
  52437. */
  52438. finalize(state: NodeMaterialBuildState): void;
  52439. /** @hidden */
  52440. readonly _repeatableContentAnchor: string;
  52441. /** @hidden */
  52442. _getFreeVariableName(prefix: string): string;
  52443. /** @hidden */
  52444. _getFreeDefineName(prefix: string): string;
  52445. /** @hidden */
  52446. _excludeVariableName(name: string): void;
  52447. /** @hidden */
  52448. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52449. /** @hidden */
  52450. _emitFunction(name: string, code: string, comments: string): void;
  52451. /** @hidden */
  52452. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52453. replaceStrings?: {
  52454. search: RegExp;
  52455. replace: string;
  52456. }[];
  52457. repeatKey?: string;
  52458. }): string;
  52459. /** @hidden */
  52460. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52461. repeatKey?: string;
  52462. removeAttributes?: boolean;
  52463. removeUniforms?: boolean;
  52464. removeVaryings?: boolean;
  52465. removeIfDef?: boolean;
  52466. replaceStrings?: {
  52467. search: RegExp;
  52468. replace: string;
  52469. }[];
  52470. }, storeKey?: string): void;
  52471. /** @hidden */
  52472. _registerTempVariable(name: string): boolean;
  52473. /** @hidden */
  52474. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52475. /** @hidden */
  52476. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52477. }
  52478. }
  52479. declare module BABYLON {
  52480. /**
  52481. * Defines a block that can be used inside a node based material
  52482. */
  52483. export class NodeMaterialBlock {
  52484. private _buildId;
  52485. private _buildTarget;
  52486. private _target;
  52487. private _isFinalMerger;
  52488. private _isInput;
  52489. /** @hidden */
  52490. _codeVariableName: string;
  52491. /** @hidden */
  52492. _inputs: NodeMaterialConnectionPoint[];
  52493. /** @hidden */
  52494. _outputs: NodeMaterialConnectionPoint[];
  52495. /** @hidden */
  52496. _preparationId: number;
  52497. /**
  52498. * Gets or sets the name of the block
  52499. */
  52500. name: string;
  52501. /**
  52502. * Gets or sets the unique id of the node
  52503. */
  52504. uniqueId: number;
  52505. /**
  52506. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52507. */
  52508. readonly isFinalMerger: boolean;
  52509. /**
  52510. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52511. */
  52512. readonly isInput: boolean;
  52513. /**
  52514. * Gets or sets the build Id
  52515. */
  52516. buildId: number;
  52517. /**
  52518. * Gets or sets the target of the block
  52519. */
  52520. target: NodeMaterialBlockTargets;
  52521. /**
  52522. * Gets the list of input points
  52523. */
  52524. readonly inputs: NodeMaterialConnectionPoint[];
  52525. /** Gets the list of output points */
  52526. readonly outputs: NodeMaterialConnectionPoint[];
  52527. /**
  52528. * Find an input by its name
  52529. * @param name defines the name of the input to look for
  52530. * @returns the input or null if not found
  52531. */
  52532. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52533. /**
  52534. * Find an output by its name
  52535. * @param name defines the name of the outputto look for
  52536. * @returns the output or null if not found
  52537. */
  52538. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52539. /**
  52540. * Creates a new NodeMaterialBlock
  52541. * @param name defines the block name
  52542. * @param target defines the target of that block (Vertex by default)
  52543. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52544. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52545. */
  52546. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52547. /**
  52548. * Initialize the block and prepare the context for build
  52549. * @param state defines the state that will be used for the build
  52550. */
  52551. initialize(state: NodeMaterialBuildState): void;
  52552. /**
  52553. * Bind data to effect. Will only be called for blocks with isBindable === true
  52554. * @param effect defines the effect to bind data to
  52555. * @param nodeMaterial defines the hosting NodeMaterial
  52556. * @param mesh defines the mesh that will be rendered
  52557. */
  52558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52559. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52560. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52561. protected _writeFloat(value: number): string;
  52562. /**
  52563. * Gets the current class name e.g. "NodeMaterialBlock"
  52564. * @returns the class name
  52565. */
  52566. getClassName(): string;
  52567. /**
  52568. * Register a new input. Must be called inside a block constructor
  52569. * @param name defines the connection point name
  52570. * @param type defines the connection point type
  52571. * @param isOptional defines a boolean indicating that this input can be omitted
  52572. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52573. * @returns the current block
  52574. */
  52575. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52576. /**
  52577. * Register a new output. Must be called inside a block constructor
  52578. * @param name defines the connection point name
  52579. * @param type defines the connection point type
  52580. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52581. * @returns the current block
  52582. */
  52583. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52584. /**
  52585. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52586. * @param forOutput defines an optional connection point to check compatibility with
  52587. * @returns the first available input or null
  52588. */
  52589. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52590. /**
  52591. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52592. * @param forBlock defines an optional block to check compatibility with
  52593. * @returns the first available input or null
  52594. */
  52595. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52596. /**
  52597. * Gets the sibling of the given output
  52598. * @param current defines the current output
  52599. * @returns the next output in the list or null
  52600. */
  52601. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52602. /**
  52603. * Connect current block with another block
  52604. * @param other defines the block to connect with
  52605. * @param options define the various options to help pick the right connections
  52606. * @returns the current block
  52607. */
  52608. connectTo(other: NodeMaterialBlock, options?: {
  52609. input?: string;
  52610. output?: string;
  52611. outputSwizzle?: string;
  52612. }): this | undefined;
  52613. protected _buildBlock(state: NodeMaterialBuildState): void;
  52614. /**
  52615. * Add uniforms, samplers and uniform buffers at compilation time
  52616. * @param state defines the state to update
  52617. * @param nodeMaterial defines the node material requesting the update
  52618. * @param defines defines the material defines to update
  52619. */
  52620. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52621. /**
  52622. * Add potential fallbacks if shader compilation fails
  52623. * @param mesh defines the mesh to be rendered
  52624. * @param fallbacks defines the current prioritized list of fallbacks
  52625. */
  52626. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52627. /**
  52628. * Update defines for shader compilation
  52629. * @param mesh defines the mesh to be rendered
  52630. * @param nodeMaterial defines the node material requesting the update
  52631. * @param defines defines the material defines to update
  52632. * @param useInstances specifies that instances should be used
  52633. */
  52634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52635. /**
  52636. * Initialize defines for shader compilation
  52637. * @param mesh defines the mesh to be rendered
  52638. * @param nodeMaterial defines the node material requesting the update
  52639. * @param defines defines the material defines to be prepared
  52640. * @param useInstances specifies that instances should be used
  52641. */
  52642. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52643. /**
  52644. * Lets the block try to connect some inputs automatically
  52645. * @param material defines the hosting NodeMaterial
  52646. */
  52647. autoConfigure(material: NodeMaterial): void;
  52648. /**
  52649. * Function called when a block is declared as repeatable content generator
  52650. * @param vertexShaderState defines the current compilation state for the vertex shader
  52651. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52652. * @param mesh defines the mesh to be rendered
  52653. * @param defines defines the material defines to update
  52654. */
  52655. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52656. /**
  52657. * Checks if the block is ready
  52658. * @param mesh defines the mesh to be rendered
  52659. * @param nodeMaterial defines the node material requesting the update
  52660. * @param defines defines the material defines to update
  52661. * @param useInstances specifies that instances should be used
  52662. * @returns true if the block is ready
  52663. */
  52664. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52665. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52666. private _processBuild;
  52667. /**
  52668. * Compile the current node and generate the shader code
  52669. * @param state defines the current compilation state (uniforms, samplers, current string)
  52670. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52671. * @returns true if already built
  52672. */
  52673. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52674. protected _inputRename(name: string): string;
  52675. protected _outputRename(name: string): string;
  52676. protected _dumpPropertiesCode(): string;
  52677. /** @hidden */
  52678. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52679. /**
  52680. * Clone the current block to a new identical block
  52681. * @param scene defines the hosting scene
  52682. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52683. * @returns a copy of the current block
  52684. */
  52685. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52686. /**
  52687. * Serializes this block in a JSON representation
  52688. * @returns the serialized block object
  52689. */
  52690. serialize(): any;
  52691. /** @hidden */
  52692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52693. }
  52694. }
  52695. declare module BABYLON {
  52696. /**
  52697. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52698. */
  52699. export enum NodeMaterialBlockConnectionPointMode {
  52700. /** Value is an uniform */
  52701. Uniform = 0,
  52702. /** Value is a mesh attribute */
  52703. Attribute = 1,
  52704. /** Value is a varying between vertex and fragment shaders */
  52705. Varying = 2,
  52706. /** Mode is undefined */
  52707. Undefined = 3
  52708. }
  52709. }
  52710. declare module BABYLON {
  52711. /**
  52712. * Enum defining the type of animations supported by InputBlock
  52713. */
  52714. export enum AnimatedInputBlockTypes {
  52715. /** No animation */
  52716. None = 0,
  52717. /** Time based animation. Will only work for floats */
  52718. Time = 1
  52719. }
  52720. }
  52721. declare module BABYLON {
  52722. /**
  52723. * Block used to expose an input value
  52724. */
  52725. export class InputBlock extends NodeMaterialBlock {
  52726. private _mode;
  52727. private _associatedVariableName;
  52728. private _storedValue;
  52729. private _valueCallback;
  52730. private _type;
  52731. private _animationType;
  52732. /** @hidden */
  52733. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52734. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52735. visibleInInspector: boolean;
  52736. /**
  52737. * Gets or sets the connection point type (default is float)
  52738. */
  52739. readonly type: NodeMaterialBlockConnectionPointTypes;
  52740. /**
  52741. * Creates a new InputBlock
  52742. * @param name defines the block name
  52743. * @param target defines the target of that block (Vertex by default)
  52744. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52745. */
  52746. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52747. /**
  52748. * Gets the output component
  52749. */
  52750. readonly output: NodeMaterialConnectionPoint;
  52751. /**
  52752. * Set the source of this connection point to a vertex attribute
  52753. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52754. * @returns the current connection point
  52755. */
  52756. setAsAttribute(attributeName?: string): InputBlock;
  52757. /**
  52758. * Set the source of this connection point to a well known value
  52759. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52760. * @returns the current connection point
  52761. */
  52762. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52763. /**
  52764. * Gets or sets the value of that point.
  52765. * Please note that this value will be ignored if valueCallback is defined
  52766. */
  52767. value: any;
  52768. /**
  52769. * Gets or sets a callback used to get the value of that point.
  52770. * Please note that setting this value will force the connection point to ignore the value property
  52771. */
  52772. valueCallback: () => any;
  52773. /**
  52774. * Gets or sets the associated variable name in the shader
  52775. */
  52776. associatedVariableName: string;
  52777. /** Gets or sets the type of animation applied to the input */
  52778. animationType: AnimatedInputBlockTypes;
  52779. /**
  52780. * Gets a boolean indicating that this connection point not defined yet
  52781. */
  52782. readonly isUndefined: boolean;
  52783. /**
  52784. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52785. * In this case the connection point name must be the name of the uniform to use.
  52786. * Can only be set on inputs
  52787. */
  52788. isUniform: boolean;
  52789. /**
  52790. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52791. * In this case the connection point name must be the name of the attribute to use
  52792. * Can only be set on inputs
  52793. */
  52794. isAttribute: boolean;
  52795. /**
  52796. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52797. * Can only be set on exit points
  52798. */
  52799. isVarying: boolean;
  52800. /**
  52801. * Gets a boolean indicating that the current connection point is a well known value
  52802. */
  52803. readonly isWellKnownValue: boolean;
  52804. /**
  52805. * Gets or sets the current well known value or null if not defined as well know value
  52806. */
  52807. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52808. /**
  52809. * Gets the current class name
  52810. * @returns the class name
  52811. */
  52812. getClassName(): string;
  52813. /**
  52814. * Animate the input if animationType !== None
  52815. * @param scene defines the rendering scene
  52816. */
  52817. animate(scene: Scene): void;
  52818. private _emitDefine;
  52819. /**
  52820. * Set the input block to its default value (based on its type)
  52821. */
  52822. setDefaultValue(): void;
  52823. protected _dumpPropertiesCode(): string;
  52824. private _emit;
  52825. /** @hidden */
  52826. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52827. /** @hidden */
  52828. _transmit(effect: Effect, scene: Scene): void;
  52829. protected _buildBlock(state: NodeMaterialBuildState): void;
  52830. serialize(): any;
  52831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52832. }
  52833. }
  52834. declare module BABYLON {
  52835. /**
  52836. * Defines a connection point for a block
  52837. */
  52838. export class NodeMaterialConnectionPoint {
  52839. /** @hidden */
  52840. _ownerBlock: NodeMaterialBlock;
  52841. /** @hidden */
  52842. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52843. private _endpoints;
  52844. private _associatedVariableName;
  52845. /** @hidden */
  52846. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52847. /** @hidden */
  52848. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52849. private _type;
  52850. /** @hidden */
  52851. _enforceAssociatedVariableName: boolean;
  52852. /**
  52853. * Gets or sets the additional types supported byt this connection point
  52854. */
  52855. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52856. /**
  52857. * Gets or sets the associated variable name in the shader
  52858. */
  52859. associatedVariableName: string;
  52860. /**
  52861. * Gets or sets the connection point type (default is float)
  52862. */
  52863. type: NodeMaterialBlockConnectionPointTypes;
  52864. /**
  52865. * Gets or sets the connection point name
  52866. */
  52867. name: string;
  52868. /**
  52869. * Gets or sets a boolean indicating that this connection point can be omitted
  52870. */
  52871. isOptional: boolean;
  52872. /**
  52873. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52874. */
  52875. define: string;
  52876. /** Gets or sets the target of that connection point */
  52877. target: NodeMaterialBlockTargets;
  52878. /**
  52879. * Gets a boolean indicating that the current point is connected
  52880. */
  52881. readonly isConnected: boolean;
  52882. /**
  52883. * Gets a boolean indicating that the current point is connected to an input block
  52884. */
  52885. readonly isConnectedToInputBlock: boolean;
  52886. /**
  52887. * Gets a the connected input block (if any)
  52888. */
  52889. readonly connectInputBlock: Nullable<InputBlock>;
  52890. /** Get the other side of the connection (if any) */
  52891. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52892. /** Get the block that owns this connection point */
  52893. readonly ownerBlock: NodeMaterialBlock;
  52894. /** Get the block connected on the other side of this connection (if any) */
  52895. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52896. /** Get the block connected on the endpoints of this connection (if any) */
  52897. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52898. /** Gets the list of connected endpoints */
  52899. readonly endpoints: NodeMaterialConnectionPoint[];
  52900. /** Gets a boolean indicating if that output point is connected to at least one input */
  52901. readonly hasEndpoints: boolean;
  52902. /**
  52903. * Creates a new connection point
  52904. * @param name defines the connection point name
  52905. * @param ownerBlock defines the block hosting this connection point
  52906. */
  52907. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52908. /**
  52909. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52910. * @returns the class name
  52911. */
  52912. getClassName(): string;
  52913. /**
  52914. * Gets an boolean indicating if the current point can be connected to another point
  52915. * @param connectionPoint defines the other connection point
  52916. * @returns true if the connection is possible
  52917. */
  52918. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52919. /**
  52920. * Connect this point to another connection point
  52921. * @param connectionPoint defines the other connection point
  52922. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52923. * @returns the current connection point
  52924. */
  52925. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52926. /**
  52927. * Disconnect this point from one of his endpoint
  52928. * @param endpoint defines the other connection point
  52929. * @returns the current connection point
  52930. */
  52931. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52932. /**
  52933. * Serializes this point in a JSON representation
  52934. * @returns the serialized point object
  52935. */
  52936. serialize(): any;
  52937. }
  52938. }
  52939. declare module BABYLON {
  52940. /**
  52941. * Block used to add support for vertex skinning (bones)
  52942. */
  52943. export class BonesBlock extends NodeMaterialBlock {
  52944. /**
  52945. * Creates a new BonesBlock
  52946. * @param name defines the block name
  52947. */
  52948. constructor(name: string);
  52949. /**
  52950. * Initialize the block and prepare the context for build
  52951. * @param state defines the state that will be used for the build
  52952. */
  52953. initialize(state: NodeMaterialBuildState): void;
  52954. /**
  52955. * Gets the current class name
  52956. * @returns the class name
  52957. */
  52958. getClassName(): string;
  52959. /**
  52960. * Gets the matrix indices input component
  52961. */
  52962. readonly matricesIndices: NodeMaterialConnectionPoint;
  52963. /**
  52964. * Gets the matrix weights input component
  52965. */
  52966. readonly matricesWeights: NodeMaterialConnectionPoint;
  52967. /**
  52968. * Gets the extra matrix indices input component
  52969. */
  52970. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52971. /**
  52972. * Gets the extra matrix weights input component
  52973. */
  52974. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52975. /**
  52976. * Gets the world input component
  52977. */
  52978. readonly world: NodeMaterialConnectionPoint;
  52979. /**
  52980. * Gets the output component
  52981. */
  52982. readonly output: NodeMaterialConnectionPoint;
  52983. autoConfigure(material: NodeMaterial): void;
  52984. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52987. protected _buildBlock(state: NodeMaterialBuildState): this;
  52988. }
  52989. }
  52990. declare module BABYLON {
  52991. /**
  52992. * Block used to add support for instances
  52993. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52994. */
  52995. export class InstancesBlock extends NodeMaterialBlock {
  52996. /**
  52997. * Creates a new InstancesBlock
  52998. * @param name defines the block name
  52999. */
  53000. constructor(name: string);
  53001. /**
  53002. * Gets the current class name
  53003. * @returns the class name
  53004. */
  53005. getClassName(): string;
  53006. /**
  53007. * Gets the first world row input component
  53008. */
  53009. readonly world0: NodeMaterialConnectionPoint;
  53010. /**
  53011. * Gets the second world row input component
  53012. */
  53013. readonly world1: NodeMaterialConnectionPoint;
  53014. /**
  53015. * Gets the third world row input component
  53016. */
  53017. readonly world2: NodeMaterialConnectionPoint;
  53018. /**
  53019. * Gets the forth world row input component
  53020. */
  53021. readonly world3: NodeMaterialConnectionPoint;
  53022. /**
  53023. * Gets the world input component
  53024. */
  53025. readonly world: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the output component
  53028. */
  53029. readonly output: NodeMaterialConnectionPoint;
  53030. autoConfigure(material: NodeMaterial): void;
  53031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53032. protected _buildBlock(state: NodeMaterialBuildState): this;
  53033. }
  53034. }
  53035. declare module BABYLON {
  53036. /**
  53037. * Block used to add morph targets support to vertex shader
  53038. */
  53039. export class MorphTargetsBlock extends NodeMaterialBlock {
  53040. private _repeatableContentAnchor;
  53041. private _repeatebleContentGenerated;
  53042. /**
  53043. * Create a new MorphTargetsBlock
  53044. * @param name defines the block name
  53045. */
  53046. constructor(name: string);
  53047. /**
  53048. * Gets the current class name
  53049. * @returns the class name
  53050. */
  53051. getClassName(): string;
  53052. /**
  53053. * Gets the position input component
  53054. */
  53055. readonly position: NodeMaterialConnectionPoint;
  53056. /**
  53057. * Gets the normal input component
  53058. */
  53059. readonly normal: NodeMaterialConnectionPoint;
  53060. /**
  53061. * Gets the tangent input component
  53062. */
  53063. readonly tangent: NodeMaterialConnectionPoint;
  53064. /**
  53065. * Gets the tangent input component
  53066. */
  53067. readonly uv: NodeMaterialConnectionPoint;
  53068. /**
  53069. * Gets the position output component
  53070. */
  53071. readonly positionOutput: NodeMaterialConnectionPoint;
  53072. /**
  53073. * Gets the normal output component
  53074. */
  53075. readonly normalOutput: NodeMaterialConnectionPoint;
  53076. /**
  53077. * Gets the tangent output component
  53078. */
  53079. readonly tangentOutput: NodeMaterialConnectionPoint;
  53080. /**
  53081. * Gets the tangent output component
  53082. */
  53083. readonly uvOutput: NodeMaterialConnectionPoint;
  53084. initialize(state: NodeMaterialBuildState): void;
  53085. autoConfigure(material: NodeMaterial): void;
  53086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53088. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53089. protected _buildBlock(state: NodeMaterialBuildState): this;
  53090. }
  53091. }
  53092. declare module BABYLON {
  53093. /**
  53094. * Block used to get data information from a light
  53095. */
  53096. export class LightInformationBlock extends NodeMaterialBlock {
  53097. private _lightDataDefineName;
  53098. private _lightColorDefineName;
  53099. /**
  53100. * Gets or sets the light associated with this block
  53101. */
  53102. light: Nullable<Light>;
  53103. /**
  53104. * Creates a new LightInformationBlock
  53105. * @param name defines the block name
  53106. */
  53107. constructor(name: string);
  53108. /**
  53109. * Gets the current class name
  53110. * @returns the class name
  53111. */
  53112. getClassName(): string;
  53113. /**
  53114. * Gets the world position input component
  53115. */
  53116. readonly worldPosition: NodeMaterialConnectionPoint;
  53117. /**
  53118. * Gets the direction output component
  53119. */
  53120. readonly direction: NodeMaterialConnectionPoint;
  53121. /**
  53122. * Gets the direction output component
  53123. */
  53124. readonly color: NodeMaterialConnectionPoint;
  53125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53126. protected _buildBlock(state: NodeMaterialBuildState): this;
  53127. serialize(): any;
  53128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53129. }
  53130. }
  53131. declare module BABYLON {
  53132. /**
  53133. * Block used to add an alpha test in the fragment shader
  53134. */
  53135. export class AlphaTestBlock extends NodeMaterialBlock {
  53136. /**
  53137. * Gets or sets the alpha value where alpha testing happens
  53138. */
  53139. alphaCutOff: number;
  53140. /**
  53141. * Create a new AlphaTestBlock
  53142. * @param name defines the block name
  53143. */
  53144. constructor(name: string);
  53145. /**
  53146. * Gets the current class name
  53147. * @returns the class name
  53148. */
  53149. getClassName(): string;
  53150. /**
  53151. * Gets the color input component
  53152. */
  53153. readonly color: NodeMaterialConnectionPoint;
  53154. /**
  53155. * Gets the alpha input component
  53156. */
  53157. readonly alpha: NodeMaterialConnectionPoint;
  53158. protected _buildBlock(state: NodeMaterialBuildState): this;
  53159. protected _dumpPropertiesCode(): string;
  53160. serialize(): any;
  53161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * Block used to add image processing support to fragment shader
  53167. */
  53168. export class ImageProcessingBlock extends NodeMaterialBlock {
  53169. /**
  53170. * Create a new ImageProcessingBlock
  53171. * @param name defines the block name
  53172. */
  53173. constructor(name: string);
  53174. /**
  53175. * Gets the current class name
  53176. * @returns the class name
  53177. */
  53178. getClassName(): string;
  53179. /**
  53180. * Gets the color input component
  53181. */
  53182. readonly color: NodeMaterialConnectionPoint;
  53183. /**
  53184. * Gets the output component
  53185. */
  53186. readonly output: NodeMaterialConnectionPoint;
  53187. /**
  53188. * Initialize the block and prepare the context for build
  53189. * @param state defines the state that will be used for the build
  53190. */
  53191. initialize(state: NodeMaterialBuildState): void;
  53192. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53194. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53195. protected _buildBlock(state: NodeMaterialBuildState): this;
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * Block used to add support for scene fog
  53201. */
  53202. export class FogBlock extends NodeMaterialBlock {
  53203. private _fogDistanceName;
  53204. private _fogParameters;
  53205. /**
  53206. * Create a new FogBlock
  53207. * @param name defines the block name
  53208. */
  53209. constructor(name: string);
  53210. /**
  53211. * Gets the current class name
  53212. * @returns the class name
  53213. */
  53214. getClassName(): string;
  53215. /**
  53216. * Gets the world position input component
  53217. */
  53218. readonly worldPosition: NodeMaterialConnectionPoint;
  53219. /**
  53220. * Gets the view input component
  53221. */
  53222. readonly view: NodeMaterialConnectionPoint;
  53223. /**
  53224. * Gets the color input component
  53225. */
  53226. readonly input: NodeMaterialConnectionPoint;
  53227. /**
  53228. * Gets the fog color input component
  53229. */
  53230. readonly fogColor: NodeMaterialConnectionPoint;
  53231. /**
  53232. * Gets the output component
  53233. */
  53234. readonly output: NodeMaterialConnectionPoint;
  53235. autoConfigure(material: NodeMaterial): void;
  53236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53238. protected _buildBlock(state: NodeMaterialBuildState): this;
  53239. }
  53240. }
  53241. declare module BABYLON {
  53242. /**
  53243. * Block used to add light in the fragment shader
  53244. */
  53245. export class LightBlock extends NodeMaterialBlock {
  53246. private _lightId;
  53247. /**
  53248. * Gets or sets the light associated with this block
  53249. */
  53250. light: Nullable<Light>;
  53251. /**
  53252. * Create a new LightBlock
  53253. * @param name defines the block name
  53254. */
  53255. constructor(name: string);
  53256. /**
  53257. * Gets the current class name
  53258. * @returns the class name
  53259. */
  53260. getClassName(): string;
  53261. /**
  53262. * Gets the world position input component
  53263. */
  53264. readonly worldPosition: NodeMaterialConnectionPoint;
  53265. /**
  53266. * Gets the world normal input component
  53267. */
  53268. readonly worldNormal: NodeMaterialConnectionPoint;
  53269. /**
  53270. * Gets the camera (or eye) position component
  53271. */
  53272. readonly cameraPosition: NodeMaterialConnectionPoint;
  53273. /**
  53274. * Gets the diffuse output component
  53275. */
  53276. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53277. /**
  53278. * Gets the specular output component
  53279. */
  53280. readonly specularOutput: NodeMaterialConnectionPoint;
  53281. autoConfigure(material: NodeMaterial): void;
  53282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53283. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53285. private _injectVertexCode;
  53286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53287. serialize(): any;
  53288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53289. }
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Block used to multiply 2 values
  53294. */
  53295. export class MultiplyBlock extends NodeMaterialBlock {
  53296. /**
  53297. * Creates a new MultiplyBlock
  53298. * @param name defines the block name
  53299. */
  53300. constructor(name: string);
  53301. /**
  53302. * Gets the current class name
  53303. * @returns the class name
  53304. */
  53305. getClassName(): string;
  53306. /**
  53307. * Gets the left operand input component
  53308. */
  53309. readonly left: NodeMaterialConnectionPoint;
  53310. /**
  53311. * Gets the right operand input component
  53312. */
  53313. readonly right: NodeMaterialConnectionPoint;
  53314. /**
  53315. * Gets the output component
  53316. */
  53317. readonly output: NodeMaterialConnectionPoint;
  53318. protected _buildBlock(state: NodeMaterialBuildState): this;
  53319. }
  53320. }
  53321. declare module BABYLON {
  53322. /**
  53323. * Block used to add 2 vectors
  53324. */
  53325. export class AddBlock extends NodeMaterialBlock {
  53326. /**
  53327. * Creates a new AddBlock
  53328. * @param name defines the block name
  53329. */
  53330. constructor(name: string);
  53331. /**
  53332. * Gets the current class name
  53333. * @returns the class name
  53334. */
  53335. getClassName(): string;
  53336. /**
  53337. * Gets the left operand input component
  53338. */
  53339. readonly left: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the right operand input component
  53342. */
  53343. readonly right: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the output component
  53346. */
  53347. readonly output: NodeMaterialConnectionPoint;
  53348. protected _buildBlock(state: NodeMaterialBuildState): this;
  53349. }
  53350. }
  53351. declare module BABYLON {
  53352. /**
  53353. * Block used to scale a vector by a float
  53354. */
  53355. export class ScaleBlock extends NodeMaterialBlock {
  53356. /**
  53357. * Creates a new ScaleBlock
  53358. * @param name defines the block name
  53359. */
  53360. constructor(name: string);
  53361. /**
  53362. * Gets the current class name
  53363. * @returns the class name
  53364. */
  53365. getClassName(): string;
  53366. /**
  53367. * Gets the input component
  53368. */
  53369. readonly input: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the factor input component
  53372. */
  53373. readonly factor: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the output component
  53376. */
  53377. readonly output: NodeMaterialConnectionPoint;
  53378. protected _buildBlock(state: NodeMaterialBuildState): this;
  53379. }
  53380. }
  53381. declare module BABYLON {
  53382. /**
  53383. * Block used to clamp a float
  53384. */
  53385. export class ClampBlock extends NodeMaterialBlock {
  53386. /** Gets or sets the minimum range */
  53387. minimum: number;
  53388. /** Gets or sets the maximum range */
  53389. maximum: number;
  53390. /**
  53391. * Creates a new ClampBlock
  53392. * @param name defines the block name
  53393. */
  53394. constructor(name: string);
  53395. /**
  53396. * Gets the current class name
  53397. * @returns the class name
  53398. */
  53399. getClassName(): string;
  53400. /**
  53401. * Gets the value input component
  53402. */
  53403. readonly value: NodeMaterialConnectionPoint;
  53404. /**
  53405. * Gets the output component
  53406. */
  53407. readonly output: NodeMaterialConnectionPoint;
  53408. protected _buildBlock(state: NodeMaterialBuildState): this;
  53409. protected _dumpPropertiesCode(): string;
  53410. serialize(): any;
  53411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53412. }
  53413. }
  53414. declare module BABYLON {
  53415. /**
  53416. * Block used to apply a cross product between 2 vectors
  53417. */
  53418. export class CrossBlock extends NodeMaterialBlock {
  53419. /**
  53420. * Creates a new CrossBlock
  53421. * @param name defines the block name
  53422. */
  53423. constructor(name: string);
  53424. /**
  53425. * Gets the current class name
  53426. * @returns the class name
  53427. */
  53428. getClassName(): string;
  53429. /**
  53430. * Gets the left operand input component
  53431. */
  53432. readonly left: NodeMaterialConnectionPoint;
  53433. /**
  53434. * Gets the right operand input component
  53435. */
  53436. readonly right: NodeMaterialConnectionPoint;
  53437. /**
  53438. * Gets the output component
  53439. */
  53440. readonly output: NodeMaterialConnectionPoint;
  53441. protected _buildBlock(state: NodeMaterialBuildState): this;
  53442. }
  53443. }
  53444. declare module BABYLON {
  53445. /**
  53446. * Block used to apply a dot product between 2 vectors
  53447. */
  53448. export class DotBlock extends NodeMaterialBlock {
  53449. /**
  53450. * Creates a new DotBlock
  53451. * @param name defines the block name
  53452. */
  53453. constructor(name: string);
  53454. /**
  53455. * Gets the current class name
  53456. * @returns the class name
  53457. */
  53458. getClassName(): string;
  53459. /**
  53460. * Gets the left operand input component
  53461. */
  53462. readonly left: NodeMaterialConnectionPoint;
  53463. /**
  53464. * Gets the right operand input component
  53465. */
  53466. readonly right: NodeMaterialConnectionPoint;
  53467. /**
  53468. * Gets the output component
  53469. */
  53470. readonly output: NodeMaterialConnectionPoint;
  53471. protected _buildBlock(state: NodeMaterialBuildState): this;
  53472. }
  53473. }
  53474. declare module BABYLON {
  53475. /**
  53476. * Block used to remap a float from a range to a new one
  53477. */
  53478. export class RemapBlock extends NodeMaterialBlock {
  53479. /**
  53480. * Gets or sets the source range
  53481. */
  53482. sourceRange: Vector2;
  53483. /**
  53484. * Gets or sets the target range
  53485. */
  53486. targetRange: Vector2;
  53487. /**
  53488. * Creates a new RemapBlock
  53489. * @param name defines the block name
  53490. */
  53491. constructor(name: string);
  53492. /**
  53493. * Gets the current class name
  53494. * @returns the class name
  53495. */
  53496. getClassName(): string;
  53497. /**
  53498. * Gets the input component
  53499. */
  53500. readonly input: NodeMaterialConnectionPoint;
  53501. /**
  53502. * Gets the output component
  53503. */
  53504. readonly output: NodeMaterialConnectionPoint;
  53505. protected _buildBlock(state: NodeMaterialBuildState): this;
  53506. protected _dumpPropertiesCode(): string;
  53507. serialize(): any;
  53508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53509. }
  53510. }
  53511. declare module BABYLON {
  53512. /**
  53513. * Block used to normalize a vector
  53514. */
  53515. export class NormalizeBlock extends NodeMaterialBlock {
  53516. /**
  53517. * Creates a new NormalizeBlock
  53518. * @param name defines the block name
  53519. */
  53520. constructor(name: string);
  53521. /**
  53522. * Gets the current class name
  53523. * @returns the class name
  53524. */
  53525. getClassName(): string;
  53526. /**
  53527. * Gets the input component
  53528. */
  53529. readonly input: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Gets the output component
  53532. */
  53533. readonly output: NodeMaterialConnectionPoint;
  53534. protected _buildBlock(state: NodeMaterialBuildState): this;
  53535. }
  53536. }
  53537. declare module BABYLON {
  53538. /**
  53539. * Operations supported by the Trigonometry block
  53540. */
  53541. export enum TrigonometryBlockOperations {
  53542. /** Cos */
  53543. Cos = 0,
  53544. /** Sin */
  53545. Sin = 1,
  53546. /** Abs */
  53547. Abs = 2,
  53548. /** Exp */
  53549. Exp = 3,
  53550. /** Exp2 */
  53551. Exp2 = 4,
  53552. /** Round */
  53553. Round = 5,
  53554. /** Floor */
  53555. Floor = 6,
  53556. /** Ceiling */
  53557. Ceiling = 7
  53558. }
  53559. /**
  53560. * Block used to apply trigonometry operation to floats
  53561. */
  53562. export class TrigonometryBlock extends NodeMaterialBlock {
  53563. /**
  53564. * Gets or sets the operation applied by the block
  53565. */
  53566. operation: TrigonometryBlockOperations;
  53567. /**
  53568. * Creates a new TrigonometryBlock
  53569. * @param name defines the block name
  53570. */
  53571. constructor(name: string);
  53572. /**
  53573. * Gets the current class name
  53574. * @returns the class name
  53575. */
  53576. getClassName(): string;
  53577. /**
  53578. * Gets the input component
  53579. */
  53580. readonly input: NodeMaterialConnectionPoint;
  53581. /**
  53582. * Gets the output component
  53583. */
  53584. readonly output: NodeMaterialConnectionPoint;
  53585. protected _buildBlock(state: NodeMaterialBuildState): this;
  53586. }
  53587. }
  53588. declare module BABYLON {
  53589. /**
  53590. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53591. */
  53592. export class ColorMergerBlock extends NodeMaterialBlock {
  53593. /**
  53594. * Create a new ColorMergerBlock
  53595. * @param name defines the block name
  53596. */
  53597. constructor(name: string);
  53598. /**
  53599. * Gets the current class name
  53600. * @returns the class name
  53601. */
  53602. getClassName(): string;
  53603. /**
  53604. * Gets the r component (input)
  53605. */
  53606. readonly r: NodeMaterialConnectionPoint;
  53607. /**
  53608. * Gets the g component (input)
  53609. */
  53610. readonly g: NodeMaterialConnectionPoint;
  53611. /**
  53612. * Gets the b component (input)
  53613. */
  53614. readonly b: NodeMaterialConnectionPoint;
  53615. /**
  53616. * Gets the a component (input)
  53617. */
  53618. readonly a: NodeMaterialConnectionPoint;
  53619. /**
  53620. * Gets the rgba component (output)
  53621. */
  53622. readonly rgba: NodeMaterialConnectionPoint;
  53623. /**
  53624. * Gets the rgb component (output)
  53625. */
  53626. readonly rgb: NodeMaterialConnectionPoint;
  53627. protected _buildBlock(state: NodeMaterialBuildState): this;
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. /**
  53632. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53633. */
  53634. export class VectorMergerBlock extends NodeMaterialBlock {
  53635. /**
  53636. * Create a new VectorMergerBlock
  53637. * @param name defines the block name
  53638. */
  53639. constructor(name: string);
  53640. /**
  53641. * Gets the current class name
  53642. * @returns the class name
  53643. */
  53644. getClassName(): string;
  53645. /**
  53646. * Gets the x component (input)
  53647. */
  53648. readonly x: NodeMaterialConnectionPoint;
  53649. /**
  53650. * Gets the y component (input)
  53651. */
  53652. readonly y: NodeMaterialConnectionPoint;
  53653. /**
  53654. * Gets the z component (input)
  53655. */
  53656. readonly z: NodeMaterialConnectionPoint;
  53657. /**
  53658. * Gets the w component (input)
  53659. */
  53660. readonly w: NodeMaterialConnectionPoint;
  53661. /**
  53662. * Gets the xyzw component (output)
  53663. */
  53664. readonly xyzw: NodeMaterialConnectionPoint;
  53665. /**
  53666. * Gets the xyz component (output)
  53667. */
  53668. readonly xyz: NodeMaterialConnectionPoint;
  53669. /**
  53670. * Gets the xy component (output)
  53671. */
  53672. readonly xy: NodeMaterialConnectionPoint;
  53673. protected _buildBlock(state: NodeMaterialBuildState): this;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53679. */
  53680. export class ColorSplitterBlock extends NodeMaterialBlock {
  53681. /**
  53682. * Create a new ColorSplitterBlock
  53683. * @param name defines the block name
  53684. */
  53685. constructor(name: string);
  53686. /**
  53687. * Gets the current class name
  53688. * @returns the class name
  53689. */
  53690. getClassName(): string;
  53691. /**
  53692. * Gets the rgba component (input)
  53693. */
  53694. readonly rgba: NodeMaterialConnectionPoint;
  53695. /**
  53696. * Gets the rgb component (input)
  53697. */
  53698. readonly rgbIn: NodeMaterialConnectionPoint;
  53699. /**
  53700. * Gets the rgb component (output)
  53701. */
  53702. readonly rgbOut: NodeMaterialConnectionPoint;
  53703. /**
  53704. * Gets the r component (output)
  53705. */
  53706. readonly r: NodeMaterialConnectionPoint;
  53707. /**
  53708. * Gets the g component (output)
  53709. */
  53710. readonly g: NodeMaterialConnectionPoint;
  53711. /**
  53712. * Gets the b component (output)
  53713. */
  53714. readonly b: NodeMaterialConnectionPoint;
  53715. /**
  53716. * Gets the a component (output)
  53717. */
  53718. readonly a: NodeMaterialConnectionPoint;
  53719. protected _inputRename(name: string): string;
  53720. protected _outputRename(name: string): string;
  53721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53722. }
  53723. }
  53724. declare module BABYLON {
  53725. /**
  53726. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53727. */
  53728. export class VectorSplitterBlock extends NodeMaterialBlock {
  53729. /**
  53730. * Create a new VectorSplitterBlock
  53731. * @param name defines the block name
  53732. */
  53733. constructor(name: string);
  53734. /**
  53735. * Gets the current class name
  53736. * @returns the class name
  53737. */
  53738. getClassName(): string;
  53739. /**
  53740. * Gets the xyzw component (input)
  53741. */
  53742. readonly xyzw: NodeMaterialConnectionPoint;
  53743. /**
  53744. * Gets the xyz component (input)
  53745. */
  53746. readonly xyzIn: NodeMaterialConnectionPoint;
  53747. /**
  53748. * Gets the xy component (input)
  53749. */
  53750. readonly xyIn: NodeMaterialConnectionPoint;
  53751. /**
  53752. * Gets the xyz component (output)
  53753. */
  53754. readonly xyzOut: NodeMaterialConnectionPoint;
  53755. /**
  53756. * Gets the xy component (output)
  53757. */
  53758. readonly xyOut: NodeMaterialConnectionPoint;
  53759. /**
  53760. * Gets the x component (output)
  53761. */
  53762. readonly x: NodeMaterialConnectionPoint;
  53763. /**
  53764. * Gets the y component (output)
  53765. */
  53766. readonly y: NodeMaterialConnectionPoint;
  53767. /**
  53768. * Gets the z component (output)
  53769. */
  53770. readonly z: NodeMaterialConnectionPoint;
  53771. /**
  53772. * Gets the w component (output)
  53773. */
  53774. readonly w: NodeMaterialConnectionPoint;
  53775. protected _inputRename(name: string): string;
  53776. protected _outputRename(name: string): string;
  53777. protected _buildBlock(state: NodeMaterialBuildState): this;
  53778. }
  53779. }
  53780. declare module BABYLON {
  53781. /**
  53782. * Block used to lerp 2 values
  53783. */
  53784. export class LerpBlock extends NodeMaterialBlock {
  53785. /**
  53786. * Creates a new LerpBlock
  53787. * @param name defines the block name
  53788. */
  53789. constructor(name: string);
  53790. /**
  53791. * Gets the current class name
  53792. * @returns the class name
  53793. */
  53794. getClassName(): string;
  53795. /**
  53796. * Gets the left operand input component
  53797. */
  53798. readonly left: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the right operand input component
  53801. */
  53802. readonly right: NodeMaterialConnectionPoint;
  53803. /**
  53804. * Gets the gradient operand input component
  53805. */
  53806. readonly gradient: NodeMaterialConnectionPoint;
  53807. /**
  53808. * Gets the output component
  53809. */
  53810. readonly output: NodeMaterialConnectionPoint;
  53811. protected _buildBlock(state: NodeMaterialBuildState): this;
  53812. }
  53813. }
  53814. declare module BABYLON {
  53815. /**
  53816. * Block used to divide 2 vectors
  53817. */
  53818. export class DivideBlock extends NodeMaterialBlock {
  53819. /**
  53820. * Creates a new DivideBlock
  53821. * @param name defines the block name
  53822. */
  53823. constructor(name: string);
  53824. /**
  53825. * Gets the current class name
  53826. * @returns the class name
  53827. */
  53828. getClassName(): string;
  53829. /**
  53830. * Gets the left operand input component
  53831. */
  53832. readonly left: NodeMaterialConnectionPoint;
  53833. /**
  53834. * Gets the right operand input component
  53835. */
  53836. readonly right: NodeMaterialConnectionPoint;
  53837. /**
  53838. * Gets the output component
  53839. */
  53840. readonly output: NodeMaterialConnectionPoint;
  53841. protected _buildBlock(state: NodeMaterialBuildState): this;
  53842. }
  53843. }
  53844. declare module BABYLON {
  53845. /**
  53846. * Block used to subtract 2 vectors
  53847. */
  53848. export class SubtractBlock extends NodeMaterialBlock {
  53849. /**
  53850. * Creates a new SubtractBlock
  53851. * @param name defines the block name
  53852. */
  53853. constructor(name: string);
  53854. /**
  53855. * Gets the current class name
  53856. * @returns the class name
  53857. */
  53858. getClassName(): string;
  53859. /**
  53860. * Gets the left operand input component
  53861. */
  53862. readonly left: NodeMaterialConnectionPoint;
  53863. /**
  53864. * Gets the right operand input component
  53865. */
  53866. readonly right: NodeMaterialConnectionPoint;
  53867. /**
  53868. * Gets the output component
  53869. */
  53870. readonly output: NodeMaterialConnectionPoint;
  53871. protected _buildBlock(state: NodeMaterialBuildState): this;
  53872. }
  53873. }
  53874. declare module BABYLON {
  53875. /**
  53876. * Block used to step a value
  53877. */
  53878. export class StepBlock extends NodeMaterialBlock {
  53879. /**
  53880. * Creates a new AddBlock
  53881. * @param name defines the block name
  53882. */
  53883. constructor(name: string);
  53884. /**
  53885. * Gets the current class name
  53886. * @returns the class name
  53887. */
  53888. getClassName(): string;
  53889. /**
  53890. * Gets the value operand input component
  53891. */
  53892. readonly value: NodeMaterialConnectionPoint;
  53893. /**
  53894. * Gets the edge operand input component
  53895. */
  53896. readonly edge: NodeMaterialConnectionPoint;
  53897. /**
  53898. * Gets the output component
  53899. */
  53900. readonly output: NodeMaterialConnectionPoint;
  53901. protected _buildBlock(state: NodeMaterialBuildState): this;
  53902. }
  53903. }
  53904. declare module BABYLON {
  53905. /**
  53906. * Block used to get the opposite of a value
  53907. */
  53908. export class OppositeBlock extends NodeMaterialBlock {
  53909. /**
  53910. * Creates a new OppositeBlock
  53911. * @param name defines the block name
  53912. */
  53913. constructor(name: string);
  53914. /**
  53915. * Gets the current class name
  53916. * @returns the class name
  53917. */
  53918. getClassName(): string;
  53919. /**
  53920. * Gets the input component
  53921. */
  53922. readonly input: NodeMaterialConnectionPoint;
  53923. /**
  53924. * Gets the output component
  53925. */
  53926. readonly output: NodeMaterialConnectionPoint;
  53927. protected _buildBlock(state: NodeMaterialBuildState): this;
  53928. }
  53929. }
  53930. declare module BABYLON {
  53931. /**
  53932. * Block used to get the view direction
  53933. */
  53934. export class ViewDirectionBlock extends NodeMaterialBlock {
  53935. /**
  53936. * Creates a new ViewDirectionBlock
  53937. * @param name defines the block name
  53938. */
  53939. constructor(name: string);
  53940. /**
  53941. * Gets the current class name
  53942. * @returns the class name
  53943. */
  53944. getClassName(): string;
  53945. /**
  53946. * Gets the world position component
  53947. */
  53948. readonly worldPosition: NodeMaterialConnectionPoint;
  53949. /**
  53950. * Gets the camera position component
  53951. */
  53952. readonly cameraPosition: NodeMaterialConnectionPoint;
  53953. /**
  53954. * Gets the output component
  53955. */
  53956. readonly output: NodeMaterialConnectionPoint;
  53957. autoConfigure(material: NodeMaterial): void;
  53958. protected _buildBlock(state: NodeMaterialBuildState): this;
  53959. }
  53960. }
  53961. declare module BABYLON {
  53962. /**
  53963. * Block used to compute fresnel value
  53964. */
  53965. export class FresnelBlock extends NodeMaterialBlock {
  53966. /**
  53967. * Create a new FresnelBlock
  53968. * @param name defines the block name
  53969. */
  53970. constructor(name: string);
  53971. /**
  53972. * Gets the current class name
  53973. * @returns the class name
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Gets the world normal input component
  53978. */
  53979. readonly worldNormal: NodeMaterialConnectionPoint;
  53980. /**
  53981. * Gets the view direction input component
  53982. */
  53983. readonly viewDirection: NodeMaterialConnectionPoint;
  53984. /**
  53985. * Gets the bias input component
  53986. */
  53987. readonly bias: NodeMaterialConnectionPoint;
  53988. /**
  53989. * Gets the camera (or eye) position component
  53990. */
  53991. readonly power: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the fresnel output component
  53994. */
  53995. readonly fresnel: NodeMaterialConnectionPoint;
  53996. autoConfigure(material: NodeMaterial): void;
  53997. protected _buildBlock(state: NodeMaterialBuildState): this;
  53998. }
  53999. }
  54000. declare module BABYLON {
  54001. /**
  54002. * Effect Render Options
  54003. */
  54004. export interface IEffectRendererOptions {
  54005. /**
  54006. * Defines the vertices positions.
  54007. */
  54008. positions?: number[];
  54009. /**
  54010. * Defines the indices.
  54011. */
  54012. indices?: number[];
  54013. }
  54014. /**
  54015. * Helper class to render one or more effects
  54016. */
  54017. export class EffectRenderer {
  54018. private engine;
  54019. private static _DefaultOptions;
  54020. private _vertexBuffers;
  54021. private _indexBuffer;
  54022. private _ringBufferIndex;
  54023. private _ringScreenBuffer;
  54024. private _fullscreenViewport;
  54025. private _getNextFrameBuffer;
  54026. /**
  54027. * Creates an effect renderer
  54028. * @param engine the engine to use for rendering
  54029. * @param options defines the options of the effect renderer
  54030. */
  54031. constructor(engine: Engine, options?: IEffectRendererOptions);
  54032. /**
  54033. * Sets the current viewport in normalized coordinates 0-1
  54034. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54035. */
  54036. setViewport(viewport?: Viewport): void;
  54037. /**
  54038. * Sets the current effect wrapper to use during draw.
  54039. * The effect needs to be ready before calling this api.
  54040. * This also sets the default full screen position attribute.
  54041. * @param effectWrapper Defines the effect to draw with
  54042. */
  54043. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54044. /**
  54045. * Draws a full screen quad.
  54046. */
  54047. draw(): void;
  54048. /**
  54049. * renders one or more effects to a specified texture
  54050. * @param effectWrappers list of effects to renderer
  54051. * @param outputTexture texture to draw to, if null it will render to the screen
  54052. */
  54053. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54054. /**
  54055. * Disposes of the effect renderer
  54056. */
  54057. dispose(): void;
  54058. }
  54059. /**
  54060. * Options to create an EffectWrapper
  54061. */
  54062. interface EffectWrapperCreationOptions {
  54063. /**
  54064. * Engine to use to create the effect
  54065. */
  54066. engine: Engine;
  54067. /**
  54068. * Fragment shader for the effect
  54069. */
  54070. fragmentShader: string;
  54071. /**
  54072. * Vertex shader for the effect
  54073. */
  54074. vertexShader?: string;
  54075. /**
  54076. * Attributes to use in the shader
  54077. */
  54078. attributeNames?: Array<string>;
  54079. /**
  54080. * Uniforms to use in the shader
  54081. */
  54082. uniformNames?: Array<string>;
  54083. /**
  54084. * Texture sampler names to use in the shader
  54085. */
  54086. samplerNames?: Array<string>;
  54087. /**
  54088. * The friendly name of the effect displayed in Spector.
  54089. */
  54090. name?: string;
  54091. }
  54092. /**
  54093. * Wraps an effect to be used for rendering
  54094. */
  54095. export class EffectWrapper {
  54096. /**
  54097. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54098. */
  54099. onApplyObservable: Observable<{}>;
  54100. /**
  54101. * The underlying effect
  54102. */
  54103. effect: Effect;
  54104. /**
  54105. * Creates an effect to be renderer
  54106. * @param creationOptions options to create the effect
  54107. */
  54108. constructor(creationOptions: EffectWrapperCreationOptions);
  54109. /**
  54110. * Disposes of the effect wrapper
  54111. */
  54112. dispose(): void;
  54113. }
  54114. }
  54115. declare module BABYLON {
  54116. /**
  54117. * Helper class to push actions to a pool of workers.
  54118. */
  54119. export class WorkerPool implements IDisposable {
  54120. private _workerInfos;
  54121. private _pendingActions;
  54122. /**
  54123. * Constructor
  54124. * @param workers Array of workers to use for actions
  54125. */
  54126. constructor(workers: Array<Worker>);
  54127. /**
  54128. * Terminates all workers and clears any pending actions.
  54129. */
  54130. dispose(): void;
  54131. /**
  54132. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54133. * pended until a worker has completed its action.
  54134. * @param action The action to perform. Call onComplete when the action is complete.
  54135. */
  54136. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54137. private _execute;
  54138. }
  54139. }
  54140. declare module BABYLON {
  54141. /**
  54142. * Configuration for Draco compression
  54143. */
  54144. export interface IDracoCompressionConfiguration {
  54145. /**
  54146. * Configuration for the decoder.
  54147. */
  54148. decoder: {
  54149. /**
  54150. * The url to the WebAssembly module.
  54151. */
  54152. wasmUrl?: string;
  54153. /**
  54154. * The url to the WebAssembly binary.
  54155. */
  54156. wasmBinaryUrl?: string;
  54157. /**
  54158. * The url to the fallback JavaScript module.
  54159. */
  54160. fallbackUrl?: string;
  54161. };
  54162. }
  54163. /**
  54164. * Draco compression (https://google.github.io/draco/)
  54165. *
  54166. * This class wraps the Draco module.
  54167. *
  54168. * **Encoder**
  54169. *
  54170. * The encoder is not currently implemented.
  54171. *
  54172. * **Decoder**
  54173. *
  54174. * 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.
  54175. *
  54176. * To update the configuration, use the following code:
  54177. * ```javascript
  54178. * DracoCompression.Configuration = {
  54179. * decoder: {
  54180. * wasmUrl: "<url to the WebAssembly library>",
  54181. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54182. * fallbackUrl: "<url to the fallback JavaScript library>",
  54183. * }
  54184. * };
  54185. * ```
  54186. *
  54187. * 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.
  54188. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54189. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54190. *
  54191. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54192. * ```javascript
  54193. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54194. * ```
  54195. *
  54196. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54197. */
  54198. export class DracoCompression implements IDisposable {
  54199. private _workerPoolPromise?;
  54200. private _decoderModulePromise?;
  54201. /**
  54202. * The configuration. Defaults to the following urls:
  54203. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54204. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54205. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54206. */
  54207. static Configuration: IDracoCompressionConfiguration;
  54208. /**
  54209. * Returns true if the decoder configuration is available.
  54210. */
  54211. static readonly DecoderAvailable: boolean;
  54212. /**
  54213. * Default number of workers to create when creating the draco compression object.
  54214. */
  54215. static DefaultNumWorkers: number;
  54216. private static GetDefaultNumWorkers;
  54217. private static _Default;
  54218. /**
  54219. * Default instance for the draco compression object.
  54220. */
  54221. static readonly Default: DracoCompression;
  54222. /**
  54223. * Constructor
  54224. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54225. */
  54226. constructor(numWorkers?: number);
  54227. /**
  54228. * Stop all async operations and release resources.
  54229. */
  54230. dispose(): void;
  54231. /**
  54232. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54233. * @returns a promise that resolves when ready
  54234. */
  54235. whenReadyAsync(): Promise<void>;
  54236. /**
  54237. * Decode Draco compressed mesh data to vertex data.
  54238. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54239. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54240. * @returns A promise that resolves with the decoded vertex data
  54241. */
  54242. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54243. [kind: string]: number;
  54244. }): Promise<VertexData>;
  54245. }
  54246. }
  54247. declare module BABYLON {
  54248. /**
  54249. * Class for building Constructive Solid Geometry
  54250. */
  54251. export class CSG {
  54252. private polygons;
  54253. /**
  54254. * The world matrix
  54255. */
  54256. matrix: Matrix;
  54257. /**
  54258. * Stores the position
  54259. */
  54260. position: Vector3;
  54261. /**
  54262. * Stores the rotation
  54263. */
  54264. rotation: Vector3;
  54265. /**
  54266. * Stores the rotation quaternion
  54267. */
  54268. rotationQuaternion: Nullable<Quaternion>;
  54269. /**
  54270. * Stores the scaling vector
  54271. */
  54272. scaling: Vector3;
  54273. /**
  54274. * Convert the Mesh to CSG
  54275. * @param mesh The Mesh to convert to CSG
  54276. * @returns A new CSG from the Mesh
  54277. */
  54278. static FromMesh(mesh: Mesh): CSG;
  54279. /**
  54280. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54281. * @param polygons Polygons used to construct a CSG solid
  54282. */
  54283. private static FromPolygons;
  54284. /**
  54285. * Clones, or makes a deep copy, of the CSG
  54286. * @returns A new CSG
  54287. */
  54288. clone(): CSG;
  54289. /**
  54290. * Unions this CSG with another CSG
  54291. * @param csg The CSG to union against this CSG
  54292. * @returns The unioned CSG
  54293. */
  54294. union(csg: CSG): CSG;
  54295. /**
  54296. * Unions this CSG with another CSG in place
  54297. * @param csg The CSG to union against this CSG
  54298. */
  54299. unionInPlace(csg: CSG): void;
  54300. /**
  54301. * Subtracts this CSG with another CSG
  54302. * @param csg The CSG to subtract against this CSG
  54303. * @returns A new CSG
  54304. */
  54305. subtract(csg: CSG): CSG;
  54306. /**
  54307. * Subtracts this CSG with another CSG in place
  54308. * @param csg The CSG to subtact against this CSG
  54309. */
  54310. subtractInPlace(csg: CSG): void;
  54311. /**
  54312. * Intersect this CSG with another CSG
  54313. * @param csg The CSG to intersect against this CSG
  54314. * @returns A new CSG
  54315. */
  54316. intersect(csg: CSG): CSG;
  54317. /**
  54318. * Intersects this CSG with another CSG in place
  54319. * @param csg The CSG to intersect against this CSG
  54320. */
  54321. intersectInPlace(csg: CSG): void;
  54322. /**
  54323. * Return a new CSG solid with solid and empty space switched. This solid is
  54324. * not modified.
  54325. * @returns A new CSG solid with solid and empty space switched
  54326. */
  54327. inverse(): CSG;
  54328. /**
  54329. * Inverses the CSG in place
  54330. */
  54331. inverseInPlace(): void;
  54332. /**
  54333. * This is used to keep meshes transformations so they can be restored
  54334. * when we build back a Babylon Mesh
  54335. * NB : All CSG operations are performed in world coordinates
  54336. * @param csg The CSG to copy the transform attributes from
  54337. * @returns This CSG
  54338. */
  54339. copyTransformAttributes(csg: CSG): CSG;
  54340. /**
  54341. * Build Raw mesh from CSG
  54342. * Coordinates here are in world space
  54343. * @param name The name of the mesh geometry
  54344. * @param scene The Scene
  54345. * @param keepSubMeshes Specifies if the submeshes should be kept
  54346. * @returns A new Mesh
  54347. */
  54348. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54349. /**
  54350. * Build Mesh from CSG taking material and transforms into account
  54351. * @param name The name of the Mesh
  54352. * @param material The material of the Mesh
  54353. * @param scene The Scene
  54354. * @param keepSubMeshes Specifies if submeshes should be kept
  54355. * @returns The new Mesh
  54356. */
  54357. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54358. }
  54359. }
  54360. declare module BABYLON {
  54361. /**
  54362. * Class used to create a trail following a mesh
  54363. */
  54364. export class TrailMesh extends Mesh {
  54365. private _generator;
  54366. private _autoStart;
  54367. private _running;
  54368. private _diameter;
  54369. private _length;
  54370. private _sectionPolygonPointsCount;
  54371. private _sectionVectors;
  54372. private _sectionNormalVectors;
  54373. private _beforeRenderObserver;
  54374. /**
  54375. * @constructor
  54376. * @param name The value used by scene.getMeshByName() to do a lookup.
  54377. * @param generator The mesh to generate a trail.
  54378. * @param scene The scene to add this mesh to.
  54379. * @param diameter Diameter of trailing mesh. Default is 1.
  54380. * @param length Length of trailing mesh. Default is 60.
  54381. * @param autoStart Automatically start trailing mesh. Default true.
  54382. */
  54383. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54384. /**
  54385. * "TrailMesh"
  54386. * @returns "TrailMesh"
  54387. */
  54388. getClassName(): string;
  54389. private _createMesh;
  54390. /**
  54391. * Start trailing mesh.
  54392. */
  54393. start(): void;
  54394. /**
  54395. * Stop trailing mesh.
  54396. */
  54397. stop(): void;
  54398. /**
  54399. * Update trailing mesh geometry.
  54400. */
  54401. update(): void;
  54402. /**
  54403. * Returns a new TrailMesh object.
  54404. * @param name is a string, the name given to the new mesh
  54405. * @param newGenerator use new generator object for cloned trail mesh
  54406. * @returns a new mesh
  54407. */
  54408. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54409. /**
  54410. * Serializes this trail mesh
  54411. * @param serializationObject object to write serialization to
  54412. */
  54413. serialize(serializationObject: any): void;
  54414. /**
  54415. * Parses a serialized trail mesh
  54416. * @param parsedMesh the serialized mesh
  54417. * @param scene the scene to create the trail mesh in
  54418. * @returns the created trail mesh
  54419. */
  54420. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54421. }
  54422. }
  54423. declare module BABYLON {
  54424. /**
  54425. * Class containing static functions to help procedurally build meshes
  54426. */
  54427. export class TiledBoxBuilder {
  54428. /**
  54429. * Creates a box mesh
  54430. * 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)
  54431. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54433. * * 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
  54434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54435. * @param name defines the name of the mesh
  54436. * @param options defines the options used to create the mesh
  54437. * @param scene defines the hosting scene
  54438. * @returns the box mesh
  54439. */
  54440. static CreateTiledBox(name: string, options: {
  54441. pattern?: number;
  54442. width?: number;
  54443. height?: number;
  54444. depth?: number;
  54445. tileSize?: number;
  54446. tileWidth?: number;
  54447. tileHeight?: number;
  54448. alignHorizontal?: number;
  54449. alignVertical?: number;
  54450. faceUV?: Vector4[];
  54451. faceColors?: Color4[];
  54452. sideOrientation?: number;
  54453. updatable?: boolean;
  54454. }, scene?: Nullable<Scene>): Mesh;
  54455. }
  54456. }
  54457. declare module BABYLON {
  54458. /**
  54459. * Class containing static functions to help procedurally build meshes
  54460. */
  54461. export class TorusKnotBuilder {
  54462. /**
  54463. * Creates a torus knot mesh
  54464. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54465. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54466. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54467. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54469. * * 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
  54470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54471. * @param name defines the name of the mesh
  54472. * @param options defines the options used to create the mesh
  54473. * @param scene defines the hosting scene
  54474. * @returns the torus knot mesh
  54475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54476. */
  54477. static CreateTorusKnot(name: string, options: {
  54478. radius?: number;
  54479. tube?: number;
  54480. radialSegments?: number;
  54481. tubularSegments?: number;
  54482. p?: number;
  54483. q?: number;
  54484. updatable?: boolean;
  54485. sideOrientation?: number;
  54486. frontUVs?: Vector4;
  54487. backUVs?: Vector4;
  54488. }, scene: any): Mesh;
  54489. }
  54490. }
  54491. declare module BABYLON {
  54492. /**
  54493. * Polygon
  54494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54495. */
  54496. export class Polygon {
  54497. /**
  54498. * Creates a rectangle
  54499. * @param xmin bottom X coord
  54500. * @param ymin bottom Y coord
  54501. * @param xmax top X coord
  54502. * @param ymax top Y coord
  54503. * @returns points that make the resulting rectation
  54504. */
  54505. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54506. /**
  54507. * Creates a circle
  54508. * @param radius radius of circle
  54509. * @param cx scale in x
  54510. * @param cy scale in y
  54511. * @param numberOfSides number of sides that make up the circle
  54512. * @returns points that make the resulting circle
  54513. */
  54514. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54515. /**
  54516. * Creates a polygon from input string
  54517. * @param input Input polygon data
  54518. * @returns the parsed points
  54519. */
  54520. static Parse(input: string): Vector2[];
  54521. /**
  54522. * Starts building a polygon from x and y coordinates
  54523. * @param x x coordinate
  54524. * @param y y coordinate
  54525. * @returns the started path2
  54526. */
  54527. static StartingAt(x: number, y: number): Path2;
  54528. }
  54529. /**
  54530. * Builds a polygon
  54531. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54532. */
  54533. export class PolygonMeshBuilder {
  54534. private _points;
  54535. private _outlinepoints;
  54536. private _holes;
  54537. private _name;
  54538. private _scene;
  54539. private _epoints;
  54540. private _eholes;
  54541. private _addToepoint;
  54542. /**
  54543. * Babylon reference to the earcut plugin.
  54544. */
  54545. bjsEarcut: any;
  54546. /**
  54547. * Creates a PolygonMeshBuilder
  54548. * @param name name of the builder
  54549. * @param contours Path of the polygon
  54550. * @param scene scene to add to when creating the mesh
  54551. * @param earcutInjection can be used to inject your own earcut reference
  54552. */
  54553. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54554. /**
  54555. * Adds a whole within the polygon
  54556. * @param hole Array of points defining the hole
  54557. * @returns this
  54558. */
  54559. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54560. /**
  54561. * Creates the polygon
  54562. * @param updatable If the mesh should be updatable
  54563. * @param depth The depth of the mesh created
  54564. * @returns the created mesh
  54565. */
  54566. build(updatable?: boolean, depth?: number): Mesh;
  54567. /**
  54568. * Creates the polygon
  54569. * @param depth The depth of the mesh created
  54570. * @returns the created VertexData
  54571. */
  54572. buildVertexData(depth?: number): VertexData;
  54573. /**
  54574. * Adds a side to the polygon
  54575. * @param positions points that make the polygon
  54576. * @param normals normals of the polygon
  54577. * @param uvs uvs of the polygon
  54578. * @param indices indices of the polygon
  54579. * @param bounds bounds of the polygon
  54580. * @param points points of the polygon
  54581. * @param depth depth of the polygon
  54582. * @param flip flip of the polygon
  54583. */
  54584. private addSide;
  54585. }
  54586. }
  54587. declare module BABYLON {
  54588. /**
  54589. * Class containing static functions to help procedurally build meshes
  54590. */
  54591. export class PolygonBuilder {
  54592. /**
  54593. * Creates a polygon mesh
  54594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54595. * * 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
  54596. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54598. * * 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)
  54599. * * Remember you can only change the shape positions, not their number when updating a polygon
  54600. * @param name defines the name of the mesh
  54601. * @param options defines the options used to create the mesh
  54602. * @param scene defines the hosting scene
  54603. * @param earcutInjection can be used to inject your own earcut reference
  54604. * @returns the polygon mesh
  54605. */
  54606. static CreatePolygon(name: string, options: {
  54607. shape: Vector3[];
  54608. holes?: Vector3[][];
  54609. depth?: number;
  54610. faceUV?: Vector4[];
  54611. faceColors?: Color4[];
  54612. updatable?: boolean;
  54613. sideOrientation?: number;
  54614. frontUVs?: Vector4;
  54615. backUVs?: Vector4;
  54616. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54617. /**
  54618. * Creates an extruded polygon mesh, with depth in the Y direction.
  54619. * * 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)
  54620. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54621. * @param name defines the name of the mesh
  54622. * @param options defines the options used to create the mesh
  54623. * @param scene defines the hosting scene
  54624. * @param earcutInjection can be used to inject your own earcut reference
  54625. * @returns the polygon mesh
  54626. */
  54627. static ExtrudePolygon(name: string, options: {
  54628. shape: Vector3[];
  54629. holes?: Vector3[][];
  54630. depth?: number;
  54631. faceUV?: Vector4[];
  54632. faceColors?: Color4[];
  54633. updatable?: boolean;
  54634. sideOrientation?: number;
  54635. frontUVs?: Vector4;
  54636. backUVs?: Vector4;
  54637. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. /**
  54642. * Class containing static functions to help procedurally build meshes
  54643. */
  54644. export class LatheBuilder {
  54645. /**
  54646. * Creates lathe mesh.
  54647. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54648. * * 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
  54649. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54650. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54651. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54652. * * 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
  54653. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54654. * * 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
  54655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54656. * * 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
  54657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54659. * @param name defines the name of the mesh
  54660. * @param options defines the options used to create the mesh
  54661. * @param scene defines the hosting scene
  54662. * @returns the lathe mesh
  54663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54664. */
  54665. static CreateLathe(name: string, options: {
  54666. shape: Vector3[];
  54667. radius?: number;
  54668. tessellation?: number;
  54669. clip?: number;
  54670. arc?: number;
  54671. closed?: boolean;
  54672. updatable?: boolean;
  54673. sideOrientation?: number;
  54674. frontUVs?: Vector4;
  54675. backUVs?: Vector4;
  54676. cap?: number;
  54677. invertUV?: boolean;
  54678. }, scene?: Nullable<Scene>): Mesh;
  54679. }
  54680. }
  54681. declare module BABYLON {
  54682. /**
  54683. * Class containing static functions to help procedurally build meshes
  54684. */
  54685. export class TiledPlaneBuilder {
  54686. /**
  54687. * Creates a tiled plane mesh
  54688. * * The parameter `pattern` will, depending on value, do nothing or
  54689. * * * flip (reflect about central vertical) alternate tiles across and up
  54690. * * * flip every tile on alternate rows
  54691. * * * rotate (180 degs) alternate tiles across and up
  54692. * * * rotate every tile on alternate rows
  54693. * * * flip and rotate alternate tiles across and up
  54694. * * * flip and rotate every tile on alternate rows
  54695. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54696. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54697. * * 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
  54698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54699. * * 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)
  54700. * * 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)
  54701. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54702. * @param name defines the name of the mesh
  54703. * @param options defines the options used to create the mesh
  54704. * @param scene defines the hosting scene
  54705. * @returns the box mesh
  54706. */
  54707. static CreateTiledPlane(name: string, options: {
  54708. pattern?: number;
  54709. tileSize?: number;
  54710. tileWidth?: number;
  54711. tileHeight?: number;
  54712. size?: number;
  54713. width?: number;
  54714. height?: number;
  54715. alignHorizontal?: number;
  54716. alignVertical?: number;
  54717. sideOrientation?: number;
  54718. frontUVs?: Vector4;
  54719. backUVs?: Vector4;
  54720. updatable?: boolean;
  54721. }, scene?: Nullable<Scene>): Mesh;
  54722. }
  54723. }
  54724. declare module BABYLON {
  54725. /**
  54726. * Class containing static functions to help procedurally build meshes
  54727. */
  54728. export class TubeBuilder {
  54729. /**
  54730. * Creates a tube mesh.
  54731. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54732. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54733. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54734. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54735. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54736. * * 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)
  54737. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54738. * * 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
  54739. * * 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
  54740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54741. * * 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
  54742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54744. * @param name defines the name of the mesh
  54745. * @param options defines the options used to create the mesh
  54746. * @param scene defines the hosting scene
  54747. * @returns the tube mesh
  54748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54749. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54750. */
  54751. static CreateTube(name: string, options: {
  54752. path: Vector3[];
  54753. radius?: number;
  54754. tessellation?: number;
  54755. radiusFunction?: {
  54756. (i: number, distance: number): number;
  54757. };
  54758. cap?: number;
  54759. arc?: number;
  54760. updatable?: boolean;
  54761. sideOrientation?: number;
  54762. frontUVs?: Vector4;
  54763. backUVs?: Vector4;
  54764. instance?: Mesh;
  54765. invertUV?: boolean;
  54766. }, scene?: Nullable<Scene>): Mesh;
  54767. }
  54768. }
  54769. declare module BABYLON {
  54770. /**
  54771. * Class containing static functions to help procedurally build meshes
  54772. */
  54773. export class IcoSphereBuilder {
  54774. /**
  54775. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54776. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54777. * * 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`)
  54778. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54779. * * 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
  54780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54781. * * 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
  54782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54783. * @param name defines the name of the mesh
  54784. * @param options defines the options used to create the mesh
  54785. * @param scene defines the hosting scene
  54786. * @returns the icosahedron mesh
  54787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54788. */
  54789. static CreateIcoSphere(name: string, options: {
  54790. radius?: number;
  54791. radiusX?: number;
  54792. radiusY?: number;
  54793. radiusZ?: number;
  54794. flat?: boolean;
  54795. subdivisions?: number;
  54796. sideOrientation?: number;
  54797. frontUVs?: Vector4;
  54798. backUVs?: Vector4;
  54799. updatable?: boolean;
  54800. }, scene?: Nullable<Scene>): Mesh;
  54801. }
  54802. }
  54803. declare module BABYLON {
  54804. /**
  54805. * Class containing static functions to help procedurally build meshes
  54806. */
  54807. export class DecalBuilder {
  54808. /**
  54809. * Creates a decal mesh.
  54810. * 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
  54811. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54812. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54813. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54814. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54815. * @param name defines the name of the mesh
  54816. * @param sourceMesh defines the mesh where the decal must be applied
  54817. * @param options defines the options used to create the mesh
  54818. * @param scene defines the hosting scene
  54819. * @returns the decal mesh
  54820. * @see https://doc.babylonjs.com/how_to/decals
  54821. */
  54822. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54823. position?: Vector3;
  54824. normal?: Vector3;
  54825. size?: Vector3;
  54826. angle?: number;
  54827. }): Mesh;
  54828. }
  54829. }
  54830. declare module BABYLON {
  54831. /**
  54832. * Class containing static functions to help procedurally build meshes
  54833. */
  54834. export class MeshBuilder {
  54835. /**
  54836. * Creates a box mesh
  54837. * * The parameter `size` sets the size (float) of each box side (default 1)
  54838. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54839. * * 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)
  54840. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54842. * * 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
  54843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54844. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54845. * @param name defines the name of the mesh
  54846. * @param options defines the options used to create the mesh
  54847. * @param scene defines the hosting scene
  54848. * @returns the box mesh
  54849. */
  54850. static CreateBox(name: string, options: {
  54851. size?: number;
  54852. width?: number;
  54853. height?: number;
  54854. depth?: number;
  54855. faceUV?: Vector4[];
  54856. faceColors?: Color4[];
  54857. sideOrientation?: number;
  54858. frontUVs?: Vector4;
  54859. backUVs?: Vector4;
  54860. updatable?: boolean;
  54861. }, scene?: Nullable<Scene>): Mesh;
  54862. /**
  54863. * Creates a tiled box mesh
  54864. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54866. * @param name defines the name of the mesh
  54867. * @param options defines the options used to create the mesh
  54868. * @param scene defines the hosting scene
  54869. * @returns the tiled box mesh
  54870. */
  54871. static CreateTiledBox(name: string, options: {
  54872. pattern?: number;
  54873. size?: number;
  54874. width?: number;
  54875. height?: number;
  54876. depth: number;
  54877. tileSize?: number;
  54878. tileWidth?: number;
  54879. tileHeight?: number;
  54880. faceUV?: Vector4[];
  54881. faceColors?: Color4[];
  54882. alignHorizontal?: number;
  54883. alignVertical?: number;
  54884. sideOrientation?: number;
  54885. updatable?: boolean;
  54886. }, scene?: Nullable<Scene>): Mesh;
  54887. /**
  54888. * Creates a sphere mesh
  54889. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54890. * * 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`)
  54891. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54892. * * 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
  54893. * * 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)
  54894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54895. * * 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
  54896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54897. * @param name defines the name of the mesh
  54898. * @param options defines the options used to create the mesh
  54899. * @param scene defines the hosting scene
  54900. * @returns the sphere mesh
  54901. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54902. */
  54903. static CreateSphere(name: string, options: {
  54904. segments?: number;
  54905. diameter?: number;
  54906. diameterX?: number;
  54907. diameterY?: number;
  54908. diameterZ?: number;
  54909. arc?: number;
  54910. slice?: number;
  54911. sideOrientation?: number;
  54912. frontUVs?: Vector4;
  54913. backUVs?: Vector4;
  54914. updatable?: boolean;
  54915. }, scene?: Nullable<Scene>): Mesh;
  54916. /**
  54917. * Creates a plane polygonal mesh. By default, this is a disc
  54918. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54919. * * 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
  54920. * * 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
  54921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54922. * * 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
  54923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54924. * @param name defines the name of the mesh
  54925. * @param options defines the options used to create the mesh
  54926. * @param scene defines the hosting scene
  54927. * @returns the plane polygonal mesh
  54928. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54929. */
  54930. static CreateDisc(name: string, options: {
  54931. radius?: number;
  54932. tessellation?: number;
  54933. arc?: number;
  54934. updatable?: boolean;
  54935. sideOrientation?: number;
  54936. frontUVs?: Vector4;
  54937. backUVs?: Vector4;
  54938. }, scene?: Nullable<Scene>): Mesh;
  54939. /**
  54940. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54941. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54942. * * 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`)
  54943. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54944. * * 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
  54945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54946. * * 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
  54947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54948. * @param name defines the name of the mesh
  54949. * @param options defines the options used to create the mesh
  54950. * @param scene defines the hosting scene
  54951. * @returns the icosahedron mesh
  54952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54953. */
  54954. static CreateIcoSphere(name: string, options: {
  54955. radius?: number;
  54956. radiusX?: number;
  54957. radiusY?: number;
  54958. radiusZ?: number;
  54959. flat?: boolean;
  54960. subdivisions?: number;
  54961. sideOrientation?: number;
  54962. frontUVs?: Vector4;
  54963. backUVs?: Vector4;
  54964. updatable?: boolean;
  54965. }, scene?: Nullable<Scene>): Mesh;
  54966. /**
  54967. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54968. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54969. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54970. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54971. * * 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
  54972. * * 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
  54973. * * 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
  54974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54975. * * 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
  54976. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54977. * * 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
  54978. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54979. * * 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
  54980. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54982. * @param name defines the name of the mesh
  54983. * @param options defines the options used to create the mesh
  54984. * @param scene defines the hosting scene
  54985. * @returns the ribbon mesh
  54986. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54988. */
  54989. static CreateRibbon(name: string, options: {
  54990. pathArray: Vector3[][];
  54991. closeArray?: boolean;
  54992. closePath?: boolean;
  54993. offset?: number;
  54994. updatable?: boolean;
  54995. sideOrientation?: number;
  54996. frontUVs?: Vector4;
  54997. backUVs?: Vector4;
  54998. instance?: Mesh;
  54999. invertUV?: boolean;
  55000. uvs?: Vector2[];
  55001. colors?: Color4[];
  55002. }, scene?: Nullable<Scene>): Mesh;
  55003. /**
  55004. * Creates a cylinder or a cone mesh
  55005. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55006. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55007. * * 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.
  55008. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55009. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55010. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55011. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55012. * * 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).
  55013. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55014. * * 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).
  55015. * * 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
  55016. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55017. * * 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
  55018. * * 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.
  55019. * * If `enclose` is false, a ring surface is one element.
  55020. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55021. * * 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
  55022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55023. * * 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
  55024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55025. * @param name defines the name of the mesh
  55026. * @param options defines the options used to create the mesh
  55027. * @param scene defines the hosting scene
  55028. * @returns the cylinder mesh
  55029. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55030. */
  55031. static CreateCylinder(name: string, options: {
  55032. height?: number;
  55033. diameterTop?: number;
  55034. diameterBottom?: number;
  55035. diameter?: number;
  55036. tessellation?: number;
  55037. subdivisions?: number;
  55038. arc?: number;
  55039. faceColors?: Color4[];
  55040. faceUV?: Vector4[];
  55041. updatable?: boolean;
  55042. hasRings?: boolean;
  55043. enclose?: boolean;
  55044. cap?: number;
  55045. sideOrientation?: number;
  55046. frontUVs?: Vector4;
  55047. backUVs?: Vector4;
  55048. }, scene?: Nullable<Scene>): Mesh;
  55049. /**
  55050. * Creates a torus mesh
  55051. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55052. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55053. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55057. * @param name defines the name of the mesh
  55058. * @param options defines the options used to create the mesh
  55059. * @param scene defines the hosting scene
  55060. * @returns the torus mesh
  55061. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55062. */
  55063. static CreateTorus(name: string, options: {
  55064. diameter?: number;
  55065. thickness?: number;
  55066. tessellation?: number;
  55067. updatable?: boolean;
  55068. sideOrientation?: number;
  55069. frontUVs?: Vector4;
  55070. backUVs?: Vector4;
  55071. }, scene?: Nullable<Scene>): Mesh;
  55072. /**
  55073. * Creates a torus knot mesh
  55074. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55075. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55076. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55077. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55079. * * 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
  55080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55081. * @param name defines the name of the mesh
  55082. * @param options defines the options used to create the mesh
  55083. * @param scene defines the hosting scene
  55084. * @returns the torus knot mesh
  55085. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55086. */
  55087. static CreateTorusKnot(name: string, options: {
  55088. radius?: number;
  55089. tube?: number;
  55090. radialSegments?: number;
  55091. tubularSegments?: number;
  55092. p?: number;
  55093. q?: number;
  55094. updatable?: boolean;
  55095. sideOrientation?: number;
  55096. frontUVs?: Vector4;
  55097. backUVs?: Vector4;
  55098. }, scene?: Nullable<Scene>): Mesh;
  55099. /**
  55100. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55101. * * 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
  55102. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55103. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55104. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55105. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55106. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55107. * * 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
  55108. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55111. * @param name defines the name of the new line system
  55112. * @param options defines the options used to create the line system
  55113. * @param scene defines the hosting scene
  55114. * @returns a new line system mesh
  55115. */
  55116. static CreateLineSystem(name: string, options: {
  55117. lines: Vector3[][];
  55118. updatable?: boolean;
  55119. instance?: Nullable<LinesMesh>;
  55120. colors?: Nullable<Color4[][]>;
  55121. useVertexAlpha?: boolean;
  55122. }, scene: Nullable<Scene>): LinesMesh;
  55123. /**
  55124. * Creates a line mesh
  55125. * 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
  55126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55127. * * The parameter `points` is an array successive Vector3
  55128. * * 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
  55129. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55130. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55131. * * When updating an instance, remember that only point positions can change, not the number of points
  55132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55134. * @param name defines the name of the new line system
  55135. * @param options defines the options used to create the line system
  55136. * @param scene defines the hosting scene
  55137. * @returns a new line mesh
  55138. */
  55139. static CreateLines(name: string, options: {
  55140. points: Vector3[];
  55141. updatable?: boolean;
  55142. instance?: Nullable<LinesMesh>;
  55143. colors?: Color4[];
  55144. useVertexAlpha?: boolean;
  55145. }, scene?: Nullable<Scene>): LinesMesh;
  55146. /**
  55147. * Creates a dashed line mesh
  55148. * * 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
  55149. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55150. * * The parameter `points` is an array successive Vector3
  55151. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55152. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55153. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55154. * * 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
  55155. * * When updating an instance, remember that only point positions can change, not the number of points
  55156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55157. * @param name defines the name of the mesh
  55158. * @param options defines the options used to create the mesh
  55159. * @param scene defines the hosting scene
  55160. * @returns the dashed line mesh
  55161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55162. */
  55163. static CreateDashedLines(name: string, options: {
  55164. points: Vector3[];
  55165. dashSize?: number;
  55166. gapSize?: number;
  55167. dashNb?: number;
  55168. updatable?: boolean;
  55169. instance?: LinesMesh;
  55170. }, scene?: Nullable<Scene>): LinesMesh;
  55171. /**
  55172. * 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.
  55173. * * 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.
  55174. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55175. * * 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.
  55176. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55177. * * 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
  55178. * * 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
  55179. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55181. * * 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
  55182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55184. * @param name defines the name of the mesh
  55185. * @param options defines the options used to create the mesh
  55186. * @param scene defines the hosting scene
  55187. * @returns the extruded shape mesh
  55188. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55190. */
  55191. static ExtrudeShape(name: string, options: {
  55192. shape: Vector3[];
  55193. path: Vector3[];
  55194. scale?: number;
  55195. rotation?: number;
  55196. cap?: number;
  55197. updatable?: boolean;
  55198. sideOrientation?: number;
  55199. frontUVs?: Vector4;
  55200. backUVs?: Vector4;
  55201. instance?: Mesh;
  55202. invertUV?: boolean;
  55203. }, scene?: Nullable<Scene>): Mesh;
  55204. /**
  55205. * Creates an custom extruded shape mesh.
  55206. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55207. * * 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.
  55208. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55209. * * 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
  55210. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55211. * * 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
  55212. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55213. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55214. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55215. * * 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
  55216. * * 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
  55217. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55219. * * 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
  55220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55222. * @param name defines the name of the mesh
  55223. * @param options defines the options used to create the mesh
  55224. * @param scene defines the hosting scene
  55225. * @returns the custom extruded shape mesh
  55226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55229. */
  55230. static ExtrudeShapeCustom(name: string, options: {
  55231. shape: Vector3[];
  55232. path: Vector3[];
  55233. scaleFunction?: any;
  55234. rotationFunction?: any;
  55235. ribbonCloseArray?: boolean;
  55236. ribbonClosePath?: boolean;
  55237. cap?: number;
  55238. updatable?: boolean;
  55239. sideOrientation?: number;
  55240. frontUVs?: Vector4;
  55241. backUVs?: Vector4;
  55242. instance?: Mesh;
  55243. invertUV?: boolean;
  55244. }, scene?: Nullable<Scene>): Mesh;
  55245. /**
  55246. * Creates lathe mesh.
  55247. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55248. * * 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
  55249. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55250. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55251. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55252. * * 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
  55253. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55254. * * 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
  55255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55256. * * 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
  55257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55259. * @param name defines the name of the mesh
  55260. * @param options defines the options used to create the mesh
  55261. * @param scene defines the hosting scene
  55262. * @returns the lathe mesh
  55263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55264. */
  55265. static CreateLathe(name: string, options: {
  55266. shape: Vector3[];
  55267. radius?: number;
  55268. tessellation?: number;
  55269. clip?: number;
  55270. arc?: number;
  55271. closed?: boolean;
  55272. updatable?: boolean;
  55273. sideOrientation?: number;
  55274. frontUVs?: Vector4;
  55275. backUVs?: Vector4;
  55276. cap?: number;
  55277. invertUV?: boolean;
  55278. }, scene?: Nullable<Scene>): Mesh;
  55279. /**
  55280. * Creates a tiled plane mesh
  55281. * * You can set a limited pattern arrangement with the tiles
  55282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55283. * * 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
  55284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55285. * @param name defines the name of the mesh
  55286. * @param options defines the options used to create the mesh
  55287. * @param scene defines the hosting scene
  55288. * @returns the plane mesh
  55289. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55290. */
  55291. static CreateTiledPlane(name: string, options: {
  55292. pattern?: number;
  55293. tileSize?: number;
  55294. tileWidth?: number;
  55295. tileHeight?: number;
  55296. size?: number;
  55297. width?: number;
  55298. height?: number;
  55299. alignHorizontal?: number;
  55300. alignVertical?: number;
  55301. sideOrientation?: number;
  55302. frontUVs?: Vector4;
  55303. backUVs?: Vector4;
  55304. updatable?: boolean;
  55305. }, scene?: Nullable<Scene>): Mesh;
  55306. /**
  55307. * Creates a plane mesh
  55308. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55309. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55310. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55312. * * 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
  55313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55314. * @param name defines the name of the mesh
  55315. * @param options defines the options used to create the mesh
  55316. * @param scene defines the hosting scene
  55317. * @returns the plane mesh
  55318. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55319. */
  55320. static CreatePlane(name: string, options: {
  55321. size?: number;
  55322. width?: number;
  55323. height?: number;
  55324. sideOrientation?: number;
  55325. frontUVs?: Vector4;
  55326. backUVs?: Vector4;
  55327. updatable?: boolean;
  55328. sourcePlane?: Plane;
  55329. }, scene?: Nullable<Scene>): Mesh;
  55330. /**
  55331. * Creates a ground mesh
  55332. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55333. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55335. * @param name defines the name of the mesh
  55336. * @param options defines the options used to create the mesh
  55337. * @param scene defines the hosting scene
  55338. * @returns the ground mesh
  55339. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55340. */
  55341. static CreateGround(name: string, options: {
  55342. width?: number;
  55343. height?: number;
  55344. subdivisions?: number;
  55345. subdivisionsX?: number;
  55346. subdivisionsY?: number;
  55347. updatable?: boolean;
  55348. }, scene?: Nullable<Scene>): Mesh;
  55349. /**
  55350. * Creates a tiled ground mesh
  55351. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55352. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55353. * * 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
  55354. * * 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
  55355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55356. * @param name defines the name of the mesh
  55357. * @param options defines the options used to create the mesh
  55358. * @param scene defines the hosting scene
  55359. * @returns the tiled ground mesh
  55360. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55361. */
  55362. static CreateTiledGround(name: string, options: {
  55363. xmin: number;
  55364. zmin: number;
  55365. xmax: number;
  55366. zmax: number;
  55367. subdivisions?: {
  55368. w: number;
  55369. h: number;
  55370. };
  55371. precision?: {
  55372. w: number;
  55373. h: number;
  55374. };
  55375. updatable?: boolean;
  55376. }, scene?: Nullable<Scene>): Mesh;
  55377. /**
  55378. * Creates a ground mesh from a height map
  55379. * * The parameter `url` sets the URL of the height map image resource.
  55380. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55381. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55382. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55383. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55384. * * 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.
  55385. * * 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).
  55386. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55388. * @param name defines the name of the mesh
  55389. * @param url defines the url to the height map
  55390. * @param options defines the options used to create the mesh
  55391. * @param scene defines the hosting scene
  55392. * @returns the ground mesh
  55393. * @see https://doc.babylonjs.com/babylon101/height_map
  55394. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55395. */
  55396. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55397. width?: number;
  55398. height?: number;
  55399. subdivisions?: number;
  55400. minHeight?: number;
  55401. maxHeight?: number;
  55402. colorFilter?: Color3;
  55403. alphaFilter?: number;
  55404. updatable?: boolean;
  55405. onReady?: (mesh: GroundMesh) => void;
  55406. }, scene?: Nullable<Scene>): GroundMesh;
  55407. /**
  55408. * Creates a polygon mesh
  55409. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55410. * * 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
  55411. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55414. * * Remember you can only change the shape positions, not their number when updating a polygon
  55415. * @param name defines the name of the mesh
  55416. * @param options defines the options used to create the mesh
  55417. * @param scene defines the hosting scene
  55418. * @param earcutInjection can be used to inject your own earcut reference
  55419. * @returns the polygon mesh
  55420. */
  55421. static CreatePolygon(name: string, options: {
  55422. shape: Vector3[];
  55423. holes?: Vector3[][];
  55424. depth?: number;
  55425. faceUV?: Vector4[];
  55426. faceColors?: Color4[];
  55427. updatable?: boolean;
  55428. sideOrientation?: number;
  55429. frontUVs?: Vector4;
  55430. backUVs?: Vector4;
  55431. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55432. /**
  55433. * Creates an extruded polygon mesh, with depth in the Y direction.
  55434. * * 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)
  55435. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55436. * @param name defines the name of the mesh
  55437. * @param options defines the options used to create the mesh
  55438. * @param scene defines the hosting scene
  55439. * @param earcutInjection can be used to inject your own earcut reference
  55440. * @returns the polygon mesh
  55441. */
  55442. static ExtrudePolygon(name: string, options: {
  55443. shape: Vector3[];
  55444. holes?: Vector3[][];
  55445. depth?: number;
  55446. faceUV?: Vector4[];
  55447. faceColors?: Color4[];
  55448. updatable?: boolean;
  55449. sideOrientation?: number;
  55450. frontUVs?: Vector4;
  55451. backUVs?: Vector4;
  55452. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55453. /**
  55454. * Creates a tube mesh.
  55455. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55456. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55457. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55458. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55459. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55460. * * 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)
  55461. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55462. * * 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
  55463. * * 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
  55464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55465. * * 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
  55466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55468. * @param name defines the name of the mesh
  55469. * @param options defines the options used to create the mesh
  55470. * @param scene defines the hosting scene
  55471. * @returns the tube mesh
  55472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55473. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55474. */
  55475. static CreateTube(name: string, options: {
  55476. path: Vector3[];
  55477. radius?: number;
  55478. tessellation?: number;
  55479. radiusFunction?: {
  55480. (i: number, distance: number): number;
  55481. };
  55482. cap?: number;
  55483. arc?: number;
  55484. updatable?: boolean;
  55485. sideOrientation?: number;
  55486. frontUVs?: Vector4;
  55487. backUVs?: Vector4;
  55488. instance?: Mesh;
  55489. invertUV?: boolean;
  55490. }, scene?: Nullable<Scene>): Mesh;
  55491. /**
  55492. * Creates a polyhedron mesh
  55493. * * 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
  55494. * * The parameter `size` (positive float, default 1) sets the polygon size
  55495. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55496. * * 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`
  55497. * * 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
  55498. * * 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)`)
  55499. * * 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
  55500. * * 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
  55501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55502. * * 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
  55503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55504. * @param name defines the name of the mesh
  55505. * @param options defines the options used to create the mesh
  55506. * @param scene defines the hosting scene
  55507. * @returns the polyhedron mesh
  55508. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55509. */
  55510. static CreatePolyhedron(name: string, options: {
  55511. type?: number;
  55512. size?: number;
  55513. sizeX?: number;
  55514. sizeY?: number;
  55515. sizeZ?: number;
  55516. custom?: any;
  55517. faceUV?: Vector4[];
  55518. faceColors?: Color4[];
  55519. flat?: boolean;
  55520. updatable?: boolean;
  55521. sideOrientation?: number;
  55522. frontUVs?: Vector4;
  55523. backUVs?: Vector4;
  55524. }, scene?: Nullable<Scene>): Mesh;
  55525. /**
  55526. * Creates a decal mesh.
  55527. * 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
  55528. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55529. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55530. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55531. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55532. * @param name defines the name of the mesh
  55533. * @param sourceMesh defines the mesh where the decal must be applied
  55534. * @param options defines the options used to create the mesh
  55535. * @param scene defines the hosting scene
  55536. * @returns the decal mesh
  55537. * @see https://doc.babylonjs.com/how_to/decals
  55538. */
  55539. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55540. position?: Vector3;
  55541. normal?: Vector3;
  55542. size?: Vector3;
  55543. angle?: number;
  55544. }): Mesh;
  55545. }
  55546. }
  55547. declare module BABYLON {
  55548. /**
  55549. * A simplifier interface for future simplification implementations
  55550. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55551. */
  55552. export interface ISimplifier {
  55553. /**
  55554. * Simplification of a given mesh according to the given settings.
  55555. * Since this requires computation, it is assumed that the function runs async.
  55556. * @param settings The settings of the simplification, including quality and distance
  55557. * @param successCallback A callback that will be called after the mesh was simplified.
  55558. * @param errorCallback in case of an error, this callback will be called. optional.
  55559. */
  55560. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55561. }
  55562. /**
  55563. * Expected simplification settings.
  55564. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55565. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55566. */
  55567. export interface ISimplificationSettings {
  55568. /**
  55569. * Gets or sets the expected quality
  55570. */
  55571. quality: number;
  55572. /**
  55573. * Gets or sets the distance when this optimized version should be used
  55574. */
  55575. distance: number;
  55576. /**
  55577. * Gets an already optimized mesh
  55578. */
  55579. optimizeMesh?: boolean;
  55580. }
  55581. /**
  55582. * Class used to specify simplification options
  55583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55584. */
  55585. export class SimplificationSettings implements ISimplificationSettings {
  55586. /** expected quality */
  55587. quality: number;
  55588. /** distance when this optimized version should be used */
  55589. distance: number;
  55590. /** already optimized mesh */
  55591. optimizeMesh?: boolean | undefined;
  55592. /**
  55593. * Creates a SimplificationSettings
  55594. * @param quality expected quality
  55595. * @param distance distance when this optimized version should be used
  55596. * @param optimizeMesh already optimized mesh
  55597. */
  55598. constructor(
  55599. /** expected quality */
  55600. quality: number,
  55601. /** distance when this optimized version should be used */
  55602. distance: number,
  55603. /** already optimized mesh */
  55604. optimizeMesh?: boolean | undefined);
  55605. }
  55606. /**
  55607. * Interface used to define a simplification task
  55608. */
  55609. export interface ISimplificationTask {
  55610. /**
  55611. * Array of settings
  55612. */
  55613. settings: Array<ISimplificationSettings>;
  55614. /**
  55615. * Simplification type
  55616. */
  55617. simplificationType: SimplificationType;
  55618. /**
  55619. * Mesh to simplify
  55620. */
  55621. mesh: Mesh;
  55622. /**
  55623. * Callback called on success
  55624. */
  55625. successCallback?: () => void;
  55626. /**
  55627. * Defines if parallel processing can be used
  55628. */
  55629. parallelProcessing: boolean;
  55630. }
  55631. /**
  55632. * Queue used to order the simplification tasks
  55633. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55634. */
  55635. export class SimplificationQueue {
  55636. private _simplificationArray;
  55637. /**
  55638. * Gets a boolean indicating that the process is still running
  55639. */
  55640. running: boolean;
  55641. /**
  55642. * Creates a new queue
  55643. */
  55644. constructor();
  55645. /**
  55646. * Adds a new simplification task
  55647. * @param task defines a task to add
  55648. */
  55649. addTask(task: ISimplificationTask): void;
  55650. /**
  55651. * Execute next task
  55652. */
  55653. executeNext(): void;
  55654. /**
  55655. * Execute a simplification task
  55656. * @param task defines the task to run
  55657. */
  55658. runSimplification(task: ISimplificationTask): void;
  55659. private getSimplifier;
  55660. }
  55661. /**
  55662. * The implemented types of simplification
  55663. * At the moment only Quadratic Error Decimation is implemented
  55664. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55665. */
  55666. export enum SimplificationType {
  55667. /** Quadratic error decimation */
  55668. QUADRATIC = 0
  55669. }
  55670. }
  55671. declare module BABYLON {
  55672. interface Scene {
  55673. /** @hidden (Backing field) */
  55674. _simplificationQueue: SimplificationQueue;
  55675. /**
  55676. * Gets or sets the simplification queue attached to the scene
  55677. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55678. */
  55679. simplificationQueue: SimplificationQueue;
  55680. }
  55681. interface Mesh {
  55682. /**
  55683. * Simplify the mesh according to the given array of settings.
  55684. * Function will return immediately and will simplify async
  55685. * @param settings a collection of simplification settings
  55686. * @param parallelProcessing should all levels calculate parallel or one after the other
  55687. * @param simplificationType the type of simplification to run
  55688. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55689. * @returns the current mesh
  55690. */
  55691. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55692. }
  55693. /**
  55694. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55695. * created in a scene
  55696. */
  55697. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55698. /**
  55699. * The component name helpfull to identify the component in the list of scene components.
  55700. */
  55701. readonly name: string;
  55702. /**
  55703. * The scene the component belongs to.
  55704. */
  55705. scene: Scene;
  55706. /**
  55707. * Creates a new instance of the component for the given scene
  55708. * @param scene Defines the scene to register the component in
  55709. */
  55710. constructor(scene: Scene);
  55711. /**
  55712. * Registers the component in a given scene
  55713. */
  55714. register(): void;
  55715. /**
  55716. * Rebuilds the elements related to this component in case of
  55717. * context lost for instance.
  55718. */
  55719. rebuild(): void;
  55720. /**
  55721. * Disposes the component and the associated ressources
  55722. */
  55723. dispose(): void;
  55724. private _beforeCameraUpdate;
  55725. }
  55726. }
  55727. declare module BABYLON {
  55728. /**
  55729. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55730. */
  55731. export interface INavigationEnginePlugin {
  55732. /**
  55733. * plugin name
  55734. */
  55735. name: string;
  55736. /**
  55737. * Creates a navigation mesh
  55738. * @param meshes array of all the geometry used to compute the navigatio mesh
  55739. * @param parameters bunch of parameters used to filter geometry
  55740. */
  55741. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55742. /**
  55743. * Create a navigation mesh debug mesh
  55744. * @param scene is where the mesh will be added
  55745. * @returns debug display mesh
  55746. */
  55747. createDebugNavMesh(scene: Scene): Mesh;
  55748. /**
  55749. * Get a navigation mesh constrained position, closest to the parameter position
  55750. * @param position world position
  55751. * @returns the closest point to position constrained by the navigation mesh
  55752. */
  55753. getClosestPoint(position: Vector3): Vector3;
  55754. /**
  55755. * Get a navigation mesh constrained position, within a particular radius
  55756. * @param position world position
  55757. * @param maxRadius the maximum distance to the constrained world position
  55758. * @returns the closest point to position constrained by the navigation mesh
  55759. */
  55760. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55761. /**
  55762. * Compute the final position from a segment made of destination-position
  55763. * @param position world position
  55764. * @param destination world position
  55765. * @returns the resulting point along the navmesh
  55766. */
  55767. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55768. /**
  55769. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55770. * @param start world position
  55771. * @param end world position
  55772. * @returns array containing world position composing the path
  55773. */
  55774. computePath(start: Vector3, end: Vector3): Vector3[];
  55775. /**
  55776. * If this plugin is supported
  55777. * @returns true if plugin is supported
  55778. */
  55779. isSupported(): boolean;
  55780. /**
  55781. * Create a new Crowd so you can add agents
  55782. * @param maxAgents the maximum agent count in the crowd
  55783. * @param maxAgentRadius the maximum radius an agent can have
  55784. * @param scene to attach the crowd to
  55785. * @returns the crowd you can add agents to
  55786. */
  55787. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55788. /**
  55789. * Release all resources
  55790. */
  55791. dispose(): void;
  55792. }
  55793. /**
  55794. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55795. */
  55796. export interface ICrowd {
  55797. /**
  55798. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55799. * You can attach anything to that node. The node position is updated in the scene update tick.
  55800. * @param pos world position that will be constrained by the navigation mesh
  55801. * @param parameters agent parameters
  55802. * @param transform hooked to the agent that will be update by the scene
  55803. * @returns agent index
  55804. */
  55805. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55806. /**
  55807. * Returns the agent position in world space
  55808. * @param index agent index returned by addAgent
  55809. * @returns world space position
  55810. */
  55811. getAgentPosition(index: number): Vector3;
  55812. /**
  55813. * Gets the agent velocity in world space
  55814. * @param index agent index returned by addAgent
  55815. * @returns world space velocity
  55816. */
  55817. getAgentVelocity(index: number): Vector3;
  55818. /**
  55819. * remove a particular agent previously created
  55820. * @param index agent index returned by addAgent
  55821. */
  55822. removeAgent(index: number): void;
  55823. /**
  55824. * get the list of all agents attached to this crowd
  55825. * @returns list of agent indices
  55826. */
  55827. getAgents(): number[];
  55828. /**
  55829. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55830. * @param deltaTime in seconds
  55831. */
  55832. update(deltaTime: number): void;
  55833. /**
  55834. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55835. * @param index agent index returned by addAgent
  55836. * @param destination targeted world position
  55837. */
  55838. agentGoto(index: number, destination: Vector3): void;
  55839. /**
  55840. * Release all resources
  55841. */
  55842. dispose(): void;
  55843. }
  55844. /**
  55845. * Configures an agent
  55846. */
  55847. export interface IAgentParameters {
  55848. /**
  55849. * Agent radius. [Limit: >= 0]
  55850. */
  55851. radius: number;
  55852. /**
  55853. * Agent height. [Limit: > 0]
  55854. */
  55855. height: number;
  55856. /**
  55857. * Maximum allowed acceleration. [Limit: >= 0]
  55858. */
  55859. maxAcceleration: number;
  55860. /**
  55861. * Maximum allowed speed. [Limit: >= 0]
  55862. */
  55863. maxSpeed: number;
  55864. /**
  55865. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55866. */
  55867. collisionQueryRange: number;
  55868. /**
  55869. * The path visibility optimization range. [Limit: > 0]
  55870. */
  55871. pathOptimizationRange: number;
  55872. /**
  55873. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55874. */
  55875. separationWeight: number;
  55876. }
  55877. /**
  55878. * Configures the navigation mesh creation
  55879. */
  55880. export interface INavMeshParameters {
  55881. /**
  55882. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55883. */
  55884. cs: number;
  55885. /**
  55886. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55887. */
  55888. ch: number;
  55889. /**
  55890. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55891. */
  55892. walkableSlopeAngle: number;
  55893. /**
  55894. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55895. * be considered walkable. [Limit: >= 3] [Units: vx]
  55896. */
  55897. walkableHeight: number;
  55898. /**
  55899. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55900. */
  55901. walkableClimb: number;
  55902. /**
  55903. * The distance to erode/shrink the walkable area of the heightfield away from
  55904. * obstructions. [Limit: >=0] [Units: vx]
  55905. */
  55906. walkableRadius: number;
  55907. /**
  55908. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55909. */
  55910. maxEdgeLen: number;
  55911. /**
  55912. * The maximum distance a simplfied contour's border edges should deviate
  55913. * the original raw contour. [Limit: >=0] [Units: vx]
  55914. */
  55915. maxSimplificationError: number;
  55916. /**
  55917. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55918. */
  55919. minRegionArea: number;
  55920. /**
  55921. * Any regions with a span count smaller than this value will, if possible,
  55922. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55923. */
  55924. mergeRegionArea: number;
  55925. /**
  55926. * The maximum number of vertices allowed for polygons generated during the
  55927. * contour to polygon conversion process. [Limit: >= 3]
  55928. */
  55929. maxVertsPerPoly: number;
  55930. /**
  55931. * Sets the sampling distance to use when generating the detail mesh.
  55932. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55933. */
  55934. detailSampleDist: number;
  55935. /**
  55936. * The maximum distance the detail mesh surface should deviate from heightfield
  55937. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55938. */
  55939. detailSampleMaxError: number;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /**
  55944. * RecastJS navigation plugin
  55945. */
  55946. export class RecastJSPlugin implements INavigationEnginePlugin {
  55947. /**
  55948. * Reference to the Recast library
  55949. */
  55950. bjsRECAST: any;
  55951. /**
  55952. * plugin name
  55953. */
  55954. name: string;
  55955. /**
  55956. * the first navmesh created. We might extend this to support multiple navmeshes
  55957. */
  55958. navMesh: any;
  55959. /**
  55960. * Initializes the recastJS plugin
  55961. * @param recastInjection can be used to inject your own recast reference
  55962. */
  55963. constructor(recastInjection?: any);
  55964. /**
  55965. * Creates a navigation mesh
  55966. * @param meshes array of all the geometry used to compute the navigatio mesh
  55967. * @param parameters bunch of parameters used to filter geometry
  55968. */
  55969. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55970. /**
  55971. * Create a navigation mesh debug mesh
  55972. * @param scene is where the mesh will be added
  55973. * @returns debug display mesh
  55974. */
  55975. createDebugNavMesh(scene: Scene): Mesh;
  55976. /**
  55977. * Get a navigation mesh constrained position, closest to the parameter position
  55978. * @param position world position
  55979. * @returns the closest point to position constrained by the navigation mesh
  55980. */
  55981. getClosestPoint(position: Vector3): Vector3;
  55982. /**
  55983. * Get a navigation mesh constrained position, within a particular radius
  55984. * @param position world position
  55985. * @param maxRadius the maximum distance to the constrained world position
  55986. * @returns the closest point to position constrained by the navigation mesh
  55987. */
  55988. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55989. /**
  55990. * Compute the final position from a segment made of destination-position
  55991. * @param position world position
  55992. * @param destination world position
  55993. * @returns the resulting point along the navmesh
  55994. */
  55995. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55996. /**
  55997. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55998. * @param start world position
  55999. * @param end world position
  56000. * @returns array containing world position composing the path
  56001. */
  56002. computePath(start: Vector3, end: Vector3): Vector3[];
  56003. /**
  56004. * Create a new Crowd so you can add agents
  56005. * @param maxAgents the maximum agent count in the crowd
  56006. * @param maxAgentRadius the maximum radius an agent can have
  56007. * @param scene to attach the crowd to
  56008. * @returns the crowd you can add agents to
  56009. */
  56010. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56011. /**
  56012. * Disposes
  56013. */
  56014. dispose(): void;
  56015. /**
  56016. * If this plugin is supported
  56017. * @returns true if plugin is supported
  56018. */
  56019. isSupported(): boolean;
  56020. }
  56021. /**
  56022. * Recast detour crowd implementation
  56023. */
  56024. export class RecastJSCrowd implements ICrowd {
  56025. /**
  56026. * Recast/detour plugin
  56027. */
  56028. bjsRECASTPlugin: RecastJSPlugin;
  56029. /**
  56030. * Link to the detour crowd
  56031. */
  56032. recastCrowd: any;
  56033. /**
  56034. * One transform per agent
  56035. */
  56036. transforms: TransformNode[];
  56037. /**
  56038. * All agents created
  56039. */
  56040. agents: number[];
  56041. /**
  56042. * Link to the scene is kept to unregister the crowd from the scene
  56043. */
  56044. private _scene;
  56045. /**
  56046. * Observer for crowd updates
  56047. */
  56048. private _onBeforeAnimationsObserver;
  56049. /**
  56050. * Constructor
  56051. * @param plugin recastJS plugin
  56052. * @param maxAgents the maximum agent count in the crowd
  56053. * @param maxAgentRadius the maximum radius an agent can have
  56054. * @param scene to attach the crowd to
  56055. * @returns the crowd you can add agents to
  56056. */
  56057. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56058. /**
  56059. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56060. * You can attach anything to that node. The node position is updated in the scene update tick.
  56061. * @param pos world position that will be constrained by the navigation mesh
  56062. * @param parameters agent parameters
  56063. * @param transform hooked to the agent that will be update by the scene
  56064. * @returns agent index
  56065. */
  56066. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56067. /**
  56068. * Returns the agent position in world space
  56069. * @param index agent index returned by addAgent
  56070. * @returns world space position
  56071. */
  56072. getAgentPosition(index: number): Vector3;
  56073. /**
  56074. * Returns the agent velocity in world space
  56075. * @param index agent index returned by addAgent
  56076. * @returns world space velocity
  56077. */
  56078. getAgentVelocity(index: number): Vector3;
  56079. /**
  56080. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56081. * @param index agent index returned by addAgent
  56082. * @param destination targeted world position
  56083. */
  56084. agentGoto(index: number, destination: Vector3): void;
  56085. /**
  56086. * remove a particular agent previously created
  56087. * @param index agent index returned by addAgent
  56088. */
  56089. removeAgent(index: number): void;
  56090. /**
  56091. * get the list of all agents attached to this crowd
  56092. * @returns list of agent indices
  56093. */
  56094. getAgents(): number[];
  56095. /**
  56096. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56097. * @param deltaTime in seconds
  56098. */
  56099. update(deltaTime: number): void;
  56100. /**
  56101. * Release all resources
  56102. */
  56103. dispose(): void;
  56104. }
  56105. }
  56106. declare module BABYLON {
  56107. /**
  56108. * Class used to enable access to IndexedDB
  56109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56110. */
  56111. export class Database implements IOfflineProvider {
  56112. private _callbackManifestChecked;
  56113. private _currentSceneUrl;
  56114. private _db;
  56115. private _enableSceneOffline;
  56116. private _enableTexturesOffline;
  56117. private _manifestVersionFound;
  56118. private _mustUpdateRessources;
  56119. private _hasReachedQuota;
  56120. private _isSupported;
  56121. private _idbFactory;
  56122. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56123. private static IsUASupportingBlobStorage;
  56124. /**
  56125. * Gets a boolean indicating if Database storate is enabled (off by default)
  56126. */
  56127. static IDBStorageEnabled: boolean;
  56128. /**
  56129. * Gets a boolean indicating if scene must be saved in the database
  56130. */
  56131. readonly enableSceneOffline: boolean;
  56132. /**
  56133. * Gets a boolean indicating if textures must be saved in the database
  56134. */
  56135. readonly enableTexturesOffline: boolean;
  56136. /**
  56137. * Creates a new Database
  56138. * @param urlToScene defines the url to load the scene
  56139. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56140. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56141. */
  56142. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56143. private static _ParseURL;
  56144. private static _ReturnFullUrlLocation;
  56145. private _checkManifestFile;
  56146. /**
  56147. * Open the database and make it available
  56148. * @param successCallback defines the callback to call on success
  56149. * @param errorCallback defines the callback to call on error
  56150. */
  56151. open(successCallback: () => void, errorCallback: () => void): void;
  56152. /**
  56153. * Loads an image from the database
  56154. * @param url defines the url to load from
  56155. * @param image defines the target DOM image
  56156. */
  56157. loadImage(url: string, image: HTMLImageElement): void;
  56158. private _loadImageFromDBAsync;
  56159. private _saveImageIntoDBAsync;
  56160. private _checkVersionFromDB;
  56161. private _loadVersionFromDBAsync;
  56162. private _saveVersionIntoDBAsync;
  56163. /**
  56164. * Loads a file from database
  56165. * @param url defines the URL to load from
  56166. * @param sceneLoaded defines a callback to call on success
  56167. * @param progressCallBack defines a callback to call when progress changed
  56168. * @param errorCallback defines a callback to call on error
  56169. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56170. */
  56171. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56172. private _loadFileAsync;
  56173. private _saveFileAsync;
  56174. /**
  56175. * Validates if xhr data is correct
  56176. * @param xhr defines the request to validate
  56177. * @param dataType defines the expected data type
  56178. * @returns true if data is correct
  56179. */
  56180. private static _ValidateXHRData;
  56181. }
  56182. }
  56183. declare module BABYLON {
  56184. /** @hidden */
  56185. export var gpuUpdateParticlesPixelShader: {
  56186. name: string;
  56187. shader: string;
  56188. };
  56189. }
  56190. declare module BABYLON {
  56191. /** @hidden */
  56192. export var gpuUpdateParticlesVertexShader: {
  56193. name: string;
  56194. shader: string;
  56195. };
  56196. }
  56197. declare module BABYLON {
  56198. /** @hidden */
  56199. export var clipPlaneFragmentDeclaration2: {
  56200. name: string;
  56201. shader: string;
  56202. };
  56203. }
  56204. declare module BABYLON {
  56205. /** @hidden */
  56206. export var gpuRenderParticlesPixelShader: {
  56207. name: string;
  56208. shader: string;
  56209. };
  56210. }
  56211. declare module BABYLON {
  56212. /** @hidden */
  56213. export var clipPlaneVertexDeclaration2: {
  56214. name: string;
  56215. shader: string;
  56216. };
  56217. }
  56218. declare module BABYLON {
  56219. /** @hidden */
  56220. export var gpuRenderParticlesVertexShader: {
  56221. name: string;
  56222. shader: string;
  56223. };
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * This represents a GPU particle system in Babylon
  56228. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56229. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56230. */
  56231. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56232. /**
  56233. * The layer mask we are rendering the particles through.
  56234. */
  56235. layerMask: number;
  56236. private _capacity;
  56237. private _activeCount;
  56238. private _currentActiveCount;
  56239. private _accumulatedCount;
  56240. private _renderEffect;
  56241. private _updateEffect;
  56242. private _buffer0;
  56243. private _buffer1;
  56244. private _spriteBuffer;
  56245. private _updateVAO;
  56246. private _renderVAO;
  56247. private _targetIndex;
  56248. private _sourceBuffer;
  56249. private _targetBuffer;
  56250. private _engine;
  56251. private _currentRenderId;
  56252. private _started;
  56253. private _stopped;
  56254. private _timeDelta;
  56255. private _randomTexture;
  56256. private _randomTexture2;
  56257. private _attributesStrideSize;
  56258. private _updateEffectOptions;
  56259. private _randomTextureSize;
  56260. private _actualFrame;
  56261. private readonly _rawTextureWidth;
  56262. /**
  56263. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56264. */
  56265. static readonly IsSupported: boolean;
  56266. /**
  56267. * An event triggered when the system is disposed.
  56268. */
  56269. onDisposeObservable: Observable<GPUParticleSystem>;
  56270. /**
  56271. * Gets the maximum number of particles active at the same time.
  56272. * @returns The max number of active particles.
  56273. */
  56274. getCapacity(): number;
  56275. /**
  56276. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56277. * to override the particles.
  56278. */
  56279. forceDepthWrite: boolean;
  56280. /**
  56281. * Gets or set the number of active particles
  56282. */
  56283. activeParticleCount: number;
  56284. private _preWarmDone;
  56285. /**
  56286. * Is this system ready to be used/rendered
  56287. * @return true if the system is ready
  56288. */
  56289. isReady(): boolean;
  56290. /**
  56291. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56292. * @returns True if it has been started, otherwise false.
  56293. */
  56294. isStarted(): boolean;
  56295. /**
  56296. * Starts the particle system and begins to emit
  56297. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56298. */
  56299. start(delay?: number): void;
  56300. /**
  56301. * Stops the particle system.
  56302. */
  56303. stop(): void;
  56304. /**
  56305. * Remove all active particles
  56306. */
  56307. reset(): void;
  56308. /**
  56309. * Returns the string "GPUParticleSystem"
  56310. * @returns a string containing the class name
  56311. */
  56312. getClassName(): string;
  56313. private _colorGradientsTexture;
  56314. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56315. /**
  56316. * Adds a new color gradient
  56317. * @param gradient defines the gradient to use (between 0 and 1)
  56318. * @param color1 defines the color to affect to the specified gradient
  56319. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56320. * @returns the current particle system
  56321. */
  56322. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56323. /**
  56324. * Remove a specific color gradient
  56325. * @param gradient defines the gradient to remove
  56326. * @returns the current particle system
  56327. */
  56328. removeColorGradient(gradient: number): GPUParticleSystem;
  56329. private _angularSpeedGradientsTexture;
  56330. private _sizeGradientsTexture;
  56331. private _velocityGradientsTexture;
  56332. private _limitVelocityGradientsTexture;
  56333. private _dragGradientsTexture;
  56334. private _addFactorGradient;
  56335. /**
  56336. * Adds a new size gradient
  56337. * @param gradient defines the gradient to use (between 0 and 1)
  56338. * @param factor defines the size factor to affect to the specified gradient
  56339. * @returns the current particle system
  56340. */
  56341. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56342. /**
  56343. * Remove a specific size gradient
  56344. * @param gradient defines the gradient to remove
  56345. * @returns the current particle system
  56346. */
  56347. removeSizeGradient(gradient: number): GPUParticleSystem;
  56348. /**
  56349. * Adds a new angular speed gradient
  56350. * @param gradient defines the gradient to use (between 0 and 1)
  56351. * @param factor defines the angular speed to affect to the specified gradient
  56352. * @returns the current particle system
  56353. */
  56354. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56355. /**
  56356. * Remove a specific angular speed gradient
  56357. * @param gradient defines the gradient to remove
  56358. * @returns the current particle system
  56359. */
  56360. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56361. /**
  56362. * Adds a new velocity gradient
  56363. * @param gradient defines the gradient to use (between 0 and 1)
  56364. * @param factor defines the velocity to affect to the specified gradient
  56365. * @returns the current particle system
  56366. */
  56367. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56368. /**
  56369. * Remove a specific velocity gradient
  56370. * @param gradient defines the gradient to remove
  56371. * @returns the current particle system
  56372. */
  56373. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56374. /**
  56375. * Adds a new limit velocity gradient
  56376. * @param gradient defines the gradient to use (between 0 and 1)
  56377. * @param factor defines the limit velocity value to affect to the specified gradient
  56378. * @returns the current particle system
  56379. */
  56380. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56381. /**
  56382. * Remove a specific limit velocity gradient
  56383. * @param gradient defines the gradient to remove
  56384. * @returns the current particle system
  56385. */
  56386. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56387. /**
  56388. * Adds a new drag gradient
  56389. * @param gradient defines the gradient to use (between 0 and 1)
  56390. * @param factor defines the drag value to affect to the specified gradient
  56391. * @returns the current particle system
  56392. */
  56393. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56394. /**
  56395. * Remove a specific drag gradient
  56396. * @param gradient defines the gradient to remove
  56397. * @returns the current particle system
  56398. */
  56399. removeDragGradient(gradient: number): GPUParticleSystem;
  56400. /**
  56401. * Not supported by GPUParticleSystem
  56402. * @param gradient defines the gradient to use (between 0 and 1)
  56403. * @param factor defines the emit rate value to affect to the specified gradient
  56404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56405. * @returns the current particle system
  56406. */
  56407. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56408. /**
  56409. * Not supported by GPUParticleSystem
  56410. * @param gradient defines the gradient to remove
  56411. * @returns the current particle system
  56412. */
  56413. removeEmitRateGradient(gradient: number): IParticleSystem;
  56414. /**
  56415. * Not supported by GPUParticleSystem
  56416. * @param gradient defines the gradient to use (between 0 and 1)
  56417. * @param factor defines the start size value to affect to the specified gradient
  56418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56419. * @returns the current particle system
  56420. */
  56421. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56422. /**
  56423. * Not supported by GPUParticleSystem
  56424. * @param gradient defines the gradient to remove
  56425. * @returns the current particle system
  56426. */
  56427. removeStartSizeGradient(gradient: number): IParticleSystem;
  56428. /**
  56429. * Not supported by GPUParticleSystem
  56430. * @param gradient defines the gradient to use (between 0 and 1)
  56431. * @param min defines the color remap minimal range
  56432. * @param max defines the color remap maximal range
  56433. * @returns the current particle system
  56434. */
  56435. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56436. /**
  56437. * Not supported by GPUParticleSystem
  56438. * @param gradient defines the gradient to remove
  56439. * @returns the current particle system
  56440. */
  56441. removeColorRemapGradient(): IParticleSystem;
  56442. /**
  56443. * Not supported by GPUParticleSystem
  56444. * @param gradient defines the gradient to use (between 0 and 1)
  56445. * @param min defines the alpha remap minimal range
  56446. * @param max defines the alpha remap maximal range
  56447. * @returns the current particle system
  56448. */
  56449. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56450. /**
  56451. * Not supported by GPUParticleSystem
  56452. * @param gradient defines the gradient to remove
  56453. * @returns the current particle system
  56454. */
  56455. removeAlphaRemapGradient(): IParticleSystem;
  56456. /**
  56457. * Not supported by GPUParticleSystem
  56458. * @param gradient defines the gradient to use (between 0 and 1)
  56459. * @param color defines the color to affect to the specified gradient
  56460. * @returns the current particle system
  56461. */
  56462. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56463. /**
  56464. * Not supported by GPUParticleSystem
  56465. * @param gradient defines the gradient to remove
  56466. * @returns the current particle system
  56467. */
  56468. removeRampGradient(): IParticleSystem;
  56469. /**
  56470. * Not supported by GPUParticleSystem
  56471. * @returns the list of ramp gradients
  56472. */
  56473. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56474. /**
  56475. * Not supported by GPUParticleSystem
  56476. * Gets or sets a boolean indicating that ramp gradients must be used
  56477. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56478. */
  56479. useRampGradients: boolean;
  56480. /**
  56481. * Not supported by GPUParticleSystem
  56482. * @param gradient defines the gradient to use (between 0 and 1)
  56483. * @param factor defines the life time factor to affect to the specified gradient
  56484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56485. * @returns the current particle system
  56486. */
  56487. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56488. /**
  56489. * Not supported by GPUParticleSystem
  56490. * @param gradient defines the gradient to remove
  56491. * @returns the current particle system
  56492. */
  56493. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56494. /**
  56495. * Instantiates a GPU particle system.
  56496. * 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.
  56497. * @param name The name of the particle system
  56498. * @param options The options used to create the system
  56499. * @param scene The scene the particle system belongs to
  56500. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56501. */
  56502. constructor(name: string, options: Partial<{
  56503. capacity: number;
  56504. randomTextureSize: number;
  56505. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56506. protected _reset(): void;
  56507. private _createUpdateVAO;
  56508. private _createRenderVAO;
  56509. private _initialize;
  56510. /** @hidden */
  56511. _recreateUpdateEffect(): void;
  56512. /** @hidden */
  56513. _recreateRenderEffect(): void;
  56514. /**
  56515. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56516. * @param preWarm defines if we are in the pre-warmimg phase
  56517. */
  56518. animate(preWarm?: boolean): void;
  56519. private _createFactorGradientTexture;
  56520. private _createSizeGradientTexture;
  56521. private _createAngularSpeedGradientTexture;
  56522. private _createVelocityGradientTexture;
  56523. private _createLimitVelocityGradientTexture;
  56524. private _createDragGradientTexture;
  56525. private _createColorGradientTexture;
  56526. /**
  56527. * Renders the particle system in its current state
  56528. * @param preWarm defines if the system should only update the particles but not render them
  56529. * @returns the current number of particles
  56530. */
  56531. render(preWarm?: boolean): number;
  56532. /**
  56533. * Rebuilds the particle system
  56534. */
  56535. rebuild(): void;
  56536. private _releaseBuffers;
  56537. private _releaseVAOs;
  56538. /**
  56539. * Disposes the particle system and free the associated resources
  56540. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56541. */
  56542. dispose(disposeTexture?: boolean): void;
  56543. /**
  56544. * Clones the particle system.
  56545. * @param name The name of the cloned object
  56546. * @param newEmitter The new emitter to use
  56547. * @returns the cloned particle system
  56548. */
  56549. clone(name: string, newEmitter: any): GPUParticleSystem;
  56550. /**
  56551. * Serializes the particle system to a JSON object.
  56552. * @returns the JSON object
  56553. */
  56554. serialize(): any;
  56555. /**
  56556. * Parses a JSON object to create a GPU particle system.
  56557. * @param parsedParticleSystem The JSON object to parse
  56558. * @param scene The scene to create the particle system in
  56559. * @param rootUrl The root url to use to load external dependencies like texture
  56560. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56561. * @returns the parsed GPU particle system
  56562. */
  56563. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56564. }
  56565. }
  56566. declare module BABYLON {
  56567. /**
  56568. * Represents a set of particle systems working together to create a specific effect
  56569. */
  56570. export class ParticleSystemSet implements IDisposable {
  56571. private _emitterCreationOptions;
  56572. private _emitterNode;
  56573. /**
  56574. * Gets the particle system list
  56575. */
  56576. systems: IParticleSystem[];
  56577. /**
  56578. * Gets the emitter node used with this set
  56579. */
  56580. readonly emitterNode: Nullable<TransformNode>;
  56581. /**
  56582. * Creates a new emitter mesh as a sphere
  56583. * @param options defines the options used to create the sphere
  56584. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56585. * @param scene defines the hosting scene
  56586. */
  56587. setEmitterAsSphere(options: {
  56588. diameter: number;
  56589. segments: number;
  56590. color: Color3;
  56591. }, renderingGroupId: number, scene: Scene): void;
  56592. /**
  56593. * Starts all particle systems of the set
  56594. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56595. */
  56596. start(emitter?: AbstractMesh): void;
  56597. /**
  56598. * Release all associated resources
  56599. */
  56600. dispose(): void;
  56601. /**
  56602. * Serialize the set into a JSON compatible object
  56603. * @returns a JSON compatible representation of the set
  56604. */
  56605. serialize(): any;
  56606. /**
  56607. * Parse a new ParticleSystemSet from a serialized source
  56608. * @param data defines a JSON compatible representation of the set
  56609. * @param scene defines the hosting scene
  56610. * @param gpu defines if we want GPU particles or CPU particles
  56611. * @returns a new ParticleSystemSet
  56612. */
  56613. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56614. }
  56615. }
  56616. declare module BABYLON {
  56617. /**
  56618. * This class is made for on one-liner static method to help creating particle system set.
  56619. */
  56620. export class ParticleHelper {
  56621. /**
  56622. * Gets or sets base Assets URL
  56623. */
  56624. static BaseAssetsUrl: string;
  56625. /**
  56626. * Create a default particle system that you can tweak
  56627. * @param emitter defines the emitter to use
  56628. * @param capacity defines the system capacity (default is 500 particles)
  56629. * @param scene defines the hosting scene
  56630. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56631. * @returns the new Particle system
  56632. */
  56633. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56634. /**
  56635. * This is the main static method (one-liner) of this helper to create different particle systems
  56636. * @param type This string represents the type to the particle system to create
  56637. * @param scene The scene where the particle system should live
  56638. * @param gpu If the system will use gpu
  56639. * @returns the ParticleSystemSet created
  56640. */
  56641. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56642. /**
  56643. * Static function used to export a particle system to a ParticleSystemSet variable.
  56644. * Please note that the emitter shape is not exported
  56645. * @param systems defines the particle systems to export
  56646. * @returns the created particle system set
  56647. */
  56648. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56649. }
  56650. }
  56651. declare module BABYLON {
  56652. interface Engine {
  56653. /**
  56654. * Create an effect to use with particle systems.
  56655. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56656. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56657. * @param uniformsNames defines a list of attribute names
  56658. * @param samplers defines an array of string used to represent textures
  56659. * @param defines defines the string containing the defines to use to compile the shaders
  56660. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56661. * @param onCompiled defines a function to call when the effect creation is successful
  56662. * @param onError defines a function to call when the effect creation has failed
  56663. * @returns the new Effect
  56664. */
  56665. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56666. }
  56667. interface Mesh {
  56668. /**
  56669. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56670. * @returns an array of IParticleSystem
  56671. */
  56672. getEmittedParticleSystems(): IParticleSystem[];
  56673. /**
  56674. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56675. * @returns an array of IParticleSystem
  56676. */
  56677. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56678. }
  56679. /**
  56680. * @hidden
  56681. */
  56682. export var _IDoNeedToBeInTheBuild: number;
  56683. }
  56684. declare module BABYLON {
  56685. interface Scene {
  56686. /** @hidden (Backing field) */
  56687. _physicsEngine: Nullable<IPhysicsEngine>;
  56688. /**
  56689. * Gets the current physics engine
  56690. * @returns a IPhysicsEngine or null if none attached
  56691. */
  56692. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56693. /**
  56694. * Enables physics to the current scene
  56695. * @param gravity defines the scene's gravity for the physics engine
  56696. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56697. * @return a boolean indicating if the physics engine was initialized
  56698. */
  56699. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56700. /**
  56701. * Disables and disposes the physics engine associated with the scene
  56702. */
  56703. disablePhysicsEngine(): void;
  56704. /**
  56705. * Gets a boolean indicating if there is an active physics engine
  56706. * @returns a boolean indicating if there is an active physics engine
  56707. */
  56708. isPhysicsEnabled(): boolean;
  56709. /**
  56710. * Deletes a physics compound impostor
  56711. * @param compound defines the compound to delete
  56712. */
  56713. deleteCompoundImpostor(compound: any): void;
  56714. /**
  56715. * An event triggered when physic simulation is about to be run
  56716. */
  56717. onBeforePhysicsObservable: Observable<Scene>;
  56718. /**
  56719. * An event triggered when physic simulation has been done
  56720. */
  56721. onAfterPhysicsObservable: Observable<Scene>;
  56722. }
  56723. interface AbstractMesh {
  56724. /** @hidden */
  56725. _physicsImpostor: Nullable<PhysicsImpostor>;
  56726. /**
  56727. * Gets or sets impostor used for physic simulation
  56728. * @see http://doc.babylonjs.com/features/physics_engine
  56729. */
  56730. physicsImpostor: Nullable<PhysicsImpostor>;
  56731. /**
  56732. * Gets the current physics impostor
  56733. * @see http://doc.babylonjs.com/features/physics_engine
  56734. * @returns a physics impostor or null
  56735. */
  56736. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56737. /** Apply a physic impulse to the mesh
  56738. * @param force defines the force to apply
  56739. * @param contactPoint defines where to apply the force
  56740. * @returns the current mesh
  56741. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56742. */
  56743. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56744. /**
  56745. * Creates a physic joint between two meshes
  56746. * @param otherMesh defines the other mesh to use
  56747. * @param pivot1 defines the pivot to use on this mesh
  56748. * @param pivot2 defines the pivot to use on the other mesh
  56749. * @param options defines additional options (can be plugin dependent)
  56750. * @returns the current mesh
  56751. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56752. */
  56753. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56754. /** @hidden */
  56755. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56756. }
  56757. /**
  56758. * Defines the physics engine scene component responsible to manage a physics engine
  56759. */
  56760. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56761. /**
  56762. * The component name helpful to identify the component in the list of scene components.
  56763. */
  56764. readonly name: string;
  56765. /**
  56766. * The scene the component belongs to.
  56767. */
  56768. scene: Scene;
  56769. /**
  56770. * Creates a new instance of the component for the given scene
  56771. * @param scene Defines the scene to register the component in
  56772. */
  56773. constructor(scene: Scene);
  56774. /**
  56775. * Registers the component in a given scene
  56776. */
  56777. register(): void;
  56778. /**
  56779. * Rebuilds the elements related to this component in case of
  56780. * context lost for instance.
  56781. */
  56782. rebuild(): void;
  56783. /**
  56784. * Disposes the component and the associated ressources
  56785. */
  56786. dispose(): void;
  56787. }
  56788. }
  56789. declare module BABYLON {
  56790. /**
  56791. * A helper for physics simulations
  56792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56793. */
  56794. export class PhysicsHelper {
  56795. private _scene;
  56796. private _physicsEngine;
  56797. /**
  56798. * Initializes the Physics helper
  56799. * @param scene Babylon.js scene
  56800. */
  56801. constructor(scene: Scene);
  56802. /**
  56803. * Applies a radial explosion impulse
  56804. * @param origin the origin of the explosion
  56805. * @param radiusOrEventOptions the radius or the options of radial explosion
  56806. * @param strength the explosion strength
  56807. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56808. * @returns A physics radial explosion event, or null
  56809. */
  56810. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56811. /**
  56812. * Applies a radial explosion force
  56813. * @param origin the origin of the explosion
  56814. * @param radiusOrEventOptions the radius or the options of radial explosion
  56815. * @param strength the explosion strength
  56816. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56817. * @returns A physics radial explosion event, or null
  56818. */
  56819. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56820. /**
  56821. * Creates a gravitational field
  56822. * @param origin the origin of the explosion
  56823. * @param radiusOrEventOptions the radius or the options of radial explosion
  56824. * @param strength the explosion strength
  56825. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56826. * @returns A physics gravitational field event, or null
  56827. */
  56828. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56829. /**
  56830. * Creates a physics updraft event
  56831. * @param origin the origin of the updraft
  56832. * @param radiusOrEventOptions the radius or the options of the updraft
  56833. * @param strength the strength of the updraft
  56834. * @param height the height of the updraft
  56835. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56836. * @returns A physics updraft event, or null
  56837. */
  56838. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56839. /**
  56840. * Creates a physics vortex event
  56841. * @param origin the of the vortex
  56842. * @param radiusOrEventOptions the radius or the options of the vortex
  56843. * @param strength the strength of the vortex
  56844. * @param height the height of the vortex
  56845. * @returns a Physics vortex event, or null
  56846. * A physics vortex event or null
  56847. */
  56848. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56849. }
  56850. /**
  56851. * Represents a physics radial explosion event
  56852. */
  56853. class PhysicsRadialExplosionEvent {
  56854. private _scene;
  56855. private _options;
  56856. private _sphere;
  56857. private _dataFetched;
  56858. /**
  56859. * Initializes a radial explosioin event
  56860. * @param _scene BabylonJS scene
  56861. * @param _options The options for the vortex event
  56862. */
  56863. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56864. /**
  56865. * Returns the data related to the radial explosion event (sphere).
  56866. * @returns The radial explosion event data
  56867. */
  56868. getData(): PhysicsRadialExplosionEventData;
  56869. /**
  56870. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56871. * @param impostor A physics imposter
  56872. * @param origin the origin of the explosion
  56873. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56874. */
  56875. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56876. /**
  56877. * Triggers affecterd impostors callbacks
  56878. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56879. */
  56880. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56881. /**
  56882. * Disposes the sphere.
  56883. * @param force Specifies if the sphere should be disposed by force
  56884. */
  56885. dispose(force?: boolean): void;
  56886. /*** Helpers ***/
  56887. private _prepareSphere;
  56888. private _intersectsWithSphere;
  56889. }
  56890. /**
  56891. * Represents a gravitational field event
  56892. */
  56893. class PhysicsGravitationalFieldEvent {
  56894. private _physicsHelper;
  56895. private _scene;
  56896. private _origin;
  56897. private _options;
  56898. private _tickCallback;
  56899. private _sphere;
  56900. private _dataFetched;
  56901. /**
  56902. * Initializes the physics gravitational field event
  56903. * @param _physicsHelper A physics helper
  56904. * @param _scene BabylonJS scene
  56905. * @param _origin The origin position of the gravitational field event
  56906. * @param _options The options for the vortex event
  56907. */
  56908. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56909. /**
  56910. * Returns the data related to the gravitational field event (sphere).
  56911. * @returns A gravitational field event
  56912. */
  56913. getData(): PhysicsGravitationalFieldEventData;
  56914. /**
  56915. * Enables the gravitational field.
  56916. */
  56917. enable(): void;
  56918. /**
  56919. * Disables the gravitational field.
  56920. */
  56921. disable(): void;
  56922. /**
  56923. * Disposes the sphere.
  56924. * @param force The force to dispose from the gravitational field event
  56925. */
  56926. dispose(force?: boolean): void;
  56927. private _tick;
  56928. }
  56929. /**
  56930. * Represents a physics updraft event
  56931. */
  56932. class PhysicsUpdraftEvent {
  56933. private _scene;
  56934. private _origin;
  56935. private _options;
  56936. private _physicsEngine;
  56937. private _originTop;
  56938. private _originDirection;
  56939. private _tickCallback;
  56940. private _cylinder;
  56941. private _cylinderPosition;
  56942. private _dataFetched;
  56943. /**
  56944. * Initializes the physics updraft event
  56945. * @param _scene BabylonJS scene
  56946. * @param _origin The origin position of the updraft
  56947. * @param _options The options for the updraft event
  56948. */
  56949. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56950. /**
  56951. * Returns the data related to the updraft event (cylinder).
  56952. * @returns A physics updraft event
  56953. */
  56954. getData(): PhysicsUpdraftEventData;
  56955. /**
  56956. * Enables the updraft.
  56957. */
  56958. enable(): void;
  56959. /**
  56960. * Disables the updraft.
  56961. */
  56962. disable(): void;
  56963. /**
  56964. * Disposes the cylinder.
  56965. * @param force Specifies if the updraft should be disposed by force
  56966. */
  56967. dispose(force?: boolean): void;
  56968. private getImpostorHitData;
  56969. private _tick;
  56970. /*** Helpers ***/
  56971. private _prepareCylinder;
  56972. private _intersectsWithCylinder;
  56973. }
  56974. /**
  56975. * Represents a physics vortex event
  56976. */
  56977. class PhysicsVortexEvent {
  56978. private _scene;
  56979. private _origin;
  56980. private _options;
  56981. private _physicsEngine;
  56982. private _originTop;
  56983. private _tickCallback;
  56984. private _cylinder;
  56985. private _cylinderPosition;
  56986. private _dataFetched;
  56987. /**
  56988. * Initializes the physics vortex event
  56989. * @param _scene The BabylonJS scene
  56990. * @param _origin The origin position of the vortex
  56991. * @param _options The options for the vortex event
  56992. */
  56993. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56994. /**
  56995. * Returns the data related to the vortex event (cylinder).
  56996. * @returns The physics vortex event data
  56997. */
  56998. getData(): PhysicsVortexEventData;
  56999. /**
  57000. * Enables the vortex.
  57001. */
  57002. enable(): void;
  57003. /**
  57004. * Disables the cortex.
  57005. */
  57006. disable(): void;
  57007. /**
  57008. * Disposes the sphere.
  57009. * @param force
  57010. */
  57011. dispose(force?: boolean): void;
  57012. private getImpostorHitData;
  57013. private _tick;
  57014. /*** Helpers ***/
  57015. private _prepareCylinder;
  57016. private _intersectsWithCylinder;
  57017. }
  57018. /**
  57019. * Options fot the radial explosion event
  57020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57021. */
  57022. export class PhysicsRadialExplosionEventOptions {
  57023. /**
  57024. * The radius of the sphere for the radial explosion.
  57025. */
  57026. radius: number;
  57027. /**
  57028. * The strenth of the explosion.
  57029. */
  57030. strength: number;
  57031. /**
  57032. * The strenght of the force in correspondence to the distance of the affected object
  57033. */
  57034. falloff: PhysicsRadialImpulseFalloff;
  57035. /**
  57036. * Sphere options for the radial explosion.
  57037. */
  57038. sphere: {
  57039. segments: number;
  57040. diameter: number;
  57041. };
  57042. /**
  57043. * Sphere options for the radial explosion.
  57044. */
  57045. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57046. }
  57047. /**
  57048. * Options fot the updraft event
  57049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57050. */
  57051. export class PhysicsUpdraftEventOptions {
  57052. /**
  57053. * The radius of the cylinder for the vortex
  57054. */
  57055. radius: number;
  57056. /**
  57057. * The strenth of the updraft.
  57058. */
  57059. strength: number;
  57060. /**
  57061. * The height of the cylinder for the updraft.
  57062. */
  57063. height: number;
  57064. /**
  57065. * The mode for the the updraft.
  57066. */
  57067. updraftMode: PhysicsUpdraftMode;
  57068. }
  57069. /**
  57070. * Options fot the vortex event
  57071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57072. */
  57073. export class PhysicsVortexEventOptions {
  57074. /**
  57075. * The radius of the cylinder for the vortex
  57076. */
  57077. radius: number;
  57078. /**
  57079. * The strenth of the vortex.
  57080. */
  57081. strength: number;
  57082. /**
  57083. * The height of the cylinder for the vortex.
  57084. */
  57085. height: number;
  57086. /**
  57087. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57088. */
  57089. centripetalForceThreshold: number;
  57090. /**
  57091. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57092. */
  57093. centripetalForceMultiplier: number;
  57094. /**
  57095. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57096. */
  57097. centrifugalForceMultiplier: number;
  57098. /**
  57099. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57100. */
  57101. updraftForceMultiplier: number;
  57102. }
  57103. /**
  57104. * The strenght of the force in correspondence to the distance of the affected object
  57105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57106. */
  57107. export enum PhysicsRadialImpulseFalloff {
  57108. /** Defines that impulse is constant in strength across it's whole radius */
  57109. Constant = 0,
  57110. /** Defines that impulse gets weaker if it's further from the origin */
  57111. Linear = 1
  57112. }
  57113. /**
  57114. * The strength of the force in correspondence to the distance of the affected object
  57115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57116. */
  57117. export enum PhysicsUpdraftMode {
  57118. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57119. Center = 0,
  57120. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57121. Perpendicular = 1
  57122. }
  57123. /**
  57124. * Interface for a physics hit data
  57125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57126. */
  57127. export interface PhysicsHitData {
  57128. /**
  57129. * The force applied at the contact point
  57130. */
  57131. force: Vector3;
  57132. /**
  57133. * The contact point
  57134. */
  57135. contactPoint: Vector3;
  57136. /**
  57137. * The distance from the origin to the contact point
  57138. */
  57139. distanceFromOrigin: number;
  57140. }
  57141. /**
  57142. * Interface for radial explosion event data
  57143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57144. */
  57145. export interface PhysicsRadialExplosionEventData {
  57146. /**
  57147. * A sphere used for the radial explosion event
  57148. */
  57149. sphere: Mesh;
  57150. }
  57151. /**
  57152. * Interface for gravitational field event data
  57153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57154. */
  57155. export interface PhysicsGravitationalFieldEventData {
  57156. /**
  57157. * A sphere mesh used for the gravitational field event
  57158. */
  57159. sphere: Mesh;
  57160. }
  57161. /**
  57162. * Interface for updraft event data
  57163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57164. */
  57165. export interface PhysicsUpdraftEventData {
  57166. /**
  57167. * A cylinder used for the updraft event
  57168. */
  57169. cylinder: Mesh;
  57170. }
  57171. /**
  57172. * Interface for vortex event data
  57173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57174. */
  57175. export interface PhysicsVortexEventData {
  57176. /**
  57177. * A cylinder used for the vortex event
  57178. */
  57179. cylinder: Mesh;
  57180. }
  57181. /**
  57182. * Interface for an affected physics impostor
  57183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57184. */
  57185. export interface PhysicsAffectedImpostorWithData {
  57186. /**
  57187. * The impostor affected by the effect
  57188. */
  57189. impostor: PhysicsImpostor;
  57190. /**
  57191. * The data about the hit/horce from the explosion
  57192. */
  57193. hitData: PhysicsHitData;
  57194. }
  57195. }
  57196. declare module BABYLON {
  57197. /** @hidden */
  57198. export var blackAndWhitePixelShader: {
  57199. name: string;
  57200. shader: string;
  57201. };
  57202. }
  57203. declare module BABYLON {
  57204. /**
  57205. * Post process used to render in black and white
  57206. */
  57207. export class BlackAndWhitePostProcess extends PostProcess {
  57208. /**
  57209. * Linear about to convert he result to black and white (default: 1)
  57210. */
  57211. degree: number;
  57212. /**
  57213. * Creates a black and white post process
  57214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57215. * @param name The name of the effect.
  57216. * @param options The required width/height ratio to downsize to before computing the render pass.
  57217. * @param camera The camera to apply the render pass to.
  57218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57219. * @param engine The engine which the post process will be applied. (default: current engine)
  57220. * @param reusable If the post process can be reused on the same frame. (default: false)
  57221. */
  57222. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57223. }
  57224. }
  57225. declare module BABYLON {
  57226. /**
  57227. * This represents a set of one or more post processes in Babylon.
  57228. * A post process can be used to apply a shader to a texture after it is rendered.
  57229. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57230. */
  57231. export class PostProcessRenderEffect {
  57232. private _postProcesses;
  57233. private _getPostProcesses;
  57234. private _singleInstance;
  57235. private _cameras;
  57236. private _indicesForCamera;
  57237. /**
  57238. * Name of the effect
  57239. * @hidden
  57240. */
  57241. _name: string;
  57242. /**
  57243. * Instantiates a post process render effect.
  57244. * A post process can be used to apply a shader to a texture after it is rendered.
  57245. * @param engine The engine the effect is tied to
  57246. * @param name The name of the effect
  57247. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57248. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57249. */
  57250. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57251. /**
  57252. * Checks if all the post processes in the effect are supported.
  57253. */
  57254. readonly isSupported: boolean;
  57255. /**
  57256. * Updates the current state of the effect
  57257. * @hidden
  57258. */
  57259. _update(): void;
  57260. /**
  57261. * Attaches the effect on cameras
  57262. * @param cameras The camera to attach to.
  57263. * @hidden
  57264. */
  57265. _attachCameras(cameras: Camera): void;
  57266. /**
  57267. * Attaches the effect on cameras
  57268. * @param cameras The camera to attach to.
  57269. * @hidden
  57270. */
  57271. _attachCameras(cameras: Camera[]): void;
  57272. /**
  57273. * Detaches the effect on cameras
  57274. * @param cameras The camera to detatch from.
  57275. * @hidden
  57276. */
  57277. _detachCameras(cameras: Camera): void;
  57278. /**
  57279. * Detatches the effect on cameras
  57280. * @param cameras The camera to detatch from.
  57281. * @hidden
  57282. */
  57283. _detachCameras(cameras: Camera[]): void;
  57284. /**
  57285. * Enables the effect on given cameras
  57286. * @param cameras The camera to enable.
  57287. * @hidden
  57288. */
  57289. _enable(cameras: Camera): void;
  57290. /**
  57291. * Enables the effect on given cameras
  57292. * @param cameras The camera to enable.
  57293. * @hidden
  57294. */
  57295. _enable(cameras: Nullable<Camera[]>): void;
  57296. /**
  57297. * Disables the effect on the given cameras
  57298. * @param cameras The camera to disable.
  57299. * @hidden
  57300. */
  57301. _disable(cameras: Camera): void;
  57302. /**
  57303. * Disables the effect on the given cameras
  57304. * @param cameras The camera to disable.
  57305. * @hidden
  57306. */
  57307. _disable(cameras: Nullable<Camera[]>): void;
  57308. /**
  57309. * Gets a list of the post processes contained in the effect.
  57310. * @param camera The camera to get the post processes on.
  57311. * @returns The list of the post processes in the effect.
  57312. */
  57313. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57314. }
  57315. }
  57316. declare module BABYLON {
  57317. /** @hidden */
  57318. export var extractHighlightsPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * 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.
  57326. */
  57327. export class ExtractHighlightsPostProcess extends PostProcess {
  57328. /**
  57329. * The luminance threshold, pixels below this value will be set to black.
  57330. */
  57331. threshold: number;
  57332. /** @hidden */
  57333. _exposure: number;
  57334. /**
  57335. * Post process which has the input texture to be used when performing highlight extraction
  57336. * @hidden
  57337. */
  57338. _inputPostProcess: Nullable<PostProcess>;
  57339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /** @hidden */
  57344. export var bloomMergePixelShader: {
  57345. name: string;
  57346. shader: string;
  57347. };
  57348. }
  57349. declare module BABYLON {
  57350. /**
  57351. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57352. */
  57353. export class BloomMergePostProcess extends PostProcess {
  57354. /** Weight of the bloom to be added to the original input. */
  57355. weight: number;
  57356. /**
  57357. * Creates a new instance of @see BloomMergePostProcess
  57358. * @param name The name of the effect.
  57359. * @param originalFromInput Post process which's input will be used for the merge.
  57360. * @param blurred Blurred highlights post process which's output will be used.
  57361. * @param weight Weight of the bloom to be added to the original input.
  57362. * @param options The required width/height ratio to downsize to before computing the render pass.
  57363. * @param camera The camera to apply the render pass to.
  57364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57365. * @param engine The engine which the post process will be applied. (default: current engine)
  57366. * @param reusable If the post process can be reused on the same frame. (default: false)
  57367. * @param textureType Type of textures used when performing the post process. (default: 0)
  57368. * @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)
  57369. */
  57370. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57371. /** Weight of the bloom to be added to the original input. */
  57372. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57373. }
  57374. }
  57375. declare module BABYLON {
  57376. /**
  57377. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57378. */
  57379. export class BloomEffect extends PostProcessRenderEffect {
  57380. private bloomScale;
  57381. /**
  57382. * @hidden Internal
  57383. */
  57384. _effects: Array<PostProcess>;
  57385. /**
  57386. * @hidden Internal
  57387. */
  57388. _downscale: ExtractHighlightsPostProcess;
  57389. private _blurX;
  57390. private _blurY;
  57391. private _merge;
  57392. /**
  57393. * The luminance threshold to find bright areas of the image to bloom.
  57394. */
  57395. threshold: number;
  57396. /**
  57397. * The strength of the bloom.
  57398. */
  57399. weight: number;
  57400. /**
  57401. * Specifies the size of the bloom blur kernel, relative to the final output size
  57402. */
  57403. kernel: number;
  57404. /**
  57405. * Creates a new instance of @see BloomEffect
  57406. * @param scene The scene the effect belongs to.
  57407. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57408. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57409. * @param bloomWeight The the strength of bloom.
  57410. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57411. * @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)
  57412. */
  57413. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57414. /**
  57415. * Disposes each of the internal effects for a given camera.
  57416. * @param camera The camera to dispose the effect on.
  57417. */
  57418. disposeEffects(camera: Camera): void;
  57419. /**
  57420. * @hidden Internal
  57421. */
  57422. _updateEffects(): void;
  57423. /**
  57424. * Internal
  57425. * @returns if all the contained post processes are ready.
  57426. * @hidden
  57427. */
  57428. _isReady(): boolean;
  57429. }
  57430. }
  57431. declare module BABYLON {
  57432. /** @hidden */
  57433. export var chromaticAberrationPixelShader: {
  57434. name: string;
  57435. shader: string;
  57436. };
  57437. }
  57438. declare module BABYLON {
  57439. /**
  57440. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57441. */
  57442. export class ChromaticAberrationPostProcess extends PostProcess {
  57443. /**
  57444. * The amount of seperation of rgb channels (default: 30)
  57445. */
  57446. aberrationAmount: number;
  57447. /**
  57448. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57449. */
  57450. radialIntensity: number;
  57451. /**
  57452. * 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))
  57453. */
  57454. direction: Vector2;
  57455. /**
  57456. * 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))
  57457. */
  57458. centerPosition: Vector2;
  57459. /**
  57460. * Creates a new instance ChromaticAberrationPostProcess
  57461. * @param name The name of the effect.
  57462. * @param screenWidth The width of the screen to apply the effect on.
  57463. * @param screenHeight The height of the screen to apply the effect on.
  57464. * @param options The required width/height ratio to downsize to before computing the render pass.
  57465. * @param camera The camera to apply the render pass to.
  57466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57467. * @param engine The engine which the post process will be applied. (default: current engine)
  57468. * @param reusable If the post process can be reused on the same frame. (default: false)
  57469. * @param textureType Type of textures used when performing the post process. (default: 0)
  57470. * @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)
  57471. */
  57472. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57473. }
  57474. }
  57475. declare module BABYLON {
  57476. /** @hidden */
  57477. export var circleOfConfusionPixelShader: {
  57478. name: string;
  57479. shader: string;
  57480. };
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57485. */
  57486. export class CircleOfConfusionPostProcess extends PostProcess {
  57487. /**
  57488. * 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.
  57489. */
  57490. lensSize: number;
  57491. /**
  57492. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57493. */
  57494. fStop: number;
  57495. /**
  57496. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57497. */
  57498. focusDistance: number;
  57499. /**
  57500. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57501. */
  57502. focalLength: number;
  57503. private _depthTexture;
  57504. /**
  57505. * Creates a new instance CircleOfConfusionPostProcess
  57506. * @param name The name of the effect.
  57507. * @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.
  57508. * @param options The required width/height ratio to downsize to before computing the render pass.
  57509. * @param camera The camera to apply the render pass to.
  57510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57511. * @param engine The engine which the post process will be applied. (default: current engine)
  57512. * @param reusable If the post process can be reused on the same frame. (default: false)
  57513. * @param textureType Type of textures used when performing the post process. (default: 0)
  57514. * @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)
  57515. */
  57516. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57517. /**
  57518. * 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.
  57519. */
  57520. depthTexture: RenderTargetTexture;
  57521. }
  57522. }
  57523. declare module BABYLON {
  57524. /** @hidden */
  57525. export var colorCorrectionPixelShader: {
  57526. name: string;
  57527. shader: string;
  57528. };
  57529. }
  57530. declare module BABYLON {
  57531. /**
  57532. *
  57533. * This post-process allows the modification of rendered colors by using
  57534. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57535. *
  57536. * The object needs to be provided an url to a texture containing the color
  57537. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57538. * Use an image editing software to tweak the LUT to match your needs.
  57539. *
  57540. * For an example of a color LUT, see here:
  57541. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57542. * For explanations on color grading, see here:
  57543. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57544. *
  57545. */
  57546. export class ColorCorrectionPostProcess extends PostProcess {
  57547. private _colorTableTexture;
  57548. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57549. }
  57550. }
  57551. declare module BABYLON {
  57552. /** @hidden */
  57553. export var convolutionPixelShader: {
  57554. name: string;
  57555. shader: string;
  57556. };
  57557. }
  57558. declare module BABYLON {
  57559. /**
  57560. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57561. * input texture to perform effects such as edge detection or sharpening
  57562. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57563. */
  57564. export class ConvolutionPostProcess extends PostProcess {
  57565. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57566. kernel: number[];
  57567. /**
  57568. * Creates a new instance ConvolutionPostProcess
  57569. * @param name The name of the effect.
  57570. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57571. * @param options The required width/height ratio to downsize to before computing the render pass.
  57572. * @param camera The camera to apply the render pass to.
  57573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57574. * @param engine The engine which the post process will be applied. (default: current engine)
  57575. * @param reusable If the post process can be reused on the same frame. (default: false)
  57576. * @param textureType Type of textures used when performing the post process. (default: 0)
  57577. */
  57578. constructor(name: string,
  57579. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57580. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57581. /**
  57582. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57583. */
  57584. static EdgeDetect0Kernel: number[];
  57585. /**
  57586. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57587. */
  57588. static EdgeDetect1Kernel: number[];
  57589. /**
  57590. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57591. */
  57592. static EdgeDetect2Kernel: number[];
  57593. /**
  57594. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57595. */
  57596. static SharpenKernel: number[];
  57597. /**
  57598. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57599. */
  57600. static EmbossKernel: number[];
  57601. /**
  57602. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57603. */
  57604. static GaussianKernel: number[];
  57605. }
  57606. }
  57607. declare module BABYLON {
  57608. /**
  57609. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57610. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57611. * based on samples that have a large difference in distance than the center pixel.
  57612. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57613. */
  57614. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57615. direction: Vector2;
  57616. /**
  57617. * Creates a new instance CircleOfConfusionPostProcess
  57618. * @param name The name of the effect.
  57619. * @param scene The scene the effect belongs to.
  57620. * @param direction The direction the blur should be applied.
  57621. * @param kernel The size of the kernel used to blur.
  57622. * @param options The required width/height ratio to downsize to before computing the render pass.
  57623. * @param camera The camera to apply the render pass to.
  57624. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57625. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57627. * @param engine The engine which the post process will be applied. (default: current engine)
  57628. * @param reusable If the post process can be reused on the same frame. (default: false)
  57629. * @param textureType Type of textures used when performing the post process. (default: 0)
  57630. * @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)
  57631. */
  57632. 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);
  57633. }
  57634. }
  57635. declare module BABYLON {
  57636. /** @hidden */
  57637. export var depthOfFieldMergePixelShader: {
  57638. name: string;
  57639. shader: string;
  57640. };
  57641. }
  57642. declare module BABYLON {
  57643. /**
  57644. * Options to be set when merging outputs from the default pipeline.
  57645. */
  57646. export class DepthOfFieldMergePostProcessOptions {
  57647. /**
  57648. * The original image to merge on top of
  57649. */
  57650. originalFromInput: PostProcess;
  57651. /**
  57652. * Parameters to perform the merge of the depth of field effect
  57653. */
  57654. depthOfField?: {
  57655. circleOfConfusion: PostProcess;
  57656. blurSteps: Array<PostProcess>;
  57657. };
  57658. /**
  57659. * Parameters to perform the merge of bloom effect
  57660. */
  57661. bloom?: {
  57662. blurred: PostProcess;
  57663. weight: number;
  57664. };
  57665. }
  57666. /**
  57667. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57668. */
  57669. export class DepthOfFieldMergePostProcess extends PostProcess {
  57670. private blurSteps;
  57671. /**
  57672. * Creates a new instance of DepthOfFieldMergePostProcess
  57673. * @param name The name of the effect.
  57674. * @param originalFromInput Post process which's input will be used for the merge.
  57675. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57676. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57677. * @param options The required width/height ratio to downsize to before computing the render pass.
  57678. * @param camera The camera to apply the render pass to.
  57679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57680. * @param engine The engine which the post process will be applied. (default: current engine)
  57681. * @param reusable If the post process can be reused on the same frame. (default: false)
  57682. * @param textureType Type of textures used when performing the post process. (default: 0)
  57683. * @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)
  57684. */
  57685. 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);
  57686. /**
  57687. * Updates the effect with the current post process compile time values and recompiles the shader.
  57688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57691. * @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
  57692. * @param onCompiled Called when the shader has been compiled.
  57693. * @param onError Called if there is an error when compiling a shader.
  57694. */
  57695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57696. }
  57697. }
  57698. declare module BABYLON {
  57699. /**
  57700. * Specifies the level of max blur that should be applied when using the depth of field effect
  57701. */
  57702. export enum DepthOfFieldEffectBlurLevel {
  57703. /**
  57704. * Subtle blur
  57705. */
  57706. Low = 0,
  57707. /**
  57708. * Medium blur
  57709. */
  57710. Medium = 1,
  57711. /**
  57712. * Large blur
  57713. */
  57714. High = 2
  57715. }
  57716. /**
  57717. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57718. */
  57719. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57720. private _circleOfConfusion;
  57721. /**
  57722. * @hidden Internal, blurs from high to low
  57723. */
  57724. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57725. private _depthOfFieldBlurY;
  57726. private _dofMerge;
  57727. /**
  57728. * @hidden Internal post processes in depth of field effect
  57729. */
  57730. _effects: Array<PostProcess>;
  57731. /**
  57732. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57733. */
  57734. focalLength: number;
  57735. /**
  57736. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57737. */
  57738. fStop: number;
  57739. /**
  57740. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57741. */
  57742. focusDistance: number;
  57743. /**
  57744. * 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.
  57745. */
  57746. lensSize: number;
  57747. /**
  57748. * Creates a new instance DepthOfFieldEffect
  57749. * @param scene The scene the effect belongs to.
  57750. * @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.
  57751. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57752. * @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)
  57753. */
  57754. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57755. /**
  57756. * Get the current class name of the current effet
  57757. * @returns "DepthOfFieldEffect"
  57758. */
  57759. getClassName(): string;
  57760. /**
  57761. * 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.
  57762. */
  57763. depthTexture: RenderTargetTexture;
  57764. /**
  57765. * Disposes each of the internal effects for a given camera.
  57766. * @param camera The camera to dispose the effect on.
  57767. */
  57768. disposeEffects(camera: Camera): void;
  57769. /**
  57770. * @hidden Internal
  57771. */
  57772. _updateEffects(): void;
  57773. /**
  57774. * Internal
  57775. * @returns if all the contained post processes are ready.
  57776. * @hidden
  57777. */
  57778. _isReady(): boolean;
  57779. }
  57780. }
  57781. declare module BABYLON {
  57782. /** @hidden */
  57783. export var displayPassPixelShader: {
  57784. name: string;
  57785. shader: string;
  57786. };
  57787. }
  57788. declare module BABYLON {
  57789. /**
  57790. * DisplayPassPostProcess which produces an output the same as it's input
  57791. */
  57792. export class DisplayPassPostProcess extends PostProcess {
  57793. /**
  57794. * Creates the DisplayPassPostProcess
  57795. * @param name The name of the effect.
  57796. * @param options The required width/height ratio to downsize to before computing the render pass.
  57797. * @param camera The camera to apply the render pass to.
  57798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57799. * @param engine The engine which the post process will be applied. (default: current engine)
  57800. * @param reusable If the post process can be reused on the same frame. (default: false)
  57801. */
  57802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57803. }
  57804. }
  57805. declare module BABYLON {
  57806. /** @hidden */
  57807. export var filterPixelShader: {
  57808. name: string;
  57809. shader: string;
  57810. };
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * Applies a kernel filter to the image
  57815. */
  57816. export class FilterPostProcess extends PostProcess {
  57817. /** The matrix to be applied to the image */
  57818. kernelMatrix: Matrix;
  57819. /**
  57820. *
  57821. * @param name The name of the effect.
  57822. * @param kernelMatrix The matrix to be applied to the image
  57823. * @param options The required width/height ratio to downsize to before computing the render pass.
  57824. * @param camera The camera to apply the render pass to.
  57825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57826. * @param engine The engine which the post process will be applied. (default: current engine)
  57827. * @param reusable If the post process can be reused on the same frame. (default: false)
  57828. */
  57829. constructor(name: string,
  57830. /** The matrix to be applied to the image */
  57831. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57832. }
  57833. }
  57834. declare module BABYLON {
  57835. /** @hidden */
  57836. export var fxaaPixelShader: {
  57837. name: string;
  57838. shader: string;
  57839. };
  57840. }
  57841. declare module BABYLON {
  57842. /** @hidden */
  57843. export var fxaaVertexShader: {
  57844. name: string;
  57845. shader: string;
  57846. };
  57847. }
  57848. declare module BABYLON {
  57849. /**
  57850. * Fxaa post process
  57851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57852. */
  57853. export class FxaaPostProcess extends PostProcess {
  57854. /** @hidden */
  57855. texelWidth: number;
  57856. /** @hidden */
  57857. texelHeight: number;
  57858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57859. private _getDefines;
  57860. }
  57861. }
  57862. declare module BABYLON {
  57863. /** @hidden */
  57864. export var grainPixelShader: {
  57865. name: string;
  57866. shader: string;
  57867. };
  57868. }
  57869. declare module BABYLON {
  57870. /**
  57871. * The GrainPostProcess adds noise to the image at mid luminance levels
  57872. */
  57873. export class GrainPostProcess extends PostProcess {
  57874. /**
  57875. * The intensity of the grain added (default: 30)
  57876. */
  57877. intensity: number;
  57878. /**
  57879. * If the grain should be randomized on every frame
  57880. */
  57881. animated: boolean;
  57882. /**
  57883. * Creates a new instance of @see GrainPostProcess
  57884. * @param name The name of the effect.
  57885. * @param options The required width/height ratio to downsize to before computing the render pass.
  57886. * @param camera The camera to apply the render pass to.
  57887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57888. * @param engine The engine which the post process will be applied. (default: current engine)
  57889. * @param reusable If the post process can be reused on the same frame. (default: false)
  57890. * @param textureType Type of textures used when performing the post process. (default: 0)
  57891. * @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)
  57892. */
  57893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57894. }
  57895. }
  57896. declare module BABYLON {
  57897. /** @hidden */
  57898. export var highlightsPixelShader: {
  57899. name: string;
  57900. shader: string;
  57901. };
  57902. }
  57903. declare module BABYLON {
  57904. /**
  57905. * Extracts highlights from the image
  57906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57907. */
  57908. export class HighlightsPostProcess extends PostProcess {
  57909. /**
  57910. * Extracts highlights from the image
  57911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57912. * @param name The name of the effect.
  57913. * @param options The required width/height ratio to downsize to before computing the render pass.
  57914. * @param camera The camera to apply the render pass to.
  57915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57916. * @param engine The engine which the post process will be applied. (default: current engine)
  57917. * @param reusable If the post process can be reused on the same frame. (default: false)
  57918. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57919. */
  57920. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57921. }
  57922. }
  57923. declare module BABYLON {
  57924. /** @hidden */
  57925. export var mrtFragmentDeclaration: {
  57926. name: string;
  57927. shader: string;
  57928. };
  57929. }
  57930. declare module BABYLON {
  57931. /** @hidden */
  57932. export var geometryPixelShader: {
  57933. name: string;
  57934. shader: string;
  57935. };
  57936. }
  57937. declare module BABYLON {
  57938. /** @hidden */
  57939. export var geometryVertexShader: {
  57940. name: string;
  57941. shader: string;
  57942. };
  57943. }
  57944. declare module BABYLON {
  57945. /** @hidden */
  57946. interface ISavedTransformationMatrix {
  57947. world: Matrix;
  57948. viewProjection: Matrix;
  57949. }
  57950. /**
  57951. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57952. */
  57953. export class GeometryBufferRenderer {
  57954. /**
  57955. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57956. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57957. */
  57958. static readonly POSITION_TEXTURE_TYPE: number;
  57959. /**
  57960. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57961. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57962. */
  57963. static readonly VELOCITY_TEXTURE_TYPE: number;
  57964. /**
  57965. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57966. * in order to compute objects velocities when enableVelocity is set to "true"
  57967. * @hidden
  57968. */
  57969. _previousTransformationMatrices: {
  57970. [index: number]: ISavedTransformationMatrix;
  57971. };
  57972. /**
  57973. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57974. * in order to compute objects velocities when enableVelocity is set to "true"
  57975. * @hidden
  57976. */
  57977. _previousBonesTransformationMatrices: {
  57978. [index: number]: Float32Array;
  57979. };
  57980. /**
  57981. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57982. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57983. */
  57984. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57985. private _scene;
  57986. private _multiRenderTarget;
  57987. private _ratio;
  57988. private _enablePosition;
  57989. private _enableVelocity;
  57990. private _positionIndex;
  57991. private _velocityIndex;
  57992. protected _effect: Effect;
  57993. protected _cachedDefines: string;
  57994. /**
  57995. * Set the render list (meshes to be rendered) used in the G buffer.
  57996. */
  57997. renderList: Mesh[];
  57998. /**
  57999. * Gets wether or not G buffer are supported by the running hardware.
  58000. * This requires draw buffer supports
  58001. */
  58002. readonly isSupported: boolean;
  58003. /**
  58004. * Returns the index of the given texture type in the G-Buffer textures array
  58005. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58006. * @returns the index of the given texture type in the G-Buffer textures array
  58007. */
  58008. getTextureIndex(textureType: number): number;
  58009. /**
  58010. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58011. */
  58012. /**
  58013. * Sets whether or not objects positions are enabled for the G buffer.
  58014. */
  58015. enablePosition: boolean;
  58016. /**
  58017. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58018. */
  58019. /**
  58020. * Sets wether or not objects velocities are enabled for the G buffer.
  58021. */
  58022. enableVelocity: boolean;
  58023. /**
  58024. * Gets the scene associated with the buffer.
  58025. */
  58026. readonly scene: Scene;
  58027. /**
  58028. * Gets the ratio used by the buffer during its creation.
  58029. * How big is the buffer related to the main canvas.
  58030. */
  58031. readonly ratio: number;
  58032. /** @hidden */
  58033. static _SceneComponentInitialization: (scene: Scene) => void;
  58034. /**
  58035. * Creates a new G Buffer for the scene
  58036. * @param scene The scene the buffer belongs to
  58037. * @param ratio How big is the buffer related to the main canvas.
  58038. */
  58039. constructor(scene: Scene, ratio?: number);
  58040. /**
  58041. * Checks wether everything is ready to render a submesh to the G buffer.
  58042. * @param subMesh the submesh to check readiness for
  58043. * @param useInstances is the mesh drawn using instance or not
  58044. * @returns true if ready otherwise false
  58045. */
  58046. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58047. /**
  58048. * Gets the current underlying G Buffer.
  58049. * @returns the buffer
  58050. */
  58051. getGBuffer(): MultiRenderTarget;
  58052. /**
  58053. * Gets the number of samples used to render the buffer (anti aliasing).
  58054. */
  58055. /**
  58056. * Sets the number of samples used to render the buffer (anti aliasing).
  58057. */
  58058. samples: number;
  58059. /**
  58060. * Disposes the renderer and frees up associated resources.
  58061. */
  58062. dispose(): void;
  58063. protected _createRenderTargets(): void;
  58064. private _copyBonesTransformationMatrices;
  58065. }
  58066. }
  58067. declare module BABYLON {
  58068. interface Scene {
  58069. /** @hidden (Backing field) */
  58070. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58071. /**
  58072. * Gets or Sets the current geometry buffer associated to the scene.
  58073. */
  58074. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58075. /**
  58076. * Enables a GeometryBufferRender and associates it with the scene
  58077. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58078. * @returns the GeometryBufferRenderer
  58079. */
  58080. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58081. /**
  58082. * Disables the GeometryBufferRender associated with the scene
  58083. */
  58084. disableGeometryBufferRenderer(): void;
  58085. }
  58086. /**
  58087. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58088. * in several rendering techniques.
  58089. */
  58090. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58091. /**
  58092. * The component name helpful to identify the component in the list of scene components.
  58093. */
  58094. readonly name: string;
  58095. /**
  58096. * The scene the component belongs to.
  58097. */
  58098. scene: Scene;
  58099. /**
  58100. * Creates a new instance of the component for the given scene
  58101. * @param scene Defines the scene to register the component in
  58102. */
  58103. constructor(scene: Scene);
  58104. /**
  58105. * Registers the component in a given scene
  58106. */
  58107. register(): void;
  58108. /**
  58109. * Rebuilds the elements related to this component in case of
  58110. * context lost for instance.
  58111. */
  58112. rebuild(): void;
  58113. /**
  58114. * Disposes the component and the associated ressources
  58115. */
  58116. dispose(): void;
  58117. private _gatherRenderTargets;
  58118. }
  58119. }
  58120. declare module BABYLON {
  58121. /** @hidden */
  58122. export var motionBlurPixelShader: {
  58123. name: string;
  58124. shader: string;
  58125. };
  58126. }
  58127. declare module BABYLON {
  58128. /**
  58129. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58130. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58131. * As an example, all you have to do is to create the post-process:
  58132. * var mb = new BABYLON.MotionBlurPostProcess(
  58133. * 'mb', // The name of the effect.
  58134. * scene, // The scene containing the objects to blur according to their velocity.
  58135. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58136. * camera // The camera to apply the render pass to.
  58137. * );
  58138. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58139. */
  58140. export class MotionBlurPostProcess extends PostProcess {
  58141. /**
  58142. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58143. */
  58144. motionStrength: number;
  58145. /**
  58146. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58147. */
  58148. /**
  58149. * Sets the number of iterations to be used for motion blur quality
  58150. */
  58151. motionBlurSamples: number;
  58152. private _motionBlurSamples;
  58153. private _geometryBufferRenderer;
  58154. /**
  58155. * Creates a new instance MotionBlurPostProcess
  58156. * @param name The name of the effect.
  58157. * @param scene The scene containing the objects to blur according to their velocity.
  58158. * @param options The required width/height ratio to downsize to before computing the render pass.
  58159. * @param camera The camera to apply the render pass to.
  58160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58161. * @param engine The engine which the post process will be applied. (default: current engine)
  58162. * @param reusable If the post process can be reused on the same frame. (default: false)
  58163. * @param textureType Type of textures used when performing the post process. (default: 0)
  58164. * @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)
  58165. */
  58166. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58167. /**
  58168. * Excludes the given skinned mesh from computing bones velocities.
  58169. * 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.
  58170. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58171. */
  58172. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58173. /**
  58174. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58175. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58176. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58177. */
  58178. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58179. /**
  58180. * Disposes the post process.
  58181. * @param camera The camera to dispose the post process on.
  58182. */
  58183. dispose(camera?: Camera): void;
  58184. }
  58185. }
  58186. declare module BABYLON {
  58187. /** @hidden */
  58188. export var refractionPixelShader: {
  58189. name: string;
  58190. shader: string;
  58191. };
  58192. }
  58193. declare module BABYLON {
  58194. /**
  58195. * Post process which applies a refractin texture
  58196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58197. */
  58198. export class RefractionPostProcess extends PostProcess {
  58199. /** the base color of the refraction (used to taint the rendering) */
  58200. color: Color3;
  58201. /** simulated refraction depth */
  58202. depth: number;
  58203. /** the coefficient of the base color (0 to remove base color tainting) */
  58204. colorLevel: number;
  58205. private _refTexture;
  58206. private _ownRefractionTexture;
  58207. /**
  58208. * Gets or sets the refraction texture
  58209. * Please note that you are responsible for disposing the texture if you set it manually
  58210. */
  58211. refractionTexture: Texture;
  58212. /**
  58213. * Initializes the RefractionPostProcess
  58214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58215. * @param name The name of the effect.
  58216. * @param refractionTextureUrl Url of the refraction texture to use
  58217. * @param color the base color of the refraction (used to taint the rendering)
  58218. * @param depth simulated refraction depth
  58219. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58220. * @param camera The camera to apply the render pass to.
  58221. * @param options The required width/height ratio to downsize to before computing the render pass.
  58222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58223. * @param engine The engine which the post process will be applied. (default: current engine)
  58224. * @param reusable If the post process can be reused on the same frame. (default: false)
  58225. */
  58226. constructor(name: string, refractionTextureUrl: string,
  58227. /** the base color of the refraction (used to taint the rendering) */
  58228. color: Color3,
  58229. /** simulated refraction depth */
  58230. depth: number,
  58231. /** the coefficient of the base color (0 to remove base color tainting) */
  58232. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58233. /**
  58234. * Disposes of the post process
  58235. * @param camera Camera to dispose post process on
  58236. */
  58237. dispose(camera: Camera): void;
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /** @hidden */
  58242. export var sharpenPixelShader: {
  58243. name: string;
  58244. shader: string;
  58245. };
  58246. }
  58247. declare module BABYLON {
  58248. /**
  58249. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58250. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58251. */
  58252. export class SharpenPostProcess extends PostProcess {
  58253. /**
  58254. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58255. */
  58256. colorAmount: number;
  58257. /**
  58258. * How much sharpness should be applied (default: 0.3)
  58259. */
  58260. edgeAmount: number;
  58261. /**
  58262. * Creates a new instance ConvolutionPostProcess
  58263. * @param name The name of the effect.
  58264. * @param options The required width/height ratio to downsize to before computing the render pass.
  58265. * @param camera The camera to apply the render pass to.
  58266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58267. * @param engine The engine which the post process will be applied. (default: current engine)
  58268. * @param reusable If the post process can be reused on the same frame. (default: false)
  58269. * @param textureType Type of textures used when performing the post process. (default: 0)
  58270. * @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)
  58271. */
  58272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58273. }
  58274. }
  58275. declare module BABYLON {
  58276. /**
  58277. * PostProcessRenderPipeline
  58278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58279. */
  58280. export class PostProcessRenderPipeline {
  58281. private engine;
  58282. private _renderEffects;
  58283. private _renderEffectsForIsolatedPass;
  58284. /**
  58285. * List of inspectable custom properties (used by the Inspector)
  58286. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58287. */
  58288. inspectableCustomProperties: IInspectable[];
  58289. /**
  58290. * @hidden
  58291. */
  58292. protected _cameras: Camera[];
  58293. /** @hidden */
  58294. _name: string;
  58295. /**
  58296. * Gets pipeline name
  58297. */
  58298. readonly name: string;
  58299. /**
  58300. * Initializes a PostProcessRenderPipeline
  58301. * @param engine engine to add the pipeline to
  58302. * @param name name of the pipeline
  58303. */
  58304. constructor(engine: Engine, name: string);
  58305. /**
  58306. * Gets the class name
  58307. * @returns "PostProcessRenderPipeline"
  58308. */
  58309. getClassName(): string;
  58310. /**
  58311. * If all the render effects in the pipeline are supported
  58312. */
  58313. readonly isSupported: boolean;
  58314. /**
  58315. * Adds an effect to the pipeline
  58316. * @param renderEffect the effect to add
  58317. */
  58318. addEffect(renderEffect: PostProcessRenderEffect): void;
  58319. /** @hidden */
  58320. _rebuild(): void;
  58321. /** @hidden */
  58322. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58323. /** @hidden */
  58324. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58325. /** @hidden */
  58326. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58327. /** @hidden */
  58328. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58329. /** @hidden */
  58330. _attachCameras(cameras: Camera, unique: boolean): void;
  58331. /** @hidden */
  58332. _attachCameras(cameras: Camera[], unique: boolean): void;
  58333. /** @hidden */
  58334. _detachCameras(cameras: Camera): void;
  58335. /** @hidden */
  58336. _detachCameras(cameras: Nullable<Camera[]>): void;
  58337. /** @hidden */
  58338. _update(): void;
  58339. /** @hidden */
  58340. _reset(): void;
  58341. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58342. /**
  58343. * Disposes of the pipeline
  58344. */
  58345. dispose(): void;
  58346. }
  58347. }
  58348. declare module BABYLON {
  58349. /**
  58350. * PostProcessRenderPipelineManager class
  58351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58352. */
  58353. export class PostProcessRenderPipelineManager {
  58354. private _renderPipelines;
  58355. /**
  58356. * Initializes a PostProcessRenderPipelineManager
  58357. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58358. */
  58359. constructor();
  58360. /**
  58361. * Gets the list of supported render pipelines
  58362. */
  58363. readonly supportedPipelines: PostProcessRenderPipeline[];
  58364. /**
  58365. * Adds a pipeline to the manager
  58366. * @param renderPipeline The pipeline to add
  58367. */
  58368. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58369. /**
  58370. * Attaches a camera to the pipeline
  58371. * @param renderPipelineName The name of the pipeline to attach to
  58372. * @param cameras the camera to attach
  58373. * @param unique if the camera can be attached multiple times to the pipeline
  58374. */
  58375. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58376. /**
  58377. * Detaches a camera from the pipeline
  58378. * @param renderPipelineName The name of the pipeline to detach from
  58379. * @param cameras the camera to detach
  58380. */
  58381. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58382. /**
  58383. * Enables an effect by name on a pipeline
  58384. * @param renderPipelineName the name of the pipeline to enable the effect in
  58385. * @param renderEffectName the name of the effect to enable
  58386. * @param cameras the cameras that the effect should be enabled on
  58387. */
  58388. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58389. /**
  58390. * Disables an effect by name on a pipeline
  58391. * @param renderPipelineName the name of the pipeline to disable the effect in
  58392. * @param renderEffectName the name of the effect to disable
  58393. * @param cameras the cameras that the effect should be disabled on
  58394. */
  58395. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58396. /**
  58397. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58398. */
  58399. update(): void;
  58400. /** @hidden */
  58401. _rebuild(): void;
  58402. /**
  58403. * Disposes of the manager and pipelines
  58404. */
  58405. dispose(): void;
  58406. }
  58407. }
  58408. declare module BABYLON {
  58409. interface Scene {
  58410. /** @hidden (Backing field) */
  58411. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58412. /**
  58413. * Gets the postprocess render pipeline manager
  58414. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58415. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58416. */
  58417. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58418. }
  58419. /**
  58420. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58421. */
  58422. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58423. /**
  58424. * The component name helpfull to identify the component in the list of scene components.
  58425. */
  58426. readonly name: string;
  58427. /**
  58428. * The scene the component belongs to.
  58429. */
  58430. scene: Scene;
  58431. /**
  58432. * Creates a new instance of the component for the given scene
  58433. * @param scene Defines the scene to register the component in
  58434. */
  58435. constructor(scene: Scene);
  58436. /**
  58437. * Registers the component in a given scene
  58438. */
  58439. register(): void;
  58440. /**
  58441. * Rebuilds the elements related to this component in case of
  58442. * context lost for instance.
  58443. */
  58444. rebuild(): void;
  58445. /**
  58446. * Disposes the component and the associated ressources
  58447. */
  58448. dispose(): void;
  58449. private _gatherRenderTargets;
  58450. }
  58451. }
  58452. declare module BABYLON {
  58453. /**
  58454. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58455. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58456. */
  58457. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58458. private _scene;
  58459. private _camerasToBeAttached;
  58460. /**
  58461. * ID of the sharpen post process,
  58462. */
  58463. private readonly SharpenPostProcessId;
  58464. /**
  58465. * @ignore
  58466. * ID of the image processing post process;
  58467. */
  58468. readonly ImageProcessingPostProcessId: string;
  58469. /**
  58470. * @ignore
  58471. * ID of the Fast Approximate Anti-Aliasing post process;
  58472. */
  58473. readonly FxaaPostProcessId: string;
  58474. /**
  58475. * ID of the chromatic aberration post process,
  58476. */
  58477. private readonly ChromaticAberrationPostProcessId;
  58478. /**
  58479. * ID of the grain post process
  58480. */
  58481. private readonly GrainPostProcessId;
  58482. /**
  58483. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58484. */
  58485. sharpen: SharpenPostProcess;
  58486. private _sharpenEffect;
  58487. private bloom;
  58488. /**
  58489. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58490. */
  58491. depthOfField: DepthOfFieldEffect;
  58492. /**
  58493. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58494. */
  58495. fxaa: FxaaPostProcess;
  58496. /**
  58497. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58498. */
  58499. imageProcessing: ImageProcessingPostProcess;
  58500. /**
  58501. * Chromatic aberration post process which will shift rgb colors in the image
  58502. */
  58503. chromaticAberration: ChromaticAberrationPostProcess;
  58504. private _chromaticAberrationEffect;
  58505. /**
  58506. * Grain post process which add noise to the image
  58507. */
  58508. grain: GrainPostProcess;
  58509. private _grainEffect;
  58510. /**
  58511. * Glow post process which adds a glow to emissive areas of the image
  58512. */
  58513. private _glowLayer;
  58514. /**
  58515. * Animations which can be used to tweak settings over a period of time
  58516. */
  58517. animations: Animation[];
  58518. private _imageProcessingConfigurationObserver;
  58519. private _sharpenEnabled;
  58520. private _bloomEnabled;
  58521. private _depthOfFieldEnabled;
  58522. private _depthOfFieldBlurLevel;
  58523. private _fxaaEnabled;
  58524. private _imageProcessingEnabled;
  58525. private _defaultPipelineTextureType;
  58526. private _bloomScale;
  58527. private _chromaticAberrationEnabled;
  58528. private _grainEnabled;
  58529. private _buildAllowed;
  58530. /**
  58531. * Gets active scene
  58532. */
  58533. readonly scene: Scene;
  58534. /**
  58535. * Enable or disable the sharpen process from the pipeline
  58536. */
  58537. sharpenEnabled: boolean;
  58538. private _resizeObserver;
  58539. private _hardwareScaleLevel;
  58540. private _bloomKernel;
  58541. /**
  58542. * Specifies the size of the bloom blur kernel, relative to the final output size
  58543. */
  58544. bloomKernel: number;
  58545. /**
  58546. * Specifies the weight of the bloom in the final rendering
  58547. */
  58548. private _bloomWeight;
  58549. /**
  58550. * Specifies the luma threshold for the area that will be blurred by the bloom
  58551. */
  58552. private _bloomThreshold;
  58553. private _hdr;
  58554. /**
  58555. * The strength of the bloom.
  58556. */
  58557. bloomWeight: number;
  58558. /**
  58559. * The strength of the bloom.
  58560. */
  58561. bloomThreshold: number;
  58562. /**
  58563. * The scale of the bloom, lower value will provide better performance.
  58564. */
  58565. bloomScale: number;
  58566. /**
  58567. * Enable or disable the bloom from the pipeline
  58568. */
  58569. bloomEnabled: boolean;
  58570. private _rebuildBloom;
  58571. /**
  58572. * If the depth of field is enabled.
  58573. */
  58574. depthOfFieldEnabled: boolean;
  58575. /**
  58576. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58577. */
  58578. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58579. /**
  58580. * If the anti aliasing is enabled.
  58581. */
  58582. fxaaEnabled: boolean;
  58583. private _samples;
  58584. /**
  58585. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58586. */
  58587. samples: number;
  58588. /**
  58589. * If image processing is enabled.
  58590. */
  58591. imageProcessingEnabled: boolean;
  58592. /**
  58593. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58594. */
  58595. glowLayerEnabled: boolean;
  58596. /**
  58597. * Gets the glow layer (or null if not defined)
  58598. */
  58599. readonly glowLayer: Nullable<GlowLayer>;
  58600. /**
  58601. * Enable or disable the chromaticAberration process from the pipeline
  58602. */
  58603. chromaticAberrationEnabled: boolean;
  58604. /**
  58605. * Enable or disable the grain process from the pipeline
  58606. */
  58607. grainEnabled: boolean;
  58608. /**
  58609. * @constructor
  58610. * @param name - The rendering pipeline name (default: "")
  58611. * @param hdr - If high dynamic range textures should be used (default: true)
  58612. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58613. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58614. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58615. */
  58616. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58617. /**
  58618. * Get the class name
  58619. * @returns "DefaultRenderingPipeline"
  58620. */
  58621. getClassName(): string;
  58622. /**
  58623. * Force the compilation of the entire pipeline.
  58624. */
  58625. prepare(): void;
  58626. private _hasCleared;
  58627. private _prevPostProcess;
  58628. private _prevPrevPostProcess;
  58629. private _setAutoClearAndTextureSharing;
  58630. private _depthOfFieldSceneObserver;
  58631. private _buildPipeline;
  58632. private _disposePostProcesses;
  58633. /**
  58634. * Adds a camera to the pipeline
  58635. * @param camera the camera to be added
  58636. */
  58637. addCamera(camera: Camera): void;
  58638. /**
  58639. * Removes a camera from the pipeline
  58640. * @param camera the camera to remove
  58641. */
  58642. removeCamera(camera: Camera): void;
  58643. /**
  58644. * Dispose of the pipeline and stop all post processes
  58645. */
  58646. dispose(): void;
  58647. /**
  58648. * Serialize the rendering pipeline (Used when exporting)
  58649. * @returns the serialized object
  58650. */
  58651. serialize(): any;
  58652. /**
  58653. * Parse the serialized pipeline
  58654. * @param source Source pipeline.
  58655. * @param scene The scene to load the pipeline to.
  58656. * @param rootUrl The URL of the serialized pipeline.
  58657. * @returns An instantiated pipeline from the serialized object.
  58658. */
  58659. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58660. }
  58661. }
  58662. declare module BABYLON {
  58663. /** @hidden */
  58664. export var lensHighlightsPixelShader: {
  58665. name: string;
  58666. shader: string;
  58667. };
  58668. }
  58669. declare module BABYLON {
  58670. /** @hidden */
  58671. export var depthOfFieldPixelShader: {
  58672. name: string;
  58673. shader: string;
  58674. };
  58675. }
  58676. declare module BABYLON {
  58677. /**
  58678. * BABYLON.JS Chromatic Aberration GLSL Shader
  58679. * Author: Olivier Guyot
  58680. * Separates very slightly R, G and B colors on the edges of the screen
  58681. * Inspired by Francois Tarlier & Martins Upitis
  58682. */
  58683. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58684. /**
  58685. * @ignore
  58686. * The chromatic aberration PostProcess id in the pipeline
  58687. */
  58688. LensChromaticAberrationEffect: string;
  58689. /**
  58690. * @ignore
  58691. * The highlights enhancing PostProcess id in the pipeline
  58692. */
  58693. HighlightsEnhancingEffect: string;
  58694. /**
  58695. * @ignore
  58696. * The depth-of-field PostProcess id in the pipeline
  58697. */
  58698. LensDepthOfFieldEffect: string;
  58699. private _scene;
  58700. private _depthTexture;
  58701. private _grainTexture;
  58702. private _chromaticAberrationPostProcess;
  58703. private _highlightsPostProcess;
  58704. private _depthOfFieldPostProcess;
  58705. private _edgeBlur;
  58706. private _grainAmount;
  58707. private _chromaticAberration;
  58708. private _distortion;
  58709. private _highlightsGain;
  58710. private _highlightsThreshold;
  58711. private _dofDistance;
  58712. private _dofAperture;
  58713. private _dofDarken;
  58714. private _dofPentagon;
  58715. private _blurNoise;
  58716. /**
  58717. * @constructor
  58718. *
  58719. * Effect parameters are as follow:
  58720. * {
  58721. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58722. * edge_blur: number; // from 0 to x (1 for realism)
  58723. * distortion: number; // from 0 to x (1 for realism)
  58724. * grain_amount: number; // from 0 to 1
  58725. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58726. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58727. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58728. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58729. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58730. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58731. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58732. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58733. * }
  58734. * Note: if an effect parameter is unset, effect is disabled
  58735. *
  58736. * @param name The rendering pipeline name
  58737. * @param parameters - An object containing all parameters (see above)
  58738. * @param scene The scene linked to this pipeline
  58739. * @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)
  58740. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58741. */
  58742. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58743. /**
  58744. * Get the class name
  58745. * @returns "LensRenderingPipeline"
  58746. */
  58747. getClassName(): string;
  58748. /**
  58749. * Gets associated scene
  58750. */
  58751. readonly scene: Scene;
  58752. /**
  58753. * Gets or sets the edge blur
  58754. */
  58755. edgeBlur: number;
  58756. /**
  58757. * Gets or sets the grain amount
  58758. */
  58759. grainAmount: number;
  58760. /**
  58761. * Gets or sets the chromatic aberration amount
  58762. */
  58763. chromaticAberration: number;
  58764. /**
  58765. * Gets or sets the depth of field aperture
  58766. */
  58767. dofAperture: number;
  58768. /**
  58769. * Gets or sets the edge distortion
  58770. */
  58771. edgeDistortion: number;
  58772. /**
  58773. * Gets or sets the depth of field distortion
  58774. */
  58775. dofDistortion: number;
  58776. /**
  58777. * Gets or sets the darken out of focus amount
  58778. */
  58779. darkenOutOfFocus: number;
  58780. /**
  58781. * Gets or sets a boolean indicating if blur noise is enabled
  58782. */
  58783. blurNoise: boolean;
  58784. /**
  58785. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58786. */
  58787. pentagonBokeh: boolean;
  58788. /**
  58789. * Gets or sets the highlight grain amount
  58790. */
  58791. highlightsGain: number;
  58792. /**
  58793. * Gets or sets the highlight threshold
  58794. */
  58795. highlightsThreshold: number;
  58796. /**
  58797. * Sets the amount of blur at the edges
  58798. * @param amount blur amount
  58799. */
  58800. setEdgeBlur(amount: number): void;
  58801. /**
  58802. * Sets edge blur to 0
  58803. */
  58804. disableEdgeBlur(): void;
  58805. /**
  58806. * Sets the amout of grain
  58807. * @param amount Amount of grain
  58808. */
  58809. setGrainAmount(amount: number): void;
  58810. /**
  58811. * Set grain amount to 0
  58812. */
  58813. disableGrain(): void;
  58814. /**
  58815. * Sets the chromatic aberration amount
  58816. * @param amount amount of chromatic aberration
  58817. */
  58818. setChromaticAberration(amount: number): void;
  58819. /**
  58820. * Sets chromatic aberration amount to 0
  58821. */
  58822. disableChromaticAberration(): void;
  58823. /**
  58824. * Sets the EdgeDistortion amount
  58825. * @param amount amount of EdgeDistortion
  58826. */
  58827. setEdgeDistortion(amount: number): void;
  58828. /**
  58829. * Sets edge distortion to 0
  58830. */
  58831. disableEdgeDistortion(): void;
  58832. /**
  58833. * Sets the FocusDistance amount
  58834. * @param amount amount of FocusDistance
  58835. */
  58836. setFocusDistance(amount: number): void;
  58837. /**
  58838. * Disables depth of field
  58839. */
  58840. disableDepthOfField(): void;
  58841. /**
  58842. * Sets the Aperture amount
  58843. * @param amount amount of Aperture
  58844. */
  58845. setAperture(amount: number): void;
  58846. /**
  58847. * Sets the DarkenOutOfFocus amount
  58848. * @param amount amount of DarkenOutOfFocus
  58849. */
  58850. setDarkenOutOfFocus(amount: number): void;
  58851. private _pentagonBokehIsEnabled;
  58852. /**
  58853. * Creates a pentagon bokeh effect
  58854. */
  58855. enablePentagonBokeh(): void;
  58856. /**
  58857. * Disables the pentagon bokeh effect
  58858. */
  58859. disablePentagonBokeh(): void;
  58860. /**
  58861. * Enables noise blur
  58862. */
  58863. enableNoiseBlur(): void;
  58864. /**
  58865. * Disables noise blur
  58866. */
  58867. disableNoiseBlur(): void;
  58868. /**
  58869. * Sets the HighlightsGain amount
  58870. * @param amount amount of HighlightsGain
  58871. */
  58872. setHighlightsGain(amount: number): void;
  58873. /**
  58874. * Sets the HighlightsThreshold amount
  58875. * @param amount amount of HighlightsThreshold
  58876. */
  58877. setHighlightsThreshold(amount: number): void;
  58878. /**
  58879. * Disables highlights
  58880. */
  58881. disableHighlights(): void;
  58882. /**
  58883. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58884. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58885. */
  58886. dispose(disableDepthRender?: boolean): void;
  58887. private _createChromaticAberrationPostProcess;
  58888. private _createHighlightsPostProcess;
  58889. private _createDepthOfFieldPostProcess;
  58890. private _createGrainTexture;
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /** @hidden */
  58895. export var ssao2PixelShader: {
  58896. name: string;
  58897. shader: string;
  58898. };
  58899. }
  58900. declare module BABYLON {
  58901. /** @hidden */
  58902. export var ssaoCombinePixelShader: {
  58903. name: string;
  58904. shader: string;
  58905. };
  58906. }
  58907. declare module BABYLON {
  58908. /**
  58909. * Render pipeline to produce ssao effect
  58910. */
  58911. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58912. /**
  58913. * @ignore
  58914. * The PassPostProcess id in the pipeline that contains the original scene color
  58915. */
  58916. SSAOOriginalSceneColorEffect: string;
  58917. /**
  58918. * @ignore
  58919. * The SSAO PostProcess id in the pipeline
  58920. */
  58921. SSAORenderEffect: string;
  58922. /**
  58923. * @ignore
  58924. * The horizontal blur PostProcess id in the pipeline
  58925. */
  58926. SSAOBlurHRenderEffect: string;
  58927. /**
  58928. * @ignore
  58929. * The vertical blur PostProcess id in the pipeline
  58930. */
  58931. SSAOBlurVRenderEffect: string;
  58932. /**
  58933. * @ignore
  58934. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58935. */
  58936. SSAOCombineRenderEffect: string;
  58937. /**
  58938. * The output strength of the SSAO post-process. Default value is 1.0.
  58939. */
  58940. totalStrength: number;
  58941. /**
  58942. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58943. */
  58944. maxZ: number;
  58945. /**
  58946. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58947. */
  58948. minZAspect: number;
  58949. private _samples;
  58950. /**
  58951. * Number of samples used for the SSAO calculations. Default value is 8
  58952. */
  58953. samples: number;
  58954. private _textureSamples;
  58955. /**
  58956. * Number of samples to use for antialiasing
  58957. */
  58958. textureSamples: number;
  58959. /**
  58960. * Ratio object used for SSAO ratio and blur ratio
  58961. */
  58962. private _ratio;
  58963. /**
  58964. * Dynamically generated sphere sampler.
  58965. */
  58966. private _sampleSphere;
  58967. /**
  58968. * Blur filter offsets
  58969. */
  58970. private _samplerOffsets;
  58971. private _expensiveBlur;
  58972. /**
  58973. * If bilateral blur should be used
  58974. */
  58975. expensiveBlur: boolean;
  58976. /**
  58977. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58978. */
  58979. radius: number;
  58980. /**
  58981. * The base color of the SSAO post-process
  58982. * The final result is "base + ssao" between [0, 1]
  58983. */
  58984. base: number;
  58985. /**
  58986. * Support test.
  58987. */
  58988. static readonly IsSupported: boolean;
  58989. private _scene;
  58990. private _depthTexture;
  58991. private _normalTexture;
  58992. private _randomTexture;
  58993. private _originalColorPostProcess;
  58994. private _ssaoPostProcess;
  58995. private _blurHPostProcess;
  58996. private _blurVPostProcess;
  58997. private _ssaoCombinePostProcess;
  58998. private _firstUpdate;
  58999. /**
  59000. * Gets active scene
  59001. */
  59002. readonly scene: Scene;
  59003. /**
  59004. * @constructor
  59005. * @param name The rendering pipeline name
  59006. * @param scene The scene linked to this pipeline
  59007. * @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 }
  59008. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59009. */
  59010. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59011. /**
  59012. * Get the class name
  59013. * @returns "SSAO2RenderingPipeline"
  59014. */
  59015. getClassName(): string;
  59016. /**
  59017. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59018. */
  59019. dispose(disableGeometryBufferRenderer?: boolean): void;
  59020. private _createBlurPostProcess;
  59021. /** @hidden */
  59022. _rebuild(): void;
  59023. private _bits;
  59024. private _radicalInverse_VdC;
  59025. private _hammersley;
  59026. private _hemisphereSample_uniform;
  59027. private _generateHemisphere;
  59028. private _createSSAOPostProcess;
  59029. private _createSSAOCombinePostProcess;
  59030. private _createRandomTexture;
  59031. /**
  59032. * Serialize the rendering pipeline (Used when exporting)
  59033. * @returns the serialized object
  59034. */
  59035. serialize(): any;
  59036. /**
  59037. * Parse the serialized pipeline
  59038. * @param source Source pipeline.
  59039. * @param scene The scene to load the pipeline to.
  59040. * @param rootUrl The URL of the serialized pipeline.
  59041. * @returns An instantiated pipeline from the serialized object.
  59042. */
  59043. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /** @hidden */
  59048. export var ssaoPixelShader: {
  59049. name: string;
  59050. shader: string;
  59051. };
  59052. }
  59053. declare module BABYLON {
  59054. /**
  59055. * Render pipeline to produce ssao effect
  59056. */
  59057. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59058. /**
  59059. * @ignore
  59060. * The PassPostProcess id in the pipeline that contains the original scene color
  59061. */
  59062. SSAOOriginalSceneColorEffect: string;
  59063. /**
  59064. * @ignore
  59065. * The SSAO PostProcess id in the pipeline
  59066. */
  59067. SSAORenderEffect: string;
  59068. /**
  59069. * @ignore
  59070. * The horizontal blur PostProcess id in the pipeline
  59071. */
  59072. SSAOBlurHRenderEffect: string;
  59073. /**
  59074. * @ignore
  59075. * The vertical blur PostProcess id in the pipeline
  59076. */
  59077. SSAOBlurVRenderEffect: string;
  59078. /**
  59079. * @ignore
  59080. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59081. */
  59082. SSAOCombineRenderEffect: string;
  59083. /**
  59084. * The output strength of the SSAO post-process. Default value is 1.0.
  59085. */
  59086. totalStrength: number;
  59087. /**
  59088. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59089. */
  59090. radius: number;
  59091. /**
  59092. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59093. * Must not be equal to fallOff and superior to fallOff.
  59094. * Default value is 0.0075
  59095. */
  59096. area: number;
  59097. /**
  59098. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59099. * Must not be equal to area and inferior to area.
  59100. * Default value is 0.000001
  59101. */
  59102. fallOff: number;
  59103. /**
  59104. * The base color of the SSAO post-process
  59105. * The final result is "base + ssao" between [0, 1]
  59106. */
  59107. base: number;
  59108. private _scene;
  59109. private _depthTexture;
  59110. private _randomTexture;
  59111. private _originalColorPostProcess;
  59112. private _ssaoPostProcess;
  59113. private _blurHPostProcess;
  59114. private _blurVPostProcess;
  59115. private _ssaoCombinePostProcess;
  59116. private _firstUpdate;
  59117. /**
  59118. * Gets active scene
  59119. */
  59120. readonly scene: Scene;
  59121. /**
  59122. * @constructor
  59123. * @param name - The rendering pipeline name
  59124. * @param scene - The scene linked to this pipeline
  59125. * @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 }
  59126. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59127. */
  59128. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59129. /**
  59130. * Get the class name
  59131. * @returns "SSAORenderingPipeline"
  59132. */
  59133. getClassName(): string;
  59134. /**
  59135. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59136. */
  59137. dispose(disableDepthRender?: boolean): void;
  59138. private _createBlurPostProcess;
  59139. /** @hidden */
  59140. _rebuild(): void;
  59141. private _createSSAOPostProcess;
  59142. private _createSSAOCombinePostProcess;
  59143. private _createRandomTexture;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /** @hidden */
  59148. export var standardPixelShader: {
  59149. name: string;
  59150. shader: string;
  59151. };
  59152. }
  59153. declare module BABYLON {
  59154. /**
  59155. * Standard rendering pipeline
  59156. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59157. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59158. */
  59159. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59160. /**
  59161. * Public members
  59162. */
  59163. /**
  59164. * Post-process which contains the original scene color before the pipeline applies all the effects
  59165. */
  59166. originalPostProcess: Nullable<PostProcess>;
  59167. /**
  59168. * Post-process used to down scale an image x4
  59169. */
  59170. downSampleX4PostProcess: Nullable<PostProcess>;
  59171. /**
  59172. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59173. */
  59174. brightPassPostProcess: Nullable<PostProcess>;
  59175. /**
  59176. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59177. */
  59178. blurHPostProcesses: PostProcess[];
  59179. /**
  59180. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59181. */
  59182. blurVPostProcesses: PostProcess[];
  59183. /**
  59184. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59185. */
  59186. textureAdderPostProcess: Nullable<PostProcess>;
  59187. /**
  59188. * Post-process used to create volumetric lighting effect
  59189. */
  59190. volumetricLightPostProcess: Nullable<PostProcess>;
  59191. /**
  59192. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59193. */
  59194. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59195. /**
  59196. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59197. */
  59198. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59199. /**
  59200. * Post-process used to merge the volumetric light effect and the real scene color
  59201. */
  59202. volumetricLightMergePostProces: Nullable<PostProcess>;
  59203. /**
  59204. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59205. */
  59206. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59207. /**
  59208. * Base post-process used to calculate the average luminance of the final image for HDR
  59209. */
  59210. luminancePostProcess: Nullable<PostProcess>;
  59211. /**
  59212. * Post-processes used to create down sample post-processes in order to get
  59213. * the average luminance of the final image for HDR
  59214. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59215. */
  59216. luminanceDownSamplePostProcesses: PostProcess[];
  59217. /**
  59218. * Post-process used to create a HDR effect (light adaptation)
  59219. */
  59220. hdrPostProcess: Nullable<PostProcess>;
  59221. /**
  59222. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59223. */
  59224. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59225. /**
  59226. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59227. */
  59228. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59229. /**
  59230. * Post-process used to merge the final HDR post-process and the real scene color
  59231. */
  59232. hdrFinalPostProcess: Nullable<PostProcess>;
  59233. /**
  59234. * Post-process used to create a lens flare effect
  59235. */
  59236. lensFlarePostProcess: Nullable<PostProcess>;
  59237. /**
  59238. * Post-process that merges the result of the lens flare post-process and the real scene color
  59239. */
  59240. lensFlareComposePostProcess: Nullable<PostProcess>;
  59241. /**
  59242. * Post-process used to create a motion blur effect
  59243. */
  59244. motionBlurPostProcess: Nullable<PostProcess>;
  59245. /**
  59246. * Post-process used to create a depth of field effect
  59247. */
  59248. depthOfFieldPostProcess: Nullable<PostProcess>;
  59249. /**
  59250. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59251. */
  59252. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59253. /**
  59254. * Represents the brightness threshold in order to configure the illuminated surfaces
  59255. */
  59256. brightThreshold: number;
  59257. /**
  59258. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59259. */
  59260. blurWidth: number;
  59261. /**
  59262. * Sets if the blur for highlighted surfaces must be only horizontal
  59263. */
  59264. horizontalBlur: boolean;
  59265. /**
  59266. * Gets the overall exposure used by the pipeline
  59267. */
  59268. /**
  59269. * Sets the overall exposure used by the pipeline
  59270. */
  59271. exposure: number;
  59272. /**
  59273. * Texture used typically to simulate "dirty" on camera lens
  59274. */
  59275. lensTexture: Nullable<Texture>;
  59276. /**
  59277. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59278. */
  59279. volumetricLightCoefficient: number;
  59280. /**
  59281. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59282. */
  59283. volumetricLightPower: number;
  59284. /**
  59285. * Used the set the blur intensity to smooth the volumetric lights
  59286. */
  59287. volumetricLightBlurScale: number;
  59288. /**
  59289. * Light (spot or directional) used to generate the volumetric lights rays
  59290. * The source light must have a shadow generate so the pipeline can get its
  59291. * depth map
  59292. */
  59293. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59294. /**
  59295. * For eye adaptation, represents the minimum luminance the eye can see
  59296. */
  59297. hdrMinimumLuminance: number;
  59298. /**
  59299. * For eye adaptation, represents the decrease luminance speed
  59300. */
  59301. hdrDecreaseRate: number;
  59302. /**
  59303. * For eye adaptation, represents the increase luminance speed
  59304. */
  59305. hdrIncreaseRate: number;
  59306. /**
  59307. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59308. */
  59309. /**
  59310. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59311. */
  59312. hdrAutoExposure: boolean;
  59313. /**
  59314. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59315. */
  59316. lensColorTexture: Nullable<Texture>;
  59317. /**
  59318. * The overall strengh for the lens flare effect
  59319. */
  59320. lensFlareStrength: number;
  59321. /**
  59322. * Dispersion coefficient for lens flare ghosts
  59323. */
  59324. lensFlareGhostDispersal: number;
  59325. /**
  59326. * Main lens flare halo width
  59327. */
  59328. lensFlareHaloWidth: number;
  59329. /**
  59330. * Based on the lens distortion effect, defines how much the lens flare result
  59331. * is distorted
  59332. */
  59333. lensFlareDistortionStrength: number;
  59334. /**
  59335. * Configures the blur intensity used for for lens flare (halo)
  59336. */
  59337. lensFlareBlurWidth: number;
  59338. /**
  59339. * Lens star texture must be used to simulate rays on the flares and is available
  59340. * in the documentation
  59341. */
  59342. lensStarTexture: Nullable<Texture>;
  59343. /**
  59344. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59345. * flare effect by taking account of the dirt texture
  59346. */
  59347. lensFlareDirtTexture: Nullable<Texture>;
  59348. /**
  59349. * Represents the focal length for the depth of field effect
  59350. */
  59351. depthOfFieldDistance: number;
  59352. /**
  59353. * Represents the blur intensity for the blurred part of the depth of field effect
  59354. */
  59355. depthOfFieldBlurWidth: number;
  59356. /**
  59357. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59358. */
  59359. /**
  59360. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59361. */
  59362. motionStrength: number;
  59363. /**
  59364. * Gets wether or not the motion blur post-process is object based or screen based.
  59365. */
  59366. /**
  59367. * Sets wether or not the motion blur post-process should be object based or screen based
  59368. */
  59369. objectBasedMotionBlur: boolean;
  59370. /**
  59371. * List of animations for the pipeline (IAnimatable implementation)
  59372. */
  59373. animations: Animation[];
  59374. /**
  59375. * Private members
  59376. */
  59377. private _scene;
  59378. private _currentDepthOfFieldSource;
  59379. private _basePostProcess;
  59380. private _fixedExposure;
  59381. private _currentExposure;
  59382. private _hdrAutoExposure;
  59383. private _hdrCurrentLuminance;
  59384. private _motionStrength;
  59385. private _isObjectBasedMotionBlur;
  59386. private _floatTextureType;
  59387. private _camerasToBeAttached;
  59388. private _ratio;
  59389. private _bloomEnabled;
  59390. private _depthOfFieldEnabled;
  59391. private _vlsEnabled;
  59392. private _lensFlareEnabled;
  59393. private _hdrEnabled;
  59394. private _motionBlurEnabled;
  59395. private _fxaaEnabled;
  59396. private _motionBlurSamples;
  59397. private _volumetricLightStepsCount;
  59398. private _samples;
  59399. /**
  59400. * @ignore
  59401. * Specifies if the bloom pipeline is enabled
  59402. */
  59403. BloomEnabled: boolean;
  59404. /**
  59405. * @ignore
  59406. * Specifies if the depth of field pipeline is enabed
  59407. */
  59408. DepthOfFieldEnabled: boolean;
  59409. /**
  59410. * @ignore
  59411. * Specifies if the lens flare pipeline is enabed
  59412. */
  59413. LensFlareEnabled: boolean;
  59414. /**
  59415. * @ignore
  59416. * Specifies if the HDR pipeline is enabled
  59417. */
  59418. HDREnabled: boolean;
  59419. /**
  59420. * @ignore
  59421. * Specifies if the volumetric lights scattering effect is enabled
  59422. */
  59423. VLSEnabled: boolean;
  59424. /**
  59425. * @ignore
  59426. * Specifies if the motion blur effect is enabled
  59427. */
  59428. MotionBlurEnabled: boolean;
  59429. /**
  59430. * Specifies if anti-aliasing is enabled
  59431. */
  59432. fxaaEnabled: boolean;
  59433. /**
  59434. * Specifies the number of steps used to calculate the volumetric lights
  59435. * Typically in interval [50, 200]
  59436. */
  59437. volumetricLightStepsCount: number;
  59438. /**
  59439. * Specifies the number of samples used for the motion blur effect
  59440. * Typically in interval [16, 64]
  59441. */
  59442. motionBlurSamples: number;
  59443. /**
  59444. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59445. */
  59446. samples: number;
  59447. /**
  59448. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59449. * @constructor
  59450. * @param name The rendering pipeline name
  59451. * @param scene The scene linked to this pipeline
  59452. * @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)
  59453. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59454. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59455. */
  59456. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59457. private _buildPipeline;
  59458. private _createDownSampleX4PostProcess;
  59459. private _createBrightPassPostProcess;
  59460. private _createBlurPostProcesses;
  59461. private _createTextureAdderPostProcess;
  59462. private _createVolumetricLightPostProcess;
  59463. private _createLuminancePostProcesses;
  59464. private _createHdrPostProcess;
  59465. private _createLensFlarePostProcess;
  59466. private _createDepthOfFieldPostProcess;
  59467. private _createMotionBlurPostProcess;
  59468. private _getDepthTexture;
  59469. private _disposePostProcesses;
  59470. /**
  59471. * Dispose of the pipeline and stop all post processes
  59472. */
  59473. dispose(): void;
  59474. /**
  59475. * Serialize the rendering pipeline (Used when exporting)
  59476. * @returns the serialized object
  59477. */
  59478. serialize(): any;
  59479. /**
  59480. * Parse the serialized pipeline
  59481. * @param source Source pipeline.
  59482. * @param scene The scene to load the pipeline to.
  59483. * @param rootUrl The URL of the serialized pipeline.
  59484. * @returns An instantiated pipeline from the serialized object.
  59485. */
  59486. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59487. /**
  59488. * Luminance steps
  59489. */
  59490. static LuminanceSteps: number;
  59491. }
  59492. }
  59493. declare module BABYLON {
  59494. /** @hidden */
  59495. export var tonemapPixelShader: {
  59496. name: string;
  59497. shader: string;
  59498. };
  59499. }
  59500. declare module BABYLON {
  59501. /** Defines operator used for tonemapping */
  59502. export enum TonemappingOperator {
  59503. /** Hable */
  59504. Hable = 0,
  59505. /** Reinhard */
  59506. Reinhard = 1,
  59507. /** HejiDawson */
  59508. HejiDawson = 2,
  59509. /** Photographic */
  59510. Photographic = 3
  59511. }
  59512. /**
  59513. * Defines a post process to apply tone mapping
  59514. */
  59515. export class TonemapPostProcess extends PostProcess {
  59516. private _operator;
  59517. /** Defines the required exposure adjustement */
  59518. exposureAdjustment: number;
  59519. /**
  59520. * Creates a new TonemapPostProcess
  59521. * @param name defines the name of the postprocess
  59522. * @param _operator defines the operator to use
  59523. * @param exposureAdjustment defines the required exposure adjustement
  59524. * @param camera defines the camera to use (can be null)
  59525. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59526. * @param engine defines the hosting engine (can be ignore if camera is set)
  59527. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59528. */
  59529. constructor(name: string, _operator: TonemappingOperator,
  59530. /** Defines the required exposure adjustement */
  59531. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59532. }
  59533. }
  59534. declare module BABYLON {
  59535. /** @hidden */
  59536. export var depthVertexShader: {
  59537. name: string;
  59538. shader: string;
  59539. };
  59540. }
  59541. declare module BABYLON {
  59542. /** @hidden */
  59543. export var volumetricLightScatteringPixelShader: {
  59544. name: string;
  59545. shader: string;
  59546. };
  59547. }
  59548. declare module BABYLON {
  59549. /** @hidden */
  59550. export var volumetricLightScatteringPassVertexShader: {
  59551. name: string;
  59552. shader: string;
  59553. };
  59554. }
  59555. declare module BABYLON {
  59556. /** @hidden */
  59557. export var volumetricLightScatteringPassPixelShader: {
  59558. name: string;
  59559. shader: string;
  59560. };
  59561. }
  59562. declare module BABYLON {
  59563. /**
  59564. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59565. */
  59566. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59567. private _volumetricLightScatteringPass;
  59568. private _volumetricLightScatteringRTT;
  59569. private _viewPort;
  59570. private _screenCoordinates;
  59571. private _cachedDefines;
  59572. /**
  59573. * If not undefined, the mesh position is computed from the attached node position
  59574. */
  59575. attachedNode: {
  59576. position: Vector3;
  59577. };
  59578. /**
  59579. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59580. */
  59581. customMeshPosition: Vector3;
  59582. /**
  59583. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59584. */
  59585. useCustomMeshPosition: boolean;
  59586. /**
  59587. * If the post-process should inverse the light scattering direction
  59588. */
  59589. invert: boolean;
  59590. /**
  59591. * The internal mesh used by the post-process
  59592. */
  59593. mesh: Mesh;
  59594. /**
  59595. * @hidden
  59596. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59597. */
  59598. useDiffuseColor: boolean;
  59599. /**
  59600. * Array containing the excluded meshes not rendered in the internal pass
  59601. */
  59602. excludedMeshes: AbstractMesh[];
  59603. /**
  59604. * Controls the overall intensity of the post-process
  59605. */
  59606. exposure: number;
  59607. /**
  59608. * Dissipates each sample's contribution in range [0, 1]
  59609. */
  59610. decay: number;
  59611. /**
  59612. * Controls the overall intensity of each sample
  59613. */
  59614. weight: number;
  59615. /**
  59616. * Controls the density of each sample
  59617. */
  59618. density: number;
  59619. /**
  59620. * @constructor
  59621. * @param name The post-process name
  59622. * @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)
  59623. * @param camera The camera that the post-process will be attached to
  59624. * @param mesh The mesh used to create the light scattering
  59625. * @param samples The post-process quality, default 100
  59626. * @param samplingModeThe post-process filtering mode
  59627. * @param engine The babylon engine
  59628. * @param reusable If the post-process is reusable
  59629. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59630. */
  59631. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59632. /**
  59633. * Returns the string "VolumetricLightScatteringPostProcess"
  59634. * @returns "VolumetricLightScatteringPostProcess"
  59635. */
  59636. getClassName(): string;
  59637. private _isReady;
  59638. /**
  59639. * Sets the new light position for light scattering effect
  59640. * @param position The new custom light position
  59641. */
  59642. setCustomMeshPosition(position: Vector3): void;
  59643. /**
  59644. * Returns the light position for light scattering effect
  59645. * @return Vector3 The custom light position
  59646. */
  59647. getCustomMeshPosition(): Vector3;
  59648. /**
  59649. * Disposes the internal assets and detaches the post-process from the camera
  59650. */
  59651. dispose(camera: Camera): void;
  59652. /**
  59653. * Returns the render target texture used by the post-process
  59654. * @return the render target texture used by the post-process
  59655. */
  59656. getPass(): RenderTargetTexture;
  59657. private _meshExcluded;
  59658. private _createPass;
  59659. private _updateMeshScreenCoordinates;
  59660. /**
  59661. * Creates a default mesh for the Volumeric Light Scattering post-process
  59662. * @param name The mesh name
  59663. * @param scene The scene where to create the mesh
  59664. * @return the default mesh
  59665. */
  59666. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. interface Scene {
  59671. /** @hidden (Backing field) */
  59672. _boundingBoxRenderer: BoundingBoxRenderer;
  59673. /** @hidden (Backing field) */
  59674. _forceShowBoundingBoxes: boolean;
  59675. /**
  59676. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59677. */
  59678. forceShowBoundingBoxes: boolean;
  59679. /**
  59680. * Gets the bounding box renderer associated with the scene
  59681. * @returns a BoundingBoxRenderer
  59682. */
  59683. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59684. }
  59685. interface AbstractMesh {
  59686. /** @hidden (Backing field) */
  59687. _showBoundingBox: boolean;
  59688. /**
  59689. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59690. */
  59691. showBoundingBox: boolean;
  59692. }
  59693. /**
  59694. * Component responsible of rendering the bounding box of the meshes in a scene.
  59695. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59696. */
  59697. export class BoundingBoxRenderer implements ISceneComponent {
  59698. /**
  59699. * The component name helpfull to identify the component in the list of scene components.
  59700. */
  59701. readonly name: string;
  59702. /**
  59703. * The scene the component belongs to.
  59704. */
  59705. scene: Scene;
  59706. /**
  59707. * Color of the bounding box lines placed in front of an object
  59708. */
  59709. frontColor: Color3;
  59710. /**
  59711. * Color of the bounding box lines placed behind an object
  59712. */
  59713. backColor: Color3;
  59714. /**
  59715. * Defines if the renderer should show the back lines or not
  59716. */
  59717. showBackLines: boolean;
  59718. /**
  59719. * @hidden
  59720. */
  59721. renderList: SmartArray<BoundingBox>;
  59722. private _colorShader;
  59723. private _vertexBuffers;
  59724. private _indexBuffer;
  59725. private _fillIndexBuffer;
  59726. private _fillIndexData;
  59727. /**
  59728. * Instantiates a new bounding box renderer in a scene.
  59729. * @param scene the scene the renderer renders in
  59730. */
  59731. constructor(scene: Scene);
  59732. /**
  59733. * Registers the component in a given scene
  59734. */
  59735. register(): void;
  59736. private _evaluateSubMesh;
  59737. private _activeMesh;
  59738. private _prepareRessources;
  59739. private _createIndexBuffer;
  59740. /**
  59741. * Rebuilds the elements related to this component in case of
  59742. * context lost for instance.
  59743. */
  59744. rebuild(): void;
  59745. /**
  59746. * @hidden
  59747. */
  59748. reset(): void;
  59749. /**
  59750. * Render the bounding boxes of a specific rendering group
  59751. * @param renderingGroupId defines the rendering group to render
  59752. */
  59753. render(renderingGroupId: number): void;
  59754. /**
  59755. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59756. * @param mesh Define the mesh to render the occlusion bounding box for
  59757. */
  59758. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59759. /**
  59760. * Dispose and release the resources attached to this renderer.
  59761. */
  59762. dispose(): void;
  59763. }
  59764. }
  59765. declare module BABYLON {
  59766. /** @hidden */
  59767. export var depthPixelShader: {
  59768. name: string;
  59769. shader: string;
  59770. };
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * This represents a depth renderer in Babylon.
  59775. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59776. */
  59777. export class DepthRenderer {
  59778. private _scene;
  59779. private _depthMap;
  59780. private _effect;
  59781. private readonly _storeNonLinearDepth;
  59782. private readonly _clearColor;
  59783. /** Get if the depth renderer is using packed depth or not */
  59784. readonly isPacked: boolean;
  59785. private _cachedDefines;
  59786. private _camera;
  59787. /**
  59788. * Specifiess that the depth renderer will only be used within
  59789. * the camera it is created for.
  59790. * This can help forcing its rendering during the camera processing.
  59791. */
  59792. useOnlyInActiveCamera: boolean;
  59793. /** @hidden */
  59794. static _SceneComponentInitialization: (scene: Scene) => void;
  59795. /**
  59796. * Instantiates a depth renderer
  59797. * @param scene The scene the renderer belongs to
  59798. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59799. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59800. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59801. */
  59802. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59803. /**
  59804. * Creates the depth rendering effect and checks if the effect is ready.
  59805. * @param subMesh The submesh to be used to render the depth map of
  59806. * @param useInstances If multiple world instances should be used
  59807. * @returns if the depth renderer is ready to render the depth map
  59808. */
  59809. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59810. /**
  59811. * Gets the texture which the depth map will be written to.
  59812. * @returns The depth map texture
  59813. */
  59814. getDepthMap(): RenderTargetTexture;
  59815. /**
  59816. * Disposes of the depth renderer.
  59817. */
  59818. dispose(): void;
  59819. }
  59820. }
  59821. declare module BABYLON {
  59822. interface Scene {
  59823. /** @hidden (Backing field) */
  59824. _depthRenderer: {
  59825. [id: string]: DepthRenderer;
  59826. };
  59827. /**
  59828. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59829. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59830. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59831. * @returns the created depth renderer
  59832. */
  59833. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59834. /**
  59835. * Disables a depth renderer for a given camera
  59836. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59837. */
  59838. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59839. }
  59840. /**
  59841. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59842. * in several rendering techniques.
  59843. */
  59844. export class DepthRendererSceneComponent implements ISceneComponent {
  59845. /**
  59846. * The component name helpfull to identify the component in the list of scene components.
  59847. */
  59848. readonly name: string;
  59849. /**
  59850. * The scene the component belongs to.
  59851. */
  59852. scene: Scene;
  59853. /**
  59854. * Creates a new instance of the component for the given scene
  59855. * @param scene Defines the scene to register the component in
  59856. */
  59857. constructor(scene: Scene);
  59858. /**
  59859. * Registers the component in a given scene
  59860. */
  59861. register(): void;
  59862. /**
  59863. * Rebuilds the elements related to this component in case of
  59864. * context lost for instance.
  59865. */
  59866. rebuild(): void;
  59867. /**
  59868. * Disposes the component and the associated ressources
  59869. */
  59870. dispose(): void;
  59871. private _gatherRenderTargets;
  59872. private _gatherActiveCameraRenderTargets;
  59873. }
  59874. }
  59875. declare module BABYLON {
  59876. /** @hidden */
  59877. export var outlinePixelShader: {
  59878. name: string;
  59879. shader: string;
  59880. };
  59881. }
  59882. declare module BABYLON {
  59883. /** @hidden */
  59884. export var outlineVertexShader: {
  59885. name: string;
  59886. shader: string;
  59887. };
  59888. }
  59889. declare module BABYLON {
  59890. interface Scene {
  59891. /** @hidden */
  59892. _outlineRenderer: OutlineRenderer;
  59893. /**
  59894. * Gets the outline renderer associated with the scene
  59895. * @returns a OutlineRenderer
  59896. */
  59897. getOutlineRenderer(): OutlineRenderer;
  59898. }
  59899. interface AbstractMesh {
  59900. /** @hidden (Backing field) */
  59901. _renderOutline: boolean;
  59902. /**
  59903. * Gets or sets a boolean indicating if the outline must be rendered as well
  59904. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59905. */
  59906. renderOutline: boolean;
  59907. /** @hidden (Backing field) */
  59908. _renderOverlay: boolean;
  59909. /**
  59910. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59911. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59912. */
  59913. renderOverlay: boolean;
  59914. }
  59915. /**
  59916. * This class is responsible to draw bothe outline/overlay of meshes.
  59917. * It should not be used directly but through the available method on mesh.
  59918. */
  59919. export class OutlineRenderer implements ISceneComponent {
  59920. /**
  59921. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59922. */
  59923. private static _StencilReference;
  59924. /**
  59925. * The name of the component. Each component must have a unique name.
  59926. */
  59927. name: string;
  59928. /**
  59929. * The scene the component belongs to.
  59930. */
  59931. scene: Scene;
  59932. /**
  59933. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59934. */
  59935. zOffset: number;
  59936. private _engine;
  59937. private _effect;
  59938. private _cachedDefines;
  59939. private _savedDepthWrite;
  59940. /**
  59941. * Instantiates a new outline renderer. (There could be only one per scene).
  59942. * @param scene Defines the scene it belongs to
  59943. */
  59944. constructor(scene: Scene);
  59945. /**
  59946. * Register the component to one instance of a scene.
  59947. */
  59948. register(): void;
  59949. /**
  59950. * Rebuilds the elements related to this component in case of
  59951. * context lost for instance.
  59952. */
  59953. rebuild(): void;
  59954. /**
  59955. * Disposes the component and the associated ressources.
  59956. */
  59957. dispose(): void;
  59958. /**
  59959. * Renders the outline in the canvas.
  59960. * @param subMesh Defines the sumesh to render
  59961. * @param batch Defines the batch of meshes in case of instances
  59962. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59963. */
  59964. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59965. /**
  59966. * Returns whether or not the outline renderer is ready for a given submesh.
  59967. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59968. * @param subMesh Defines the submesh to check readyness for
  59969. * @param useInstances Defines wheter wee are trying to render instances or not
  59970. * @returns true if ready otherwise false
  59971. */
  59972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59973. private _beforeRenderingMesh;
  59974. private _afterRenderingMesh;
  59975. }
  59976. }
  59977. declare module BABYLON {
  59978. /**
  59979. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59980. * @see http://doc.babylonjs.com/babylon101/sprites
  59981. */
  59982. export class SpritePackedManager extends SpriteManager {
  59983. /** defines the packed manager's name */
  59984. name: string;
  59985. /**
  59986. * Creates a new sprite manager from a packed sprite sheet
  59987. * @param name defines the manager's name
  59988. * @param imgUrl defines the sprite sheet url
  59989. * @param capacity defines the maximum allowed number of sprites
  59990. * @param scene defines the hosting scene
  59991. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59992. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59993. * @param samplingMode defines the smapling mode to use with spritesheet
  59994. * @param fromPacked set to true; do not alter
  59995. */
  59996. constructor(
  59997. /** defines the packed manager's name */
  59998. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59999. }
  60000. }
  60001. declare module BABYLON {
  60002. /**
  60003. * Defines the list of states available for a task inside a AssetsManager
  60004. */
  60005. export enum AssetTaskState {
  60006. /**
  60007. * Initialization
  60008. */
  60009. INIT = 0,
  60010. /**
  60011. * Running
  60012. */
  60013. RUNNING = 1,
  60014. /**
  60015. * Done
  60016. */
  60017. DONE = 2,
  60018. /**
  60019. * Error
  60020. */
  60021. ERROR = 3
  60022. }
  60023. /**
  60024. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60025. */
  60026. export abstract class AbstractAssetTask {
  60027. /**
  60028. * Task name
  60029. */ name: string;
  60030. /**
  60031. * Callback called when the task is successful
  60032. */
  60033. onSuccess: (task: any) => void;
  60034. /**
  60035. * Callback called when the task is not successful
  60036. */
  60037. onError: (task: any, message?: string, exception?: any) => void;
  60038. /**
  60039. * Creates a new AssetsManager
  60040. * @param name defines the name of the task
  60041. */
  60042. constructor(
  60043. /**
  60044. * Task name
  60045. */ name: string);
  60046. private _isCompleted;
  60047. private _taskState;
  60048. private _errorObject;
  60049. /**
  60050. * Get if the task is completed
  60051. */
  60052. readonly isCompleted: boolean;
  60053. /**
  60054. * Gets the current state of the task
  60055. */
  60056. readonly taskState: AssetTaskState;
  60057. /**
  60058. * Gets the current error object (if task is in error)
  60059. */
  60060. readonly errorObject: {
  60061. message?: string;
  60062. exception?: any;
  60063. };
  60064. /**
  60065. * Internal only
  60066. * @hidden
  60067. */
  60068. _setErrorObject(message?: string, exception?: any): void;
  60069. /**
  60070. * Execute the current task
  60071. * @param scene defines the scene where you want your assets to be loaded
  60072. * @param onSuccess is a callback called when the task is successfully executed
  60073. * @param onError is a callback called if an error occurs
  60074. */
  60075. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60076. /**
  60077. * Execute the current task
  60078. * @param scene defines the scene where you want your assets to be loaded
  60079. * @param onSuccess is a callback called when the task is successfully executed
  60080. * @param onError is a callback called if an error occurs
  60081. */
  60082. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60083. /**
  60084. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60085. * This can be used with failed tasks that have the reason for failure fixed.
  60086. */
  60087. reset(): void;
  60088. private onErrorCallback;
  60089. private onDoneCallback;
  60090. }
  60091. /**
  60092. * Define the interface used by progress events raised during assets loading
  60093. */
  60094. export interface IAssetsProgressEvent {
  60095. /**
  60096. * Defines the number of remaining tasks to process
  60097. */
  60098. remainingCount: number;
  60099. /**
  60100. * Defines the total number of tasks
  60101. */
  60102. totalCount: number;
  60103. /**
  60104. * Defines the task that was just processed
  60105. */
  60106. task: AbstractAssetTask;
  60107. }
  60108. /**
  60109. * Class used to share progress information about assets loading
  60110. */
  60111. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60112. /**
  60113. * Defines the number of remaining tasks to process
  60114. */
  60115. remainingCount: number;
  60116. /**
  60117. * Defines the total number of tasks
  60118. */
  60119. totalCount: number;
  60120. /**
  60121. * Defines the task that was just processed
  60122. */
  60123. task: AbstractAssetTask;
  60124. /**
  60125. * Creates a AssetsProgressEvent
  60126. * @param remainingCount defines the number of remaining tasks to process
  60127. * @param totalCount defines the total number of tasks
  60128. * @param task defines the task that was just processed
  60129. */
  60130. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60131. }
  60132. /**
  60133. * Define a task used by AssetsManager to load meshes
  60134. */
  60135. export class MeshAssetTask extends AbstractAssetTask {
  60136. /**
  60137. * Defines the name of the task
  60138. */
  60139. name: string;
  60140. /**
  60141. * Defines the list of mesh's names you want to load
  60142. */
  60143. meshesNames: any;
  60144. /**
  60145. * Defines the root url to use as a base to load your meshes and associated resources
  60146. */
  60147. rootUrl: string;
  60148. /**
  60149. * Defines the filename of the scene to load from
  60150. */
  60151. sceneFilename: string;
  60152. /**
  60153. * Gets the list of loaded meshes
  60154. */
  60155. loadedMeshes: Array<AbstractMesh>;
  60156. /**
  60157. * Gets the list of loaded particle systems
  60158. */
  60159. loadedParticleSystems: Array<IParticleSystem>;
  60160. /**
  60161. * Gets the list of loaded skeletons
  60162. */
  60163. loadedSkeletons: Array<Skeleton>;
  60164. /**
  60165. * Gets the list of loaded animation groups
  60166. */
  60167. loadedAnimationGroups: Array<AnimationGroup>;
  60168. /**
  60169. * Callback called when the task is successful
  60170. */
  60171. onSuccess: (task: MeshAssetTask) => void;
  60172. /**
  60173. * Callback called when the task is successful
  60174. */
  60175. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60176. /**
  60177. * Creates a new MeshAssetTask
  60178. * @param name defines the name of the task
  60179. * @param meshesNames defines the list of mesh's names you want to load
  60180. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60181. * @param sceneFilename defines the filename of the scene to load from
  60182. */
  60183. constructor(
  60184. /**
  60185. * Defines the name of the task
  60186. */
  60187. name: string,
  60188. /**
  60189. * Defines the list of mesh's names you want to load
  60190. */
  60191. meshesNames: any,
  60192. /**
  60193. * Defines the root url to use as a base to load your meshes and associated resources
  60194. */
  60195. rootUrl: string,
  60196. /**
  60197. * Defines the filename of the scene to load from
  60198. */
  60199. sceneFilename: string);
  60200. /**
  60201. * Execute the current task
  60202. * @param scene defines the scene where you want your assets to be loaded
  60203. * @param onSuccess is a callback called when the task is successfully executed
  60204. * @param onError is a callback called if an error occurs
  60205. */
  60206. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60207. }
  60208. /**
  60209. * Define a task used by AssetsManager to load text content
  60210. */
  60211. export class TextFileAssetTask extends AbstractAssetTask {
  60212. /**
  60213. * Defines the name of the task
  60214. */
  60215. name: string;
  60216. /**
  60217. * Defines the location of the file to load
  60218. */
  60219. url: string;
  60220. /**
  60221. * Gets the loaded text string
  60222. */
  60223. text: string;
  60224. /**
  60225. * Callback called when the task is successful
  60226. */
  60227. onSuccess: (task: TextFileAssetTask) => void;
  60228. /**
  60229. * Callback called when the task is successful
  60230. */
  60231. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60232. /**
  60233. * Creates a new TextFileAssetTask object
  60234. * @param name defines the name of the task
  60235. * @param url defines the location of the file to load
  60236. */
  60237. constructor(
  60238. /**
  60239. * Defines the name of the task
  60240. */
  60241. name: string,
  60242. /**
  60243. * Defines the location of the file to load
  60244. */
  60245. url: string);
  60246. /**
  60247. * Execute the current task
  60248. * @param scene defines the scene where you want your assets to be loaded
  60249. * @param onSuccess is a callback called when the task is successfully executed
  60250. * @param onError is a callback called if an error occurs
  60251. */
  60252. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60253. }
  60254. /**
  60255. * Define a task used by AssetsManager to load binary data
  60256. */
  60257. export class BinaryFileAssetTask extends AbstractAssetTask {
  60258. /**
  60259. * Defines the name of the task
  60260. */
  60261. name: string;
  60262. /**
  60263. * Defines the location of the file to load
  60264. */
  60265. url: string;
  60266. /**
  60267. * Gets the lodaded data (as an array buffer)
  60268. */
  60269. data: ArrayBuffer;
  60270. /**
  60271. * Callback called when the task is successful
  60272. */
  60273. onSuccess: (task: BinaryFileAssetTask) => void;
  60274. /**
  60275. * Callback called when the task is successful
  60276. */
  60277. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60278. /**
  60279. * Creates a new BinaryFileAssetTask object
  60280. * @param name defines the name of the new task
  60281. * @param url defines the location of the file to load
  60282. */
  60283. constructor(
  60284. /**
  60285. * Defines the name of the task
  60286. */
  60287. name: string,
  60288. /**
  60289. * Defines the location of the file to load
  60290. */
  60291. url: string);
  60292. /**
  60293. * Execute the current task
  60294. * @param scene defines the scene where you want your assets to be loaded
  60295. * @param onSuccess is a callback called when the task is successfully executed
  60296. * @param onError is a callback called if an error occurs
  60297. */
  60298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60299. }
  60300. /**
  60301. * Define a task used by AssetsManager to load images
  60302. */
  60303. export class ImageAssetTask extends AbstractAssetTask {
  60304. /**
  60305. * Defines the name of the task
  60306. */
  60307. name: string;
  60308. /**
  60309. * Defines the location of the image to load
  60310. */
  60311. url: string;
  60312. /**
  60313. * Gets the loaded images
  60314. */
  60315. image: HTMLImageElement;
  60316. /**
  60317. * Callback called when the task is successful
  60318. */
  60319. onSuccess: (task: ImageAssetTask) => void;
  60320. /**
  60321. * Callback called when the task is successful
  60322. */
  60323. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60324. /**
  60325. * Creates a new ImageAssetTask
  60326. * @param name defines the name of the task
  60327. * @param url defines the location of the image to load
  60328. */
  60329. constructor(
  60330. /**
  60331. * Defines the name of the task
  60332. */
  60333. name: string,
  60334. /**
  60335. * Defines the location of the image to load
  60336. */
  60337. url: string);
  60338. /**
  60339. * Execute the current task
  60340. * @param scene defines the scene where you want your assets to be loaded
  60341. * @param onSuccess is a callback called when the task is successfully executed
  60342. * @param onError is a callback called if an error occurs
  60343. */
  60344. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60345. }
  60346. /**
  60347. * Defines the interface used by texture loading tasks
  60348. */
  60349. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60350. /**
  60351. * Gets the loaded texture
  60352. */
  60353. texture: TEX;
  60354. }
  60355. /**
  60356. * Define a task used by AssetsManager to load 2D textures
  60357. */
  60358. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60359. /**
  60360. * Defines the name of the task
  60361. */
  60362. name: string;
  60363. /**
  60364. * Defines the location of the file to load
  60365. */
  60366. url: string;
  60367. /**
  60368. * Defines if mipmap should not be generated (default is false)
  60369. */
  60370. noMipmap?: boolean | undefined;
  60371. /**
  60372. * Defines if texture must be inverted on Y axis (default is false)
  60373. */
  60374. invertY?: boolean | undefined;
  60375. /**
  60376. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60377. */
  60378. samplingMode: number;
  60379. /**
  60380. * Gets the loaded texture
  60381. */
  60382. texture: Texture;
  60383. /**
  60384. * Callback called when the task is successful
  60385. */
  60386. onSuccess: (task: TextureAssetTask) => void;
  60387. /**
  60388. * Callback called when the task is successful
  60389. */
  60390. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60391. /**
  60392. * Creates a new TextureAssetTask object
  60393. * @param name defines the name of the task
  60394. * @param url defines the location of the file to load
  60395. * @param noMipmap defines if mipmap should not be generated (default is false)
  60396. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60397. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60398. */
  60399. constructor(
  60400. /**
  60401. * Defines the name of the task
  60402. */
  60403. name: string,
  60404. /**
  60405. * Defines the location of the file to load
  60406. */
  60407. url: string,
  60408. /**
  60409. * Defines if mipmap should not be generated (default is false)
  60410. */
  60411. noMipmap?: boolean | undefined,
  60412. /**
  60413. * Defines if texture must be inverted on Y axis (default is false)
  60414. */
  60415. invertY?: boolean | undefined,
  60416. /**
  60417. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60418. */
  60419. samplingMode?: number);
  60420. /**
  60421. * Execute the current task
  60422. * @param scene defines the scene where you want your assets to be loaded
  60423. * @param onSuccess is a callback called when the task is successfully executed
  60424. * @param onError is a callback called if an error occurs
  60425. */
  60426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60427. }
  60428. /**
  60429. * Define a task used by AssetsManager to load cube textures
  60430. */
  60431. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60432. /**
  60433. * Defines the name of the task
  60434. */
  60435. name: string;
  60436. /**
  60437. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60438. */
  60439. url: string;
  60440. /**
  60441. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60442. */
  60443. extensions?: string[] | undefined;
  60444. /**
  60445. * Defines if mipmaps should not be generated (default is false)
  60446. */
  60447. noMipmap?: boolean | undefined;
  60448. /**
  60449. * Defines the explicit list of files (undefined by default)
  60450. */
  60451. files?: string[] | undefined;
  60452. /**
  60453. * Gets the loaded texture
  60454. */
  60455. texture: CubeTexture;
  60456. /**
  60457. * Callback called when the task is successful
  60458. */
  60459. onSuccess: (task: CubeTextureAssetTask) => void;
  60460. /**
  60461. * Callback called when the task is successful
  60462. */
  60463. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60464. /**
  60465. * Creates a new CubeTextureAssetTask
  60466. * @param name defines the name of the task
  60467. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60468. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60469. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60470. * @param files defines the explicit list of files (undefined by default)
  60471. */
  60472. constructor(
  60473. /**
  60474. * Defines the name of the task
  60475. */
  60476. name: string,
  60477. /**
  60478. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60479. */
  60480. url: string,
  60481. /**
  60482. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60483. */
  60484. extensions?: string[] | undefined,
  60485. /**
  60486. * Defines if mipmaps should not be generated (default is false)
  60487. */
  60488. noMipmap?: boolean | undefined,
  60489. /**
  60490. * Defines the explicit list of files (undefined by default)
  60491. */
  60492. files?: string[] | undefined);
  60493. /**
  60494. * Execute the current task
  60495. * @param scene defines the scene where you want your assets to be loaded
  60496. * @param onSuccess is a callback called when the task is successfully executed
  60497. * @param onError is a callback called if an error occurs
  60498. */
  60499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60500. }
  60501. /**
  60502. * Define a task used by AssetsManager to load HDR cube textures
  60503. */
  60504. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60505. /**
  60506. * Defines the name of the task
  60507. */
  60508. name: string;
  60509. /**
  60510. * Defines the location of the file to load
  60511. */
  60512. url: string;
  60513. /**
  60514. * Defines the desired size (the more it increases the longer the generation will be)
  60515. */
  60516. size: number;
  60517. /**
  60518. * Defines if mipmaps should not be generated (default is false)
  60519. */
  60520. noMipmap: boolean;
  60521. /**
  60522. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60523. */
  60524. generateHarmonics: boolean;
  60525. /**
  60526. * 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)
  60527. */
  60528. gammaSpace: boolean;
  60529. /**
  60530. * Internal Use Only
  60531. */
  60532. reserved: boolean;
  60533. /**
  60534. * Gets the loaded texture
  60535. */
  60536. texture: HDRCubeTexture;
  60537. /**
  60538. * Callback called when the task is successful
  60539. */
  60540. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60541. /**
  60542. * Callback called when the task is successful
  60543. */
  60544. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60545. /**
  60546. * Creates a new HDRCubeTextureAssetTask object
  60547. * @param name defines the name of the task
  60548. * @param url defines the location of the file to load
  60549. * @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.
  60550. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60551. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60552. * @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)
  60553. * @param reserved Internal use only
  60554. */
  60555. constructor(
  60556. /**
  60557. * Defines the name of the task
  60558. */
  60559. name: string,
  60560. /**
  60561. * Defines the location of the file to load
  60562. */
  60563. url: string,
  60564. /**
  60565. * Defines the desired size (the more it increases the longer the generation will be)
  60566. */
  60567. size: number,
  60568. /**
  60569. * Defines if mipmaps should not be generated (default is false)
  60570. */
  60571. noMipmap?: boolean,
  60572. /**
  60573. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60574. */
  60575. generateHarmonics?: boolean,
  60576. /**
  60577. * 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)
  60578. */
  60579. gammaSpace?: boolean,
  60580. /**
  60581. * Internal Use Only
  60582. */
  60583. reserved?: boolean);
  60584. /**
  60585. * Execute the current task
  60586. * @param scene defines the scene where you want your assets to be loaded
  60587. * @param onSuccess is a callback called when the task is successfully executed
  60588. * @param onError is a callback called if an error occurs
  60589. */
  60590. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60591. }
  60592. /**
  60593. * Define a task used by AssetsManager to load Equirectangular cube textures
  60594. */
  60595. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60596. /**
  60597. * Defines the name of the task
  60598. */
  60599. name: string;
  60600. /**
  60601. * Defines the location of the file to load
  60602. */
  60603. url: string;
  60604. /**
  60605. * Defines the desired size (the more it increases the longer the generation will be)
  60606. */
  60607. size: number;
  60608. /**
  60609. * Defines if mipmaps should not be generated (default is false)
  60610. */
  60611. noMipmap: boolean;
  60612. /**
  60613. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60614. * but the standard material would require them in Gamma space) (default is true)
  60615. */
  60616. gammaSpace: boolean;
  60617. /**
  60618. * Gets the loaded texture
  60619. */
  60620. texture: EquiRectangularCubeTexture;
  60621. /**
  60622. * Callback called when the task is successful
  60623. */
  60624. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60625. /**
  60626. * Callback called when the task is successful
  60627. */
  60628. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60629. /**
  60630. * Creates a new EquiRectangularCubeTextureAssetTask object
  60631. * @param name defines the name of the task
  60632. * @param url defines the location of the file to load
  60633. * @param size defines the desired size (the more it increases the longer the generation will be)
  60634. * If the size is omitted this implies you are using a preprocessed cubemap.
  60635. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60636. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60637. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60638. * (default is true)
  60639. */
  60640. constructor(
  60641. /**
  60642. * Defines the name of the task
  60643. */
  60644. name: string,
  60645. /**
  60646. * Defines the location of the file to load
  60647. */
  60648. url: string,
  60649. /**
  60650. * Defines the desired size (the more it increases the longer the generation will be)
  60651. */
  60652. size: number,
  60653. /**
  60654. * Defines if mipmaps should not be generated (default is false)
  60655. */
  60656. noMipmap?: boolean,
  60657. /**
  60658. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60659. * but the standard material would require them in Gamma space) (default is true)
  60660. */
  60661. gammaSpace?: boolean);
  60662. /**
  60663. * Execute the current task
  60664. * @param scene defines the scene where you want your assets to be loaded
  60665. * @param onSuccess is a callback called when the task is successfully executed
  60666. * @param onError is a callback called if an error occurs
  60667. */
  60668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60669. }
  60670. /**
  60671. * This class can be used to easily import assets into a scene
  60672. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60673. */
  60674. export class AssetsManager {
  60675. private _scene;
  60676. private _isLoading;
  60677. protected _tasks: AbstractAssetTask[];
  60678. protected _waitingTasksCount: number;
  60679. protected _totalTasksCount: number;
  60680. /**
  60681. * Callback called when all tasks are processed
  60682. */
  60683. onFinish: (tasks: AbstractAssetTask[]) => void;
  60684. /**
  60685. * Callback called when a task is successful
  60686. */
  60687. onTaskSuccess: (task: AbstractAssetTask) => void;
  60688. /**
  60689. * Callback called when a task had an error
  60690. */
  60691. onTaskError: (task: AbstractAssetTask) => void;
  60692. /**
  60693. * Callback called when a task is done (whatever the result is)
  60694. */
  60695. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60696. /**
  60697. * Observable called when all tasks are processed
  60698. */
  60699. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60700. /**
  60701. * Observable called when a task had an error
  60702. */
  60703. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60704. /**
  60705. * Observable called when all tasks were executed
  60706. */
  60707. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60708. /**
  60709. * Observable called when a task is done (whatever the result is)
  60710. */
  60711. onProgressObservable: Observable<IAssetsProgressEvent>;
  60712. /**
  60713. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60715. */
  60716. useDefaultLoadingScreen: boolean;
  60717. /**
  60718. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60719. * when all assets have been downloaded.
  60720. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60721. */
  60722. autoHideLoadingUI: boolean;
  60723. /**
  60724. * Creates a new AssetsManager
  60725. * @param scene defines the scene to work on
  60726. */
  60727. constructor(scene: Scene);
  60728. /**
  60729. * Add a MeshAssetTask to the list of active tasks
  60730. * @param taskName defines the name of the new task
  60731. * @param meshesNames defines the name of meshes to load
  60732. * @param rootUrl defines the root url to use to locate files
  60733. * @param sceneFilename defines the filename of the scene file
  60734. * @returns a new MeshAssetTask object
  60735. */
  60736. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60737. /**
  60738. * Add a TextFileAssetTask to the list of active tasks
  60739. * @param taskName defines the name of the new task
  60740. * @param url defines the url of the file to load
  60741. * @returns a new TextFileAssetTask object
  60742. */
  60743. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60744. /**
  60745. * Add a BinaryFileAssetTask to the list of active tasks
  60746. * @param taskName defines the name of the new task
  60747. * @param url defines the url of the file to load
  60748. * @returns a new BinaryFileAssetTask object
  60749. */
  60750. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60751. /**
  60752. * Add a ImageAssetTask to the list of active tasks
  60753. * @param taskName defines the name of the new task
  60754. * @param url defines the url of the file to load
  60755. * @returns a new ImageAssetTask object
  60756. */
  60757. addImageTask(taskName: string, url: string): ImageAssetTask;
  60758. /**
  60759. * Add a TextureAssetTask to the list of active tasks
  60760. * @param taskName defines the name of the new task
  60761. * @param url defines the url of the file to load
  60762. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60763. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60764. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60765. * @returns a new TextureAssetTask object
  60766. */
  60767. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60768. /**
  60769. * Add a CubeTextureAssetTask to the list of active tasks
  60770. * @param taskName defines the name of the new task
  60771. * @param url defines the url of the file to load
  60772. * @param extensions defines the extension to use to load the cube map (can be null)
  60773. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60774. * @param files defines the list of files to load (can be null)
  60775. * @returns a new CubeTextureAssetTask object
  60776. */
  60777. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60778. /**
  60779. *
  60780. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60781. * @param taskName defines the name of the new task
  60782. * @param url defines the url of the file to load
  60783. * @param size defines the size you want for the cubemap (can be null)
  60784. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60785. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60786. * @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)
  60787. * @param reserved Internal use only
  60788. * @returns a new HDRCubeTextureAssetTask object
  60789. */
  60790. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60791. /**
  60792. *
  60793. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60794. * @param taskName defines the name of the new task
  60795. * @param url defines the url of the file to load
  60796. * @param size defines the size you want for the cubemap (can be null)
  60797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60798. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60799. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60800. * @returns a new EquiRectangularCubeTextureAssetTask object
  60801. */
  60802. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60803. /**
  60804. * Remove a task from the assets manager.
  60805. * @param task the task to remove
  60806. */
  60807. removeTask(task: AbstractAssetTask): void;
  60808. private _decreaseWaitingTasksCount;
  60809. private _runTask;
  60810. /**
  60811. * Reset the AssetsManager and remove all tasks
  60812. * @return the current instance of the AssetsManager
  60813. */
  60814. reset(): AssetsManager;
  60815. /**
  60816. * Start the loading process
  60817. * @return the current instance of the AssetsManager
  60818. */
  60819. load(): AssetsManager;
  60820. /**
  60821. * Start the loading process as an async operation
  60822. * @return a promise returning the list of failed tasks
  60823. */
  60824. loadAsync(): Promise<void>;
  60825. }
  60826. }
  60827. declare module BABYLON {
  60828. /**
  60829. * Wrapper class for promise with external resolve and reject.
  60830. */
  60831. export class Deferred<T> {
  60832. /**
  60833. * The promise associated with this deferred object.
  60834. */
  60835. readonly promise: Promise<T>;
  60836. private _resolve;
  60837. private _reject;
  60838. /**
  60839. * The resolve method of the promise associated with this deferred object.
  60840. */
  60841. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60842. /**
  60843. * The reject method of the promise associated with this deferred object.
  60844. */
  60845. readonly reject: (reason?: any) => void;
  60846. /**
  60847. * Constructor for this deferred object.
  60848. */
  60849. constructor();
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /**
  60854. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60855. */
  60856. export class MeshExploder {
  60857. private _centerMesh;
  60858. private _meshes;
  60859. private _meshesOrigins;
  60860. private _toCenterVectors;
  60861. private _scaledDirection;
  60862. private _newPosition;
  60863. private _centerPosition;
  60864. /**
  60865. * Explodes meshes from a center mesh.
  60866. * @param meshes The meshes to explode.
  60867. * @param centerMesh The mesh to be center of explosion.
  60868. */
  60869. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60870. private _setCenterMesh;
  60871. /**
  60872. * Get class name
  60873. * @returns "MeshExploder"
  60874. */
  60875. getClassName(): string;
  60876. /**
  60877. * "Exploded meshes"
  60878. * @returns Array of meshes with the centerMesh at index 0.
  60879. */
  60880. getMeshes(): Array<Mesh>;
  60881. /**
  60882. * Explodes meshes giving a specific direction
  60883. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60884. */
  60885. explode(direction?: number): void;
  60886. }
  60887. }
  60888. declare module BABYLON {
  60889. /**
  60890. * Class used to help managing file picking and drag'n'drop
  60891. */
  60892. export class FilesInput {
  60893. /**
  60894. * List of files ready to be loaded
  60895. */
  60896. static readonly FilesToLoad: {
  60897. [key: string]: File;
  60898. };
  60899. /**
  60900. * Callback called when a file is processed
  60901. */
  60902. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60903. private _engine;
  60904. private _currentScene;
  60905. private _sceneLoadedCallback;
  60906. private _progressCallback;
  60907. private _additionalRenderLoopLogicCallback;
  60908. private _textureLoadingCallback;
  60909. private _startingProcessingFilesCallback;
  60910. private _onReloadCallback;
  60911. private _errorCallback;
  60912. private _elementToMonitor;
  60913. private _sceneFileToLoad;
  60914. private _filesToLoad;
  60915. /**
  60916. * Creates a new FilesInput
  60917. * @param engine defines the rendering engine
  60918. * @param scene defines the hosting scene
  60919. * @param sceneLoadedCallback callback called when scene is loaded
  60920. * @param progressCallback callback called to track progress
  60921. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60922. * @param textureLoadingCallback callback called when a texture is loading
  60923. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60924. * @param onReloadCallback callback called when a reload is requested
  60925. * @param errorCallback callback call if an error occurs
  60926. */
  60927. 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);
  60928. private _dragEnterHandler;
  60929. private _dragOverHandler;
  60930. private _dropHandler;
  60931. /**
  60932. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60933. * @param elementToMonitor defines the DOM element to track
  60934. */
  60935. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60936. /**
  60937. * Release all associated resources
  60938. */
  60939. dispose(): void;
  60940. private renderFunction;
  60941. private drag;
  60942. private drop;
  60943. private _traverseFolder;
  60944. private _processFiles;
  60945. /**
  60946. * Load files from a drop event
  60947. * @param event defines the drop event to use as source
  60948. */
  60949. loadFiles(event: any): void;
  60950. private _processReload;
  60951. /**
  60952. * Reload the current scene from the loaded files
  60953. */
  60954. reload(): void;
  60955. }
  60956. }
  60957. declare module BABYLON {
  60958. /**
  60959. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60961. */
  60962. export class SceneOptimization {
  60963. /**
  60964. * Defines the priority of this optimization (0 by default which means first in the list)
  60965. */
  60966. priority: number;
  60967. /**
  60968. * Gets a string describing the action executed by the current optimization
  60969. * @returns description string
  60970. */
  60971. getDescription(): string;
  60972. /**
  60973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60974. * @param scene defines the current scene where to apply this optimization
  60975. * @param optimizer defines the current optimizer
  60976. * @returns true if everything that can be done was applied
  60977. */
  60978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60979. /**
  60980. * Creates the SceneOptimization object
  60981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60982. * @param desc defines the description associated with the optimization
  60983. */
  60984. constructor(
  60985. /**
  60986. * Defines the priority of this optimization (0 by default which means first in the list)
  60987. */
  60988. priority?: number);
  60989. }
  60990. /**
  60991. * Defines an optimization used to reduce the size of render target textures
  60992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60993. */
  60994. export class TextureOptimization extends SceneOptimization {
  60995. /**
  60996. * Defines the priority of this optimization (0 by default which means first in the list)
  60997. */
  60998. priority: number;
  60999. /**
  61000. * 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
  61001. */
  61002. maximumSize: number;
  61003. /**
  61004. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61005. */
  61006. step: number;
  61007. /**
  61008. * Gets a string describing the action executed by the current optimization
  61009. * @returns description string
  61010. */
  61011. getDescription(): string;
  61012. /**
  61013. * Creates the TextureOptimization object
  61014. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61015. * @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
  61016. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61017. */
  61018. constructor(
  61019. /**
  61020. * Defines the priority of this optimization (0 by default which means first in the list)
  61021. */
  61022. priority?: number,
  61023. /**
  61024. * 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
  61025. */
  61026. maximumSize?: number,
  61027. /**
  61028. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61029. */
  61030. step?: number);
  61031. /**
  61032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61033. * @param scene defines the current scene where to apply this optimization
  61034. * @param optimizer defines the current optimizer
  61035. * @returns true if everything that can be done was applied
  61036. */
  61037. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61038. }
  61039. /**
  61040. * Defines an optimization used to increase or decrease the rendering resolution
  61041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61042. */
  61043. export class HardwareScalingOptimization extends SceneOptimization {
  61044. /**
  61045. * Defines the priority of this optimization (0 by default which means first in the list)
  61046. */
  61047. priority: number;
  61048. /**
  61049. * Defines the maximum scale to use (2 by default)
  61050. */
  61051. maximumScale: number;
  61052. /**
  61053. * Defines the step to use between two passes (0.5 by default)
  61054. */
  61055. step: number;
  61056. private _currentScale;
  61057. private _directionOffset;
  61058. /**
  61059. * Gets a string describing the action executed by the current optimization
  61060. * @return description string
  61061. */
  61062. getDescription(): string;
  61063. /**
  61064. * Creates the HardwareScalingOptimization object
  61065. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61066. * @param maximumScale defines the maximum scale to use (2 by default)
  61067. * @param step defines the step to use between two passes (0.5 by default)
  61068. */
  61069. constructor(
  61070. /**
  61071. * Defines the priority of this optimization (0 by default which means first in the list)
  61072. */
  61073. priority?: number,
  61074. /**
  61075. * Defines the maximum scale to use (2 by default)
  61076. */
  61077. maximumScale?: number,
  61078. /**
  61079. * Defines the step to use between two passes (0.5 by default)
  61080. */
  61081. step?: number);
  61082. /**
  61083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61084. * @param scene defines the current scene where to apply this optimization
  61085. * @param optimizer defines the current optimizer
  61086. * @returns true if everything that can be done was applied
  61087. */
  61088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61089. }
  61090. /**
  61091. * Defines an optimization used to remove shadows
  61092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61093. */
  61094. export class ShadowsOptimization extends SceneOptimization {
  61095. /**
  61096. * Gets a string describing the action executed by the current optimization
  61097. * @return description string
  61098. */
  61099. getDescription(): string;
  61100. /**
  61101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61102. * @param scene defines the current scene where to apply this optimization
  61103. * @param optimizer defines the current optimizer
  61104. * @returns true if everything that can be done was applied
  61105. */
  61106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61107. }
  61108. /**
  61109. * Defines an optimization used to turn post-processes off
  61110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61111. */
  61112. export class PostProcessesOptimization extends SceneOptimization {
  61113. /**
  61114. * Gets a string describing the action executed by the current optimization
  61115. * @return description string
  61116. */
  61117. getDescription(): string;
  61118. /**
  61119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61120. * @param scene defines the current scene where to apply this optimization
  61121. * @param optimizer defines the current optimizer
  61122. * @returns true if everything that can be done was applied
  61123. */
  61124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61125. }
  61126. /**
  61127. * Defines an optimization used to turn lens flares off
  61128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61129. */
  61130. export class LensFlaresOptimization extends SceneOptimization {
  61131. /**
  61132. * Gets a string describing the action executed by the current optimization
  61133. * @return description string
  61134. */
  61135. getDescription(): string;
  61136. /**
  61137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61138. * @param scene defines the current scene where to apply this optimization
  61139. * @param optimizer defines the current optimizer
  61140. * @returns true if everything that can be done was applied
  61141. */
  61142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61143. }
  61144. /**
  61145. * Defines an optimization based on user defined callback.
  61146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61147. */
  61148. export class CustomOptimization extends SceneOptimization {
  61149. /**
  61150. * Callback called to apply the custom optimization.
  61151. */
  61152. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61153. /**
  61154. * Callback called to get custom description
  61155. */
  61156. onGetDescription: () => string;
  61157. /**
  61158. * Gets a string describing the action executed by the current optimization
  61159. * @returns description string
  61160. */
  61161. getDescription(): string;
  61162. /**
  61163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61164. * @param scene defines the current scene where to apply this optimization
  61165. * @param optimizer defines the current optimizer
  61166. * @returns true if everything that can be done was applied
  61167. */
  61168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61169. }
  61170. /**
  61171. * Defines an optimization used to turn particles off
  61172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61173. */
  61174. export class ParticlesOptimization extends SceneOptimization {
  61175. /**
  61176. * Gets a string describing the action executed by the current optimization
  61177. * @return description string
  61178. */
  61179. getDescription(): string;
  61180. /**
  61181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61182. * @param scene defines the current scene where to apply this optimization
  61183. * @param optimizer defines the current optimizer
  61184. * @returns true if everything that can be done was applied
  61185. */
  61186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61187. }
  61188. /**
  61189. * Defines an optimization used to turn render targets off
  61190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61191. */
  61192. export class RenderTargetsOptimization extends SceneOptimization {
  61193. /**
  61194. * Gets a string describing the action executed by the current optimization
  61195. * @return description string
  61196. */
  61197. getDescription(): string;
  61198. /**
  61199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61200. * @param scene defines the current scene where to apply this optimization
  61201. * @param optimizer defines the current optimizer
  61202. * @returns true if everything that can be done was applied
  61203. */
  61204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61205. }
  61206. /**
  61207. * Defines an optimization used to merge meshes with compatible materials
  61208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61209. */
  61210. export class MergeMeshesOptimization extends SceneOptimization {
  61211. private static _UpdateSelectionTree;
  61212. /**
  61213. * Gets or sets a boolean which defines if optimization octree has to be updated
  61214. */
  61215. /**
  61216. * Gets or sets a boolean which defines if optimization octree has to be updated
  61217. */
  61218. static UpdateSelectionTree: boolean;
  61219. /**
  61220. * Gets a string describing the action executed by the current optimization
  61221. * @return description string
  61222. */
  61223. getDescription(): string;
  61224. private _canBeMerged;
  61225. /**
  61226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61227. * @param scene defines the current scene where to apply this optimization
  61228. * @param optimizer defines the current optimizer
  61229. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61230. * @returns true if everything that can be done was applied
  61231. */
  61232. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61233. }
  61234. /**
  61235. * Defines a list of options used by SceneOptimizer
  61236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61237. */
  61238. export class SceneOptimizerOptions {
  61239. /**
  61240. * Defines the target frame rate to reach (60 by default)
  61241. */
  61242. targetFrameRate: number;
  61243. /**
  61244. * Defines the interval between two checkes (2000ms by default)
  61245. */
  61246. trackerDuration: number;
  61247. /**
  61248. * Gets the list of optimizations to apply
  61249. */
  61250. optimizations: SceneOptimization[];
  61251. /**
  61252. * Creates a new list of options used by SceneOptimizer
  61253. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61254. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61255. */
  61256. constructor(
  61257. /**
  61258. * Defines the target frame rate to reach (60 by default)
  61259. */
  61260. targetFrameRate?: number,
  61261. /**
  61262. * Defines the interval between two checkes (2000ms by default)
  61263. */
  61264. trackerDuration?: number);
  61265. /**
  61266. * Add a new optimization
  61267. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61268. * @returns the current SceneOptimizerOptions
  61269. */
  61270. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61271. /**
  61272. * Add a new custom optimization
  61273. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61274. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61275. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61276. * @returns the current SceneOptimizerOptions
  61277. */
  61278. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61279. /**
  61280. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61281. * @param targetFrameRate defines the target frame rate (60 by default)
  61282. * @returns a SceneOptimizerOptions object
  61283. */
  61284. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61285. /**
  61286. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61287. * @param targetFrameRate defines the target frame rate (60 by default)
  61288. * @returns a SceneOptimizerOptions object
  61289. */
  61290. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61291. /**
  61292. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61293. * @param targetFrameRate defines the target frame rate (60 by default)
  61294. * @returns a SceneOptimizerOptions object
  61295. */
  61296. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61297. }
  61298. /**
  61299. * Class used to run optimizations in order to reach a target frame rate
  61300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61301. */
  61302. export class SceneOptimizer implements IDisposable {
  61303. private _isRunning;
  61304. private _options;
  61305. private _scene;
  61306. private _currentPriorityLevel;
  61307. private _targetFrameRate;
  61308. private _trackerDuration;
  61309. private _currentFrameRate;
  61310. private _sceneDisposeObserver;
  61311. private _improvementMode;
  61312. /**
  61313. * Defines an observable called when the optimizer reaches the target frame rate
  61314. */
  61315. onSuccessObservable: Observable<SceneOptimizer>;
  61316. /**
  61317. * Defines an observable called when the optimizer enables an optimization
  61318. */
  61319. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61320. /**
  61321. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61322. */
  61323. onFailureObservable: Observable<SceneOptimizer>;
  61324. /**
  61325. * Gets a boolean indicating if the optimizer is in improvement mode
  61326. */
  61327. readonly isInImprovementMode: boolean;
  61328. /**
  61329. * Gets the current priority level (0 at start)
  61330. */
  61331. readonly currentPriorityLevel: number;
  61332. /**
  61333. * Gets the current frame rate checked by the SceneOptimizer
  61334. */
  61335. readonly currentFrameRate: number;
  61336. /**
  61337. * Gets or sets the current target frame rate (60 by default)
  61338. */
  61339. /**
  61340. * Gets or sets the current target frame rate (60 by default)
  61341. */
  61342. targetFrameRate: number;
  61343. /**
  61344. * Gets or sets the current interval between two checks (every 2000ms by default)
  61345. */
  61346. /**
  61347. * Gets or sets the current interval between two checks (every 2000ms by default)
  61348. */
  61349. trackerDuration: number;
  61350. /**
  61351. * Gets the list of active optimizations
  61352. */
  61353. readonly optimizations: SceneOptimization[];
  61354. /**
  61355. * Creates a new SceneOptimizer
  61356. * @param scene defines the scene to work on
  61357. * @param options defines the options to use with the SceneOptimizer
  61358. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61359. * @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)
  61360. */
  61361. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61362. /**
  61363. * Stops the current optimizer
  61364. */
  61365. stop(): void;
  61366. /**
  61367. * Reset the optimizer to initial step (current priority level = 0)
  61368. */
  61369. reset(): void;
  61370. /**
  61371. * Start the optimizer. By default it will try to reach a specific framerate
  61372. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61373. */
  61374. start(): void;
  61375. private _checkCurrentState;
  61376. /**
  61377. * Release all resources
  61378. */
  61379. dispose(): void;
  61380. /**
  61381. * Helper function to create a SceneOptimizer with one single line of code
  61382. * @param scene defines the scene to work on
  61383. * @param options defines the options to use with the SceneOptimizer
  61384. * @param onSuccess defines a callback to call on success
  61385. * @param onFailure defines a callback to call on failure
  61386. * @returns the new SceneOptimizer object
  61387. */
  61388. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61389. }
  61390. }
  61391. declare module BABYLON {
  61392. /**
  61393. * Class used to serialize a scene into a string
  61394. */
  61395. export class SceneSerializer {
  61396. /**
  61397. * Clear cache used by a previous serialization
  61398. */
  61399. static ClearCache(): void;
  61400. /**
  61401. * Serialize a scene into a JSON compatible object
  61402. * @param scene defines the scene to serialize
  61403. * @returns a JSON compatible object
  61404. */
  61405. static Serialize(scene: Scene): any;
  61406. /**
  61407. * Serialize a mesh into a JSON compatible object
  61408. * @param toSerialize defines the mesh to serialize
  61409. * @param withParents defines if parents must be serialized as well
  61410. * @param withChildren defines if children must be serialized as well
  61411. * @returns a JSON compatible object
  61412. */
  61413. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61414. }
  61415. }
  61416. declare module BABYLON {
  61417. /**
  61418. * Class used to host texture specific utilities
  61419. */
  61420. export class TextureTools {
  61421. /**
  61422. * Uses the GPU to create a copy texture rescaled at a given size
  61423. * @param texture Texture to copy from
  61424. * @param width defines the desired width
  61425. * @param height defines the desired height
  61426. * @param useBilinearMode defines if bilinear mode has to be used
  61427. * @return the generated texture
  61428. */
  61429. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61430. }
  61431. }
  61432. declare module BABYLON {
  61433. /**
  61434. * This represents the different options available for the video capture.
  61435. */
  61436. export interface VideoRecorderOptions {
  61437. /** Defines the mime type of the video. */
  61438. mimeType: string;
  61439. /** Defines the FPS the video should be recorded at. */
  61440. fps: number;
  61441. /** Defines the chunk size for the recording data. */
  61442. recordChunckSize: number;
  61443. /** The audio tracks to attach to the recording. */
  61444. audioTracks?: MediaStreamTrack[];
  61445. }
  61446. /**
  61447. * This can help with recording videos from BabylonJS.
  61448. * This is based on the available WebRTC functionalities of the browser.
  61449. *
  61450. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61451. */
  61452. export class VideoRecorder {
  61453. private static readonly _defaultOptions;
  61454. /**
  61455. * Returns whether or not the VideoRecorder is available in your browser.
  61456. * @param engine Defines the Babylon Engine.
  61457. * @returns true if supported otherwise false.
  61458. */
  61459. static IsSupported(engine: Engine): boolean;
  61460. private readonly _options;
  61461. private _canvas;
  61462. private _mediaRecorder;
  61463. private _recordedChunks;
  61464. private _fileName;
  61465. private _resolve;
  61466. private _reject;
  61467. /**
  61468. * True when a recording is already in progress.
  61469. */
  61470. readonly isRecording: boolean;
  61471. /**
  61472. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61473. * @param engine Defines the BabylonJS Engine you wish to record.
  61474. * @param options Defines options that can be used to customize the capture.
  61475. */
  61476. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61477. /**
  61478. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61479. */
  61480. stopRecording(): void;
  61481. /**
  61482. * Starts recording the canvas for a max duration specified in parameters.
  61483. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61484. * If null no automatic download will start and you can rely on the promise to get the data back.
  61485. * @param maxDuration Defines the maximum recording time in seconds.
  61486. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61487. * @return A promise callback at the end of the recording with the video data in Blob.
  61488. */
  61489. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61490. /**
  61491. * Releases internal resources used during the recording.
  61492. */
  61493. dispose(): void;
  61494. private _handleDataAvailable;
  61495. private _handleError;
  61496. private _handleStop;
  61497. }
  61498. }
  61499. declare module BABYLON {
  61500. /**
  61501. * Class containing a set of static utilities functions for screenshots
  61502. */
  61503. export class ScreenshotTools {
  61504. /**
  61505. * Captures a screenshot of the current rendering
  61506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61507. * @param engine defines the rendering engine
  61508. * @param camera defines the source camera
  61509. * @param size This parameter can be set to a single number or to an object with the
  61510. * following (optional) properties: precision, width, height. If a single number is passed,
  61511. * it will be used for both width and height. If an object is passed, the screenshot size
  61512. * will be derived from the parameters. The precision property is a multiplier allowing
  61513. * rendering at a higher or lower resolution
  61514. * @param successCallback defines the callback receives a single parameter which contains the
  61515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61516. * src parameter of an <img> to display it
  61517. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61518. * Check your browser for supported MIME types
  61519. */
  61520. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61521. /**
  61522. * Captures a screenshot of the current rendering
  61523. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61524. * @param engine defines the rendering engine
  61525. * @param camera defines the source camera
  61526. * @param size This parameter can be set to a single number or to an object with the
  61527. * following (optional) properties: precision, width, height. If a single number is passed,
  61528. * it will be used for both width and height. If an object is passed, the screenshot size
  61529. * will be derived from the parameters. The precision property is a multiplier allowing
  61530. * rendering at a higher or lower resolution
  61531. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61532. * Check your browser for supported MIME types
  61533. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61534. * to the src parameter of an <img> to display it
  61535. */
  61536. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61537. /**
  61538. * Generates an image screenshot from the specified camera.
  61539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61540. * @param engine The engine to use for rendering
  61541. * @param camera The camera to use for rendering
  61542. * @param size This parameter can be set to a single number or to an object with the
  61543. * following (optional) properties: precision, width, height. If a single number is passed,
  61544. * it will be used for both width and height. If an object is passed, the screenshot size
  61545. * will be derived from the parameters. The precision property is a multiplier allowing
  61546. * rendering at a higher or lower resolution
  61547. * @param successCallback The callback receives a single parameter which contains the
  61548. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61549. * src parameter of an <img> to display it
  61550. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61551. * Check your browser for supported MIME types
  61552. * @param samples Texture samples (default: 1)
  61553. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61554. * @param fileName A name for for the downloaded file.
  61555. */
  61556. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61557. /**
  61558. * Generates an image screenshot from the specified camera.
  61559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61560. * @param engine The engine to use for rendering
  61561. * @param camera The camera to use for rendering
  61562. * @param size This parameter can be set to a single number or to an object with the
  61563. * following (optional) properties: precision, width, height. If a single number is passed,
  61564. * it will be used for both width and height. If an object is passed, the screenshot size
  61565. * will be derived from the parameters. The precision property is a multiplier allowing
  61566. * rendering at a higher or lower resolution
  61567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61568. * Check your browser for supported MIME types
  61569. * @param samples Texture samples (default: 1)
  61570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61571. * @param fileName A name for for the downloaded file.
  61572. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61573. * to the src parameter of an <img> to display it
  61574. */
  61575. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61576. /**
  61577. * Gets height and width for screenshot size
  61578. * @private
  61579. */
  61580. private static _getScreenshotSize;
  61581. }
  61582. }
  61583. declare module BABYLON {
  61584. /**
  61585. * A cursor which tracks a point on a path
  61586. */
  61587. export class PathCursor {
  61588. private path;
  61589. /**
  61590. * Stores path cursor callbacks for when an onchange event is triggered
  61591. */
  61592. private _onchange;
  61593. /**
  61594. * The value of the path cursor
  61595. */
  61596. value: number;
  61597. /**
  61598. * The animation array of the path cursor
  61599. */
  61600. animations: Animation[];
  61601. /**
  61602. * Initializes the path cursor
  61603. * @param path The path to track
  61604. */
  61605. constructor(path: Path2);
  61606. /**
  61607. * Gets the cursor point on the path
  61608. * @returns A point on the path cursor at the cursor location
  61609. */
  61610. getPoint(): Vector3;
  61611. /**
  61612. * Moves the cursor ahead by the step amount
  61613. * @param step The amount to move the cursor forward
  61614. * @returns This path cursor
  61615. */
  61616. moveAhead(step?: number): PathCursor;
  61617. /**
  61618. * Moves the cursor behind by the step amount
  61619. * @param step The amount to move the cursor back
  61620. * @returns This path cursor
  61621. */
  61622. moveBack(step?: number): PathCursor;
  61623. /**
  61624. * Moves the cursor by the step amount
  61625. * If the step amount is greater than one, an exception is thrown
  61626. * @param step The amount to move the cursor
  61627. * @returns This path cursor
  61628. */
  61629. move(step: number): PathCursor;
  61630. /**
  61631. * Ensures that the value is limited between zero and one
  61632. * @returns This path cursor
  61633. */
  61634. private ensureLimits;
  61635. /**
  61636. * Runs onchange callbacks on change (used by the animation engine)
  61637. * @returns This path cursor
  61638. */
  61639. private raiseOnChange;
  61640. /**
  61641. * Executes a function on change
  61642. * @param f A path cursor onchange callback
  61643. * @returns This path cursor
  61644. */
  61645. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61646. }
  61647. }
  61648. declare module BABYLON {
  61649. /** @hidden */
  61650. export var blurPixelShader: {
  61651. name: string;
  61652. shader: string;
  61653. };
  61654. }
  61655. declare module BABYLON {
  61656. /** @hidden */
  61657. export var pointCloudVertexDeclaration: {
  61658. name: string;
  61659. shader: string;
  61660. };
  61661. }
  61662. // Mixins
  61663. interface Window {
  61664. mozIndexedDB: IDBFactory;
  61665. webkitIndexedDB: IDBFactory;
  61666. msIndexedDB: IDBFactory;
  61667. webkitURL: typeof URL;
  61668. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61669. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61670. WebGLRenderingContext: WebGLRenderingContext;
  61671. MSGesture: MSGesture;
  61672. CANNON: any;
  61673. AudioContext: AudioContext;
  61674. webkitAudioContext: AudioContext;
  61675. PointerEvent: any;
  61676. Math: Math;
  61677. Uint8Array: Uint8ArrayConstructor;
  61678. Float32Array: Float32ArrayConstructor;
  61679. mozURL: typeof URL;
  61680. msURL: typeof URL;
  61681. VRFrameData: any; // WebVR, from specs 1.1
  61682. DracoDecoderModule: any;
  61683. setImmediate(handler: (...args: any[]) => void): number;
  61684. }
  61685. interface HTMLCanvasElement {
  61686. requestPointerLock(): void;
  61687. msRequestPointerLock?(): void;
  61688. mozRequestPointerLock?(): void;
  61689. webkitRequestPointerLock?(): void;
  61690. /** Track wether a record is in progress */
  61691. isRecording: boolean;
  61692. /** Capture Stream method defined by some browsers */
  61693. captureStream(fps?: number): MediaStream;
  61694. }
  61695. interface CanvasRenderingContext2D {
  61696. msImageSmoothingEnabled: boolean;
  61697. }
  61698. interface MouseEvent {
  61699. mozMovementX: number;
  61700. mozMovementY: number;
  61701. webkitMovementX: number;
  61702. webkitMovementY: number;
  61703. msMovementX: number;
  61704. msMovementY: number;
  61705. }
  61706. interface Navigator {
  61707. mozGetVRDevices: (any: any) => any;
  61708. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61709. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61710. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61711. webkitGetGamepads(): Gamepad[];
  61712. msGetGamepads(): Gamepad[];
  61713. webkitGamepads(): Gamepad[];
  61714. }
  61715. interface HTMLVideoElement {
  61716. mozSrcObject: any;
  61717. }
  61718. interface Math {
  61719. fround(x: number): number;
  61720. imul(a: number, b: number): number;
  61721. }
  61722. interface WebGLRenderingContext {
  61723. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61724. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61725. vertexAttribDivisor(index: number, divisor: number): void;
  61726. createVertexArray(): any;
  61727. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61728. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61729. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61730. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61731. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61732. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61733. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61734. // Queries
  61735. createQuery(): WebGLQuery;
  61736. deleteQuery(query: WebGLQuery): void;
  61737. beginQuery(target: number, query: WebGLQuery): void;
  61738. endQuery(target: number): void;
  61739. getQueryParameter(query: WebGLQuery, pname: number): any;
  61740. getQuery(target: number, pname: number): any;
  61741. MAX_SAMPLES: number;
  61742. RGBA8: number;
  61743. READ_FRAMEBUFFER: number;
  61744. DRAW_FRAMEBUFFER: number;
  61745. UNIFORM_BUFFER: number;
  61746. HALF_FLOAT_OES: number;
  61747. RGBA16F: number;
  61748. RGBA32F: number;
  61749. R32F: number;
  61750. RG32F: number;
  61751. RGB32F: number;
  61752. R16F: number;
  61753. RG16F: number;
  61754. RGB16F: number;
  61755. RED: number;
  61756. RG: number;
  61757. R8: number;
  61758. RG8: number;
  61759. UNSIGNED_INT_24_8: number;
  61760. DEPTH24_STENCIL8: number;
  61761. /* Multiple Render Targets */
  61762. drawBuffers(buffers: number[]): void;
  61763. readBuffer(src: number): void;
  61764. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61765. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61766. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61767. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61768. // Occlusion Query
  61769. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61770. ANY_SAMPLES_PASSED: number;
  61771. QUERY_RESULT_AVAILABLE: number;
  61772. QUERY_RESULT: number;
  61773. }
  61774. interface WebGLProgram {
  61775. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61776. }
  61777. interface EXT_disjoint_timer_query {
  61778. QUERY_COUNTER_BITS_EXT: number;
  61779. TIME_ELAPSED_EXT: number;
  61780. TIMESTAMP_EXT: number;
  61781. GPU_DISJOINT_EXT: number;
  61782. QUERY_RESULT_EXT: number;
  61783. QUERY_RESULT_AVAILABLE_EXT: number;
  61784. queryCounterEXT(query: WebGLQuery, target: number): void;
  61785. createQueryEXT(): WebGLQuery;
  61786. beginQueryEXT(target: number, query: WebGLQuery): void;
  61787. endQueryEXT(target: number): void;
  61788. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61789. deleteQueryEXT(query: WebGLQuery): void;
  61790. }
  61791. interface WebGLUniformLocation {
  61792. _currentState: any;
  61793. }
  61794. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61795. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61796. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61797. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61798. interface WebGLRenderingContext {
  61799. readonly RASTERIZER_DISCARD: number;
  61800. readonly DEPTH_COMPONENT24: number;
  61801. readonly TEXTURE_3D: number;
  61802. readonly TEXTURE_2D_ARRAY: number;
  61803. readonly TEXTURE_COMPARE_FUNC: number;
  61804. readonly TEXTURE_COMPARE_MODE: number;
  61805. readonly COMPARE_REF_TO_TEXTURE: number;
  61806. readonly TEXTURE_WRAP_R: number;
  61807. readonly HALF_FLOAT: number;
  61808. readonly RGB8: number;
  61809. readonly RED_INTEGER: number;
  61810. readonly RG_INTEGER: number;
  61811. readonly RGB_INTEGER: number;
  61812. readonly RGBA_INTEGER: number;
  61813. readonly R8_SNORM: number;
  61814. readonly RG8_SNORM: number;
  61815. readonly RGB8_SNORM: number;
  61816. readonly RGBA8_SNORM: number;
  61817. readonly R8I: number;
  61818. readonly RG8I: number;
  61819. readonly RGB8I: number;
  61820. readonly RGBA8I: number;
  61821. readonly R8UI: number;
  61822. readonly RG8UI: number;
  61823. readonly RGB8UI: number;
  61824. readonly RGBA8UI: number;
  61825. readonly R16I: number;
  61826. readonly RG16I: number;
  61827. readonly RGB16I: number;
  61828. readonly RGBA16I: number;
  61829. readonly R16UI: number;
  61830. readonly RG16UI: number;
  61831. readonly RGB16UI: number;
  61832. readonly RGBA16UI: number;
  61833. readonly R32I: number;
  61834. readonly RG32I: number;
  61835. readonly RGB32I: number;
  61836. readonly RGBA32I: number;
  61837. readonly R32UI: number;
  61838. readonly RG32UI: number;
  61839. readonly RGB32UI: number;
  61840. readonly RGBA32UI: number;
  61841. readonly RGB10_A2UI: number;
  61842. readonly R11F_G11F_B10F: number;
  61843. readonly RGB9_E5: number;
  61844. readonly RGB10_A2: number;
  61845. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61846. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61847. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61848. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61849. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61850. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61851. 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;
  61852. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61853. readonly TRANSFORM_FEEDBACK: number;
  61854. readonly INTERLEAVED_ATTRIBS: number;
  61855. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61856. createTransformFeedback(): WebGLTransformFeedback;
  61857. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61858. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61859. beginTransformFeedback(primitiveMode: number): void;
  61860. endTransformFeedback(): void;
  61861. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61862. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61863. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61864. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61865. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61866. }
  61867. interface ImageBitmap {
  61868. readonly width: number;
  61869. readonly height: number;
  61870. close(): void;
  61871. }
  61872. interface WebGLQuery extends WebGLObject {
  61873. }
  61874. declare var WebGLQuery: {
  61875. prototype: WebGLQuery;
  61876. new(): WebGLQuery;
  61877. };
  61878. interface WebGLSampler extends WebGLObject {
  61879. }
  61880. declare var WebGLSampler: {
  61881. prototype: WebGLSampler;
  61882. new(): WebGLSampler;
  61883. };
  61884. interface WebGLSync extends WebGLObject {
  61885. }
  61886. declare var WebGLSync: {
  61887. prototype: WebGLSync;
  61888. new(): WebGLSync;
  61889. };
  61890. interface WebGLTransformFeedback extends WebGLObject {
  61891. }
  61892. declare var WebGLTransformFeedback: {
  61893. prototype: WebGLTransformFeedback;
  61894. new(): WebGLTransformFeedback;
  61895. };
  61896. interface WebGLVertexArrayObject extends WebGLObject {
  61897. }
  61898. declare var WebGLVertexArrayObject: {
  61899. prototype: WebGLVertexArrayObject;
  61900. new(): WebGLVertexArrayObject;
  61901. };
  61902. // Type definitions for WebVR API
  61903. // Project: https://w3c.github.io/webvr/
  61904. // Definitions by: six a <https://github.com/lostfictions>
  61905. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61906. interface VRDisplay extends EventTarget {
  61907. /**
  61908. * Dictionary of capabilities describing the VRDisplay.
  61909. */
  61910. readonly capabilities: VRDisplayCapabilities;
  61911. /**
  61912. * z-depth defining the far plane of the eye view frustum
  61913. * enables mapping of values in the render target depth
  61914. * attachment to scene coordinates. Initially set to 10000.0.
  61915. */
  61916. depthFar: number;
  61917. /**
  61918. * z-depth defining the near plane of the eye view frustum
  61919. * enables mapping of values in the render target depth
  61920. * attachment to scene coordinates. Initially set to 0.01.
  61921. */
  61922. depthNear: number;
  61923. /**
  61924. * An identifier for this distinct VRDisplay. Used as an
  61925. * association point in the Gamepad API.
  61926. */
  61927. readonly displayId: number;
  61928. /**
  61929. * A display name, a user-readable name identifying it.
  61930. */
  61931. readonly displayName: string;
  61932. readonly isConnected: boolean;
  61933. readonly isPresenting: boolean;
  61934. /**
  61935. * If this VRDisplay supports room-scale experiences, the optional
  61936. * stage attribute contains details on the room-scale parameters.
  61937. */
  61938. readonly stageParameters: VRStageParameters | null;
  61939. /**
  61940. * Passing the value returned by `requestAnimationFrame` to
  61941. * `cancelAnimationFrame` will unregister the callback.
  61942. * @param handle Define the hanle of the request to cancel
  61943. */
  61944. cancelAnimationFrame(handle: number): void;
  61945. /**
  61946. * Stops presenting to the VRDisplay.
  61947. * @returns a promise to know when it stopped
  61948. */
  61949. exitPresent(): Promise<void>;
  61950. /**
  61951. * Return the current VREyeParameters for the given eye.
  61952. * @param whichEye Define the eye we want the parameter for
  61953. * @returns the eye parameters
  61954. */
  61955. getEyeParameters(whichEye: string): VREyeParameters;
  61956. /**
  61957. * Populates the passed VRFrameData with the information required to render
  61958. * the current frame.
  61959. * @param frameData Define the data structure to populate
  61960. * @returns true if ok otherwise false
  61961. */
  61962. getFrameData(frameData: VRFrameData): boolean;
  61963. /**
  61964. * Get the layers currently being presented.
  61965. * @returns the list of VR layers
  61966. */
  61967. getLayers(): VRLayer[];
  61968. /**
  61969. * Return a VRPose containing the future predicted pose of the VRDisplay
  61970. * when the current frame will be presented. The value returned will not
  61971. * change until JavaScript has returned control to the browser.
  61972. *
  61973. * The VRPose will contain the position, orientation, velocity,
  61974. * and acceleration of each of these properties.
  61975. * @returns the pose object
  61976. */
  61977. getPose(): VRPose;
  61978. /**
  61979. * Return the current instantaneous pose of the VRDisplay, with no
  61980. * prediction applied.
  61981. * @returns the current instantaneous pose
  61982. */
  61983. getImmediatePose(): VRPose;
  61984. /**
  61985. * The callback passed to `requestAnimationFrame` will be called
  61986. * any time a new frame should be rendered. When the VRDisplay is
  61987. * presenting the callback will be called at the native refresh
  61988. * rate of the HMD. When not presenting this function acts
  61989. * identically to how window.requestAnimationFrame acts. Content should
  61990. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61991. * asynchronously from other displays and at differing refresh rates.
  61992. * @param callback Define the eaction to run next frame
  61993. * @returns the request handle it
  61994. */
  61995. requestAnimationFrame(callback: FrameRequestCallback): number;
  61996. /**
  61997. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61998. * Repeat calls while already presenting will update the VRLayers being displayed.
  61999. * @param layers Define the list of layer to present
  62000. * @returns a promise to know when the request has been fulfilled
  62001. */
  62002. requestPresent(layers: VRLayer[]): Promise<void>;
  62003. /**
  62004. * Reset the pose for this display, treating its current position and
  62005. * orientation as the "origin/zero" values. VRPose.position,
  62006. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62007. * updated when calling resetPose(). This should be called in only
  62008. * sitting-space experiences.
  62009. */
  62010. resetPose(): void;
  62011. /**
  62012. * The VRLayer provided to the VRDisplay will be captured and presented
  62013. * in the HMD. Calling this function has the same effect on the source
  62014. * canvas as any other operation that uses its source image, and canvases
  62015. * created without preserveDrawingBuffer set to true will be cleared.
  62016. * @param pose Define the pose to submit
  62017. */
  62018. submitFrame(pose?: VRPose): void;
  62019. }
  62020. declare var VRDisplay: {
  62021. prototype: VRDisplay;
  62022. new(): VRDisplay;
  62023. };
  62024. interface VRLayer {
  62025. leftBounds?: number[] | Float32Array | null;
  62026. rightBounds?: number[] | Float32Array | null;
  62027. source?: HTMLCanvasElement | null;
  62028. }
  62029. interface VRDisplayCapabilities {
  62030. readonly canPresent: boolean;
  62031. readonly hasExternalDisplay: boolean;
  62032. readonly hasOrientation: boolean;
  62033. readonly hasPosition: boolean;
  62034. readonly maxLayers: number;
  62035. }
  62036. interface VREyeParameters {
  62037. /** @deprecated */
  62038. readonly fieldOfView: VRFieldOfView;
  62039. readonly offset: Float32Array;
  62040. readonly renderHeight: number;
  62041. readonly renderWidth: number;
  62042. }
  62043. interface VRFieldOfView {
  62044. readonly downDegrees: number;
  62045. readonly leftDegrees: number;
  62046. readonly rightDegrees: number;
  62047. readonly upDegrees: number;
  62048. }
  62049. interface VRFrameData {
  62050. readonly leftProjectionMatrix: Float32Array;
  62051. readonly leftViewMatrix: Float32Array;
  62052. readonly pose: VRPose;
  62053. readonly rightProjectionMatrix: Float32Array;
  62054. readonly rightViewMatrix: Float32Array;
  62055. readonly timestamp: number;
  62056. }
  62057. interface VRPose {
  62058. readonly angularAcceleration: Float32Array | null;
  62059. readonly angularVelocity: Float32Array | null;
  62060. readonly linearAcceleration: Float32Array | null;
  62061. readonly linearVelocity: Float32Array | null;
  62062. readonly orientation: Float32Array | null;
  62063. readonly position: Float32Array | null;
  62064. readonly timestamp: number;
  62065. }
  62066. interface VRStageParameters {
  62067. sittingToStandingTransform?: Float32Array;
  62068. sizeX?: number;
  62069. sizeY?: number;
  62070. }
  62071. interface Navigator {
  62072. getVRDisplays(): Promise<VRDisplay[]>;
  62073. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62074. }
  62075. interface Window {
  62076. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62077. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62078. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62079. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62080. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62081. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62082. }
  62083. interface Gamepad {
  62084. readonly displayId: number;
  62085. }
  62086. type XRSessionMode =
  62087. | "inline"
  62088. | "immersive-vr"
  62089. | "immersive-ar";
  62090. type XRReferenceSpaceType =
  62091. | "viewer"
  62092. | "local"
  62093. | "local-floor"
  62094. | "bounded-floor"
  62095. | "unbounded";
  62096. type XREnvironmentBlendMode =
  62097. | "opaque"
  62098. | "additive"
  62099. | "alpha-blend";
  62100. type XRVisibilityState =
  62101. | "visible"
  62102. | "visible-blurred"
  62103. | "hidden";
  62104. type XRHandedness =
  62105. | "none"
  62106. | "left"
  62107. | "right";
  62108. type XRTargetRayMode =
  62109. | "gaze"
  62110. | "tracked-pointer"
  62111. | "screen";
  62112. type XREye =
  62113. | "none"
  62114. | "left"
  62115. | "right";
  62116. interface XRSpace extends EventTarget {
  62117. }
  62118. interface XRRenderState {
  62119. depthNear?: number;
  62120. depthFar?: number;
  62121. inlineVerticalFieldOfView?: number;
  62122. baseLayer?: XRWebGLLayer;
  62123. }
  62124. interface XRInputSource {
  62125. handedness: XRHandedness;
  62126. targetRayMode: XRTargetRayMode;
  62127. targetRaySpace: XRSpace;
  62128. gripSpace: XRSpace | undefined;
  62129. gamepad: Gamepad | undefined;
  62130. profiles: Array<string>;
  62131. }
  62132. interface XRSession {
  62133. addEventListener: Function;
  62134. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62135. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62136. requestAnimationFrame: Function;
  62137. end(): Promise<void>;
  62138. renderState: XRRenderState;
  62139. inputSources: Array<XRInputSource>;
  62140. }
  62141. interface XRReferenceSpace extends XRSpace {
  62142. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62143. onreset: any;
  62144. }
  62145. interface XRFrame {
  62146. session: XRSession;
  62147. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62148. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62149. }
  62150. interface XRViewerPose extends XRPose {
  62151. views: Array<XRView>;
  62152. }
  62153. interface XRPose {
  62154. transform: XRRigidTransform;
  62155. emulatedPosition: boolean;
  62156. }
  62157. declare var XRWebGLLayer: {
  62158. prototype: XRWebGLLayer;
  62159. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62160. };
  62161. interface XRWebGLLayer {
  62162. framebuffer: WebGLFramebuffer;
  62163. framebufferWidth: number;
  62164. framebufferHeight: number;
  62165. getViewport: Function;
  62166. }
  62167. interface XRRigidTransform {
  62168. position: DOMPointReadOnly;
  62169. orientation: DOMPointReadOnly;
  62170. matrix: Float32Array;
  62171. inverse: XRRigidTransform;
  62172. }
  62173. interface XRView {
  62174. eye: XREye;
  62175. projectionMatrix: Float32Array;
  62176. transform: XRRigidTransform;
  62177. }
  62178. interface XRInputSourceChangeEvent {
  62179. session: XRSession;
  62180. removed: Array<XRInputSource>;
  62181. added: Array<XRInputSource>;
  62182. }
  62183. declare module BABYLON.GUI {
  62184. /**
  62185. * Class used to specific a value and its associated unit
  62186. */
  62187. export class ValueAndUnit {
  62188. /** defines the unit to store */
  62189. unit: number;
  62190. /** defines a boolean indicating if the value can be negative */
  62191. negativeValueAllowed: boolean;
  62192. private _value;
  62193. private _originalUnit;
  62194. /**
  62195. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62196. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62197. */
  62198. ignoreAdaptiveScaling: boolean;
  62199. /**
  62200. * Creates a new ValueAndUnit
  62201. * @param value defines the value to store
  62202. * @param unit defines the unit to store
  62203. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62204. */
  62205. constructor(value: number,
  62206. /** defines the unit to store */
  62207. unit?: number,
  62208. /** defines a boolean indicating if the value can be negative */
  62209. negativeValueAllowed?: boolean);
  62210. /** Gets a boolean indicating if the value is a percentage */
  62211. readonly isPercentage: boolean;
  62212. /** Gets a boolean indicating if the value is store as pixel */
  62213. readonly isPixel: boolean;
  62214. /** Gets direct internal value */
  62215. readonly internalValue: number;
  62216. /**
  62217. * Gets value as pixel
  62218. * @param host defines the root host
  62219. * @param refValue defines the reference value for percentages
  62220. * @returns the value as pixel
  62221. */
  62222. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62223. /**
  62224. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62225. * @param value defines the value to store
  62226. * @param unit defines the unit to store
  62227. * @returns the current ValueAndUnit
  62228. */
  62229. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62230. /**
  62231. * Gets the value accordingly to its unit
  62232. * @param host defines the root host
  62233. * @returns the value
  62234. */
  62235. getValue(host: AdvancedDynamicTexture): number;
  62236. /**
  62237. * Gets a string representation of the value
  62238. * @param host defines the root host
  62239. * @param decimals defines an optional number of decimals to display
  62240. * @returns a string
  62241. */
  62242. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62243. /**
  62244. * Store a value parsed from a string
  62245. * @param source defines the source string
  62246. * @returns true if the value was successfully parsed
  62247. */
  62248. fromString(source: string | number): boolean;
  62249. private static _Regex;
  62250. private static _UNITMODE_PERCENTAGE;
  62251. private static _UNITMODE_PIXEL;
  62252. /** UNITMODE_PERCENTAGE */
  62253. static readonly UNITMODE_PERCENTAGE: number;
  62254. /** UNITMODE_PIXEL */
  62255. static readonly UNITMODE_PIXEL: number;
  62256. }
  62257. }
  62258. declare module BABYLON.GUI {
  62259. /**
  62260. * Define a style used by control to automatically setup properties based on a template.
  62261. * Only support font related properties so far
  62262. */
  62263. export class Style implements BABYLON.IDisposable {
  62264. private _fontFamily;
  62265. private _fontStyle;
  62266. private _fontWeight;
  62267. /** @hidden */
  62268. _host: AdvancedDynamicTexture;
  62269. /** @hidden */
  62270. _fontSize: ValueAndUnit;
  62271. /**
  62272. * BABYLON.Observable raised when the style values are changed
  62273. */
  62274. onChangedObservable: BABYLON.Observable<Style>;
  62275. /**
  62276. * Creates a new style object
  62277. * @param host defines the AdvancedDynamicTexture which hosts this style
  62278. */
  62279. constructor(host: AdvancedDynamicTexture);
  62280. /**
  62281. * Gets or sets the font size
  62282. */
  62283. fontSize: string | number;
  62284. /**
  62285. * Gets or sets the font family
  62286. */
  62287. fontFamily: string;
  62288. /**
  62289. * Gets or sets the font style
  62290. */
  62291. fontStyle: string;
  62292. /** Gets or sets font weight */
  62293. fontWeight: string;
  62294. /** Dispose all associated resources */
  62295. dispose(): void;
  62296. }
  62297. }
  62298. declare module BABYLON.GUI {
  62299. /**
  62300. * Class used to transport BABYLON.Vector2 information for pointer events
  62301. */
  62302. export class Vector2WithInfo extends BABYLON.Vector2 {
  62303. /** defines the current mouse button index */
  62304. buttonIndex: number;
  62305. /**
  62306. * Creates a new Vector2WithInfo
  62307. * @param source defines the vector2 data to transport
  62308. * @param buttonIndex defines the current mouse button index
  62309. */
  62310. constructor(source: BABYLON.Vector2,
  62311. /** defines the current mouse button index */
  62312. buttonIndex?: number);
  62313. }
  62314. /** Class used to provide 2D matrix features */
  62315. export class Matrix2D {
  62316. /** Gets the internal array of 6 floats used to store matrix data */
  62317. m: Float32Array;
  62318. /**
  62319. * Creates a new matrix
  62320. * @param m00 defines value for (0, 0)
  62321. * @param m01 defines value for (0, 1)
  62322. * @param m10 defines value for (1, 0)
  62323. * @param m11 defines value for (1, 1)
  62324. * @param m20 defines value for (2, 0)
  62325. * @param m21 defines value for (2, 1)
  62326. */
  62327. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62328. /**
  62329. * Fills the matrix from direct values
  62330. * @param m00 defines value for (0, 0)
  62331. * @param m01 defines value for (0, 1)
  62332. * @param m10 defines value for (1, 0)
  62333. * @param m11 defines value for (1, 1)
  62334. * @param m20 defines value for (2, 0)
  62335. * @param m21 defines value for (2, 1)
  62336. * @returns the current modified matrix
  62337. */
  62338. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62339. /**
  62340. * Gets matrix determinant
  62341. * @returns the determinant
  62342. */
  62343. determinant(): number;
  62344. /**
  62345. * Inverses the matrix and stores it in a target matrix
  62346. * @param result defines the target matrix
  62347. * @returns the current matrix
  62348. */
  62349. invertToRef(result: Matrix2D): Matrix2D;
  62350. /**
  62351. * Multiplies the current matrix with another one
  62352. * @param other defines the second operand
  62353. * @param result defines the target matrix
  62354. * @returns the current matrix
  62355. */
  62356. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62357. /**
  62358. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62359. * @param x defines the x coordinate to transform
  62360. * @param y defines the x coordinate to transform
  62361. * @param result defines the target vector2
  62362. * @returns the current matrix
  62363. */
  62364. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62365. /**
  62366. * Creates an identity matrix
  62367. * @returns a new matrix
  62368. */
  62369. static Identity(): Matrix2D;
  62370. /**
  62371. * Creates a translation matrix and stores it in a target matrix
  62372. * @param x defines the x coordinate of the translation
  62373. * @param y defines the y coordinate of the translation
  62374. * @param result defines the target matrix
  62375. */
  62376. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62377. /**
  62378. * Creates a scaling matrix and stores it in a target matrix
  62379. * @param x defines the x coordinate of the scaling
  62380. * @param y defines the y coordinate of the scaling
  62381. * @param result defines the target matrix
  62382. */
  62383. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62384. /**
  62385. * Creates a rotation matrix and stores it in a target matrix
  62386. * @param angle defines the rotation angle
  62387. * @param result defines the target matrix
  62388. */
  62389. static RotationToRef(angle: number, result: Matrix2D): void;
  62390. private static _TempPreTranslationMatrix;
  62391. private static _TempPostTranslationMatrix;
  62392. private static _TempRotationMatrix;
  62393. private static _TempScalingMatrix;
  62394. private static _TempCompose0;
  62395. private static _TempCompose1;
  62396. private static _TempCompose2;
  62397. /**
  62398. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62399. * @param tx defines the x coordinate of the translation
  62400. * @param ty defines the y coordinate of the translation
  62401. * @param angle defines the rotation angle
  62402. * @param scaleX defines the x coordinate of the scaling
  62403. * @param scaleY defines the y coordinate of the scaling
  62404. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62405. * @param result defines the target matrix
  62406. */
  62407. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62408. }
  62409. }
  62410. declare module BABYLON.GUI {
  62411. /**
  62412. * Class used to store 2D control sizes
  62413. */
  62414. export class Measure {
  62415. /** defines left coordinate */
  62416. left: number;
  62417. /** defines top coordinate */
  62418. top: number;
  62419. /** defines width dimension */
  62420. width: number;
  62421. /** defines height dimension */
  62422. height: number;
  62423. /**
  62424. * Creates a new measure
  62425. * @param left defines left coordinate
  62426. * @param top defines top coordinate
  62427. * @param width defines width dimension
  62428. * @param height defines height dimension
  62429. */
  62430. constructor(
  62431. /** defines left coordinate */
  62432. left: number,
  62433. /** defines top coordinate */
  62434. top: number,
  62435. /** defines width dimension */
  62436. width: number,
  62437. /** defines height dimension */
  62438. height: number);
  62439. /**
  62440. * Copy from another measure
  62441. * @param other defines the other measure to copy from
  62442. */
  62443. copyFrom(other: Measure): void;
  62444. /**
  62445. * Copy from a group of 4 floats
  62446. * @param left defines left coordinate
  62447. * @param top defines top coordinate
  62448. * @param width defines width dimension
  62449. * @param height defines height dimension
  62450. */
  62451. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62452. /**
  62453. * Computes the axis aligned bounding box measure for two given measures
  62454. * @param a Input measure
  62455. * @param b Input measure
  62456. * @param result the resulting bounding measure
  62457. */
  62458. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62459. /**
  62460. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62461. * @param transform the matrix to transform the measure before computing the AABB
  62462. * @param result the resulting AABB
  62463. */
  62464. transformToRef(transform: Matrix2D, result: Measure): void;
  62465. /**
  62466. * Check equality between this measure and another one
  62467. * @param other defines the other measures
  62468. * @returns true if both measures are equals
  62469. */
  62470. isEqualsTo(other: Measure): boolean;
  62471. /**
  62472. * Creates an empty measure
  62473. * @returns a new measure
  62474. */
  62475. static Empty(): Measure;
  62476. }
  62477. }
  62478. declare module BABYLON.GUI {
  62479. /**
  62480. * Interface used to define a control that can receive focus
  62481. */
  62482. export interface IFocusableControl {
  62483. /**
  62484. * Function called when the control receives the focus
  62485. */
  62486. onFocus(): void;
  62487. /**
  62488. * Function called when the control loses the focus
  62489. */
  62490. onBlur(): void;
  62491. /**
  62492. * Function called to let the control handle keyboard events
  62493. * @param evt defines the current keyboard event
  62494. */
  62495. processKeyboard(evt: KeyboardEvent): void;
  62496. /**
  62497. * Function called to get the list of controls that should not steal the focus from this control
  62498. * @returns an array of controls
  62499. */
  62500. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62501. }
  62502. /**
  62503. * Class used to create texture to support 2D GUI elements
  62504. * @see http://doc.babylonjs.com/how_to/gui
  62505. */
  62506. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62507. private _isDirty;
  62508. private _renderObserver;
  62509. private _resizeObserver;
  62510. private _preKeyboardObserver;
  62511. private _pointerMoveObserver;
  62512. private _pointerObserver;
  62513. private _canvasPointerOutObserver;
  62514. private _background;
  62515. /** @hidden */
  62516. _rootContainer: Container;
  62517. /** @hidden */
  62518. _lastPickedControl: Control;
  62519. /** @hidden */
  62520. _lastControlOver: {
  62521. [pointerId: number]: Control;
  62522. };
  62523. /** @hidden */
  62524. _lastControlDown: {
  62525. [pointerId: number]: Control;
  62526. };
  62527. /** @hidden */
  62528. _capturingControl: {
  62529. [pointerId: number]: Control;
  62530. };
  62531. /** @hidden */
  62532. _shouldBlockPointer: boolean;
  62533. /** @hidden */
  62534. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62535. /** @hidden */
  62536. _linkedControls: Control[];
  62537. private _isFullscreen;
  62538. private _fullscreenViewport;
  62539. private _idealWidth;
  62540. private _idealHeight;
  62541. private _useSmallestIdeal;
  62542. private _renderAtIdealSize;
  62543. private _focusedControl;
  62544. private _blockNextFocusCheck;
  62545. private _renderScale;
  62546. private _rootCanvas;
  62547. private _cursorChanged;
  62548. /**
  62549. * Define type to string to ensure compatibility across browsers
  62550. * Safari doesn't support DataTransfer constructor
  62551. */
  62552. private _clipboardData;
  62553. /**
  62554. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62555. */
  62556. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62557. /**
  62558. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62559. */
  62560. onControlPickedObservable: BABYLON.Observable<Control>;
  62561. /**
  62562. * BABYLON.Observable event triggered before layout is evaluated
  62563. */
  62564. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62565. /**
  62566. * BABYLON.Observable event triggered after the layout was evaluated
  62567. */
  62568. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62569. /**
  62570. * BABYLON.Observable event triggered before the texture is rendered
  62571. */
  62572. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62573. /**
  62574. * BABYLON.Observable event triggered after the texture was rendered
  62575. */
  62576. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62577. /**
  62578. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62579. */
  62580. premulAlpha: boolean;
  62581. /**
  62582. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62583. * Useful when you want more antialiasing
  62584. */
  62585. renderScale: number;
  62586. /** Gets or sets the background color */
  62587. background: string;
  62588. /**
  62589. * Gets or sets the ideal width used to design controls.
  62590. * The GUI will then rescale everything accordingly
  62591. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62592. */
  62593. idealWidth: number;
  62594. /**
  62595. * Gets or sets the ideal height used to design controls.
  62596. * The GUI will then rescale everything accordingly
  62597. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62598. */
  62599. idealHeight: number;
  62600. /**
  62601. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62602. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62603. */
  62604. useSmallestIdeal: boolean;
  62605. /**
  62606. * Gets or sets a boolean indicating if adaptive scaling must be used
  62607. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62608. */
  62609. renderAtIdealSize: boolean;
  62610. /**
  62611. * Gets the underlying layer used to render the texture when in fullscreen mode
  62612. */
  62613. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62614. /**
  62615. * Gets the root container control
  62616. */
  62617. readonly rootContainer: Container;
  62618. /**
  62619. * Returns an array containing the root container.
  62620. * This is mostly used to let the Inspector introspects the ADT
  62621. * @returns an array containing the rootContainer
  62622. */
  62623. getChildren(): Array<Container>;
  62624. /**
  62625. * Will return all controls that are inside this texture
  62626. * @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
  62627. * @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
  62628. * @return all child controls
  62629. */
  62630. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62631. /**
  62632. * Gets or sets the current focused control
  62633. */
  62634. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62635. /**
  62636. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62637. */
  62638. isForeground: boolean;
  62639. /**
  62640. * Gets or set information about clipboardData
  62641. */
  62642. clipboardData: string;
  62643. /**
  62644. * Creates a new AdvancedDynamicTexture
  62645. * @param name defines the name of the texture
  62646. * @param width defines the width of the texture
  62647. * @param height defines the height of the texture
  62648. * @param scene defines the hosting scene
  62649. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62650. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62651. */
  62652. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62653. /**
  62654. * Get the current class name of the texture useful for serialization or dynamic coding.
  62655. * @returns "AdvancedDynamicTexture"
  62656. */
  62657. getClassName(): string;
  62658. /**
  62659. * Function used to execute a function on all controls
  62660. * @param func defines the function to execute
  62661. * @param container defines the container where controls belong. If null the root container will be used
  62662. */
  62663. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62664. private _useInvalidateRectOptimization;
  62665. /**
  62666. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62667. */
  62668. useInvalidateRectOptimization: boolean;
  62669. private _invalidatedRectangle;
  62670. /**
  62671. * Invalidates a rectangle area on the gui texture
  62672. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62673. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62674. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62675. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62676. */
  62677. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62678. /**
  62679. * Marks the texture as dirty forcing a complete update
  62680. */
  62681. markAsDirty(): void;
  62682. /**
  62683. * Helper function used to create a new style
  62684. * @returns a new style
  62685. * @see http://doc.babylonjs.com/how_to/gui#styles
  62686. */
  62687. createStyle(): Style;
  62688. /**
  62689. * Adds a new control to the root container
  62690. * @param control defines the control to add
  62691. * @returns the current texture
  62692. */
  62693. addControl(control: Control): AdvancedDynamicTexture;
  62694. /**
  62695. * Removes a control from the root container
  62696. * @param control defines the control to remove
  62697. * @returns the current texture
  62698. */
  62699. removeControl(control: Control): AdvancedDynamicTexture;
  62700. /**
  62701. * Release all resources
  62702. */
  62703. dispose(): void;
  62704. private _onResize;
  62705. /** @hidden */
  62706. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62707. /**
  62708. * Get screen coordinates for a vector3
  62709. * @param position defines the position to project
  62710. * @param worldMatrix defines the world matrix to use
  62711. * @returns the projected position
  62712. */
  62713. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62714. private _checkUpdate;
  62715. private _clearMeasure;
  62716. private _render;
  62717. /** @hidden */
  62718. _changeCursor(cursor: string): void;
  62719. /** @hidden */
  62720. _registerLastControlDown(control: Control, pointerId: number): void;
  62721. private _doPicking;
  62722. /** @hidden */
  62723. _cleanControlAfterRemovalFromList(list: {
  62724. [pointerId: number]: Control;
  62725. }, control: Control): void;
  62726. /** @hidden */
  62727. _cleanControlAfterRemoval(control: Control): void;
  62728. /** Attach to all scene events required to support pointer events */
  62729. attach(): void;
  62730. /** @hidden */
  62731. private onClipboardCopy;
  62732. /** @hidden */
  62733. private onClipboardCut;
  62734. /** @hidden */
  62735. private onClipboardPaste;
  62736. /**
  62737. * Register the clipboard Events onto the canvas
  62738. */
  62739. registerClipboardEvents(): void;
  62740. /**
  62741. * Unregister the clipboard Events from the canvas
  62742. */
  62743. unRegisterClipboardEvents(): void;
  62744. /**
  62745. * Connect the texture to a hosting mesh to enable interactions
  62746. * @param mesh defines the mesh to attach to
  62747. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62748. */
  62749. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62750. /**
  62751. * Move the focus to a specific control
  62752. * @param control defines the control which will receive the focus
  62753. */
  62754. moveFocusToControl(control: IFocusableControl): void;
  62755. private _manageFocus;
  62756. private _attachToOnPointerOut;
  62757. /**
  62758. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62759. * @param mesh defines the mesh which will receive the texture
  62760. * @param width defines the texture width (1024 by default)
  62761. * @param height defines the texture height (1024 by default)
  62762. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62763. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62764. * @returns a new AdvancedDynamicTexture
  62765. */
  62766. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62767. /**
  62768. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62769. * In this mode the texture will rely on a layer for its rendering.
  62770. * This allows it to be treated like any other layer.
  62771. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62772. * LayerMask is set through advancedTexture.layer.layerMask
  62773. * @param name defines name for the texture
  62774. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62775. * @param scene defines the hsoting scene
  62776. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62777. * @returns a new AdvancedDynamicTexture
  62778. */
  62779. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62780. }
  62781. }
  62782. declare module BABYLON.GUI {
  62783. /**
  62784. * Root class used for all 2D controls
  62785. * @see http://doc.babylonjs.com/how_to/gui#controls
  62786. */
  62787. export class Control {
  62788. /** defines the name of the control */
  62789. name?: string | undefined;
  62790. /**
  62791. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62792. */
  62793. static AllowAlphaInheritance: boolean;
  62794. private _alpha;
  62795. private _alphaSet;
  62796. private _zIndex;
  62797. /** @hidden */
  62798. _host: AdvancedDynamicTexture;
  62799. /** Gets or sets the control parent */
  62800. parent: BABYLON.Nullable<Container>;
  62801. /** @hidden */
  62802. _currentMeasure: Measure;
  62803. private _fontFamily;
  62804. private _fontStyle;
  62805. private _fontWeight;
  62806. private _fontSize;
  62807. private _font;
  62808. /** @hidden */
  62809. _width: ValueAndUnit;
  62810. /** @hidden */
  62811. _height: ValueAndUnit;
  62812. /** @hidden */
  62813. protected _fontOffset: {
  62814. ascent: number;
  62815. height: number;
  62816. descent: number;
  62817. };
  62818. private _color;
  62819. private _style;
  62820. private _styleObserver;
  62821. /** @hidden */
  62822. protected _horizontalAlignment: number;
  62823. /** @hidden */
  62824. protected _verticalAlignment: number;
  62825. /** @hidden */
  62826. protected _isDirty: boolean;
  62827. /** @hidden */
  62828. protected _wasDirty: boolean;
  62829. /** @hidden */
  62830. _tempParentMeasure: Measure;
  62831. /** @hidden */
  62832. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62833. /** @hidden */
  62834. protected _cachedParentMeasure: Measure;
  62835. private _paddingLeft;
  62836. private _paddingRight;
  62837. private _paddingTop;
  62838. private _paddingBottom;
  62839. /** @hidden */
  62840. _left: ValueAndUnit;
  62841. /** @hidden */
  62842. _top: ValueAndUnit;
  62843. private _scaleX;
  62844. private _scaleY;
  62845. private _rotation;
  62846. private _transformCenterX;
  62847. private _transformCenterY;
  62848. /** @hidden */
  62849. _transformMatrix: Matrix2D;
  62850. /** @hidden */
  62851. protected _invertTransformMatrix: Matrix2D;
  62852. /** @hidden */
  62853. protected _transformedPosition: BABYLON.Vector2;
  62854. private _isMatrixDirty;
  62855. private _cachedOffsetX;
  62856. private _cachedOffsetY;
  62857. private _isVisible;
  62858. private _isHighlighted;
  62859. /** @hidden */
  62860. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62861. private _fontSet;
  62862. private _dummyVector2;
  62863. private _downCount;
  62864. private _enterCount;
  62865. private _doNotRender;
  62866. private _downPointerIds;
  62867. protected _isEnabled: boolean;
  62868. protected _disabledColor: string;
  62869. /** @hidden */
  62870. protected _rebuildLayout: boolean;
  62871. /** @hidden */
  62872. _isClipped: boolean;
  62873. /** @hidden */
  62874. _tag: any;
  62875. /**
  62876. * 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
  62877. */
  62878. uniqueId: number;
  62879. /**
  62880. * Gets or sets an object used to store user defined information for the node
  62881. */
  62882. metadata: any;
  62883. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62884. isHitTestVisible: boolean;
  62885. /** Gets or sets a boolean indicating if the control can block pointer events */
  62886. isPointerBlocker: boolean;
  62887. /** Gets or sets a boolean indicating if the control can be focusable */
  62888. isFocusInvisible: boolean;
  62889. /**
  62890. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62891. * 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
  62892. */
  62893. clipChildren: boolean;
  62894. /**
  62895. * Gets or sets a boolean indicating that control content must be clipped
  62896. * 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
  62897. */
  62898. clipContent: boolean;
  62899. /**
  62900. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62901. */
  62902. useBitmapCache: boolean;
  62903. private _cacheData;
  62904. private _shadowOffsetX;
  62905. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62906. shadowOffsetX: number;
  62907. private _shadowOffsetY;
  62908. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62909. shadowOffsetY: number;
  62910. private _shadowBlur;
  62911. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62912. shadowBlur: number;
  62913. private _shadowColor;
  62914. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62915. shadowColor: string;
  62916. /** Gets or sets the cursor to use when the control is hovered */
  62917. hoverCursor: string;
  62918. /** @hidden */
  62919. protected _linkOffsetX: ValueAndUnit;
  62920. /** @hidden */
  62921. protected _linkOffsetY: ValueAndUnit;
  62922. /** Gets the control type name */
  62923. readonly typeName: string;
  62924. /**
  62925. * Get the current class name of the control.
  62926. * @returns current class name
  62927. */
  62928. getClassName(): string;
  62929. /**
  62930. * An event triggered when the pointer move over the control.
  62931. */
  62932. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62933. /**
  62934. * An event triggered when the pointer move out of the control.
  62935. */
  62936. onPointerOutObservable: BABYLON.Observable<Control>;
  62937. /**
  62938. * An event triggered when the pointer taps the control
  62939. */
  62940. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62941. /**
  62942. * An event triggered when pointer up
  62943. */
  62944. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62945. /**
  62946. * An event triggered when a control is clicked on
  62947. */
  62948. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62949. /**
  62950. * An event triggered when pointer enters the control
  62951. */
  62952. onPointerEnterObservable: BABYLON.Observable<Control>;
  62953. /**
  62954. * An event triggered when the control is marked as dirty
  62955. */
  62956. onDirtyObservable: BABYLON.Observable<Control>;
  62957. /**
  62958. * An event triggered before drawing the control
  62959. */
  62960. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62961. /**
  62962. * An event triggered after the control was drawn
  62963. */
  62964. onAfterDrawObservable: BABYLON.Observable<Control>;
  62965. /**
  62966. * Get the hosting AdvancedDynamicTexture
  62967. */
  62968. readonly host: AdvancedDynamicTexture;
  62969. /** Gets or set information about font offsets (used to render and align text) */
  62970. fontOffset: {
  62971. ascent: number;
  62972. height: number;
  62973. descent: number;
  62974. };
  62975. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62976. alpha: number;
  62977. /**
  62978. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62979. */
  62980. isHighlighted: boolean;
  62981. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62982. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62983. */
  62984. scaleX: number;
  62985. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62986. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62987. */
  62988. scaleY: number;
  62989. /** Gets or sets the rotation angle (0 by default)
  62990. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62991. */
  62992. rotation: number;
  62993. /** Gets or sets the transformation center on Y axis (0 by default)
  62994. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62995. */
  62996. transformCenterY: number;
  62997. /** Gets or sets the transformation center on X axis (0 by default)
  62998. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62999. */
  63000. transformCenterX: number;
  63001. /**
  63002. * Gets or sets the horizontal alignment
  63003. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63004. */
  63005. horizontalAlignment: number;
  63006. /**
  63007. * Gets or sets the vertical alignment
  63008. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63009. */
  63010. verticalAlignment: number;
  63011. /**
  63012. * Gets or sets control width
  63013. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63014. */
  63015. width: string | number;
  63016. /**
  63017. * Gets or sets the control width in pixel
  63018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63019. */
  63020. widthInPixels: number;
  63021. /**
  63022. * Gets or sets control height
  63023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63024. */
  63025. height: string | number;
  63026. /**
  63027. * Gets or sets control height in pixel
  63028. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63029. */
  63030. heightInPixels: number;
  63031. /** Gets or set font family */
  63032. fontFamily: string;
  63033. /** Gets or sets font style */
  63034. fontStyle: string;
  63035. /** Gets or sets font weight */
  63036. fontWeight: string;
  63037. /**
  63038. * Gets or sets style
  63039. * @see http://doc.babylonjs.com/how_to/gui#styles
  63040. */
  63041. style: BABYLON.Nullable<Style>;
  63042. /** @hidden */
  63043. readonly _isFontSizeInPercentage: boolean;
  63044. /** Gets or sets font size in pixels */
  63045. fontSizeInPixels: number;
  63046. /** Gets or sets font size */
  63047. fontSize: string | number;
  63048. /** Gets or sets foreground color */
  63049. color: string;
  63050. /** Gets or sets z index which is used to reorder controls on the z axis */
  63051. zIndex: number;
  63052. /** Gets or sets a boolean indicating if the control can be rendered */
  63053. notRenderable: boolean;
  63054. /** Gets or sets a boolean indicating if the control is visible */
  63055. isVisible: boolean;
  63056. /** Gets a boolean indicating that the control needs to update its rendering */
  63057. readonly isDirty: boolean;
  63058. /**
  63059. * Gets the current linked mesh (or null if none)
  63060. */
  63061. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63062. /**
  63063. * Gets or sets a value indicating the padding to use on the left of the control
  63064. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63065. */
  63066. paddingLeft: string | number;
  63067. /**
  63068. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63069. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63070. */
  63071. paddingLeftInPixels: number;
  63072. /**
  63073. * Gets or sets a value indicating the padding to use on the right of the control
  63074. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63075. */
  63076. paddingRight: string | number;
  63077. /**
  63078. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63079. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63080. */
  63081. paddingRightInPixels: number;
  63082. /**
  63083. * Gets or sets a value indicating the padding to use on the top of the control
  63084. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63085. */
  63086. paddingTop: string | number;
  63087. /**
  63088. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63090. */
  63091. paddingTopInPixels: number;
  63092. /**
  63093. * Gets or sets a value indicating the padding to use on the bottom of the control
  63094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63095. */
  63096. paddingBottom: string | number;
  63097. /**
  63098. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63099. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63100. */
  63101. paddingBottomInPixels: number;
  63102. /**
  63103. * Gets or sets a value indicating the left coordinate of the control
  63104. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63105. */
  63106. left: string | number;
  63107. /**
  63108. * Gets or sets a value indicating the left coordinate in pixels of the control
  63109. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63110. */
  63111. leftInPixels: number;
  63112. /**
  63113. * Gets or sets a value indicating the top coordinate of the control
  63114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63115. */
  63116. top: string | number;
  63117. /**
  63118. * Gets or sets a value indicating the top coordinate in pixels of the control
  63119. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63120. */
  63121. topInPixels: number;
  63122. /**
  63123. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63124. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63125. */
  63126. linkOffsetX: string | number;
  63127. /**
  63128. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63129. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63130. */
  63131. linkOffsetXInPixels: number;
  63132. /**
  63133. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63134. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63135. */
  63136. linkOffsetY: string | number;
  63137. /**
  63138. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63139. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63140. */
  63141. linkOffsetYInPixels: number;
  63142. /** Gets the center coordinate on X axis */
  63143. readonly centerX: number;
  63144. /** Gets the center coordinate on Y axis */
  63145. readonly centerY: number;
  63146. /** Gets or sets if control is Enabled*/
  63147. isEnabled: boolean;
  63148. /** Gets or sets background color of control if it's disabled*/
  63149. disabledColor: string;
  63150. /**
  63151. * Creates a new control
  63152. * @param name defines the name of the control
  63153. */
  63154. constructor(
  63155. /** defines the name of the control */
  63156. name?: string | undefined);
  63157. /** @hidden */
  63158. protected _getTypeName(): string;
  63159. /**
  63160. * Gets the first ascendant in the hierarchy of the given type
  63161. * @param className defines the required type
  63162. * @returns the ascendant or null if not found
  63163. */
  63164. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63165. /** @hidden */
  63166. _resetFontCache(): void;
  63167. /**
  63168. * Determines if a container is an ascendant of the current control
  63169. * @param container defines the container to look for
  63170. * @returns true if the container is one of the ascendant of the control
  63171. */
  63172. isAscendant(container: Control): boolean;
  63173. /**
  63174. * Gets coordinates in local control space
  63175. * @param globalCoordinates defines the coordinates to transform
  63176. * @returns the new coordinates in local space
  63177. */
  63178. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63179. /**
  63180. * Gets coordinates in local control space
  63181. * @param globalCoordinates defines the coordinates to transform
  63182. * @param result defines the target vector2 where to store the result
  63183. * @returns the current control
  63184. */
  63185. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63186. /**
  63187. * Gets coordinates in parent local control space
  63188. * @param globalCoordinates defines the coordinates to transform
  63189. * @returns the new coordinates in parent local space
  63190. */
  63191. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63192. /**
  63193. * Move the current control to a vector3 position projected onto the screen.
  63194. * @param position defines the target position
  63195. * @param scene defines the hosting scene
  63196. */
  63197. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63198. /** @hidden */
  63199. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63200. /**
  63201. * Will return all controls that have this control as ascendant
  63202. * @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
  63203. * @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
  63204. * @return all child controls
  63205. */
  63206. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63207. /**
  63208. * Link current control with a target mesh
  63209. * @param mesh defines the mesh to link with
  63210. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63211. */
  63212. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63213. /** @hidden */
  63214. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63215. /** @hidden */
  63216. _offsetLeft(offset: number): void;
  63217. /** @hidden */
  63218. _offsetTop(offset: number): void;
  63219. /** @hidden */
  63220. _markMatrixAsDirty(): void;
  63221. /** @hidden */
  63222. _flagDescendantsAsMatrixDirty(): void;
  63223. /** @hidden */
  63224. _intersectsRect(rect: Measure): boolean;
  63225. /** @hidden */
  63226. protected invalidateRect(): void;
  63227. /** @hidden */
  63228. _markAsDirty(force?: boolean): void;
  63229. /** @hidden */
  63230. _markAllAsDirty(): void;
  63231. /** @hidden */
  63232. _link(host: AdvancedDynamicTexture): void;
  63233. /** @hidden */
  63234. protected _transform(context?: CanvasRenderingContext2D): void;
  63235. /** @hidden */
  63236. _renderHighlight(context: CanvasRenderingContext2D): void;
  63237. /** @hidden */
  63238. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63239. /** @hidden */
  63240. protected _applyStates(context: CanvasRenderingContext2D): void;
  63241. /** @hidden */
  63242. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63243. /** @hidden */
  63244. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63245. protected _evaluateClippingState(parentMeasure: Measure): void;
  63246. /** @hidden */
  63247. _measure(): void;
  63248. /** @hidden */
  63249. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63250. /** @hidden */
  63251. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63252. /** @hidden */
  63253. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63254. /** @hidden */
  63255. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63256. private static _ClipMeasure;
  63257. private _tmpMeasureA;
  63258. private _clip;
  63259. /** @hidden */
  63260. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63261. /** @hidden */
  63262. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63263. /**
  63264. * Tests if a given coordinates belong to the current control
  63265. * @param x defines x coordinate to test
  63266. * @param y defines y coordinate to test
  63267. * @returns true if the coordinates are inside the control
  63268. */
  63269. contains(x: number, y: number): boolean;
  63270. /** @hidden */
  63271. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63272. /** @hidden */
  63273. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63274. /** @hidden */
  63275. _onPointerEnter(target: Control): boolean;
  63276. /** @hidden */
  63277. _onPointerOut(target: Control, force?: boolean): void;
  63278. /** @hidden */
  63279. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63280. /** @hidden */
  63281. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63282. /** @hidden */
  63283. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63284. /** @hidden */
  63285. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63286. private _prepareFont;
  63287. /** Releases associated resources */
  63288. dispose(): void;
  63289. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63290. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63291. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63292. private static _VERTICAL_ALIGNMENT_TOP;
  63293. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63294. private static _VERTICAL_ALIGNMENT_CENTER;
  63295. /** HORIZONTAL_ALIGNMENT_LEFT */
  63296. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63297. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63298. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63299. /** HORIZONTAL_ALIGNMENT_CENTER */
  63300. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63301. /** VERTICAL_ALIGNMENT_TOP */
  63302. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63303. /** VERTICAL_ALIGNMENT_BOTTOM */
  63304. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63305. /** VERTICAL_ALIGNMENT_CENTER */
  63306. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63307. private static _FontHeightSizes;
  63308. /** @hidden */
  63309. static _GetFontOffset(font: string): {
  63310. ascent: number;
  63311. height: number;
  63312. descent: number;
  63313. };
  63314. /**
  63315. * Creates a stack panel that can be used to render headers
  63316. * @param control defines the control to associate with the header
  63317. * @param text defines the text of the header
  63318. * @param size defines the size of the header
  63319. * @param options defines options used to configure the header
  63320. * @returns a new StackPanel
  63321. * @ignore
  63322. * @hidden
  63323. */
  63324. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63325. isHorizontal: boolean;
  63326. controlFirst: boolean;
  63327. }) => any;
  63328. /** @hidden */
  63329. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63330. }
  63331. }
  63332. declare module BABYLON.GUI {
  63333. /**
  63334. * Root class for 2D containers
  63335. * @see http://doc.babylonjs.com/how_to/gui#containers
  63336. */
  63337. export class Container extends Control {
  63338. name?: string | undefined;
  63339. /** @hidden */
  63340. protected _children: Control[];
  63341. /** @hidden */
  63342. protected _measureForChildren: Measure;
  63343. /** @hidden */
  63344. protected _background: string;
  63345. /** @hidden */
  63346. protected _adaptWidthToChildren: boolean;
  63347. /** @hidden */
  63348. protected _adaptHeightToChildren: boolean;
  63349. /**
  63350. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63351. */
  63352. logLayoutCycleErrors: boolean;
  63353. /**
  63354. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63355. */
  63356. maxLayoutCycle: number;
  63357. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63358. adaptHeightToChildren: boolean;
  63359. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63360. adaptWidthToChildren: boolean;
  63361. /** Gets or sets background color */
  63362. background: string;
  63363. /** Gets the list of children */
  63364. readonly children: Control[];
  63365. /**
  63366. * Creates a new Container
  63367. * @param name defines the name of the container
  63368. */
  63369. constructor(name?: string | undefined);
  63370. protected _getTypeName(): string;
  63371. _flagDescendantsAsMatrixDirty(): void;
  63372. /**
  63373. * Gets a child using its name
  63374. * @param name defines the child name to look for
  63375. * @returns the child control if found
  63376. */
  63377. getChildByName(name: string): BABYLON.Nullable<Control>;
  63378. /**
  63379. * Gets a child using its type and its name
  63380. * @param name defines the child name to look for
  63381. * @param type defines the child type to look for
  63382. * @returns the child control if found
  63383. */
  63384. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63385. /**
  63386. * Search for a specific control in children
  63387. * @param control defines the control to look for
  63388. * @returns true if the control is in child list
  63389. */
  63390. containsControl(control: Control): boolean;
  63391. /**
  63392. * Adds a new control to the current container
  63393. * @param control defines the control to add
  63394. * @returns the current container
  63395. */
  63396. addControl(control: BABYLON.Nullable<Control>): Container;
  63397. /**
  63398. * Removes all controls from the current container
  63399. * @returns the current container
  63400. */
  63401. clearControls(): Container;
  63402. /**
  63403. * Removes a control from the current container
  63404. * @param control defines the control to remove
  63405. * @returns the current container
  63406. */
  63407. removeControl(control: Control): Container;
  63408. /** @hidden */
  63409. _reOrderControl(control: Control): void;
  63410. /** @hidden */
  63411. _offsetLeft(offset: number): void;
  63412. /** @hidden */
  63413. _offsetTop(offset: number): void;
  63414. /** @hidden */
  63415. _markAllAsDirty(): void;
  63416. /** @hidden */
  63417. protected _localDraw(context: CanvasRenderingContext2D): void;
  63418. /** @hidden */
  63419. _link(host: AdvancedDynamicTexture): void;
  63420. /** @hidden */
  63421. protected _beforeLayout(): void;
  63422. /** @hidden */
  63423. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63424. /** @hidden */
  63425. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63426. protected _postMeasure(): void;
  63427. /** @hidden */
  63428. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63429. /** @hidden */
  63430. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63431. /** @hidden */
  63432. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63433. /** @hidden */
  63434. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63435. /** Releases associated resources */
  63436. dispose(): void;
  63437. }
  63438. }
  63439. declare module BABYLON.GUI {
  63440. /** Class used to create rectangle container */
  63441. export class Rectangle extends Container {
  63442. name?: string | undefined;
  63443. private _thickness;
  63444. private _cornerRadius;
  63445. /** Gets or sets border thickness */
  63446. thickness: number;
  63447. /** Gets or sets the corner radius angle */
  63448. cornerRadius: number;
  63449. /**
  63450. * Creates a new Rectangle
  63451. * @param name defines the control name
  63452. */
  63453. constructor(name?: string | undefined);
  63454. protected _getTypeName(): string;
  63455. protected _localDraw(context: CanvasRenderingContext2D): void;
  63456. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63457. private _drawRoundedRect;
  63458. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63459. }
  63460. }
  63461. declare module BABYLON.GUI {
  63462. /**
  63463. * Enum that determines the text-wrapping mode to use.
  63464. */
  63465. export enum TextWrapping {
  63466. /**
  63467. * Clip the text when it's larger than Control.width; this is the default mode.
  63468. */
  63469. Clip = 0,
  63470. /**
  63471. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63472. */
  63473. WordWrap = 1,
  63474. /**
  63475. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63476. */
  63477. Ellipsis = 2
  63478. }
  63479. /**
  63480. * Class used to create text block control
  63481. */
  63482. export class TextBlock extends Control {
  63483. /**
  63484. * Defines the name of the control
  63485. */
  63486. name?: string | undefined;
  63487. private _text;
  63488. private _textWrapping;
  63489. private _textHorizontalAlignment;
  63490. private _textVerticalAlignment;
  63491. private _lines;
  63492. private _resizeToFit;
  63493. private _lineSpacing;
  63494. private _outlineWidth;
  63495. private _outlineColor;
  63496. /**
  63497. * An event triggered after the text is changed
  63498. */
  63499. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63500. /**
  63501. * An event triggered after the text was broken up into lines
  63502. */
  63503. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63504. /**
  63505. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63506. */
  63507. readonly lines: any[];
  63508. /**
  63509. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63510. */
  63511. /**
  63512. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63513. */
  63514. resizeToFit: boolean;
  63515. /**
  63516. * Gets or sets a boolean indicating if text must be wrapped
  63517. */
  63518. /**
  63519. * Gets or sets a boolean indicating if text must be wrapped
  63520. */
  63521. textWrapping: TextWrapping | boolean;
  63522. /**
  63523. * Gets or sets text to display
  63524. */
  63525. /**
  63526. * Gets or sets text to display
  63527. */
  63528. text: string;
  63529. /**
  63530. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63531. */
  63532. /**
  63533. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63534. */
  63535. textHorizontalAlignment: number;
  63536. /**
  63537. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63538. */
  63539. /**
  63540. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63541. */
  63542. textVerticalAlignment: number;
  63543. /**
  63544. * Gets or sets line spacing value
  63545. */
  63546. /**
  63547. * Gets or sets line spacing value
  63548. */
  63549. lineSpacing: string | number;
  63550. /**
  63551. * Gets or sets outlineWidth of the text to display
  63552. */
  63553. /**
  63554. * Gets or sets outlineWidth of the text to display
  63555. */
  63556. outlineWidth: number;
  63557. /**
  63558. * Gets or sets outlineColor of the text to display
  63559. */
  63560. /**
  63561. * Gets or sets outlineColor of the text to display
  63562. */
  63563. outlineColor: string;
  63564. /**
  63565. * Creates a new TextBlock object
  63566. * @param name defines the name of the control
  63567. * @param text defines the text to display (emptry string by default)
  63568. */
  63569. constructor(
  63570. /**
  63571. * Defines the name of the control
  63572. */
  63573. name?: string | undefined, text?: string);
  63574. protected _getTypeName(): string;
  63575. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63576. private _drawText;
  63577. /** @hidden */
  63578. _draw(context: CanvasRenderingContext2D): void;
  63579. protected _applyStates(context: CanvasRenderingContext2D): void;
  63580. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63581. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63582. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63583. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63584. protected _renderLines(context: CanvasRenderingContext2D): void;
  63585. /**
  63586. * Given a width constraint applied on the text block, find the expected height
  63587. * @returns expected height
  63588. */
  63589. computeExpectedHeight(): number;
  63590. dispose(): void;
  63591. }
  63592. }
  63593. declare module BABYLON.GUI {
  63594. /**
  63595. * Class used to create 2D images
  63596. */
  63597. export class Image extends Control {
  63598. name?: string | undefined;
  63599. private static _WorkingCanvas;
  63600. private _domImage;
  63601. private _imageWidth;
  63602. private _imageHeight;
  63603. private _loaded;
  63604. private _stretch;
  63605. private _source;
  63606. private _autoScale;
  63607. private _sourceLeft;
  63608. private _sourceTop;
  63609. private _sourceWidth;
  63610. private _sourceHeight;
  63611. private _cellWidth;
  63612. private _cellHeight;
  63613. private _cellId;
  63614. private _populateNinePatchSlicesFromImage;
  63615. private _sliceLeft;
  63616. private _sliceRight;
  63617. private _sliceTop;
  63618. private _sliceBottom;
  63619. private _detectPointerOnOpaqueOnly;
  63620. /**
  63621. * BABYLON.Observable notified when the content is loaded
  63622. */
  63623. onImageLoadedObservable: BABYLON.Observable<Image>;
  63624. /**
  63625. * Gets a boolean indicating that the content is loaded
  63626. */
  63627. readonly isLoaded: boolean;
  63628. /**
  63629. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63630. */
  63631. populateNinePatchSlicesFromImage: boolean;
  63632. /**
  63633. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63634. * Beware using this as this will comsume more memory as the image has to be stored twice
  63635. */
  63636. detectPointerOnOpaqueOnly: boolean;
  63637. /**
  63638. * Gets or sets the left value for slicing (9-patch)
  63639. */
  63640. sliceLeft: number;
  63641. /**
  63642. * Gets or sets the right value for slicing (9-patch)
  63643. */
  63644. sliceRight: number;
  63645. /**
  63646. * Gets or sets the top value for slicing (9-patch)
  63647. */
  63648. sliceTop: number;
  63649. /**
  63650. * Gets or sets the bottom value for slicing (9-patch)
  63651. */
  63652. sliceBottom: number;
  63653. /**
  63654. * Gets or sets the left coordinate in the source image
  63655. */
  63656. sourceLeft: number;
  63657. /**
  63658. * Gets or sets the top coordinate in the source image
  63659. */
  63660. sourceTop: number;
  63661. /**
  63662. * Gets or sets the width to capture in the source image
  63663. */
  63664. sourceWidth: number;
  63665. /**
  63666. * Gets or sets the height to capture in the source image
  63667. */
  63668. sourceHeight: number;
  63669. /**
  63670. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63671. * @see http://doc.babylonjs.com/how_to/gui#image
  63672. */
  63673. autoScale: boolean;
  63674. /** Gets or sets the streching mode used by the image */
  63675. stretch: number;
  63676. /**
  63677. * Gets or sets the internal DOM image used to render the control
  63678. */
  63679. domImage: HTMLImageElement;
  63680. private _onImageLoaded;
  63681. private _extractNinePatchSliceDataFromImage;
  63682. /**
  63683. * Gets or sets image source url
  63684. */
  63685. source: BABYLON.Nullable<string>;
  63686. /**
  63687. * Gets or sets the cell width to use when animation sheet is enabled
  63688. * @see http://doc.babylonjs.com/how_to/gui#image
  63689. */
  63690. cellWidth: number;
  63691. /**
  63692. * Gets or sets the cell height to use when animation sheet is enabled
  63693. * @see http://doc.babylonjs.com/how_to/gui#image
  63694. */
  63695. cellHeight: number;
  63696. /**
  63697. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63698. * @see http://doc.babylonjs.com/how_to/gui#image
  63699. */
  63700. cellId: number;
  63701. /**
  63702. * Creates a new Image
  63703. * @param name defines the control name
  63704. * @param url defines the image url
  63705. */
  63706. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63707. /**
  63708. * Tests if a given coordinates belong to the current control
  63709. * @param x defines x coordinate to test
  63710. * @param y defines y coordinate to test
  63711. * @returns true if the coordinates are inside the control
  63712. */
  63713. contains(x: number, y: number): boolean;
  63714. protected _getTypeName(): string;
  63715. /** Force the control to synchronize with its content */
  63716. synchronizeSizeWithContent(): void;
  63717. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63718. private _prepareWorkingCanvasForOpaqueDetection;
  63719. private _drawImage;
  63720. _draw(context: CanvasRenderingContext2D): void;
  63721. private _renderCornerPatch;
  63722. private _renderNinePatch;
  63723. dispose(): void;
  63724. /** STRETCH_NONE */
  63725. static readonly STRETCH_NONE: number;
  63726. /** STRETCH_FILL */
  63727. static readonly STRETCH_FILL: number;
  63728. /** STRETCH_UNIFORM */
  63729. static readonly STRETCH_UNIFORM: number;
  63730. /** STRETCH_EXTEND */
  63731. static readonly STRETCH_EXTEND: number;
  63732. /** NINE_PATCH */
  63733. static readonly STRETCH_NINE_PATCH: number;
  63734. }
  63735. }
  63736. declare module BABYLON.GUI {
  63737. /**
  63738. * Class used to create 2D buttons
  63739. */
  63740. export class Button extends Rectangle {
  63741. name?: string | undefined;
  63742. /**
  63743. * Function called to generate a pointer enter animation
  63744. */
  63745. pointerEnterAnimation: () => void;
  63746. /**
  63747. * Function called to generate a pointer out animation
  63748. */
  63749. pointerOutAnimation: () => void;
  63750. /**
  63751. * Function called to generate a pointer down animation
  63752. */
  63753. pointerDownAnimation: () => void;
  63754. /**
  63755. * Function called to generate a pointer up animation
  63756. */
  63757. pointerUpAnimation: () => void;
  63758. /**
  63759. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63760. */
  63761. delegatePickingToChildren: boolean;
  63762. private _image;
  63763. /**
  63764. * Returns the image part of the button (if any)
  63765. */
  63766. readonly image: BABYLON.Nullable<Image>;
  63767. private _textBlock;
  63768. /**
  63769. * Returns the image part of the button (if any)
  63770. */
  63771. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63772. /**
  63773. * Creates a new Button
  63774. * @param name defines the name of the button
  63775. */
  63776. constructor(name?: string | undefined);
  63777. protected _getTypeName(): string;
  63778. /** @hidden */
  63779. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63780. /** @hidden */
  63781. _onPointerEnter(target: Control): boolean;
  63782. /** @hidden */
  63783. _onPointerOut(target: Control, force?: boolean): void;
  63784. /** @hidden */
  63785. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63786. /** @hidden */
  63787. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63788. /**
  63789. * Creates a new button made with an image and a text
  63790. * @param name defines the name of the button
  63791. * @param text defines the text of the button
  63792. * @param imageUrl defines the url of the image
  63793. * @returns a new Button
  63794. */
  63795. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63796. /**
  63797. * Creates a new button made with an image
  63798. * @param name defines the name of the button
  63799. * @param imageUrl defines the url of the image
  63800. * @returns a new Button
  63801. */
  63802. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63803. /**
  63804. * Creates a new button made with a text
  63805. * @param name defines the name of the button
  63806. * @param text defines the text of the button
  63807. * @returns a new Button
  63808. */
  63809. static CreateSimpleButton(name: string, text: string): Button;
  63810. /**
  63811. * Creates a new button made with an image and a centered text
  63812. * @param name defines the name of the button
  63813. * @param text defines the text of the button
  63814. * @param imageUrl defines the url of the image
  63815. * @returns a new Button
  63816. */
  63817. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63818. }
  63819. }
  63820. declare module BABYLON.GUI {
  63821. /**
  63822. * Class used to create a 2D stack panel container
  63823. */
  63824. export class StackPanel extends Container {
  63825. name?: string | undefined;
  63826. private _isVertical;
  63827. private _manualWidth;
  63828. private _manualHeight;
  63829. private _doNotTrackManualChanges;
  63830. /**
  63831. * Gets or sets a boolean indicating that layou warnings should be ignored
  63832. */
  63833. ignoreLayoutWarnings: boolean;
  63834. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63835. isVertical: boolean;
  63836. /**
  63837. * Gets or sets panel width.
  63838. * This value should not be set when in horizontal mode as it will be computed automatically
  63839. */
  63840. width: string | number;
  63841. /**
  63842. * Gets or sets panel height.
  63843. * This value should not be set when in vertical mode as it will be computed automatically
  63844. */
  63845. height: string | number;
  63846. /**
  63847. * Creates a new StackPanel
  63848. * @param name defines control name
  63849. */
  63850. constructor(name?: string | undefined);
  63851. protected _getTypeName(): string;
  63852. /** @hidden */
  63853. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63854. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63855. protected _postMeasure(): void;
  63856. }
  63857. }
  63858. declare module BABYLON.GUI {
  63859. /**
  63860. * Class used to represent a 2D checkbox
  63861. */
  63862. export class Checkbox extends Control {
  63863. name?: string | undefined;
  63864. private _isChecked;
  63865. private _background;
  63866. private _checkSizeRatio;
  63867. private _thickness;
  63868. /** Gets or sets border thickness */
  63869. thickness: number;
  63870. /**
  63871. * BABYLON.Observable raised when isChecked property changes
  63872. */
  63873. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63874. /** Gets or sets a value indicating the ratio between overall size and check size */
  63875. checkSizeRatio: number;
  63876. /** Gets or sets background color */
  63877. background: string;
  63878. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63879. isChecked: boolean;
  63880. /**
  63881. * Creates a new CheckBox
  63882. * @param name defines the control name
  63883. */
  63884. constructor(name?: string | undefined);
  63885. protected _getTypeName(): string;
  63886. /** @hidden */
  63887. _draw(context: CanvasRenderingContext2D): void;
  63888. /** @hidden */
  63889. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63890. /**
  63891. * Utility function to easily create a checkbox with a header
  63892. * @param title defines the label to use for the header
  63893. * @param onValueChanged defines the callback to call when value changes
  63894. * @returns a StackPanel containing the checkbox and a textBlock
  63895. */
  63896. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63897. }
  63898. }
  63899. declare module BABYLON.GUI {
  63900. /**
  63901. * Class used to store key control properties
  63902. */
  63903. export class KeyPropertySet {
  63904. /** Width */
  63905. width?: string;
  63906. /** Height */
  63907. height?: string;
  63908. /** Left padding */
  63909. paddingLeft?: string;
  63910. /** Right padding */
  63911. paddingRight?: string;
  63912. /** Top padding */
  63913. paddingTop?: string;
  63914. /** Bottom padding */
  63915. paddingBottom?: string;
  63916. /** Foreground color */
  63917. color?: string;
  63918. /** Background color */
  63919. background?: string;
  63920. }
  63921. /**
  63922. * Class used to create virtual keyboard
  63923. */
  63924. export class VirtualKeyboard extends StackPanel {
  63925. /** BABYLON.Observable raised when a key is pressed */
  63926. onKeyPressObservable: BABYLON.Observable<string>;
  63927. /** Gets or sets default key button width */
  63928. defaultButtonWidth: string;
  63929. /** Gets or sets default key button height */
  63930. defaultButtonHeight: string;
  63931. /** Gets or sets default key button left padding */
  63932. defaultButtonPaddingLeft: string;
  63933. /** Gets or sets default key button right padding */
  63934. defaultButtonPaddingRight: string;
  63935. /** Gets or sets default key button top padding */
  63936. defaultButtonPaddingTop: string;
  63937. /** Gets or sets default key button bottom padding */
  63938. defaultButtonPaddingBottom: string;
  63939. /** Gets or sets default key button foreground color */
  63940. defaultButtonColor: string;
  63941. /** Gets or sets default key button background color */
  63942. defaultButtonBackground: string;
  63943. /** Gets or sets shift button foreground color */
  63944. shiftButtonColor: string;
  63945. /** Gets or sets shift button thickness*/
  63946. selectedShiftThickness: number;
  63947. /** Gets shift key state */
  63948. shiftState: number;
  63949. protected _getTypeName(): string;
  63950. private _createKey;
  63951. /**
  63952. * Adds a new row of keys
  63953. * @param keys defines the list of keys to add
  63954. * @param propertySets defines the associated property sets
  63955. */
  63956. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63957. /**
  63958. * Set the shift key to a specific state
  63959. * @param shiftState defines the new shift state
  63960. */
  63961. applyShiftState(shiftState: number): void;
  63962. private _currentlyConnectedInputText;
  63963. private _connectedInputTexts;
  63964. private _onKeyPressObserver;
  63965. /** Gets the input text control currently attached to the keyboard */
  63966. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63967. /**
  63968. * Connects the keyboard with an input text control
  63969. *
  63970. * @param input defines the target control
  63971. */
  63972. connect(input: InputText): void;
  63973. /**
  63974. * Disconnects the keyboard from connected InputText controls
  63975. *
  63976. * @param input optionally defines a target control, otherwise all are disconnected
  63977. */
  63978. disconnect(input?: InputText): void;
  63979. private _removeConnectedInputObservables;
  63980. /**
  63981. * Release all resources
  63982. */
  63983. dispose(): void;
  63984. /**
  63985. * Creates a new keyboard using a default layout
  63986. *
  63987. * @param name defines control name
  63988. * @returns a new VirtualKeyboard
  63989. */
  63990. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63991. }
  63992. }
  63993. declare module BABYLON.GUI {
  63994. /**
  63995. * Class used to create input text control
  63996. */
  63997. export class InputText extends Control implements IFocusableControl {
  63998. name?: string | undefined;
  63999. private _text;
  64000. private _placeholderText;
  64001. private _background;
  64002. private _focusedBackground;
  64003. private _focusedColor;
  64004. private _placeholderColor;
  64005. private _thickness;
  64006. private _margin;
  64007. private _autoStretchWidth;
  64008. private _maxWidth;
  64009. private _isFocused;
  64010. private _blinkTimeout;
  64011. private _blinkIsEven;
  64012. private _cursorOffset;
  64013. private _scrollLeft;
  64014. private _textWidth;
  64015. private _clickedCoordinate;
  64016. private _deadKey;
  64017. private _addKey;
  64018. private _currentKey;
  64019. private _isTextHighlightOn;
  64020. private _textHighlightColor;
  64021. private _highligherOpacity;
  64022. private _highlightedText;
  64023. private _startHighlightIndex;
  64024. private _endHighlightIndex;
  64025. private _cursorIndex;
  64026. private _onFocusSelectAll;
  64027. private _isPointerDown;
  64028. private _onClipboardObserver;
  64029. private _onPointerDblTapObserver;
  64030. /** @hidden */
  64031. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64032. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64033. promptMessage: string;
  64034. /** Force disable prompt on mobile device */
  64035. disableMobilePrompt: boolean;
  64036. /** BABYLON.Observable raised when the text changes */
  64037. onTextChangedObservable: BABYLON.Observable<InputText>;
  64038. /** BABYLON.Observable raised just before an entered character is to be added */
  64039. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64040. /** BABYLON.Observable raised when the control gets the focus */
  64041. onFocusObservable: BABYLON.Observable<InputText>;
  64042. /** BABYLON.Observable raised when the control loses the focus */
  64043. onBlurObservable: BABYLON.Observable<InputText>;
  64044. /**Observable raised when the text is highlighted */
  64045. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64046. /**Observable raised when copy event is triggered */
  64047. onTextCopyObservable: BABYLON.Observable<InputText>;
  64048. /** BABYLON.Observable raised when cut event is triggered */
  64049. onTextCutObservable: BABYLON.Observable<InputText>;
  64050. /** BABYLON.Observable raised when paste event is triggered */
  64051. onTextPasteObservable: BABYLON.Observable<InputText>;
  64052. /** BABYLON.Observable raised when a key event was processed */
  64053. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64054. /** Gets or sets the maximum width allowed by the control */
  64055. maxWidth: string | number;
  64056. /** Gets the maximum width allowed by the control in pixels */
  64057. readonly maxWidthInPixels: number;
  64058. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64059. highligherOpacity: number;
  64060. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64061. onFocusSelectAll: boolean;
  64062. /** Gets or sets the text hightlight color */
  64063. textHighlightColor: string;
  64064. /** Gets or sets control margin */
  64065. margin: string;
  64066. /** Gets control margin in pixels */
  64067. readonly marginInPixels: number;
  64068. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64069. autoStretchWidth: boolean;
  64070. /** Gets or sets border thickness */
  64071. thickness: number;
  64072. /** Gets or sets the background color when focused */
  64073. focusedBackground: string;
  64074. /** Gets or sets the background color when focused */
  64075. focusedColor: string;
  64076. /** Gets or sets the background color */
  64077. background: string;
  64078. /** Gets or sets the placeholder color */
  64079. placeholderColor: string;
  64080. /** Gets or sets the text displayed when the control is empty */
  64081. placeholderText: string;
  64082. /** Gets or sets the dead key flag */
  64083. deadKey: boolean;
  64084. /** Gets or sets the highlight text */
  64085. highlightedText: string;
  64086. /** Gets or sets if the current key should be added */
  64087. addKey: boolean;
  64088. /** Gets or sets the value of the current key being entered */
  64089. currentKey: string;
  64090. /** Gets or sets the text displayed in the control */
  64091. text: string;
  64092. /** Gets or sets control width */
  64093. width: string | number;
  64094. /**
  64095. * Creates a new InputText
  64096. * @param name defines the control name
  64097. * @param text defines the text of the control
  64098. */
  64099. constructor(name?: string | undefined, text?: string);
  64100. /** @hidden */
  64101. onBlur(): void;
  64102. /** @hidden */
  64103. onFocus(): void;
  64104. protected _getTypeName(): string;
  64105. /**
  64106. * Function called to get the list of controls that should not steal the focus from this control
  64107. * @returns an array of controls
  64108. */
  64109. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64110. /** @hidden */
  64111. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64112. /** @hidden */
  64113. private _updateValueFromCursorIndex;
  64114. /** @hidden */
  64115. private _processDblClick;
  64116. /** @hidden */
  64117. private _selectAllText;
  64118. /**
  64119. * Handles the keyboard event
  64120. * @param evt Defines the KeyboardEvent
  64121. */
  64122. processKeyboard(evt: KeyboardEvent): void;
  64123. /** @hidden */
  64124. private _onCopyText;
  64125. /** @hidden */
  64126. private _onCutText;
  64127. /** @hidden */
  64128. private _onPasteText;
  64129. _draw(context: CanvasRenderingContext2D): void;
  64130. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64131. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64132. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64133. protected _beforeRenderText(text: string): string;
  64134. dispose(): void;
  64135. }
  64136. }
  64137. declare module BABYLON.GUI {
  64138. /**
  64139. * Class used to create a 2D grid container
  64140. */
  64141. export class Grid extends Container {
  64142. name?: string | undefined;
  64143. private _rowDefinitions;
  64144. private _columnDefinitions;
  64145. private _cells;
  64146. private _childControls;
  64147. /**
  64148. * Gets the number of columns
  64149. */
  64150. readonly columnCount: number;
  64151. /**
  64152. * Gets the number of rows
  64153. */
  64154. readonly rowCount: number;
  64155. /** Gets the list of children */
  64156. readonly children: Control[];
  64157. /** Gets the list of cells (e.g. the containers) */
  64158. readonly cells: {
  64159. [key: string]: Container;
  64160. };
  64161. /**
  64162. * Gets the definition of a specific row
  64163. * @param index defines the index of the row
  64164. * @returns the row definition
  64165. */
  64166. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64167. /**
  64168. * Gets the definition of a specific column
  64169. * @param index defines the index of the column
  64170. * @returns the column definition
  64171. */
  64172. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64173. /**
  64174. * Adds a new row to the grid
  64175. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64176. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64177. * @returns the current grid
  64178. */
  64179. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64180. /**
  64181. * Adds a new column to the grid
  64182. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64183. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64184. * @returns the current grid
  64185. */
  64186. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64187. /**
  64188. * Update a row definition
  64189. * @param index defines the index of the row to update
  64190. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64191. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64192. * @returns the current grid
  64193. */
  64194. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64195. /**
  64196. * Update a column definition
  64197. * @param index defines the index of the column to update
  64198. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64199. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64200. * @returns the current grid
  64201. */
  64202. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64203. /**
  64204. * Gets the list of children stored in a specific cell
  64205. * @param row defines the row to check
  64206. * @param column defines the column to check
  64207. * @returns the list of controls
  64208. */
  64209. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64210. /**
  64211. * Gets a string representing the child cell info (row x column)
  64212. * @param child defines the control to get info from
  64213. * @returns a string containing the child cell info (row x column)
  64214. */
  64215. getChildCellInfo(child: Control): string;
  64216. private _removeCell;
  64217. private _offsetCell;
  64218. /**
  64219. * Remove a column definition at specified index
  64220. * @param index defines the index of the column to remove
  64221. * @returns the current grid
  64222. */
  64223. removeColumnDefinition(index: number): Grid;
  64224. /**
  64225. * Remove a row definition at specified index
  64226. * @param index defines the index of the row to remove
  64227. * @returns the current grid
  64228. */
  64229. removeRowDefinition(index: number): Grid;
  64230. /**
  64231. * Adds a new control to the current grid
  64232. * @param control defines the control to add
  64233. * @param row defines the row where to add the control (0 by default)
  64234. * @param column defines the column where to add the control (0 by default)
  64235. * @returns the current grid
  64236. */
  64237. addControl(control: Control, row?: number, column?: number): Grid;
  64238. /**
  64239. * Removes a control from the current container
  64240. * @param control defines the control to remove
  64241. * @returns the current container
  64242. */
  64243. removeControl(control: Control): Container;
  64244. /**
  64245. * Creates a new Grid
  64246. * @param name defines control name
  64247. */
  64248. constructor(name?: string | undefined);
  64249. protected _getTypeName(): string;
  64250. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64252. _flagDescendantsAsMatrixDirty(): void;
  64253. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64254. /** Releases associated resources */
  64255. dispose(): void;
  64256. }
  64257. }
  64258. declare module BABYLON.GUI {
  64259. /** Class used to create color pickers */
  64260. export class ColorPicker extends Control {
  64261. name?: string | undefined;
  64262. private static _Epsilon;
  64263. private _colorWheelCanvas;
  64264. private _value;
  64265. private _tmpColor;
  64266. private _pointerStartedOnSquare;
  64267. private _pointerStartedOnWheel;
  64268. private _squareLeft;
  64269. private _squareTop;
  64270. private _squareSize;
  64271. private _h;
  64272. private _s;
  64273. private _v;
  64274. private _lastPointerDownID;
  64275. /**
  64276. * BABYLON.Observable raised when the value changes
  64277. */
  64278. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64279. /** Gets or sets the color of the color picker */
  64280. value: BABYLON.Color3;
  64281. /**
  64282. * Gets or sets control width
  64283. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64284. */
  64285. width: string | number;
  64286. /**
  64287. * Gets or sets control height
  64288. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64289. */
  64290. /** Gets or sets control height */
  64291. height: string | number;
  64292. /** Gets or sets control size */
  64293. size: string | number;
  64294. /**
  64295. * Creates a new ColorPicker
  64296. * @param name defines the control name
  64297. */
  64298. constructor(name?: string | undefined);
  64299. protected _getTypeName(): string;
  64300. /** @hidden */
  64301. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64302. private _updateSquareProps;
  64303. private _drawGradientSquare;
  64304. private _drawCircle;
  64305. private _createColorWheelCanvas;
  64306. /** @hidden */
  64307. _draw(context: CanvasRenderingContext2D): void;
  64308. private _pointerIsDown;
  64309. private _updateValueFromPointer;
  64310. private _isPointOnSquare;
  64311. private _isPointOnWheel;
  64312. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64313. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64314. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64315. /**
  64316. * This function expands the color picker by creating a color picker dialog with manual
  64317. * color value input and the ability to save colors into an array to be used later in
  64318. * subsequent launches of the dialogue.
  64319. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64320. * @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.
  64321. * @returns picked color as a hex string and the saved colors array as hex strings.
  64322. */
  64323. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64324. pickerWidth?: string;
  64325. pickerHeight?: string;
  64326. headerHeight?: string;
  64327. lastColor?: string;
  64328. swatchLimit?: number;
  64329. numSwatchesPerLine?: number;
  64330. savedColors?: Array<string>;
  64331. }): Promise<{
  64332. savedColors?: string[];
  64333. pickedColor: string;
  64334. }>;
  64335. }
  64336. }
  64337. declare module BABYLON.GUI {
  64338. /** Class used to create 2D ellipse containers */
  64339. export class Ellipse extends Container {
  64340. name?: string | undefined;
  64341. private _thickness;
  64342. /** Gets or sets border thickness */
  64343. thickness: number;
  64344. /**
  64345. * Creates a new Ellipse
  64346. * @param name defines the control name
  64347. */
  64348. constructor(name?: string | undefined);
  64349. protected _getTypeName(): string;
  64350. protected _localDraw(context: CanvasRenderingContext2D): void;
  64351. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64352. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64353. }
  64354. }
  64355. declare module BABYLON.GUI {
  64356. /**
  64357. * Class used to create a password control
  64358. */
  64359. export class InputPassword extends InputText {
  64360. protected _beforeRenderText(text: string): string;
  64361. }
  64362. }
  64363. declare module BABYLON.GUI {
  64364. /** Class used to render 2D lines */
  64365. export class Line extends Control {
  64366. name?: string | undefined;
  64367. private _lineWidth;
  64368. private _x1;
  64369. private _y1;
  64370. private _x2;
  64371. private _y2;
  64372. private _dash;
  64373. private _connectedControl;
  64374. private _connectedControlDirtyObserver;
  64375. /** Gets or sets the dash pattern */
  64376. dash: Array<number>;
  64377. /** Gets or sets the control connected with the line end */
  64378. connectedControl: Control;
  64379. /** Gets or sets start coordinates on X axis */
  64380. x1: string | number;
  64381. /** Gets or sets start coordinates on Y axis */
  64382. y1: string | number;
  64383. /** Gets or sets end coordinates on X axis */
  64384. x2: string | number;
  64385. /** Gets or sets end coordinates on Y axis */
  64386. y2: string | number;
  64387. /** Gets or sets line width */
  64388. lineWidth: number;
  64389. /** Gets or sets horizontal alignment */
  64390. horizontalAlignment: number;
  64391. /** Gets or sets vertical alignment */
  64392. verticalAlignment: number;
  64393. private readonly _effectiveX2;
  64394. private readonly _effectiveY2;
  64395. /**
  64396. * Creates a new Line
  64397. * @param name defines the control name
  64398. */
  64399. constructor(name?: string | undefined);
  64400. protected _getTypeName(): string;
  64401. _draw(context: CanvasRenderingContext2D): void;
  64402. _measure(): void;
  64403. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64404. /**
  64405. * Move one end of the line given 3D cartesian coordinates.
  64406. * @param position Targeted world position
  64407. * @param scene BABYLON.Scene
  64408. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64409. */
  64410. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64411. /**
  64412. * Move one end of the line to a position in screen absolute space.
  64413. * @param projectedPosition Position in screen absolute space (X, Y)
  64414. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64415. */
  64416. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64417. }
  64418. }
  64419. declare module BABYLON.GUI {
  64420. /**
  64421. * Class used to store a point for a MultiLine object.
  64422. * The point can be pure 2D coordinates, a mesh or a control
  64423. */
  64424. export class MultiLinePoint {
  64425. private _multiLine;
  64426. private _x;
  64427. private _y;
  64428. private _control;
  64429. private _mesh;
  64430. private _controlObserver;
  64431. private _meshObserver;
  64432. /** @hidden */
  64433. _point: BABYLON.Vector2;
  64434. /**
  64435. * Creates a new MultiLinePoint
  64436. * @param multiLine defines the source MultiLine object
  64437. */
  64438. constructor(multiLine: MultiLine);
  64439. /** Gets or sets x coordinate */
  64440. x: string | number;
  64441. /** Gets or sets y coordinate */
  64442. y: string | number;
  64443. /** Gets or sets the control associated with this point */
  64444. control: BABYLON.Nullable<Control>;
  64445. /** Gets or sets the mesh associated with this point */
  64446. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64447. /** Resets links */
  64448. resetLinks(): void;
  64449. /**
  64450. * Gets a translation vector
  64451. * @returns the translation vector
  64452. */
  64453. translate(): BABYLON.Vector2;
  64454. private _translatePoint;
  64455. /** Release associated resources */
  64456. dispose(): void;
  64457. }
  64458. }
  64459. declare module BABYLON.GUI {
  64460. /**
  64461. * Class used to create multi line control
  64462. */
  64463. export class MultiLine extends Control {
  64464. name?: string | undefined;
  64465. private _lineWidth;
  64466. private _dash;
  64467. private _points;
  64468. private _minX;
  64469. private _minY;
  64470. private _maxX;
  64471. private _maxY;
  64472. /**
  64473. * Creates a new MultiLine
  64474. * @param name defines the control name
  64475. */
  64476. constructor(name?: string | undefined);
  64477. /** Gets or sets dash pattern */
  64478. dash: Array<number>;
  64479. /**
  64480. * Gets point stored at specified index
  64481. * @param index defines the index to look for
  64482. * @returns the requested point if found
  64483. */
  64484. getAt(index: number): MultiLinePoint;
  64485. /** Function called when a point is updated */
  64486. onPointUpdate: () => void;
  64487. /**
  64488. * Adds new points to the point collection
  64489. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64490. * @returns the list of created MultiLinePoint
  64491. */
  64492. add(...items: (AbstractMesh | Control | {
  64493. x: string | number;
  64494. y: string | number;
  64495. })[]): MultiLinePoint[];
  64496. /**
  64497. * Adds a new point to the point collection
  64498. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64499. * @returns the created MultiLinePoint
  64500. */
  64501. push(item?: (AbstractMesh | Control | {
  64502. x: string | number;
  64503. y: string | number;
  64504. })): MultiLinePoint;
  64505. /**
  64506. * Remove a specific value or point from the active point collection
  64507. * @param value defines the value or point to remove
  64508. */
  64509. remove(value: number | MultiLinePoint): void;
  64510. /**
  64511. * Resets this object to initial state (no point)
  64512. */
  64513. reset(): void;
  64514. /**
  64515. * Resets all links
  64516. */
  64517. resetLinks(): void;
  64518. /** Gets or sets line width */
  64519. lineWidth: number;
  64520. horizontalAlignment: number;
  64521. verticalAlignment: number;
  64522. protected _getTypeName(): string;
  64523. _draw(context: CanvasRenderingContext2D): void;
  64524. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64525. _measure(): void;
  64526. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64527. dispose(): void;
  64528. }
  64529. }
  64530. declare module BABYLON.GUI {
  64531. /**
  64532. * Class used to create radio button controls
  64533. */
  64534. export class RadioButton extends Control {
  64535. name?: string | undefined;
  64536. private _isChecked;
  64537. private _background;
  64538. private _checkSizeRatio;
  64539. private _thickness;
  64540. /** Gets or sets border thickness */
  64541. thickness: number;
  64542. /** Gets or sets group name */
  64543. group: string;
  64544. /** BABYLON.Observable raised when isChecked is changed */
  64545. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64546. /** Gets or sets a value indicating the ratio between overall size and check size */
  64547. checkSizeRatio: number;
  64548. /** Gets or sets background color */
  64549. background: string;
  64550. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64551. isChecked: boolean;
  64552. /**
  64553. * Creates a new RadioButton
  64554. * @param name defines the control name
  64555. */
  64556. constructor(name?: string | undefined);
  64557. protected _getTypeName(): string;
  64558. _draw(context: CanvasRenderingContext2D): void;
  64559. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64560. /**
  64561. * Utility function to easily create a radio button with a header
  64562. * @param title defines the label to use for the header
  64563. * @param group defines the group to use for the radio button
  64564. * @param isChecked defines the initial state of the radio button
  64565. * @param onValueChanged defines the callback to call when value changes
  64566. * @returns a StackPanel containing the radio button and a textBlock
  64567. */
  64568. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64569. }
  64570. }
  64571. declare module BABYLON.GUI {
  64572. /**
  64573. * Class used to create slider controls
  64574. */
  64575. export class BaseSlider extends Control {
  64576. name?: string | undefined;
  64577. protected _thumbWidth: ValueAndUnit;
  64578. private _minimum;
  64579. private _maximum;
  64580. private _value;
  64581. private _isVertical;
  64582. protected _barOffset: ValueAndUnit;
  64583. private _isThumbClamped;
  64584. protected _displayThumb: boolean;
  64585. private _step;
  64586. private _lastPointerDownID;
  64587. protected _effectiveBarOffset: number;
  64588. protected _renderLeft: number;
  64589. protected _renderTop: number;
  64590. protected _renderWidth: number;
  64591. protected _renderHeight: number;
  64592. protected _backgroundBoxLength: number;
  64593. protected _backgroundBoxThickness: number;
  64594. protected _effectiveThumbThickness: number;
  64595. /** BABYLON.Observable raised when the sldier value changes */
  64596. onValueChangedObservable: BABYLON.Observable<number>;
  64597. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64598. displayThumb: boolean;
  64599. /** Gets or sets a step to apply to values (0 by default) */
  64600. step: number;
  64601. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64602. barOffset: string | number;
  64603. /** Gets main bar offset in pixels*/
  64604. readonly barOffsetInPixels: number;
  64605. /** Gets or sets thumb width */
  64606. thumbWidth: string | number;
  64607. /** Gets thumb width in pixels */
  64608. readonly thumbWidthInPixels: number;
  64609. /** Gets or sets minimum value */
  64610. minimum: number;
  64611. /** Gets or sets maximum value */
  64612. maximum: number;
  64613. /** Gets or sets current value */
  64614. value: number;
  64615. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64616. isVertical: boolean;
  64617. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64618. isThumbClamped: boolean;
  64619. /**
  64620. * Creates a new BaseSlider
  64621. * @param name defines the control name
  64622. */
  64623. constructor(name?: string | undefined);
  64624. protected _getTypeName(): string;
  64625. protected _getThumbPosition(): number;
  64626. protected _getThumbThickness(type: string): number;
  64627. protected _prepareRenderingData(type: string): void;
  64628. private _pointerIsDown;
  64629. /** @hidden */
  64630. protected _updateValueFromPointer(x: number, y: number): void;
  64631. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64632. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64633. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64634. }
  64635. }
  64636. declare module BABYLON.GUI {
  64637. /**
  64638. * Class used to create slider controls
  64639. */
  64640. export class Slider extends BaseSlider {
  64641. name?: string | undefined;
  64642. private _background;
  64643. private _borderColor;
  64644. private _isThumbCircle;
  64645. protected _displayValueBar: boolean;
  64646. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64647. displayValueBar: boolean;
  64648. /** Gets or sets border color */
  64649. borderColor: string;
  64650. /** Gets or sets background color */
  64651. background: string;
  64652. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64653. isThumbCircle: boolean;
  64654. /**
  64655. * Creates a new Slider
  64656. * @param name defines the control name
  64657. */
  64658. constructor(name?: string | undefined);
  64659. protected _getTypeName(): string;
  64660. _draw(context: CanvasRenderingContext2D): void;
  64661. }
  64662. }
  64663. declare module BABYLON.GUI {
  64664. /** Class used to create a RadioGroup
  64665. * which contains groups of radio buttons
  64666. */
  64667. export class SelectorGroup {
  64668. /** name of SelectorGroup */
  64669. name: string;
  64670. private _groupPanel;
  64671. private _selectors;
  64672. private _groupHeader;
  64673. /**
  64674. * Creates a new SelectorGroup
  64675. * @param name of group, used as a group heading
  64676. */
  64677. constructor(
  64678. /** name of SelectorGroup */
  64679. name: string);
  64680. /** Gets the groupPanel of the SelectorGroup */
  64681. readonly groupPanel: StackPanel;
  64682. /** Gets the selectors array */
  64683. readonly selectors: StackPanel[];
  64684. /** Gets and sets the group header */
  64685. header: string;
  64686. /** @hidden */
  64687. private _addGroupHeader;
  64688. /** @hidden*/
  64689. _getSelector(selectorNb: number): StackPanel | undefined;
  64690. /** Removes the selector at the given position
  64691. * @param selectorNb the position of the selector within the group
  64692. */
  64693. removeSelector(selectorNb: number): void;
  64694. }
  64695. /** Class used to create a CheckboxGroup
  64696. * which contains groups of checkbox buttons
  64697. */
  64698. export class CheckboxGroup extends SelectorGroup {
  64699. /** Adds a checkbox as a control
  64700. * @param text is the label for the selector
  64701. * @param func is the function called when the Selector is checked
  64702. * @param checked is true when Selector is checked
  64703. */
  64704. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64705. /** @hidden */
  64706. _setSelectorLabel(selectorNb: number, label: string): void;
  64707. /** @hidden */
  64708. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64709. /** @hidden */
  64710. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64711. /** @hidden */
  64712. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64713. }
  64714. /** Class used to create a RadioGroup
  64715. * which contains groups of radio buttons
  64716. */
  64717. export class RadioGroup extends SelectorGroup {
  64718. private _selectNb;
  64719. /** Adds a radio button as a control
  64720. * @param label is the label for the selector
  64721. * @param func is the function called when the Selector is checked
  64722. * @param checked is true when Selector is checked
  64723. */
  64724. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64725. /** @hidden */
  64726. _setSelectorLabel(selectorNb: number, label: string): void;
  64727. /** @hidden */
  64728. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64729. /** @hidden */
  64730. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64731. /** @hidden */
  64732. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64733. }
  64734. /** Class used to create a SliderGroup
  64735. * which contains groups of slider buttons
  64736. */
  64737. export class SliderGroup extends SelectorGroup {
  64738. /**
  64739. * Adds a slider to the SelectorGroup
  64740. * @param label is the label for the SliderBar
  64741. * @param func is the function called when the Slider moves
  64742. * @param unit is a string describing the units used, eg degrees or metres
  64743. * @param min is the minimum value for the Slider
  64744. * @param max is the maximum value for the Slider
  64745. * @param value is the start value for the Slider between min and max
  64746. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64747. */
  64748. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64749. /** @hidden */
  64750. _setSelectorLabel(selectorNb: number, label: string): void;
  64751. /** @hidden */
  64752. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64753. /** @hidden */
  64754. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64755. /** @hidden */
  64756. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64757. }
  64758. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64759. * @see http://doc.babylonjs.com/how_to/selector
  64760. */
  64761. export class SelectionPanel extends Rectangle {
  64762. /** name of SelectionPanel */
  64763. name: string;
  64764. /** an array of SelectionGroups */
  64765. groups: SelectorGroup[];
  64766. private _panel;
  64767. private _buttonColor;
  64768. private _buttonBackground;
  64769. private _headerColor;
  64770. private _barColor;
  64771. private _barHeight;
  64772. private _spacerHeight;
  64773. private _labelColor;
  64774. private _groups;
  64775. private _bars;
  64776. /**
  64777. * Creates a new SelectionPanel
  64778. * @param name of SelectionPanel
  64779. * @param groups is an array of SelectionGroups
  64780. */
  64781. constructor(
  64782. /** name of SelectionPanel */
  64783. name: string,
  64784. /** an array of SelectionGroups */
  64785. groups?: SelectorGroup[]);
  64786. protected _getTypeName(): string;
  64787. /** Gets or sets the headerColor */
  64788. headerColor: string;
  64789. private _setHeaderColor;
  64790. /** Gets or sets the button color */
  64791. buttonColor: string;
  64792. private _setbuttonColor;
  64793. /** Gets or sets the label color */
  64794. labelColor: string;
  64795. private _setLabelColor;
  64796. /** Gets or sets the button background */
  64797. buttonBackground: string;
  64798. private _setButtonBackground;
  64799. /** Gets or sets the color of separator bar */
  64800. barColor: string;
  64801. private _setBarColor;
  64802. /** Gets or sets the height of separator bar */
  64803. barHeight: string;
  64804. private _setBarHeight;
  64805. /** Gets or sets the height of spacers*/
  64806. spacerHeight: string;
  64807. private _setSpacerHeight;
  64808. /** Adds a bar between groups */
  64809. private _addSpacer;
  64810. /** Add a group to the selection panel
  64811. * @param group is the selector group to add
  64812. */
  64813. addGroup(group: SelectorGroup): void;
  64814. /** Remove the group from the given position
  64815. * @param groupNb is the position of the group in the list
  64816. */
  64817. removeGroup(groupNb: number): void;
  64818. /** Change a group header label
  64819. * @param label is the new group header label
  64820. * @param groupNb is the number of the group to relabel
  64821. * */
  64822. setHeaderName(label: string, groupNb: number): void;
  64823. /** Change selector label to the one given
  64824. * @param label is the new selector label
  64825. * @param groupNb is the number of the groupcontaining the selector
  64826. * @param selectorNb is the number of the selector within a group to relabel
  64827. * */
  64828. relabel(label: string, groupNb: number, selectorNb: number): void;
  64829. /** For a given group position remove the selector at the given position
  64830. * @param groupNb is the number of the group to remove the selector from
  64831. * @param selectorNb is the number of the selector within the group
  64832. */
  64833. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64834. /** For a given group position of correct type add a checkbox button
  64835. * @param groupNb is the number of the group to remove the selector from
  64836. * @param label is the label for the selector
  64837. * @param func is the function called when the Selector is checked
  64838. * @param checked is true when Selector is checked
  64839. */
  64840. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64841. /** For a given group position of correct type add a radio button
  64842. * @param groupNb is the number of the group to remove the selector from
  64843. * @param label is the label for the selector
  64844. * @param func is the function called when the Selector is checked
  64845. * @param checked is true when Selector is checked
  64846. */
  64847. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64848. /**
  64849. * For a given slider group add a slider
  64850. * @param groupNb is the number of the group to add the slider to
  64851. * @param label is the label for the Slider
  64852. * @param func is the function called when the Slider moves
  64853. * @param unit is a string describing the units used, eg degrees or metres
  64854. * @param min is the minimum value for the Slider
  64855. * @param max is the maximum value for the Slider
  64856. * @param value is the start value for the Slider between min and max
  64857. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64858. */
  64859. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64860. }
  64861. }
  64862. declare module BABYLON.GUI {
  64863. /**
  64864. * Class used to hold a the container for ScrollViewer
  64865. * @hidden
  64866. */
  64867. export class _ScrollViewerWindow extends Container {
  64868. parentClientWidth: number;
  64869. parentClientHeight: number;
  64870. /**
  64871. * Creates a new ScrollViewerWindow
  64872. * @param name of ScrollViewerWindow
  64873. */
  64874. constructor(name?: string);
  64875. protected _getTypeName(): string;
  64876. /** @hidden */
  64877. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64878. protected _postMeasure(): void;
  64879. }
  64880. }
  64881. declare module BABYLON.GUI {
  64882. /**
  64883. * Class used to create slider controls
  64884. */
  64885. export class ScrollBar extends BaseSlider {
  64886. name?: string | undefined;
  64887. private _background;
  64888. private _borderColor;
  64889. private _thumbMeasure;
  64890. /** Gets or sets border color */
  64891. borderColor: string;
  64892. /** Gets or sets background color */
  64893. background: string;
  64894. /**
  64895. * Creates a new Slider
  64896. * @param name defines the control name
  64897. */
  64898. constructor(name?: string | undefined);
  64899. protected _getTypeName(): string;
  64900. protected _getThumbThickness(): number;
  64901. _draw(context: CanvasRenderingContext2D): void;
  64902. private _first;
  64903. private _originX;
  64904. private _originY;
  64905. /** @hidden */
  64906. protected _updateValueFromPointer(x: number, y: number): void;
  64907. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64908. }
  64909. }
  64910. declare module BABYLON.GUI {
  64911. /**
  64912. * Class used to hold a viewer window and sliders in a grid
  64913. */
  64914. export class ScrollViewer extends Rectangle {
  64915. private _grid;
  64916. private _horizontalBarSpace;
  64917. private _verticalBarSpace;
  64918. private _dragSpace;
  64919. private _horizontalBar;
  64920. private _verticalBar;
  64921. private _barColor;
  64922. private _barBackground;
  64923. private _barSize;
  64924. private _endLeft;
  64925. private _endTop;
  64926. private _window;
  64927. private _pointerIsOver;
  64928. private _wheelPrecision;
  64929. private _onPointerObserver;
  64930. private _clientWidth;
  64931. private _clientHeight;
  64932. /**
  64933. * Gets the horizontal scrollbar
  64934. */
  64935. readonly horizontalBar: ScrollBar;
  64936. /**
  64937. * Gets the vertical scrollbar
  64938. */
  64939. readonly verticalBar: ScrollBar;
  64940. /**
  64941. * Adds a new control to the current container
  64942. * @param control defines the control to add
  64943. * @returns the current container
  64944. */
  64945. addControl(control: BABYLON.Nullable<Control>): Container;
  64946. /**
  64947. * Removes a control from the current container
  64948. * @param control defines the control to remove
  64949. * @returns the current container
  64950. */
  64951. removeControl(control: Control): Container;
  64952. /** Gets the list of children */
  64953. readonly children: Control[];
  64954. _flagDescendantsAsMatrixDirty(): void;
  64955. /**
  64956. * Creates a new ScrollViewer
  64957. * @param name of ScrollViewer
  64958. */
  64959. constructor(name?: string);
  64960. /** Reset the scroll viewer window to initial size */
  64961. resetWindow(): void;
  64962. protected _getTypeName(): string;
  64963. private _buildClientSizes;
  64964. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64965. protected _postMeasure(): void;
  64966. /**
  64967. * Gets or sets the mouse wheel precision
  64968. * from 0 to 1 with a default value of 0.05
  64969. * */
  64970. wheelPrecision: number;
  64971. /** Gets or sets the bar color */
  64972. barColor: string;
  64973. /** Gets or sets the size of the bar */
  64974. barSize: number;
  64975. /** Gets or sets the bar background */
  64976. barBackground: string;
  64977. /** @hidden */
  64978. private _updateScroller;
  64979. _link(host: AdvancedDynamicTexture): void;
  64980. /** @hidden */
  64981. private _attachWheel;
  64982. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64983. /** Releases associated resources */
  64984. dispose(): void;
  64985. }
  64986. }
  64987. declare module BABYLON.GUI {
  64988. /** Class used to render a grid */
  64989. export class DisplayGrid extends Control {
  64990. name?: string | undefined;
  64991. private _cellWidth;
  64992. private _cellHeight;
  64993. private _minorLineTickness;
  64994. private _minorLineColor;
  64995. private _majorLineTickness;
  64996. private _majorLineColor;
  64997. private _majorLineFrequency;
  64998. private _background;
  64999. private _displayMajorLines;
  65000. private _displayMinorLines;
  65001. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65002. displayMinorLines: boolean;
  65003. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65004. displayMajorLines: boolean;
  65005. /** Gets or sets background color (Black by default) */
  65006. background: string;
  65007. /** Gets or sets the width of each cell (20 by default) */
  65008. cellWidth: number;
  65009. /** Gets or sets the height of each cell (20 by default) */
  65010. cellHeight: number;
  65011. /** Gets or sets the tickness of minor lines (1 by default) */
  65012. minorLineTickness: number;
  65013. /** Gets or sets the color of minor lines (DarkGray by default) */
  65014. minorLineColor: string;
  65015. /** Gets or sets the tickness of major lines (2 by default) */
  65016. majorLineTickness: number;
  65017. /** Gets or sets the color of major lines (White by default) */
  65018. majorLineColor: string;
  65019. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65020. majorLineFrequency: number;
  65021. /**
  65022. * Creates a new GridDisplayRectangle
  65023. * @param name defines the control name
  65024. */
  65025. constructor(name?: string | undefined);
  65026. _draw(context: CanvasRenderingContext2D): void;
  65027. protected _getTypeName(): string;
  65028. }
  65029. }
  65030. declare module BABYLON.GUI {
  65031. /**
  65032. * Class used to create slider controls based on images
  65033. */
  65034. export class ImageBasedSlider extends BaseSlider {
  65035. name?: string | undefined;
  65036. private _backgroundImage;
  65037. private _thumbImage;
  65038. private _valueBarImage;
  65039. private _tempMeasure;
  65040. displayThumb: boolean;
  65041. /**
  65042. * Gets or sets the image used to render the background
  65043. */
  65044. backgroundImage: Image;
  65045. /**
  65046. * Gets or sets the image used to render the value bar
  65047. */
  65048. valueBarImage: Image;
  65049. /**
  65050. * Gets or sets the image used to render the thumb
  65051. */
  65052. thumbImage: Image;
  65053. /**
  65054. * Creates a new ImageBasedSlider
  65055. * @param name defines the control name
  65056. */
  65057. constructor(name?: string | undefined);
  65058. protected _getTypeName(): string;
  65059. _draw(context: CanvasRenderingContext2D): void;
  65060. }
  65061. }
  65062. declare module BABYLON.GUI {
  65063. /**
  65064. * Forcing an export so that this code will execute
  65065. * @hidden
  65066. */
  65067. const name = "Statics";
  65068. }
  65069. declare module BABYLON.GUI {
  65070. /**
  65071. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65072. */
  65073. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65074. /**
  65075. * Define the instrumented AdvancedDynamicTexture.
  65076. */
  65077. texture: AdvancedDynamicTexture;
  65078. private _captureRenderTime;
  65079. private _renderTime;
  65080. private _captureLayoutTime;
  65081. private _layoutTime;
  65082. private _onBeginRenderObserver;
  65083. private _onEndRenderObserver;
  65084. private _onBeginLayoutObserver;
  65085. private _onEndLayoutObserver;
  65086. /**
  65087. * Gets the perf counter used to capture render time
  65088. */
  65089. readonly renderTimeCounter: BABYLON.PerfCounter;
  65090. /**
  65091. * Gets the perf counter used to capture layout time
  65092. */
  65093. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65094. /**
  65095. * Enable or disable the render time capture
  65096. */
  65097. captureRenderTime: boolean;
  65098. /**
  65099. * Enable or disable the layout time capture
  65100. */
  65101. captureLayoutTime: boolean;
  65102. /**
  65103. * Instantiates a new advanced dynamic texture instrumentation.
  65104. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65105. * @param texture Defines the AdvancedDynamicTexture to instrument
  65106. */
  65107. constructor(
  65108. /**
  65109. * Define the instrumented AdvancedDynamicTexture.
  65110. */
  65111. texture: AdvancedDynamicTexture);
  65112. /**
  65113. * Dispose and release associated resources.
  65114. */
  65115. dispose(): void;
  65116. }
  65117. }
  65118. declare module BABYLON.GUI {
  65119. /**
  65120. * Class used to create containers for controls
  65121. */
  65122. export class Container3D extends Control3D {
  65123. private _blockLayout;
  65124. /**
  65125. * Gets the list of child controls
  65126. */
  65127. protected _children: Control3D[];
  65128. /**
  65129. * Gets the list of child controls
  65130. */
  65131. readonly children: Array<Control3D>;
  65132. /**
  65133. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65134. * This is helpful to optimize layout operation when adding multiple children in a row
  65135. */
  65136. blockLayout: boolean;
  65137. /**
  65138. * Creates a new container
  65139. * @param name defines the container name
  65140. */
  65141. constructor(name?: string);
  65142. /**
  65143. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65144. * @returns the current container
  65145. */
  65146. updateLayout(): Container3D;
  65147. /**
  65148. * Gets a boolean indicating if the given control is in the children of this control
  65149. * @param control defines the control to check
  65150. * @returns true if the control is in the child list
  65151. */
  65152. containsControl(control: Control3D): boolean;
  65153. /**
  65154. * Adds a control to the children of this control
  65155. * @param control defines the control to add
  65156. * @returns the current container
  65157. */
  65158. addControl(control: Control3D): Container3D;
  65159. /**
  65160. * This function will be called everytime a new control is added
  65161. */
  65162. protected _arrangeChildren(): void;
  65163. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65164. /**
  65165. * Removes a control from the children of this control
  65166. * @param control defines the control to remove
  65167. * @returns the current container
  65168. */
  65169. removeControl(control: Control3D): Container3D;
  65170. protected _getTypeName(): string;
  65171. /**
  65172. * Releases all associated resources
  65173. */
  65174. dispose(): void;
  65175. /** Control rotation will remain unchanged */
  65176. static readonly UNSET_ORIENTATION: number;
  65177. /** Control will rotate to make it look at sphere central axis */
  65178. static readonly FACEORIGIN_ORIENTATION: number;
  65179. /** Control will rotate to make it look back at sphere central axis */
  65180. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65181. /** Control will rotate to look at z axis (0, 0, 1) */
  65182. static readonly FACEFORWARD_ORIENTATION: number;
  65183. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65184. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65185. }
  65186. }
  65187. declare module BABYLON.GUI {
  65188. /**
  65189. * Class used to manage 3D user interface
  65190. * @see http://doc.babylonjs.com/how_to/gui3d
  65191. */
  65192. export class GUI3DManager implements BABYLON.IDisposable {
  65193. private _scene;
  65194. private _sceneDisposeObserver;
  65195. private _utilityLayer;
  65196. private _rootContainer;
  65197. private _pointerObserver;
  65198. private _pointerOutObserver;
  65199. /** @hidden */
  65200. _lastPickedControl: Control3D;
  65201. /** @hidden */
  65202. _lastControlOver: {
  65203. [pointerId: number]: Control3D;
  65204. };
  65205. /** @hidden */
  65206. _lastControlDown: {
  65207. [pointerId: number]: Control3D;
  65208. };
  65209. /**
  65210. * BABYLON.Observable raised when the point picked by the pointer events changed
  65211. */
  65212. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65213. /** @hidden */
  65214. _sharedMaterials: {
  65215. [key: string]: BABYLON.Material;
  65216. };
  65217. /** Gets the hosting scene */
  65218. readonly scene: BABYLON.Scene;
  65219. /** Gets associated utility layer */
  65220. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65221. /**
  65222. * Creates a new GUI3DManager
  65223. * @param scene
  65224. */
  65225. constructor(scene?: BABYLON.Scene);
  65226. private _handlePointerOut;
  65227. private _doPicking;
  65228. /**
  65229. * Gets the root container
  65230. */
  65231. readonly rootContainer: Container3D;
  65232. /**
  65233. * Gets a boolean indicating if the given control is in the root child list
  65234. * @param control defines the control to check
  65235. * @returns true if the control is in the root child list
  65236. */
  65237. containsControl(control: Control3D): boolean;
  65238. /**
  65239. * Adds a control to the root child list
  65240. * @param control defines the control to add
  65241. * @returns the current manager
  65242. */
  65243. addControl(control: Control3D): GUI3DManager;
  65244. /**
  65245. * Removes a control from the root child list
  65246. * @param control defines the control to remove
  65247. * @returns the current container
  65248. */
  65249. removeControl(control: Control3D): GUI3DManager;
  65250. /**
  65251. * Releases all associated resources
  65252. */
  65253. dispose(): void;
  65254. }
  65255. }
  65256. declare module BABYLON.GUI {
  65257. /**
  65258. * Class used to transport BABYLON.Vector3 information for pointer events
  65259. */
  65260. export class Vector3WithInfo extends BABYLON.Vector3 {
  65261. /** defines the current mouse button index */
  65262. buttonIndex: number;
  65263. /**
  65264. * Creates a new Vector3WithInfo
  65265. * @param source defines the vector3 data to transport
  65266. * @param buttonIndex defines the current mouse button index
  65267. */
  65268. constructor(source: BABYLON.Vector3,
  65269. /** defines the current mouse button index */
  65270. buttonIndex?: number);
  65271. }
  65272. }
  65273. declare module BABYLON.GUI {
  65274. /**
  65275. * Class used as base class for controls
  65276. */
  65277. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65278. /** Defines the control name */
  65279. name?: string | undefined;
  65280. /** @hidden */
  65281. _host: GUI3DManager;
  65282. private _node;
  65283. private _downCount;
  65284. private _enterCount;
  65285. private _downPointerIds;
  65286. private _isVisible;
  65287. /** Gets or sets the control position in world space */
  65288. position: BABYLON.Vector3;
  65289. /** Gets or sets the control scaling in world space */
  65290. scaling: BABYLON.Vector3;
  65291. /** Callback used to start pointer enter animation */
  65292. pointerEnterAnimation: () => void;
  65293. /** Callback used to start pointer out animation */
  65294. pointerOutAnimation: () => void;
  65295. /** Callback used to start pointer down animation */
  65296. pointerDownAnimation: () => void;
  65297. /** Callback used to start pointer up animation */
  65298. pointerUpAnimation: () => void;
  65299. /**
  65300. * An event triggered when the pointer move over the control
  65301. */
  65302. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65303. /**
  65304. * An event triggered when the pointer move out of the control
  65305. */
  65306. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65307. /**
  65308. * An event triggered when the pointer taps the control
  65309. */
  65310. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65311. /**
  65312. * An event triggered when pointer is up
  65313. */
  65314. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65315. /**
  65316. * An event triggered when a control is clicked on (with a mouse)
  65317. */
  65318. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65319. /**
  65320. * An event triggered when pointer enters the control
  65321. */
  65322. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65323. /**
  65324. * Gets or sets the parent container
  65325. */
  65326. parent: BABYLON.Nullable<Container3D>;
  65327. private _behaviors;
  65328. /**
  65329. * Gets the list of attached behaviors
  65330. * @see http://doc.babylonjs.com/features/behaviour
  65331. */
  65332. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65333. /**
  65334. * Attach a behavior to the control
  65335. * @see http://doc.babylonjs.com/features/behaviour
  65336. * @param behavior defines the behavior to attach
  65337. * @returns the current control
  65338. */
  65339. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65340. /**
  65341. * Remove an attached behavior
  65342. * @see http://doc.babylonjs.com/features/behaviour
  65343. * @param behavior defines the behavior to attach
  65344. * @returns the current control
  65345. */
  65346. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65347. /**
  65348. * Gets an attached behavior by name
  65349. * @param name defines the name of the behavior to look for
  65350. * @see http://doc.babylonjs.com/features/behaviour
  65351. * @returns null if behavior was not found else the requested behavior
  65352. */
  65353. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65354. /** Gets or sets a boolean indicating if the control is visible */
  65355. isVisible: boolean;
  65356. /**
  65357. * Creates a new control
  65358. * @param name defines the control name
  65359. */
  65360. constructor(
  65361. /** Defines the control name */
  65362. name?: string | undefined);
  65363. /**
  65364. * Gets a string representing the class name
  65365. */
  65366. readonly typeName: string;
  65367. /**
  65368. * Get the current class name of the control.
  65369. * @returns current class name
  65370. */
  65371. getClassName(): string;
  65372. protected _getTypeName(): string;
  65373. /**
  65374. * Gets the transform node used by this control
  65375. */
  65376. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65377. /**
  65378. * Gets the mesh used to render this control
  65379. */
  65380. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65381. /**
  65382. * Link the control as child of the given node
  65383. * @param node defines the node to link to. Use null to unlink the control
  65384. * @returns the current control
  65385. */
  65386. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65387. /** @hidden **/
  65388. _prepareNode(scene: BABYLON.Scene): void;
  65389. /**
  65390. * Node creation.
  65391. * Can be overriden by children
  65392. * @param scene defines the scene where the node must be attached
  65393. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65394. */
  65395. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65396. /**
  65397. * Affect a material to the given mesh
  65398. * @param mesh defines the mesh which will represent the control
  65399. */
  65400. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65401. /** @hidden */
  65402. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65403. /** @hidden */
  65404. _onPointerEnter(target: Control3D): boolean;
  65405. /** @hidden */
  65406. _onPointerOut(target: Control3D): void;
  65407. /** @hidden */
  65408. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65409. /** @hidden */
  65410. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65411. /** @hidden */
  65412. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65413. /** @hidden */
  65414. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65415. /** @hidden */
  65416. _disposeNode(): void;
  65417. /**
  65418. * Releases all associated resources
  65419. */
  65420. dispose(): void;
  65421. }
  65422. }
  65423. declare module BABYLON.GUI {
  65424. /**
  65425. * Class used as a root to all buttons
  65426. */
  65427. export class AbstractButton3D extends Control3D {
  65428. /**
  65429. * Creates a new button
  65430. * @param name defines the control name
  65431. */
  65432. constructor(name?: string);
  65433. protected _getTypeName(): string;
  65434. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65435. }
  65436. }
  65437. declare module BABYLON.GUI {
  65438. /**
  65439. * Class used to create a button in 3D
  65440. */
  65441. export class Button3D extends AbstractButton3D {
  65442. /** @hidden */
  65443. protected _currentMaterial: BABYLON.Material;
  65444. private _facadeTexture;
  65445. private _content;
  65446. private _contentResolution;
  65447. private _contentScaleRatio;
  65448. /**
  65449. * Gets or sets the texture resolution used to render content (512 by default)
  65450. */
  65451. contentResolution: BABYLON.int;
  65452. /**
  65453. * Gets or sets the texture scale ratio used to render content (2 by default)
  65454. */
  65455. contentScaleRatio: number;
  65456. protected _disposeFacadeTexture(): void;
  65457. protected _resetContent(): void;
  65458. /**
  65459. * Creates a new button
  65460. * @param name defines the control name
  65461. */
  65462. constructor(name?: string);
  65463. /**
  65464. * Gets or sets the GUI 2D content used to display the button's facade
  65465. */
  65466. content: Control;
  65467. /**
  65468. * Apply the facade texture (created from the content property).
  65469. * This function can be overloaded by child classes
  65470. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65471. */
  65472. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65473. protected _getTypeName(): string;
  65474. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65475. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65476. /**
  65477. * Releases all associated resources
  65478. */
  65479. dispose(): void;
  65480. }
  65481. }
  65482. declare module BABYLON.GUI {
  65483. /**
  65484. * Abstract class used to create a container panel deployed on the surface of a volume
  65485. */
  65486. export abstract class VolumeBasedPanel extends Container3D {
  65487. private _columns;
  65488. private _rows;
  65489. private _rowThenColum;
  65490. private _orientation;
  65491. protected _cellWidth: number;
  65492. protected _cellHeight: number;
  65493. /**
  65494. * Gets or sets the distance between elements
  65495. */
  65496. margin: number;
  65497. /**
  65498. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65499. * | Value | Type | Description |
  65500. * | ----- | ----------------------------------- | ----------- |
  65501. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65502. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65503. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65504. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65505. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65506. */
  65507. orientation: number;
  65508. /**
  65509. * Gets or sets the number of columns requested (10 by default).
  65510. * The panel will automatically compute the number of rows based on number of child controls.
  65511. */
  65512. columns: BABYLON.int;
  65513. /**
  65514. * Gets or sets a the number of rows requested.
  65515. * The panel will automatically compute the number of columns based on number of child controls.
  65516. */
  65517. rows: BABYLON.int;
  65518. /**
  65519. * Creates new VolumeBasedPanel
  65520. */
  65521. constructor();
  65522. protected _arrangeChildren(): void;
  65523. /** Child classes must implement this function to provide correct control positioning */
  65524. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65525. /** Child classes can implement this function to provide additional processing */
  65526. protected _finalProcessing(): void;
  65527. }
  65528. }
  65529. declare module BABYLON.GUI {
  65530. /**
  65531. * Class used to create a container panel deployed on the surface of a cylinder
  65532. */
  65533. export class CylinderPanel extends VolumeBasedPanel {
  65534. private _radius;
  65535. /**
  65536. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65537. */
  65538. radius: BABYLON.float;
  65539. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65540. private _cylindricalMapping;
  65541. }
  65542. }
  65543. declare module BABYLON.GUI {
  65544. /** @hidden */
  65545. export var fluentVertexShader: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module BABYLON.GUI {
  65551. /** @hidden */
  65552. export var fluentPixelShader: {
  65553. name: string;
  65554. shader: string;
  65555. };
  65556. }
  65557. declare module BABYLON.GUI {
  65558. /** @hidden */
  65559. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65560. INNERGLOW: boolean;
  65561. BORDER: boolean;
  65562. HOVERLIGHT: boolean;
  65563. TEXTURE: boolean;
  65564. constructor();
  65565. }
  65566. /**
  65567. * Class used to render controls with fluent desgin
  65568. */
  65569. export class FluentMaterial extends BABYLON.PushMaterial {
  65570. /**
  65571. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65572. */
  65573. innerGlowColorIntensity: number;
  65574. /**
  65575. * Gets or sets the inner glow color (white by default)
  65576. */
  65577. innerGlowColor: BABYLON.Color3;
  65578. /**
  65579. * Gets or sets alpha value (default is 1.0)
  65580. */
  65581. alpha: number;
  65582. /**
  65583. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65584. */
  65585. albedoColor: BABYLON.Color3;
  65586. /**
  65587. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65588. */
  65589. renderBorders: boolean;
  65590. /**
  65591. * Gets or sets border width (default is 0.5)
  65592. */
  65593. borderWidth: number;
  65594. /**
  65595. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65596. */
  65597. edgeSmoothingValue: number;
  65598. /**
  65599. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65600. */
  65601. borderMinValue: number;
  65602. /**
  65603. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65604. */
  65605. renderHoverLight: boolean;
  65606. /**
  65607. * Gets or sets the radius used to render the hover light (default is 1.0)
  65608. */
  65609. hoverRadius: number;
  65610. /**
  65611. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65612. */
  65613. hoverColor: BABYLON.Color4;
  65614. /**
  65615. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65616. */
  65617. hoverPosition: BABYLON.Vector3;
  65618. private _albedoTexture;
  65619. /** Gets or sets the texture to use for albedo color */
  65620. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65621. /**
  65622. * Creates a new Fluent material
  65623. * @param name defines the name of the material
  65624. * @param scene defines the hosting scene
  65625. */
  65626. constructor(name: string, scene: BABYLON.Scene);
  65627. needAlphaBlending(): boolean;
  65628. needAlphaTesting(): boolean;
  65629. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65630. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65631. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65632. getActiveTextures(): BABYLON.BaseTexture[];
  65633. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65634. dispose(forceDisposeEffect?: boolean): void;
  65635. clone(name: string): FluentMaterial;
  65636. serialize(): any;
  65637. getClassName(): string;
  65638. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65639. }
  65640. }
  65641. declare module BABYLON.GUI {
  65642. /**
  65643. * Class used to create a holographic button in 3D
  65644. */
  65645. export class HolographicButton extends Button3D {
  65646. private _backPlate;
  65647. private _textPlate;
  65648. private _frontPlate;
  65649. private _text;
  65650. private _imageUrl;
  65651. private _shareMaterials;
  65652. private _frontMaterial;
  65653. private _backMaterial;
  65654. private _plateMaterial;
  65655. private _pickedPointObserver;
  65656. private _tooltipFade;
  65657. private _tooltipTextBlock;
  65658. private _tooltipTexture;
  65659. private _tooltipMesh;
  65660. private _tooltipHoverObserver;
  65661. private _tooltipOutObserver;
  65662. private _disposeTooltip;
  65663. /**
  65664. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65665. */
  65666. tooltipText: BABYLON.Nullable<string>;
  65667. /**
  65668. * Gets or sets text for the button
  65669. */
  65670. text: string;
  65671. /**
  65672. * Gets or sets the image url for the button
  65673. */
  65674. imageUrl: string;
  65675. /**
  65676. * Gets the back material used by this button
  65677. */
  65678. readonly backMaterial: FluentMaterial;
  65679. /**
  65680. * Gets the front material used by this button
  65681. */
  65682. readonly frontMaterial: FluentMaterial;
  65683. /**
  65684. * Gets the plate material used by this button
  65685. */
  65686. readonly plateMaterial: BABYLON.StandardMaterial;
  65687. /**
  65688. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65689. */
  65690. readonly shareMaterials: boolean;
  65691. /**
  65692. * Creates a new button
  65693. * @param name defines the control name
  65694. */
  65695. constructor(name?: string, shareMaterials?: boolean);
  65696. protected _getTypeName(): string;
  65697. private _rebuildContent;
  65698. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65699. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65700. private _createBackMaterial;
  65701. private _createFrontMaterial;
  65702. private _createPlateMaterial;
  65703. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65704. /**
  65705. * Releases all associated resources
  65706. */
  65707. dispose(): void;
  65708. }
  65709. }
  65710. declare module BABYLON.GUI {
  65711. /**
  65712. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65713. */
  65714. export class MeshButton3D extends Button3D {
  65715. /** @hidden */
  65716. protected _currentMesh: BABYLON.Mesh;
  65717. /**
  65718. * Creates a new 3D button based on a mesh
  65719. * @param mesh mesh to become a 3D button
  65720. * @param name defines the control name
  65721. */
  65722. constructor(mesh: BABYLON.Mesh, name?: string);
  65723. protected _getTypeName(): string;
  65724. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65725. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65726. }
  65727. }
  65728. declare module BABYLON.GUI {
  65729. /**
  65730. * Class used to create a container panel deployed on the surface of a plane
  65731. */
  65732. export class PlanePanel extends VolumeBasedPanel {
  65733. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65734. }
  65735. }
  65736. declare module BABYLON.GUI {
  65737. /**
  65738. * Class used to create a container panel where items get randomized planar mapping
  65739. */
  65740. export class ScatterPanel extends VolumeBasedPanel {
  65741. private _iteration;
  65742. /**
  65743. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65744. */
  65745. iteration: BABYLON.float;
  65746. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65747. private _scatterMapping;
  65748. protected _finalProcessing(): void;
  65749. }
  65750. }
  65751. declare module BABYLON.GUI {
  65752. /**
  65753. * Class used to create a container panel deployed on the surface of a sphere
  65754. */
  65755. export class SpherePanel extends VolumeBasedPanel {
  65756. private _radius;
  65757. /**
  65758. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65759. */
  65760. radius: BABYLON.float;
  65761. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65762. private _sphericalMapping;
  65763. }
  65764. }
  65765. declare module BABYLON.GUI {
  65766. /**
  65767. * Class used to create a stack panel in 3D on XY plane
  65768. */
  65769. export class StackPanel3D extends Container3D {
  65770. private _isVertical;
  65771. /**
  65772. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65773. */
  65774. isVertical: boolean;
  65775. /**
  65776. * Gets or sets the distance between elements
  65777. */
  65778. margin: number;
  65779. /**
  65780. * Creates new StackPanel
  65781. * @param isVertical
  65782. */
  65783. constructor(isVertical?: boolean);
  65784. protected _arrangeChildren(): void;
  65785. }
  65786. }
  65787. declare module BABYLON {
  65788. /**
  65789. * Mode that determines the coordinate system to use.
  65790. */
  65791. export enum GLTFLoaderCoordinateSystemMode {
  65792. /**
  65793. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65794. */
  65795. AUTO = 0,
  65796. /**
  65797. * Sets the useRightHandedSystem flag on the scene.
  65798. */
  65799. FORCE_RIGHT_HANDED = 1
  65800. }
  65801. /**
  65802. * Mode that determines what animations will start.
  65803. */
  65804. export enum GLTFLoaderAnimationStartMode {
  65805. /**
  65806. * No animation will start.
  65807. */
  65808. NONE = 0,
  65809. /**
  65810. * The first animation will start.
  65811. */
  65812. FIRST = 1,
  65813. /**
  65814. * All animations will start.
  65815. */
  65816. ALL = 2
  65817. }
  65818. /**
  65819. * Interface that contains the data for the glTF asset.
  65820. */
  65821. export interface IGLTFLoaderData {
  65822. /**
  65823. * Object that represents the glTF JSON.
  65824. */
  65825. json: Object;
  65826. /**
  65827. * The BIN chunk of a binary glTF.
  65828. */
  65829. bin: Nullable<ArrayBufferView>;
  65830. }
  65831. /**
  65832. * Interface for extending the loader.
  65833. */
  65834. export interface IGLTFLoaderExtension {
  65835. /**
  65836. * The name of this extension.
  65837. */
  65838. readonly name: string;
  65839. /**
  65840. * Defines whether this extension is enabled.
  65841. */
  65842. enabled: boolean;
  65843. }
  65844. /**
  65845. * Loader state.
  65846. */
  65847. export enum GLTFLoaderState {
  65848. /**
  65849. * The asset is loading.
  65850. */
  65851. LOADING = 0,
  65852. /**
  65853. * The asset is ready for rendering.
  65854. */
  65855. READY = 1,
  65856. /**
  65857. * The asset is completely loaded.
  65858. */
  65859. COMPLETE = 2
  65860. }
  65861. /** @hidden */
  65862. export interface IGLTFLoader extends IDisposable {
  65863. readonly state: Nullable<GLTFLoaderState>;
  65864. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65865. meshes: AbstractMesh[];
  65866. particleSystems: IParticleSystem[];
  65867. skeletons: Skeleton[];
  65868. animationGroups: AnimationGroup[];
  65869. }>;
  65870. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65871. }
  65872. /**
  65873. * File loader for loading glTF files into a scene.
  65874. */
  65875. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65876. /** @hidden */
  65877. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65878. /** @hidden */
  65879. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65880. /**
  65881. * Raised when the asset has been parsed
  65882. */
  65883. onParsedObservable: Observable<IGLTFLoaderData>;
  65884. private _onParsedObserver;
  65885. /**
  65886. * Raised when the asset has been parsed
  65887. */
  65888. onParsed: (loaderData: IGLTFLoaderData) => void;
  65889. /**
  65890. * 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.
  65891. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65892. * Defaults to true.
  65893. * @hidden
  65894. */
  65895. static IncrementalLoading: boolean;
  65896. /**
  65897. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65898. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65899. * @hidden
  65900. */
  65901. static HomogeneousCoordinates: boolean;
  65902. /**
  65903. * The coordinate system mode. Defaults to AUTO.
  65904. */
  65905. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65906. /**
  65907. * The animation start mode. Defaults to FIRST.
  65908. */
  65909. animationStartMode: GLTFLoaderAnimationStartMode;
  65910. /**
  65911. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65912. */
  65913. compileMaterials: boolean;
  65914. /**
  65915. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65916. */
  65917. useClipPlane: boolean;
  65918. /**
  65919. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65920. */
  65921. compileShadowGenerators: boolean;
  65922. /**
  65923. * Defines if the Alpha blended materials are only applied as coverage.
  65924. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65925. * If true, no extra effects are applied to transparent pixels.
  65926. */
  65927. transparencyAsCoverage: boolean;
  65928. /**
  65929. * Function called before loading a url referenced by the asset.
  65930. */
  65931. preprocessUrlAsync: (url: string) => Promise<string>;
  65932. /**
  65933. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65934. */
  65935. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65936. private _onMeshLoadedObserver;
  65937. /**
  65938. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65939. */
  65940. onMeshLoaded: (mesh: AbstractMesh) => void;
  65941. /**
  65942. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65943. */
  65944. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65945. private _onTextureLoadedObserver;
  65946. /**
  65947. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65948. */
  65949. onTextureLoaded: (texture: BaseTexture) => void;
  65950. /**
  65951. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65952. */
  65953. readonly onMaterialLoadedObservable: Observable<Material>;
  65954. private _onMaterialLoadedObserver;
  65955. /**
  65956. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65957. */
  65958. onMaterialLoaded: (material: Material) => void;
  65959. /**
  65960. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65961. */
  65962. readonly onCameraLoadedObservable: Observable<Camera>;
  65963. private _onCameraLoadedObserver;
  65964. /**
  65965. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65966. */
  65967. onCameraLoaded: (camera: Camera) => void;
  65968. /**
  65969. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65970. * For assets with LODs, raised when all of the LODs are complete.
  65971. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65972. */
  65973. readonly onCompleteObservable: Observable<void>;
  65974. private _onCompleteObserver;
  65975. /**
  65976. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65977. * For assets with LODs, raised when all of the LODs are complete.
  65978. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65979. */
  65980. onComplete: () => void;
  65981. /**
  65982. * Observable raised when an error occurs.
  65983. */
  65984. readonly onErrorObservable: Observable<any>;
  65985. private _onErrorObserver;
  65986. /**
  65987. * Callback raised when an error occurs.
  65988. */
  65989. onError: (reason: any) => void;
  65990. /**
  65991. * Observable raised after the loader is disposed.
  65992. */
  65993. readonly onDisposeObservable: Observable<void>;
  65994. private _onDisposeObserver;
  65995. /**
  65996. * Callback raised after the loader is disposed.
  65997. */
  65998. onDispose: () => void;
  65999. /**
  66000. * Observable raised after a loader extension is created.
  66001. * Set additional options for a loader extension in this event.
  66002. */
  66003. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66004. private _onExtensionLoadedObserver;
  66005. /**
  66006. * Callback raised after a loader extension is created.
  66007. */
  66008. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66009. /**
  66010. * Defines if the loader logging is enabled.
  66011. */
  66012. loggingEnabled: boolean;
  66013. /**
  66014. * Defines if the loader should capture performance counters.
  66015. */
  66016. capturePerformanceCounters: boolean;
  66017. /**
  66018. * Defines if the loader should validate the asset.
  66019. */
  66020. validate: boolean;
  66021. /**
  66022. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66023. */
  66024. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66025. private _onValidatedObserver;
  66026. /**
  66027. * Callback raised after a loader extension is created.
  66028. */
  66029. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66030. private _loader;
  66031. /**
  66032. * Name of the loader ("gltf")
  66033. */
  66034. name: string;
  66035. /**
  66036. * Supported file extensions of the loader (.gltf, .glb)
  66037. */
  66038. extensions: ISceneLoaderPluginExtensions;
  66039. /**
  66040. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66041. */
  66042. dispose(): void;
  66043. /** @hidden */
  66044. _clear(): void;
  66045. /**
  66046. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66047. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66048. * @param scene the scene the meshes should be added to
  66049. * @param data the glTF data to load
  66050. * @param rootUrl root url to load from
  66051. * @param onProgress event that fires when loading progress has occured
  66052. * @param fileName Defines the name of the file to load
  66053. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66054. */
  66055. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66056. meshes: AbstractMesh[];
  66057. particleSystems: IParticleSystem[];
  66058. skeletons: Skeleton[];
  66059. animationGroups: AnimationGroup[];
  66060. }>;
  66061. /**
  66062. * Imports all objects from the loaded glTF data and adds them to the scene
  66063. * @param scene the scene the objects should be added to
  66064. * @param data the glTF data to load
  66065. * @param rootUrl root url to load from
  66066. * @param onProgress event that fires when loading progress has occured
  66067. * @param fileName Defines the name of the file to load
  66068. * @returns a promise which completes when objects have been loaded to the scene
  66069. */
  66070. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66071. /**
  66072. * Load into an asset container.
  66073. * @param scene The scene to load into
  66074. * @param data The data to import
  66075. * @param rootUrl The root url for scene and resources
  66076. * @param onProgress The callback when the load progresses
  66077. * @param fileName Defines the name of the file to load
  66078. * @returns The loaded asset container
  66079. */
  66080. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66081. /**
  66082. * If the data string can be loaded directly.
  66083. * @param data string contianing the file data
  66084. * @returns if the data can be loaded directly
  66085. */
  66086. canDirectLoad(data: string): boolean;
  66087. /**
  66088. * Rewrites a url by combining a root url and response url.
  66089. */
  66090. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66091. /**
  66092. * Instantiates a glTF file loader plugin.
  66093. * @returns the created plugin
  66094. */
  66095. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66096. /**
  66097. * The loader state or null if the loader is not active.
  66098. */
  66099. readonly loaderState: Nullable<GLTFLoaderState>;
  66100. /**
  66101. * Returns a promise that resolves when the asset is completely loaded.
  66102. * @returns a promise that resolves when the asset is completely loaded.
  66103. */
  66104. whenCompleteAsync(): Promise<void>;
  66105. private _parseAsync;
  66106. private _validateAsync;
  66107. private _getLoader;
  66108. private _unpackBinary;
  66109. private _unpackBinaryV1;
  66110. private _unpackBinaryV2;
  66111. private static _parseVersion;
  66112. private static _compareVersion;
  66113. private static _decodeBufferToText;
  66114. private static readonly _logSpaces;
  66115. private _logIndentLevel;
  66116. private _loggingEnabled;
  66117. /** @hidden */
  66118. _log: (message: string) => void;
  66119. /** @hidden */
  66120. _logOpen(message: string): void;
  66121. /** @hidden */
  66122. _logClose(): void;
  66123. private _logEnabled;
  66124. private _logDisabled;
  66125. private _capturePerformanceCounters;
  66126. /** @hidden */
  66127. _startPerformanceCounter: (counterName: string) => void;
  66128. /** @hidden */
  66129. _endPerformanceCounter: (counterName: string) => void;
  66130. private _startPerformanceCounterEnabled;
  66131. private _startPerformanceCounterDisabled;
  66132. private _endPerformanceCounterEnabled;
  66133. private _endPerformanceCounterDisabled;
  66134. }
  66135. }
  66136. declare module BABYLON.GLTF1 {
  66137. /**
  66138. * Enums
  66139. * @hidden
  66140. */
  66141. export enum EComponentType {
  66142. BYTE = 5120,
  66143. UNSIGNED_BYTE = 5121,
  66144. SHORT = 5122,
  66145. UNSIGNED_SHORT = 5123,
  66146. FLOAT = 5126
  66147. }
  66148. /** @hidden */
  66149. export enum EShaderType {
  66150. FRAGMENT = 35632,
  66151. VERTEX = 35633
  66152. }
  66153. /** @hidden */
  66154. export enum EParameterType {
  66155. BYTE = 5120,
  66156. UNSIGNED_BYTE = 5121,
  66157. SHORT = 5122,
  66158. UNSIGNED_SHORT = 5123,
  66159. INT = 5124,
  66160. UNSIGNED_INT = 5125,
  66161. FLOAT = 5126,
  66162. FLOAT_VEC2 = 35664,
  66163. FLOAT_VEC3 = 35665,
  66164. FLOAT_VEC4 = 35666,
  66165. INT_VEC2 = 35667,
  66166. INT_VEC3 = 35668,
  66167. INT_VEC4 = 35669,
  66168. BOOL = 35670,
  66169. BOOL_VEC2 = 35671,
  66170. BOOL_VEC3 = 35672,
  66171. BOOL_VEC4 = 35673,
  66172. FLOAT_MAT2 = 35674,
  66173. FLOAT_MAT3 = 35675,
  66174. FLOAT_MAT4 = 35676,
  66175. SAMPLER_2D = 35678
  66176. }
  66177. /** @hidden */
  66178. export enum ETextureWrapMode {
  66179. CLAMP_TO_EDGE = 33071,
  66180. MIRRORED_REPEAT = 33648,
  66181. REPEAT = 10497
  66182. }
  66183. /** @hidden */
  66184. export enum ETextureFilterType {
  66185. NEAREST = 9728,
  66186. LINEAR = 9728,
  66187. NEAREST_MIPMAP_NEAREST = 9984,
  66188. LINEAR_MIPMAP_NEAREST = 9985,
  66189. NEAREST_MIPMAP_LINEAR = 9986,
  66190. LINEAR_MIPMAP_LINEAR = 9987
  66191. }
  66192. /** @hidden */
  66193. export enum ETextureFormat {
  66194. ALPHA = 6406,
  66195. RGB = 6407,
  66196. RGBA = 6408,
  66197. LUMINANCE = 6409,
  66198. LUMINANCE_ALPHA = 6410
  66199. }
  66200. /** @hidden */
  66201. export enum ECullingType {
  66202. FRONT = 1028,
  66203. BACK = 1029,
  66204. FRONT_AND_BACK = 1032
  66205. }
  66206. /** @hidden */
  66207. export enum EBlendingFunction {
  66208. ZERO = 0,
  66209. ONE = 1,
  66210. SRC_COLOR = 768,
  66211. ONE_MINUS_SRC_COLOR = 769,
  66212. DST_COLOR = 774,
  66213. ONE_MINUS_DST_COLOR = 775,
  66214. SRC_ALPHA = 770,
  66215. ONE_MINUS_SRC_ALPHA = 771,
  66216. DST_ALPHA = 772,
  66217. ONE_MINUS_DST_ALPHA = 773,
  66218. CONSTANT_COLOR = 32769,
  66219. ONE_MINUS_CONSTANT_COLOR = 32770,
  66220. CONSTANT_ALPHA = 32771,
  66221. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66222. SRC_ALPHA_SATURATE = 776
  66223. }
  66224. /** @hidden */
  66225. export interface IGLTFProperty {
  66226. extensions?: {
  66227. [key: string]: any;
  66228. };
  66229. extras?: Object;
  66230. }
  66231. /** @hidden */
  66232. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66233. name?: string;
  66234. }
  66235. /** @hidden */
  66236. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66237. bufferView: string;
  66238. byteOffset: number;
  66239. byteStride: number;
  66240. count: number;
  66241. type: string;
  66242. componentType: EComponentType;
  66243. max?: number[];
  66244. min?: number[];
  66245. name?: string;
  66246. }
  66247. /** @hidden */
  66248. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66249. buffer: string;
  66250. byteOffset: number;
  66251. byteLength: number;
  66252. byteStride: number;
  66253. target?: number;
  66254. }
  66255. /** @hidden */
  66256. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66257. uri: string;
  66258. byteLength?: number;
  66259. type?: string;
  66260. }
  66261. /** @hidden */
  66262. export interface IGLTFShader extends IGLTFChildRootProperty {
  66263. uri: string;
  66264. type: EShaderType;
  66265. }
  66266. /** @hidden */
  66267. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66268. attributes: string[];
  66269. fragmentShader: string;
  66270. vertexShader: string;
  66271. }
  66272. /** @hidden */
  66273. export interface IGLTFTechniqueParameter {
  66274. type: number;
  66275. count?: number;
  66276. semantic?: string;
  66277. node?: string;
  66278. value?: number | boolean | string | Array<any>;
  66279. source?: string;
  66280. babylonValue?: any;
  66281. }
  66282. /** @hidden */
  66283. export interface IGLTFTechniqueCommonProfile {
  66284. lightingModel: string;
  66285. texcoordBindings: Object;
  66286. parameters?: Array<any>;
  66287. }
  66288. /** @hidden */
  66289. export interface IGLTFTechniqueStatesFunctions {
  66290. blendColor?: number[];
  66291. blendEquationSeparate?: number[];
  66292. blendFuncSeparate?: number[];
  66293. colorMask: boolean[];
  66294. cullFace: number[];
  66295. }
  66296. /** @hidden */
  66297. export interface IGLTFTechniqueStates {
  66298. enable: number[];
  66299. functions: IGLTFTechniqueStatesFunctions;
  66300. }
  66301. /** @hidden */
  66302. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66303. parameters: {
  66304. [key: string]: IGLTFTechniqueParameter;
  66305. };
  66306. program: string;
  66307. attributes: {
  66308. [key: string]: string;
  66309. };
  66310. uniforms: {
  66311. [key: string]: string;
  66312. };
  66313. states: IGLTFTechniqueStates;
  66314. }
  66315. /** @hidden */
  66316. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66317. technique?: string;
  66318. values: string[];
  66319. }
  66320. /** @hidden */
  66321. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66322. attributes: {
  66323. [key: string]: string;
  66324. };
  66325. indices: string;
  66326. material: string;
  66327. mode?: number;
  66328. }
  66329. /** @hidden */
  66330. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66331. primitives: IGLTFMeshPrimitive[];
  66332. }
  66333. /** @hidden */
  66334. export interface IGLTFImage extends IGLTFChildRootProperty {
  66335. uri: string;
  66336. }
  66337. /** @hidden */
  66338. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66339. magFilter?: number;
  66340. minFilter?: number;
  66341. wrapS?: number;
  66342. wrapT?: number;
  66343. }
  66344. /** @hidden */
  66345. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66346. sampler: string;
  66347. source: string;
  66348. format?: ETextureFormat;
  66349. internalFormat?: ETextureFormat;
  66350. target?: number;
  66351. type?: number;
  66352. babylonTexture?: Texture;
  66353. }
  66354. /** @hidden */
  66355. export interface IGLTFAmbienLight {
  66356. color?: number[];
  66357. }
  66358. /** @hidden */
  66359. export interface IGLTFDirectionalLight {
  66360. color?: number[];
  66361. }
  66362. /** @hidden */
  66363. export interface IGLTFPointLight {
  66364. color?: number[];
  66365. constantAttenuation?: number;
  66366. linearAttenuation?: number;
  66367. quadraticAttenuation?: number;
  66368. }
  66369. /** @hidden */
  66370. export interface IGLTFSpotLight {
  66371. color?: number[];
  66372. constantAttenuation?: number;
  66373. fallOfAngle?: number;
  66374. fallOffExponent?: number;
  66375. linearAttenuation?: number;
  66376. quadraticAttenuation?: number;
  66377. }
  66378. /** @hidden */
  66379. export interface IGLTFLight extends IGLTFChildRootProperty {
  66380. type: string;
  66381. }
  66382. /** @hidden */
  66383. export interface IGLTFCameraOrthographic {
  66384. xmag: number;
  66385. ymag: number;
  66386. zfar: number;
  66387. znear: number;
  66388. }
  66389. /** @hidden */
  66390. export interface IGLTFCameraPerspective {
  66391. aspectRatio: number;
  66392. yfov: number;
  66393. zfar: number;
  66394. znear: number;
  66395. }
  66396. /** @hidden */
  66397. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66398. type: string;
  66399. }
  66400. /** @hidden */
  66401. export interface IGLTFAnimationChannelTarget {
  66402. id: string;
  66403. path: string;
  66404. }
  66405. /** @hidden */
  66406. export interface IGLTFAnimationChannel {
  66407. sampler: string;
  66408. target: IGLTFAnimationChannelTarget;
  66409. }
  66410. /** @hidden */
  66411. export interface IGLTFAnimationSampler {
  66412. input: string;
  66413. output: string;
  66414. interpolation?: string;
  66415. }
  66416. /** @hidden */
  66417. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66418. channels?: IGLTFAnimationChannel[];
  66419. parameters?: {
  66420. [key: string]: string;
  66421. };
  66422. samplers?: {
  66423. [key: string]: IGLTFAnimationSampler;
  66424. };
  66425. }
  66426. /** @hidden */
  66427. export interface IGLTFNodeInstanceSkin {
  66428. skeletons: string[];
  66429. skin: string;
  66430. meshes: string[];
  66431. }
  66432. /** @hidden */
  66433. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66434. bindShapeMatrix: number[];
  66435. inverseBindMatrices: string;
  66436. jointNames: string[];
  66437. babylonSkeleton?: Skeleton;
  66438. }
  66439. /** @hidden */
  66440. export interface IGLTFNode extends IGLTFChildRootProperty {
  66441. camera?: string;
  66442. children: string[];
  66443. skin?: string;
  66444. jointName?: string;
  66445. light?: string;
  66446. matrix: number[];
  66447. mesh?: string;
  66448. meshes?: string[];
  66449. rotation?: number[];
  66450. scale?: number[];
  66451. translation?: number[];
  66452. babylonNode?: Node;
  66453. }
  66454. /** @hidden */
  66455. export interface IGLTFScene extends IGLTFChildRootProperty {
  66456. nodes: string[];
  66457. }
  66458. /** @hidden */
  66459. export interface IGLTFRuntime {
  66460. extensions: {
  66461. [key: string]: any;
  66462. };
  66463. accessors: {
  66464. [key: string]: IGLTFAccessor;
  66465. };
  66466. buffers: {
  66467. [key: string]: IGLTFBuffer;
  66468. };
  66469. bufferViews: {
  66470. [key: string]: IGLTFBufferView;
  66471. };
  66472. meshes: {
  66473. [key: string]: IGLTFMesh;
  66474. };
  66475. lights: {
  66476. [key: string]: IGLTFLight;
  66477. };
  66478. cameras: {
  66479. [key: string]: IGLTFCamera;
  66480. };
  66481. nodes: {
  66482. [key: string]: IGLTFNode;
  66483. };
  66484. images: {
  66485. [key: string]: IGLTFImage;
  66486. };
  66487. textures: {
  66488. [key: string]: IGLTFTexture;
  66489. };
  66490. shaders: {
  66491. [key: string]: IGLTFShader;
  66492. };
  66493. programs: {
  66494. [key: string]: IGLTFProgram;
  66495. };
  66496. samplers: {
  66497. [key: string]: IGLTFSampler;
  66498. };
  66499. techniques: {
  66500. [key: string]: IGLTFTechnique;
  66501. };
  66502. materials: {
  66503. [key: string]: IGLTFMaterial;
  66504. };
  66505. animations: {
  66506. [key: string]: IGLTFAnimation;
  66507. };
  66508. skins: {
  66509. [key: string]: IGLTFSkins;
  66510. };
  66511. currentScene?: Object;
  66512. scenes: {
  66513. [key: string]: IGLTFScene;
  66514. };
  66515. extensionsUsed: string[];
  66516. extensionsRequired?: string[];
  66517. buffersCount: number;
  66518. shaderscount: number;
  66519. scene: Scene;
  66520. rootUrl: string;
  66521. loadedBufferCount: number;
  66522. loadedBufferViews: {
  66523. [name: string]: ArrayBufferView;
  66524. };
  66525. loadedShaderCount: number;
  66526. importOnlyMeshes: boolean;
  66527. importMeshesNames?: string[];
  66528. dummyNodes: Node[];
  66529. }
  66530. /** @hidden */
  66531. export interface INodeToRoot {
  66532. bone: Bone;
  66533. node: IGLTFNode;
  66534. id: string;
  66535. }
  66536. /** @hidden */
  66537. export interface IJointNode {
  66538. node: IGLTFNode;
  66539. id: string;
  66540. }
  66541. }
  66542. declare module BABYLON.GLTF1 {
  66543. /**
  66544. * Utils functions for GLTF
  66545. * @hidden
  66546. */
  66547. export class GLTFUtils {
  66548. /**
  66549. * Sets the given "parameter" matrix
  66550. * @param scene: the Scene object
  66551. * @param source: the source node where to pick the matrix
  66552. * @param parameter: the GLTF technique parameter
  66553. * @param uniformName: the name of the shader's uniform
  66554. * @param shaderMaterial: the shader material
  66555. */
  66556. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66557. /**
  66558. * Sets the given "parameter" matrix
  66559. * @param shaderMaterial: the shader material
  66560. * @param uniform: the name of the shader's uniform
  66561. * @param value: the value of the uniform
  66562. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66563. */
  66564. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66565. /**
  66566. * Returns the wrap mode of the texture
  66567. * @param mode: the mode value
  66568. */
  66569. static GetWrapMode(mode: number): number;
  66570. /**
  66571. * Returns the byte stride giving an accessor
  66572. * @param accessor: the GLTF accessor objet
  66573. */
  66574. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66575. /**
  66576. * Returns the texture filter mode giving a mode value
  66577. * @param mode: the filter mode value
  66578. */
  66579. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66580. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66581. /**
  66582. * Returns a buffer from its accessor
  66583. * @param gltfRuntime: the GLTF runtime
  66584. * @param accessor: the GLTF accessor
  66585. */
  66586. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66587. /**
  66588. * Decodes a buffer view into a string
  66589. * @param view: the buffer view
  66590. */
  66591. static DecodeBufferToText(view: ArrayBufferView): string;
  66592. /**
  66593. * Returns the default material of gltf. Related to
  66594. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66595. * @param scene: the Babylon.js scene
  66596. */
  66597. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66598. private static _DefaultMaterial;
  66599. }
  66600. }
  66601. declare module BABYLON.GLTF1 {
  66602. /**
  66603. * Implementation of the base glTF spec
  66604. * @hidden
  66605. */
  66606. export class GLTFLoaderBase {
  66607. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66608. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66609. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66610. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66611. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66612. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66613. }
  66614. /**
  66615. * glTF V1 Loader
  66616. * @hidden
  66617. */
  66618. export class GLTFLoader implements IGLTFLoader {
  66619. static Extensions: {
  66620. [name: string]: GLTFLoaderExtension;
  66621. };
  66622. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66623. state: Nullable<GLTFLoaderState>;
  66624. dispose(): void;
  66625. private _importMeshAsync;
  66626. /**
  66627. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66628. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66629. * @param scene the scene the meshes should be added to
  66630. * @param data gltf data containing information of the meshes in a loaded file
  66631. * @param rootUrl root url to load from
  66632. * @param onProgress event that fires when loading progress has occured
  66633. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66634. */
  66635. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66636. meshes: AbstractMesh[];
  66637. particleSystems: IParticleSystem[];
  66638. skeletons: Skeleton[];
  66639. animationGroups: AnimationGroup[];
  66640. }>;
  66641. private _loadAsync;
  66642. /**
  66643. * Imports all objects from a loaded gltf file and adds them to the scene
  66644. * @param scene the scene the objects should be added to
  66645. * @param data gltf data containing information of the meshes in a loaded file
  66646. * @param rootUrl root url to load from
  66647. * @param onProgress event that fires when loading progress has occured
  66648. * @returns a promise which completes when objects have been loaded to the scene
  66649. */
  66650. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66651. private _loadShadersAsync;
  66652. private _loadBuffersAsync;
  66653. private _createNodes;
  66654. }
  66655. /** @hidden */
  66656. export abstract class GLTFLoaderExtension {
  66657. private _name;
  66658. constructor(name: string);
  66659. readonly name: string;
  66660. /**
  66661. * Defines an override for loading the runtime
  66662. * Return true to stop further extensions from loading the runtime
  66663. */
  66664. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66665. /**
  66666. * Defines an onverride for creating gltf runtime
  66667. * Return true to stop further extensions from creating the runtime
  66668. */
  66669. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66670. /**
  66671. * Defines an override for loading buffers
  66672. * Return true to stop further extensions from loading this buffer
  66673. */
  66674. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66675. /**
  66676. * Defines an override for loading texture buffers
  66677. * Return true to stop further extensions from loading this texture data
  66678. */
  66679. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66680. /**
  66681. * Defines an override for creating textures
  66682. * Return true to stop further extensions from loading this texture
  66683. */
  66684. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66685. /**
  66686. * Defines an override for loading shader strings
  66687. * Return true to stop further extensions from loading this shader data
  66688. */
  66689. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66690. /**
  66691. * Defines an override for loading materials
  66692. * Return true to stop further extensions from loading this material
  66693. */
  66694. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66695. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66696. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66697. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66698. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66699. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66700. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66701. private static LoadTextureBufferAsync;
  66702. private static CreateTextureAsync;
  66703. private static ApplyExtensions;
  66704. }
  66705. }
  66706. declare module BABYLON.GLTF1 {
  66707. /** @hidden */
  66708. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66709. private _bin;
  66710. constructor();
  66711. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66712. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66713. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66714. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66715. }
  66716. }
  66717. declare module BABYLON.GLTF1 {
  66718. /** @hidden */
  66719. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66720. constructor();
  66721. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66722. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66723. private _loadTexture;
  66724. }
  66725. }
  66726. declare module BABYLON.GLTF2.Loader {
  66727. /**
  66728. * Loader interface with an index field.
  66729. */
  66730. export interface IArrayItem {
  66731. /**
  66732. * The index of this item in the array.
  66733. */
  66734. index: number;
  66735. }
  66736. /**
  66737. * Loader interface with additional members.
  66738. */
  66739. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66740. /** @hidden */
  66741. _data?: Promise<ArrayBufferView>;
  66742. /** @hidden */
  66743. _babylonVertexBuffer?: Promise<VertexBuffer>;
  66744. }
  66745. /**
  66746. * Loader interface with additional members.
  66747. */
  66748. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66749. }
  66750. /** @hidden */
  66751. export interface _IAnimationSamplerData {
  66752. input: Float32Array;
  66753. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66754. output: Float32Array;
  66755. }
  66756. /**
  66757. * Loader interface with additional members.
  66758. */
  66759. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66760. /** @hidden */
  66761. _data?: Promise<_IAnimationSamplerData>;
  66762. }
  66763. /**
  66764. * Loader interface with additional members.
  66765. */
  66766. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66767. channels: IAnimationChannel[];
  66768. samplers: IAnimationSampler[];
  66769. /** @hidden */
  66770. _babylonAnimationGroup?: AnimationGroup;
  66771. }
  66772. /**
  66773. * Loader interface with additional members.
  66774. */
  66775. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66776. /** @hidden */
  66777. _data?: Promise<ArrayBufferView>;
  66778. }
  66779. /**
  66780. * Loader interface with additional members.
  66781. */
  66782. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66783. /** @hidden */
  66784. _data?: Promise<ArrayBufferView>;
  66785. /** @hidden */
  66786. _babylonBuffer?: Promise<Buffer>;
  66787. }
  66788. /**
  66789. * Loader interface with additional members.
  66790. */
  66791. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66792. }
  66793. /**
  66794. * Loader interface with additional members.
  66795. */
  66796. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66797. /** @hidden */
  66798. _data?: Promise<ArrayBufferView>;
  66799. }
  66800. /**
  66801. * Loader interface with additional members.
  66802. */
  66803. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66804. }
  66805. /**
  66806. * Loader interface with additional members.
  66807. */
  66808. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66809. }
  66810. /**
  66811. * Loader interface with additional members.
  66812. */
  66813. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66814. baseColorTexture?: ITextureInfo;
  66815. metallicRoughnessTexture?: ITextureInfo;
  66816. }
  66817. /**
  66818. * Loader interface with additional members.
  66819. */
  66820. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66821. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66822. normalTexture?: IMaterialNormalTextureInfo;
  66823. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66824. emissiveTexture?: ITextureInfo;
  66825. /** @hidden */
  66826. _data?: {
  66827. [babylonDrawMode: number]: {
  66828. babylonMaterial: Material;
  66829. babylonMeshes: AbstractMesh[];
  66830. promise: Promise<void>;
  66831. };
  66832. };
  66833. }
  66834. /**
  66835. * Loader interface with additional members.
  66836. */
  66837. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66838. primitives: IMeshPrimitive[];
  66839. }
  66840. /**
  66841. * Loader interface with additional members.
  66842. */
  66843. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66844. /** @hidden */
  66845. _instanceData?: {
  66846. babylonSourceMesh: Mesh;
  66847. promise: Promise<any>;
  66848. };
  66849. }
  66850. /**
  66851. * Loader interface with additional members.
  66852. */
  66853. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66854. /**
  66855. * The parent glTF node.
  66856. */
  66857. parent?: INode;
  66858. /** @hidden */
  66859. _babylonTransformNode?: TransformNode;
  66860. /** @hidden */
  66861. _primitiveBabylonMeshes?: AbstractMesh[];
  66862. /** @hidden */
  66863. _babylonBones?: Bone[];
  66864. /** @hidden */
  66865. _numMorphTargets?: number;
  66866. }
  66867. /** @hidden */
  66868. export interface _ISamplerData {
  66869. noMipMaps: boolean;
  66870. samplingMode: number;
  66871. wrapU: number;
  66872. wrapV: number;
  66873. }
  66874. /**
  66875. * Loader interface with additional members.
  66876. */
  66877. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66878. /** @hidden */
  66879. _data?: _ISamplerData;
  66880. }
  66881. /**
  66882. * Loader interface with additional members.
  66883. */
  66884. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66885. }
  66886. /**
  66887. * Loader interface with additional members.
  66888. */
  66889. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66890. /** @hidden */
  66891. _data?: {
  66892. babylonSkeleton: Skeleton;
  66893. promise: Promise<void>;
  66894. };
  66895. }
  66896. /**
  66897. * Loader interface with additional members.
  66898. */
  66899. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66900. }
  66901. /**
  66902. * Loader interface with additional members.
  66903. */
  66904. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66905. }
  66906. /**
  66907. * Loader interface with additional members.
  66908. */
  66909. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66910. accessors?: IAccessor[];
  66911. animations?: IAnimation[];
  66912. buffers?: IBuffer[];
  66913. bufferViews?: IBufferView[];
  66914. cameras?: ICamera[];
  66915. images?: IImage[];
  66916. materials?: IMaterial[];
  66917. meshes?: IMesh[];
  66918. nodes?: INode[];
  66919. samplers?: ISampler[];
  66920. scenes?: IScene[];
  66921. skins?: ISkin[];
  66922. textures?: ITexture[];
  66923. }
  66924. }
  66925. declare module BABYLON.GLTF2 {
  66926. /**
  66927. * Interface for a glTF loader extension.
  66928. */
  66929. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66930. /**
  66931. * Called after the loader state changes to LOADING.
  66932. */
  66933. onLoading?(): void;
  66934. /**
  66935. * Called after the loader state changes to READY.
  66936. */
  66937. onReady?(): void;
  66938. /**
  66939. * Define this method to modify the default behavior when loading scenes.
  66940. * @param context The context when loading the asset
  66941. * @param scene The glTF scene property
  66942. * @returns A promise that resolves when the load is complete or null if not handled
  66943. */
  66944. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66945. /**
  66946. * Define this method to modify the default behavior when loading nodes.
  66947. * @param context The context when loading the asset
  66948. * @param node The glTF node property
  66949. * @param assign A function called synchronously after parsing the glTF properties
  66950. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66951. */
  66952. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66953. /**
  66954. * Define this method to modify the default behavior when loading cameras.
  66955. * @param context The context when loading the asset
  66956. * @param camera The glTF camera property
  66957. * @param assign A function called synchronously after parsing the glTF properties
  66958. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66959. */
  66960. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66961. /**
  66962. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66963. * @param context The context when loading the asset
  66964. * @param primitive The glTF mesh primitive property
  66965. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66966. */
  66967. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66968. /**
  66969. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66970. * @param context The context when loading the asset
  66971. * @param name The mesh name when loading the asset
  66972. * @param node The glTF node when loading the asset
  66973. * @param mesh The glTF mesh when loading the asset
  66974. * @param primitive The glTF mesh primitive property
  66975. * @param assign A function called synchronously after parsing the glTF properties
  66976. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66977. */
  66978. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66979. /**
  66980. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66981. * @param context The context when loading the asset
  66982. * @param material The glTF material property
  66983. * @param assign A function called synchronously after parsing the glTF properties
  66984. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66985. */
  66986. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66987. /**
  66988. * Define this method to modify the default behavior when creating materials.
  66989. * @param context The context when loading the asset
  66990. * @param material The glTF material property
  66991. * @param babylonDrawMode The draw mode for the Babylon material
  66992. * @returns The Babylon material or null if not handled
  66993. */
  66994. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66995. /**
  66996. * Define this method to modify the default behavior when loading material properties.
  66997. * @param context The context when loading the asset
  66998. * @param material The glTF material property
  66999. * @param babylonMaterial The Babylon material
  67000. * @returns A promise that resolves when the load is complete or null if not handled
  67001. */
  67002. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67003. /**
  67004. * Define this method to modify the default behavior when loading texture infos.
  67005. * @param context The context when loading the asset
  67006. * @param textureInfo The glTF texture info property
  67007. * @param assign A function called synchronously after parsing the glTF properties
  67008. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67009. */
  67010. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67011. /**
  67012. * Define this method to modify the default behavior when loading animations.
  67013. * @param context The context when loading the asset
  67014. * @param animation The glTF animation property
  67015. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67016. */
  67017. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67018. /**
  67019. * @hidden Define this method to modify the default behavior when loading skins.
  67020. * @param context The context when loading the asset
  67021. * @param node The glTF node property
  67022. * @param skin The glTF skin property
  67023. * @returns A promise that resolves when the load is complete or null if not handled
  67024. */
  67025. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67026. /**
  67027. * @hidden Define this method to modify the default behavior when loading uris.
  67028. * @param context The context when loading the asset
  67029. * @param property The glTF property associated with the uri
  67030. * @param uri The uri to load
  67031. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67032. */
  67033. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67034. }
  67035. }
  67036. declare module BABYLON.GLTF2 {
  67037. /**
  67038. * Helper class for working with arrays when loading the glTF asset
  67039. */
  67040. export class ArrayItem {
  67041. /**
  67042. * Gets an item from the given array.
  67043. * @param context The context when loading the asset
  67044. * @param array The array to get the item from
  67045. * @param index The index to the array
  67046. * @returns The array item
  67047. */
  67048. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67049. /**
  67050. * Assign an `index` field to each item of the given array.
  67051. * @param array The array of items
  67052. */
  67053. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67054. }
  67055. /**
  67056. * The glTF 2.0 loader
  67057. */
  67058. export class GLTFLoader implements IGLTFLoader {
  67059. /** @hidden */
  67060. _completePromises: Promise<any>[];
  67061. private _disposed;
  67062. private _parent;
  67063. private _state;
  67064. private _extensions;
  67065. private _rootUrl;
  67066. private _fileName;
  67067. private _uniqueRootUrl;
  67068. private _gltf;
  67069. private _babylonScene;
  67070. private _rootBabylonMesh;
  67071. private _defaultBabylonMaterialData;
  67072. private _progressCallback?;
  67073. private _requests;
  67074. private static readonly _DefaultSampler;
  67075. private static _ExtensionNames;
  67076. private static _ExtensionFactories;
  67077. /**
  67078. * Registers a loader extension.
  67079. * @param name The name of the loader extension.
  67080. * @param factory The factory function that creates the loader extension.
  67081. */
  67082. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67083. /**
  67084. * Unregisters a loader extension.
  67085. * @param name The name of the loader extenion.
  67086. * @returns A boolean indicating whether the extension has been unregistered
  67087. */
  67088. static UnregisterExtension(name: string): boolean;
  67089. /**
  67090. * Gets the loader state.
  67091. */
  67092. readonly state: Nullable<GLTFLoaderState>;
  67093. /**
  67094. * The glTF object parsed from the JSON.
  67095. */
  67096. readonly gltf: IGLTF;
  67097. /**
  67098. * The Babylon scene when loading the asset.
  67099. */
  67100. readonly babylonScene: Scene;
  67101. /**
  67102. * The root Babylon mesh when loading the asset.
  67103. */
  67104. readonly rootBabylonMesh: Mesh;
  67105. /** @hidden */
  67106. constructor(parent: GLTFFileLoader);
  67107. /** @hidden */
  67108. dispose(): void;
  67109. /** @hidden */
  67110. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67111. meshes: AbstractMesh[];
  67112. particleSystems: IParticleSystem[];
  67113. skeletons: Skeleton[];
  67114. animationGroups: AnimationGroup[];
  67115. }>;
  67116. /** @hidden */
  67117. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67118. private _loadAsync;
  67119. private _loadData;
  67120. private _setupData;
  67121. private _loadExtensions;
  67122. private _checkExtensions;
  67123. private _setState;
  67124. private _createRootNode;
  67125. /**
  67126. * Loads a glTF scene.
  67127. * @param context The context when loading the asset
  67128. * @param scene The glTF scene property
  67129. * @returns A promise that resolves when the load is complete
  67130. */
  67131. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67132. private _forEachPrimitive;
  67133. private _getMeshes;
  67134. private _getSkeletons;
  67135. private _getAnimationGroups;
  67136. private _startAnimations;
  67137. /**
  67138. * Loads a glTF node.
  67139. * @param context The context when loading the asset
  67140. * @param node The glTF node property
  67141. * @param assign A function called synchronously after parsing the glTF properties
  67142. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67143. */
  67144. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67145. private _loadMeshAsync;
  67146. /**
  67147. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67148. * @param context The context when loading the asset
  67149. * @param name The mesh name when loading the asset
  67150. * @param node The glTF node when loading the asset
  67151. * @param mesh The glTF mesh when loading the asset
  67152. * @param primitive The glTF mesh primitive property
  67153. * @param assign A function called synchronously after parsing the glTF properties
  67154. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67155. */
  67156. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67157. private _loadVertexDataAsync;
  67158. private _createMorphTargets;
  67159. private _loadMorphTargetsAsync;
  67160. private _loadMorphTargetVertexDataAsync;
  67161. private static _LoadTransform;
  67162. private _loadSkinAsync;
  67163. private _loadBones;
  67164. private _loadBone;
  67165. private _loadSkinInverseBindMatricesDataAsync;
  67166. private _updateBoneMatrices;
  67167. private _getNodeMatrix;
  67168. /**
  67169. * Loads a glTF camera.
  67170. * @param context The context when loading the asset
  67171. * @param camera The glTF camera property
  67172. * @param assign A function called synchronously after parsing the glTF properties
  67173. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67174. */
  67175. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67176. private _loadAnimationsAsync;
  67177. /**
  67178. * Loads a glTF animation.
  67179. * @param context The context when loading the asset
  67180. * @param animation The glTF animation property
  67181. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67182. */
  67183. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67184. /**
  67185. * @hidden Loads a glTF animation channel.
  67186. * @param context The context when loading the asset
  67187. * @param animationContext The context of the animation when loading the asset
  67188. * @param animation The glTF animation property
  67189. * @param channel The glTF animation channel property
  67190. * @param babylonAnimationGroup The babylon animation group property
  67191. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67192. * @returns A void promise when the channel load is complete
  67193. */
  67194. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67195. private _loadAnimationSamplerAsync;
  67196. private _loadBufferAsync;
  67197. /**
  67198. * Loads a glTF buffer view.
  67199. * @param context The context when loading the asset
  67200. * @param bufferView The glTF buffer view property
  67201. * @returns A promise that resolves with the loaded data when the load is complete
  67202. */
  67203. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67204. private _loadAccessorAsync;
  67205. private _loadFloatAccessorAsync;
  67206. private _loadIndicesAccessorAsync;
  67207. private _loadVertexBufferViewAsync;
  67208. private _loadVertexAccessorAsync;
  67209. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67210. /** @hidden */
  67211. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67212. private _createDefaultMaterial;
  67213. /**
  67214. * Creates a Babylon material from a glTF material.
  67215. * @param context The context when loading the asset
  67216. * @param material The glTF material property
  67217. * @param babylonDrawMode The draw mode for the Babylon material
  67218. * @returns The Babylon material
  67219. */
  67220. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67221. /**
  67222. * Loads properties from a glTF material into a Babylon material.
  67223. * @param context The context when loading the asset
  67224. * @param material The glTF material property
  67225. * @param babylonMaterial The Babylon material
  67226. * @returns A promise that resolves when the load is complete
  67227. */
  67228. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67229. /**
  67230. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67231. * @param context The context when loading the asset
  67232. * @param material The glTF material property
  67233. * @param babylonMaterial The Babylon material
  67234. * @returns A promise that resolves when the load is complete
  67235. */
  67236. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67237. /**
  67238. * Loads the alpha properties from a glTF material into a Babylon material.
  67239. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67240. * @param context The context when loading the asset
  67241. * @param material The glTF material property
  67242. * @param babylonMaterial The Babylon material
  67243. */
  67244. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67245. /**
  67246. * Loads a glTF texture info.
  67247. * @param context The context when loading the asset
  67248. * @param textureInfo The glTF texture info property
  67249. * @param assign A function called synchronously after parsing the glTF properties
  67250. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67251. */
  67252. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67253. private _loadTextureAsync;
  67254. private _loadSampler;
  67255. /**
  67256. * Loads a glTF image.
  67257. * @param context The context when loading the asset
  67258. * @param image The glTF image property
  67259. * @returns A promise that resolves with the loaded data when the load is complete
  67260. */
  67261. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67262. /**
  67263. * Loads a glTF uri.
  67264. * @param context The context when loading the asset
  67265. * @param property The glTF property associated with the uri
  67266. * @param uri The base64 or relative uri
  67267. * @returns A promise that resolves with the loaded data when the load is complete
  67268. */
  67269. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67270. private _onProgress;
  67271. /**
  67272. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67273. * @param babylonObject the Babylon object with metadata
  67274. * @param pointer the JSON pointer
  67275. */
  67276. static AddPointerMetadata(babylonObject: {
  67277. metadata: any;
  67278. }, pointer: string): void;
  67279. private static _GetTextureWrapMode;
  67280. private static _GetTextureSamplingMode;
  67281. private static _GetTypedArrayConstructor;
  67282. private static _GetTypedArray;
  67283. private static _GetNumComponents;
  67284. private static _ValidateUri;
  67285. private static _GetDrawMode;
  67286. private _compileMaterialsAsync;
  67287. private _compileShadowGeneratorsAsync;
  67288. private _forEachExtensions;
  67289. private _applyExtensions;
  67290. private _extensionsOnLoading;
  67291. private _extensionsOnReady;
  67292. private _extensionsLoadSceneAsync;
  67293. private _extensionsLoadNodeAsync;
  67294. private _extensionsLoadCameraAsync;
  67295. private _extensionsLoadVertexDataAsync;
  67296. private _extensionsLoadMeshPrimitiveAsync;
  67297. private _extensionsLoadMaterialAsync;
  67298. private _extensionsCreateMaterial;
  67299. private _extensionsLoadMaterialPropertiesAsync;
  67300. private _extensionsLoadTextureInfoAsync;
  67301. private _extensionsLoadAnimationAsync;
  67302. private _extensionsLoadSkinAsync;
  67303. private _extensionsLoadUriAsync;
  67304. /**
  67305. * Helper method called by a loader extension to load an glTF extension.
  67306. * @param context The context when loading the asset
  67307. * @param property The glTF property to load the extension from
  67308. * @param extensionName The name of the extension to load
  67309. * @param actionAsync The action to run
  67310. * @returns The promise returned by actionAsync or null if the extension does not exist
  67311. */
  67312. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67313. /**
  67314. * Helper method called by a loader extension to load a glTF extra.
  67315. * @param context The context when loading the asset
  67316. * @param property The glTF property to load the extra from
  67317. * @param extensionName The name of the extension to load
  67318. * @param actionAsync The action to run
  67319. * @returns The promise returned by actionAsync or null if the extra does not exist
  67320. */
  67321. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67322. /**
  67323. * Increments the indentation level and logs a message.
  67324. * @param message The message to log
  67325. */
  67326. logOpen(message: string): void;
  67327. /**
  67328. * Decrements the indentation level.
  67329. */
  67330. logClose(): void;
  67331. /**
  67332. * Logs a message
  67333. * @param message The message to log
  67334. */
  67335. log(message: string): void;
  67336. /**
  67337. * Starts a performance counter.
  67338. * @param counterName The name of the performance counter
  67339. */
  67340. startPerformanceCounter(counterName: string): void;
  67341. /**
  67342. * Ends a performance counter.
  67343. * @param counterName The name of the performance counter
  67344. */
  67345. endPerformanceCounter(counterName: string): void;
  67346. }
  67347. }
  67348. declare module BABYLON.GLTF2.Loader.Extensions {
  67349. /**
  67350. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67351. */
  67352. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67353. /** The name of this extension. */
  67354. readonly name: string;
  67355. /** Defines whether this extension is enabled. */
  67356. enabled: boolean;
  67357. private _loader;
  67358. private _lights?;
  67359. /** @hidden */
  67360. constructor(loader: GLTFLoader);
  67361. /** @hidden */
  67362. dispose(): void;
  67363. /** @hidden */
  67364. onLoading(): void;
  67365. /** @hidden */
  67366. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67367. private _loadLightAsync;
  67368. }
  67369. }
  67370. declare module BABYLON.GLTF2.Loader.Extensions {
  67371. /**
  67372. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67373. */
  67374. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67375. /** The name of this extension. */
  67376. readonly name: string;
  67377. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67378. dracoCompression?: DracoCompression;
  67379. /** Defines whether this extension is enabled. */
  67380. enabled: boolean;
  67381. private _loader;
  67382. /** @hidden */
  67383. constructor(loader: GLTFLoader);
  67384. /** @hidden */
  67385. dispose(): void;
  67386. /** @hidden */
  67387. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67388. }
  67389. }
  67390. declare module BABYLON.GLTF2.Loader.Extensions {
  67391. /**
  67392. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67393. */
  67394. export class KHR_lights implements IGLTFLoaderExtension {
  67395. /** The name of this extension. */
  67396. readonly name: string;
  67397. /** Defines whether this extension is enabled. */
  67398. enabled: boolean;
  67399. private _loader;
  67400. private _lights?;
  67401. /** @hidden */
  67402. constructor(loader: GLTFLoader);
  67403. /** @hidden */
  67404. dispose(): void;
  67405. /** @hidden */
  67406. onLoading(): void;
  67407. /** @hidden */
  67408. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67409. }
  67410. }
  67411. declare module BABYLON.GLTF2.Loader.Extensions {
  67412. /**
  67413. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67414. */
  67415. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67416. /** The name of this extension. */
  67417. readonly name: string;
  67418. /** Defines whether this extension is enabled. */
  67419. enabled: boolean;
  67420. private _loader;
  67421. /** @hidden */
  67422. constructor(loader: GLTFLoader);
  67423. /** @hidden */
  67424. dispose(): void;
  67425. /** @hidden */
  67426. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67427. private _loadSpecularGlossinessPropertiesAsync;
  67428. }
  67429. }
  67430. declare module BABYLON.GLTF2.Loader.Extensions {
  67431. /**
  67432. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67433. */
  67434. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67435. /** The name of this extension. */
  67436. readonly name: string;
  67437. /** Defines whether this extension is enabled. */
  67438. enabled: boolean;
  67439. private _loader;
  67440. /** @hidden */
  67441. constructor(loader: GLTFLoader);
  67442. /** @hidden */
  67443. dispose(): void;
  67444. /** @hidden */
  67445. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67446. private _loadUnlitPropertiesAsync;
  67447. }
  67448. }
  67449. declare module BABYLON.GLTF2.Loader.Extensions {
  67450. /**
  67451. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67452. */
  67453. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67454. /** The name of this extension. */
  67455. readonly name: string;
  67456. /** Defines whether this extension is enabled. */
  67457. enabled: boolean;
  67458. private _loader;
  67459. /** @hidden */
  67460. constructor(loader: GLTFLoader);
  67461. /** @hidden */
  67462. dispose(): void;
  67463. /** @hidden */
  67464. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67465. }
  67466. }
  67467. declare module BABYLON.GLTF2.Loader.Extensions {
  67468. /**
  67469. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67470. */
  67471. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67472. /** The name of this extension. */
  67473. readonly name: string;
  67474. /** Defines whether this extension is enabled. */
  67475. enabled: boolean;
  67476. private _loader;
  67477. private _clips;
  67478. private _emitters;
  67479. /** @hidden */
  67480. constructor(loader: GLTFLoader);
  67481. /** @hidden */
  67482. dispose(): void;
  67483. /** @hidden */
  67484. onLoading(): void;
  67485. /** @hidden */
  67486. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67487. /** @hidden */
  67488. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67489. /** @hidden */
  67490. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67491. private _loadClipAsync;
  67492. private _loadEmitterAsync;
  67493. private _getEventAction;
  67494. private _loadAnimationEventAsync;
  67495. }
  67496. }
  67497. declare module BABYLON.GLTF2.Loader.Extensions {
  67498. /**
  67499. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67500. */
  67501. export class MSFT_lod implements IGLTFLoaderExtension {
  67502. /** The name of this extension. */
  67503. readonly name: string;
  67504. /** Defines whether this extension is enabled. */
  67505. enabled: boolean;
  67506. /**
  67507. * Maximum number of LODs to load, starting from the lowest LOD.
  67508. */
  67509. maxLODsToLoad: number;
  67510. /**
  67511. * Observable raised when all node LODs of one level are loaded.
  67512. * The event data is the index of the loaded LOD starting from zero.
  67513. * Dispose the loader to cancel the loading of the next level of LODs.
  67514. */
  67515. onNodeLODsLoadedObservable: Observable<number>;
  67516. /**
  67517. * Observable raised when all material LODs of one level are loaded.
  67518. * The event data is the index of the loaded LOD starting from zero.
  67519. * Dispose the loader to cancel the loading of the next level of LODs.
  67520. */
  67521. onMaterialLODsLoadedObservable: Observable<number>;
  67522. private _loader;
  67523. private _nodeIndexLOD;
  67524. private _nodeSignalLODs;
  67525. private _nodePromiseLODs;
  67526. private _materialIndexLOD;
  67527. private _materialSignalLODs;
  67528. private _materialPromiseLODs;
  67529. /** @hidden */
  67530. constructor(loader: GLTFLoader);
  67531. /** @hidden */
  67532. dispose(): void;
  67533. /** @hidden */
  67534. onReady(): void;
  67535. /** @hidden */
  67536. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67537. /** @hidden */
  67538. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67539. /** @hidden */
  67540. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67541. /**
  67542. * Gets an array of LOD properties from lowest to highest.
  67543. */
  67544. private _getLODs;
  67545. private _disposeUnusedMaterials;
  67546. }
  67547. }
  67548. declare module BABYLON.GLTF2.Loader.Extensions {
  67549. /** @hidden */
  67550. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67551. readonly name: string;
  67552. enabled: boolean;
  67553. private _loader;
  67554. constructor(loader: GLTFLoader);
  67555. dispose(): void;
  67556. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67557. }
  67558. }
  67559. declare module BABYLON.GLTF2.Loader.Extensions {
  67560. /** @hidden */
  67561. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67562. readonly name: string;
  67563. enabled: boolean;
  67564. private _loader;
  67565. constructor(loader: GLTFLoader);
  67566. dispose(): void;
  67567. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67568. }
  67569. }
  67570. declare module BABYLON.GLTF2.Loader.Extensions {
  67571. /**
  67572. * Store glTF extras (if present) in BJS objects' metadata
  67573. */
  67574. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67575. /** The name of this extension. */
  67576. readonly name: string;
  67577. /** Defines whether this extension is enabled. */
  67578. enabled: boolean;
  67579. private _loader;
  67580. private _assignExtras;
  67581. /** @hidden */
  67582. constructor(loader: GLTFLoader);
  67583. /** @hidden */
  67584. dispose(): void;
  67585. /** @hidden */
  67586. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67587. /** @hidden */
  67588. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67589. /** @hidden */
  67590. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /**
  67595. * Class reading and parsing the MTL file bundled with the obj file.
  67596. */
  67597. export class MTLFileLoader {
  67598. /**
  67599. * All material loaded from the mtl will be set here
  67600. */
  67601. materials: StandardMaterial[];
  67602. /**
  67603. * This function will read the mtl file and create each material described inside
  67604. * This function could be improve by adding :
  67605. * -some component missing (Ni, Tf...)
  67606. * -including the specific options available
  67607. *
  67608. * @param scene defines the scene the material will be created in
  67609. * @param data defines the mtl data to parse
  67610. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67611. */
  67612. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67613. /**
  67614. * Gets the texture for the material.
  67615. *
  67616. * If the material is imported from input file,
  67617. * We sanitize the url to ensure it takes the textre from aside the material.
  67618. *
  67619. * @param rootUrl The root url to load from
  67620. * @param value The value stored in the mtl
  67621. * @return The Texture
  67622. */
  67623. private static _getTexture;
  67624. }
  67625. /**
  67626. * Options for loading OBJ/MTL files
  67627. */
  67628. type MeshLoadOptions = {
  67629. /**
  67630. * Defines if UVs are optimized by default during load.
  67631. */
  67632. OptimizeWithUV: boolean;
  67633. /**
  67634. * Defines custom scaling of UV coordinates of loaded meshes.
  67635. */
  67636. UVScaling: Vector2;
  67637. /**
  67638. * Invert model on y-axis (does a model scaling inversion)
  67639. */
  67640. InvertY: boolean;
  67641. /**
  67642. * Invert Y-Axis of referenced textures on load
  67643. */
  67644. InvertTextureY: boolean;
  67645. /**
  67646. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67647. */
  67648. ImportVertexColors: boolean;
  67649. /**
  67650. * Compute the normals for the model, even if normals are present in the file.
  67651. */
  67652. ComputeNormals: boolean;
  67653. /**
  67654. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67655. */
  67656. SkipMaterials: boolean;
  67657. /**
  67658. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67659. */
  67660. MaterialLoadingFailsSilently: boolean;
  67661. };
  67662. /**
  67663. * OBJ file type loader.
  67664. * This is a babylon scene loader plugin.
  67665. */
  67666. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67667. /**
  67668. * Defines if UVs are optimized by default during load.
  67669. */
  67670. static OPTIMIZE_WITH_UV: boolean;
  67671. /**
  67672. * Invert model on y-axis (does a model scaling inversion)
  67673. */
  67674. static INVERT_Y: boolean;
  67675. /**
  67676. * Invert Y-Axis of referenced textures on load
  67677. */
  67678. static INVERT_TEXTURE_Y: boolean;
  67679. /**
  67680. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67681. */
  67682. static IMPORT_VERTEX_COLORS: boolean;
  67683. /**
  67684. * Compute the normals for the model, even if normals are present in the file.
  67685. */
  67686. static COMPUTE_NORMALS: boolean;
  67687. /**
  67688. * Defines custom scaling of UV coordinates of loaded meshes.
  67689. */
  67690. static UV_SCALING: Vector2;
  67691. /**
  67692. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67693. */
  67694. static SKIP_MATERIALS: boolean;
  67695. /**
  67696. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67697. *
  67698. * Defaults to true for backwards compatibility.
  67699. */
  67700. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67701. /**
  67702. * Defines the name of the plugin.
  67703. */
  67704. name: string;
  67705. /**
  67706. * Defines the extension the plugin is able to load.
  67707. */
  67708. extensions: string;
  67709. /** @hidden */
  67710. obj: RegExp;
  67711. /** @hidden */
  67712. group: RegExp;
  67713. /** @hidden */
  67714. mtllib: RegExp;
  67715. /** @hidden */
  67716. usemtl: RegExp;
  67717. /** @hidden */
  67718. smooth: RegExp;
  67719. /** @hidden */
  67720. vertexPattern: RegExp;
  67721. /** @hidden */
  67722. normalPattern: RegExp;
  67723. /** @hidden */
  67724. uvPattern: RegExp;
  67725. /** @hidden */
  67726. facePattern1: RegExp;
  67727. /** @hidden */
  67728. facePattern2: RegExp;
  67729. /** @hidden */
  67730. facePattern3: RegExp;
  67731. /** @hidden */
  67732. facePattern4: RegExp;
  67733. /** @hidden */
  67734. facePattern5: RegExp;
  67735. private _meshLoadOptions;
  67736. /**
  67737. * Creates loader for .OBJ files
  67738. *
  67739. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67740. */
  67741. constructor(meshLoadOptions?: MeshLoadOptions);
  67742. private static readonly currentMeshLoadOptions;
  67743. /**
  67744. * Calls synchronously the MTL file attached to this obj.
  67745. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67746. * Without this function materials are not displayed in the first frame (but displayed after).
  67747. * In consequence it is impossible to get material information in your HTML file
  67748. *
  67749. * @param url The URL of the MTL file
  67750. * @param rootUrl
  67751. * @param onSuccess Callback function to be called when the MTL file is loaded
  67752. * @private
  67753. */
  67754. private _loadMTL;
  67755. /**
  67756. * Instantiates a OBJ file loader plugin.
  67757. * @returns the created plugin
  67758. */
  67759. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67760. /**
  67761. * If the data string can be loaded directly.
  67762. *
  67763. * @param data string containing the file data
  67764. * @returns if the data can be loaded directly
  67765. */
  67766. canDirectLoad(data: string): boolean;
  67767. /**
  67768. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67769. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67770. * @param scene the scene the meshes should be added to
  67771. * @param data the OBJ data to load
  67772. * @param rootUrl root url to load from
  67773. * @param onProgress event that fires when loading progress has occured
  67774. * @param fileName Defines the name of the file to load
  67775. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67776. */
  67777. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67778. meshes: AbstractMesh[];
  67779. particleSystems: IParticleSystem[];
  67780. skeletons: Skeleton[];
  67781. animationGroups: AnimationGroup[];
  67782. }>;
  67783. /**
  67784. * Imports all objects from the loaded OBJ data and adds them to the scene
  67785. * @param scene the scene the objects should be added to
  67786. * @param data the OBJ data to load
  67787. * @param rootUrl root url to load from
  67788. * @param onProgress event that fires when loading progress has occured
  67789. * @param fileName Defines the name of the file to load
  67790. * @returns a promise which completes when objects have been loaded to the scene
  67791. */
  67792. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67793. /**
  67794. * Load into an asset container.
  67795. * @param scene The scene to load into
  67796. * @param data The data to import
  67797. * @param rootUrl The root url for scene and resources
  67798. * @param onProgress The callback when the load progresses
  67799. * @param fileName Defines the name of the file to load
  67800. * @returns The loaded asset container
  67801. */
  67802. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67803. /**
  67804. * Read the OBJ file and create an Array of meshes.
  67805. * Each mesh contains all information given by the OBJ and the MTL file.
  67806. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67807. *
  67808. * @param meshesNames
  67809. * @param scene Scene The scene where are displayed the data
  67810. * @param data String The content of the obj file
  67811. * @param rootUrl String The path to the folder
  67812. * @returns Array<AbstractMesh>
  67813. * @private
  67814. */
  67815. private _parseSolid;
  67816. }
  67817. }
  67818. declare module BABYLON {
  67819. /**
  67820. * STL file type loader.
  67821. * This is a babylon scene loader plugin.
  67822. */
  67823. export class STLFileLoader implements ISceneLoaderPlugin {
  67824. /** @hidden */
  67825. solidPattern: RegExp;
  67826. /** @hidden */
  67827. facetsPattern: RegExp;
  67828. /** @hidden */
  67829. normalPattern: RegExp;
  67830. /** @hidden */
  67831. vertexPattern: RegExp;
  67832. /**
  67833. * Defines the name of the plugin.
  67834. */
  67835. name: string;
  67836. /**
  67837. * Defines the extensions the stl loader is able to load.
  67838. * force data to come in as an ArrayBuffer
  67839. * we'll convert to string if it looks like it's an ASCII .stl
  67840. */
  67841. extensions: ISceneLoaderPluginExtensions;
  67842. /**
  67843. * Import meshes into a scene.
  67844. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67845. * @param scene The scene to import into
  67846. * @param data The data to import
  67847. * @param rootUrl The root url for scene and resources
  67848. * @param meshes The meshes array to import into
  67849. * @param particleSystems The particle systems array to import into
  67850. * @param skeletons The skeletons array to import into
  67851. * @param onError The callback when import fails
  67852. * @returns True if successful or false otherwise
  67853. */
  67854. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67855. /**
  67856. * Load into a scene.
  67857. * @param scene The scene to load into
  67858. * @param data The data to import
  67859. * @param rootUrl The root url for scene and resources
  67860. * @param onError The callback when import fails
  67861. * @returns true if successful or false otherwise
  67862. */
  67863. load(scene: Scene, data: any, rootUrl: string): boolean;
  67864. /**
  67865. * Load into an asset container.
  67866. * @param scene The scene to load into
  67867. * @param data The data to import
  67868. * @param rootUrl The root url for scene and resources
  67869. * @param onError The callback when import fails
  67870. * @returns The loaded asset container
  67871. */
  67872. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67873. private _isBinary;
  67874. private _parseBinary;
  67875. private _parseASCII;
  67876. }
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * Class for generating OBJ data from a Babylon scene.
  67881. */
  67882. export class OBJExport {
  67883. /**
  67884. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67885. * @param mesh defines the list of meshes to serialize
  67886. * @param materials defines if materials should be exported
  67887. * @param matlibname defines the name of the associated mtl file
  67888. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67889. * @returns the OBJ content
  67890. */
  67891. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67892. /**
  67893. * Exports the material(s) of a mesh in .MTL file format (text)
  67894. * @param mesh defines the mesh to extract the material from
  67895. * @returns the mtl content
  67896. */
  67897. static MTL(mesh: Mesh): string;
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /** @hidden */
  67902. export var __IGLTFExporterExtension: number;
  67903. /**
  67904. * Interface for extending the exporter
  67905. * @hidden
  67906. */
  67907. export interface IGLTFExporterExtension {
  67908. /**
  67909. * The name of this extension
  67910. */
  67911. readonly name: string;
  67912. /**
  67913. * Defines whether this extension is enabled
  67914. */
  67915. enabled: boolean;
  67916. /**
  67917. * Defines whether this extension is required
  67918. */
  67919. required: boolean;
  67920. }
  67921. }
  67922. declare module BABYLON.GLTF2.Exporter {
  67923. /** @hidden */
  67924. export var __IGLTFExporterExtensionV2: number;
  67925. /**
  67926. * Interface for a glTF exporter extension
  67927. * @hidden
  67928. */
  67929. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67930. /**
  67931. * Define this method to modify the default behavior before exporting a texture
  67932. * @param context The context when loading the asset
  67933. * @param babylonTexture The glTF texture info property
  67934. * @param mimeType The mime-type of the generated image
  67935. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67936. */
  67937. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67938. /**
  67939. * Define this method to modify the default behavior when exporting texture info
  67940. * @param context The context when loading the asset
  67941. * @param meshPrimitive glTF mesh primitive
  67942. * @param babylonSubMesh Babylon submesh
  67943. * @param binaryWriter glTF serializer binary writer instance
  67944. * @returns nullable IMeshPrimitive promise
  67945. */
  67946. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67947. /**
  67948. * Define this method to modify the default behavior when exporting a node
  67949. * @param context The context when exporting the node
  67950. * @param node glTF node
  67951. * @param babylonNode BabylonJS node
  67952. * @returns nullable INode promise
  67953. */
  67954. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67955. /**
  67956. * Called after the exporter state changes to EXPORTING
  67957. */
  67958. onExporting?(): void;
  67959. }
  67960. }
  67961. declare module BABYLON.GLTF2.Exporter {
  67962. /**
  67963. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67964. * @hidden
  67965. */
  67966. export class _GLTFMaterialExporter {
  67967. /**
  67968. * Represents the dielectric specular values for R, G and B
  67969. */
  67970. private static readonly _DielectricSpecular;
  67971. /**
  67972. * Allows the maximum specular power to be defined for material calculations
  67973. */
  67974. private static readonly _MaxSpecularPower;
  67975. /**
  67976. * Mapping to store textures
  67977. */
  67978. private _textureMap;
  67979. /**
  67980. * Numeric tolerance value
  67981. */
  67982. private static readonly _Epsilon;
  67983. /**
  67984. * Reference to the glTF Exporter
  67985. */
  67986. private _exporter;
  67987. constructor(exporter: _Exporter);
  67988. /**
  67989. * Specifies if two colors are approximately equal in value
  67990. * @param color1 first color to compare to
  67991. * @param color2 second color to compare to
  67992. * @param epsilon threshold value
  67993. */
  67994. private static FuzzyEquals;
  67995. /**
  67996. * Gets the materials from a Babylon scene and converts them to glTF materials
  67997. * @param scene babylonjs scene
  67998. * @param mimeType texture mime type
  67999. * @param images array of images
  68000. * @param textures array of textures
  68001. * @param materials array of materials
  68002. * @param imageData mapping of texture names to base64 textures
  68003. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68004. */
  68005. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68006. /**
  68007. * Makes a copy of the glTF material without the texture parameters
  68008. * @param originalMaterial original glTF material
  68009. * @returns glTF material without texture parameters
  68010. */
  68011. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68012. /**
  68013. * Specifies if the material has any texture parameters present
  68014. * @param material glTF Material
  68015. * @returns boolean specifying if texture parameters are present
  68016. */
  68017. _hasTexturesPresent(material: IMaterial): boolean;
  68018. /**
  68019. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68020. * @param babylonStandardMaterial
  68021. * @returns glTF Metallic Roughness Material representation
  68022. */
  68023. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68024. /**
  68025. * Computes the metallic factor
  68026. * @param diffuse diffused value
  68027. * @param specular specular value
  68028. * @param oneMinusSpecularStrength one minus the specular strength
  68029. * @returns metallic value
  68030. */
  68031. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68032. /**
  68033. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68034. * @param glTFMaterial glTF material
  68035. * @param babylonMaterial Babylon material
  68036. */
  68037. private static _SetAlphaMode;
  68038. /**
  68039. * Converts a Babylon Standard Material to a glTF Material
  68040. * @param babylonStandardMaterial BJS Standard Material
  68041. * @param mimeType mime type to use for the textures
  68042. * @param images array of glTF image interfaces
  68043. * @param textures array of glTF texture interfaces
  68044. * @param materials array of glTF material interfaces
  68045. * @param imageData map of image file name to data
  68046. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68047. */
  68048. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68049. /**
  68050. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68051. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68052. * @param mimeType mime type to use for the textures
  68053. * @param images array of glTF image interfaces
  68054. * @param textures array of glTF texture interfaces
  68055. * @param materials array of glTF material interfaces
  68056. * @param imageData map of image file name to data
  68057. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68058. */
  68059. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68060. /**
  68061. * Converts an image typed array buffer to a base64 image
  68062. * @param buffer typed array buffer
  68063. * @param width width of the image
  68064. * @param height height of the image
  68065. * @param mimeType mimetype of the image
  68066. * @returns base64 image string
  68067. */
  68068. private _createBase64FromCanvasAsync;
  68069. /**
  68070. * Generates a white texture based on the specified width and height
  68071. * @param width width of the texture in pixels
  68072. * @param height height of the texture in pixels
  68073. * @param scene babylonjs scene
  68074. * @returns white texture
  68075. */
  68076. private _createWhiteTexture;
  68077. /**
  68078. * 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
  68079. * @param texture1 first texture to resize
  68080. * @param texture2 second texture to resize
  68081. * @param scene babylonjs scene
  68082. * @returns resized textures or null
  68083. */
  68084. private _resizeTexturesToSameDimensions;
  68085. /**
  68086. * Converts an array of pixels to a Float32Array
  68087. * Throws an error if the pixel format is not supported
  68088. * @param pixels - array buffer containing pixel values
  68089. * @returns Float32 of pixels
  68090. */
  68091. private _convertPixelArrayToFloat32;
  68092. /**
  68093. * Convert Specular Glossiness Textures to Metallic Roughness
  68094. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68095. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68096. * @param diffuseTexture texture used to store diffuse information
  68097. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68098. * @param factors specular glossiness material factors
  68099. * @param mimeType the mime type to use for the texture
  68100. * @returns pbr metallic roughness interface or null
  68101. */
  68102. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68103. /**
  68104. * Converts specular glossiness material properties to metallic roughness
  68105. * @param specularGlossiness interface with specular glossiness material properties
  68106. * @returns interface with metallic roughness material properties
  68107. */
  68108. private _convertSpecularGlossinessToMetallicRoughness;
  68109. /**
  68110. * Calculates the surface reflectance, independent of lighting conditions
  68111. * @param color Color source to calculate brightness from
  68112. * @returns number representing the perceived brightness, or zero if color is undefined
  68113. */
  68114. private _getPerceivedBrightness;
  68115. /**
  68116. * Returns the maximum color component value
  68117. * @param color
  68118. * @returns maximum color component value, or zero if color is null or undefined
  68119. */
  68120. private _getMaxComponent;
  68121. /**
  68122. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68123. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68124. * @param mimeType mime type to use for the textures
  68125. * @param images array of glTF image interfaces
  68126. * @param textures array of glTF texture interfaces
  68127. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68128. * @param imageData map of image file name to data
  68129. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68130. * @returns glTF PBR Metallic Roughness factors
  68131. */
  68132. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68133. private _getGLTFTextureSampler;
  68134. private _getGLTFTextureWrapMode;
  68135. private _getGLTFTextureWrapModesSampler;
  68136. /**
  68137. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68138. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68139. * @param mimeType mime type to use for the textures
  68140. * @param images array of glTF image interfaces
  68141. * @param textures array of glTF texture interfaces
  68142. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68143. * @param imageData map of image file name to data
  68144. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68145. * @returns glTF PBR Metallic Roughness factors
  68146. */
  68147. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68148. /**
  68149. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68150. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68151. * @param mimeType mime type to use for the textures
  68152. * @param images array of glTF image interfaces
  68153. * @param textures array of glTF texture interfaces
  68154. * @param materials array of glTF material interfaces
  68155. * @param imageData map of image file name to data
  68156. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68157. */
  68158. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68159. private setMetallicRoughnessPbrMaterial;
  68160. private getPixelsFromTexture;
  68161. /**
  68162. * Extracts a texture from a Babylon texture into file data and glTF data
  68163. * @param babylonTexture Babylon texture to extract
  68164. * @param mimeType Mime Type of the babylonTexture
  68165. * @return glTF texture info, or null if the texture format is not supported
  68166. */
  68167. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68168. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68169. /**
  68170. * Builds a texture from base64 string
  68171. * @param base64Texture base64 texture string
  68172. * @param baseTextureName Name to use for the texture
  68173. * @param mimeType image mime type for the texture
  68174. * @param images array of images
  68175. * @param textures array of textures
  68176. * @param imageData map of image data
  68177. * @returns glTF texture info, or null if the texture format is not supported
  68178. */
  68179. private _getTextureInfoFromBase64;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /**
  68184. * Class for holding and downloading glTF file data
  68185. */
  68186. export class GLTFData {
  68187. /**
  68188. * Object which contains the file name as the key and its data as the value
  68189. */
  68190. glTFFiles: {
  68191. [fileName: string]: string | Blob;
  68192. };
  68193. /**
  68194. * Initializes the glTF file object
  68195. */
  68196. constructor();
  68197. /**
  68198. * Downloads the glTF data as files based on their names and data
  68199. */
  68200. downloadFiles(): void;
  68201. }
  68202. }
  68203. declare module BABYLON {
  68204. /**
  68205. * Holds a collection of exporter options and parameters
  68206. */
  68207. export interface IExportOptions {
  68208. /**
  68209. * Function which indicates whether a babylon node should be exported or not
  68210. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68211. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68212. */
  68213. shouldExportNode?(node: Node): boolean;
  68214. /**
  68215. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68216. * @param metadata source metadata to read from
  68217. * @returns the data to store to glTF node extras
  68218. */
  68219. metadataSelector?(metadata: any): any;
  68220. /**
  68221. * The sample rate to bake animation curves
  68222. */
  68223. animationSampleRate?: number;
  68224. /**
  68225. * Begin serialization without waiting for the scene to be ready
  68226. */
  68227. exportWithoutWaitingForScene?: boolean;
  68228. }
  68229. /**
  68230. * Class for generating glTF data from a Babylon scene.
  68231. */
  68232. export class GLTF2Export {
  68233. /**
  68234. * Exports the geometry of the scene to .gltf file format asynchronously
  68235. * @param scene Babylon scene with scene hierarchy information
  68236. * @param filePrefix File prefix to use when generating the glTF file
  68237. * @param options Exporter options
  68238. * @returns Returns an object with a .gltf file and associates texture names
  68239. * as keys and their data and paths as values
  68240. */
  68241. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68242. private static _PreExportAsync;
  68243. private static _PostExportAsync;
  68244. /**
  68245. * Exports the geometry of the scene to .glb file format asychronously
  68246. * @param scene Babylon scene with scene hierarchy information
  68247. * @param filePrefix File prefix to use when generating glb file
  68248. * @param options Exporter options
  68249. * @returns Returns an object with a .glb filename as key and data as value
  68250. */
  68251. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68252. }
  68253. }
  68254. declare module BABYLON.GLTF2.Exporter {
  68255. /**
  68256. * @hidden
  68257. */
  68258. export class _GLTFUtilities {
  68259. /**
  68260. * Creates a buffer view based on the supplied arguments
  68261. * @param bufferIndex index value of the specified buffer
  68262. * @param byteOffset byte offset value
  68263. * @param byteLength byte length of the bufferView
  68264. * @param byteStride byte distance between conequential elements
  68265. * @param name name of the buffer view
  68266. * @returns bufferView for glTF
  68267. */
  68268. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68269. /**
  68270. * Creates an accessor based on the supplied arguments
  68271. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68272. * @param name The name of the accessor
  68273. * @param type The type of the accessor
  68274. * @param componentType The datatype of components in the attribute
  68275. * @param count The number of attributes referenced by this accessor
  68276. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68277. * @param min Minimum value of each component in this attribute
  68278. * @param max Maximum value of each component in this attribute
  68279. * @returns accessor for glTF
  68280. */
  68281. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68282. /**
  68283. * Calculates the minimum and maximum values of an array of position floats
  68284. * @param positions Positions array of a mesh
  68285. * @param vertexStart Starting vertex offset to calculate min and max values
  68286. * @param vertexCount Number of vertices to check for min and max values
  68287. * @returns min number array and max number array
  68288. */
  68289. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68290. min: number[];
  68291. max: number[];
  68292. };
  68293. /**
  68294. * Converts a new right-handed Vector3
  68295. * @param vector vector3 array
  68296. * @returns right-handed Vector3
  68297. */
  68298. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68299. /**
  68300. * Converts a Vector3 to right-handed
  68301. * @param vector Vector3 to convert to right-handed
  68302. */
  68303. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68304. /**
  68305. * Converts a three element number array to right-handed
  68306. * @param vector number array to convert to right-handed
  68307. */
  68308. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68309. /**
  68310. * Converts a new right-handed Vector3
  68311. * @param vector vector3 array
  68312. * @returns right-handed Vector3
  68313. */
  68314. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68315. /**
  68316. * Converts a Vector3 to right-handed
  68317. * @param vector Vector3 to convert to right-handed
  68318. */
  68319. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68320. /**
  68321. * Converts a three element number array to right-handed
  68322. * @param vector number array to convert to right-handed
  68323. */
  68324. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68325. /**
  68326. * Converts a Vector4 to right-handed
  68327. * @param vector Vector4 to convert to right-handed
  68328. */
  68329. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68330. /**
  68331. * Converts a Vector4 to right-handed
  68332. * @param vector Vector4 to convert to right-handed
  68333. */
  68334. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68335. /**
  68336. * Converts a Quaternion to right-handed
  68337. * @param quaternion Source quaternion to convert to right-handed
  68338. */
  68339. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68340. /**
  68341. * Converts a Quaternion to right-handed
  68342. * @param quaternion Source quaternion to convert to right-handed
  68343. */
  68344. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68345. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68346. }
  68347. }
  68348. declare module BABYLON.GLTF2.Exporter {
  68349. /**
  68350. * Converts Babylon Scene into glTF 2.0.
  68351. * @hidden
  68352. */
  68353. export class _Exporter {
  68354. /**
  68355. * Stores the glTF to export
  68356. */
  68357. _glTF: IGLTF;
  68358. /**
  68359. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68360. */
  68361. _bufferViews: IBufferView[];
  68362. /**
  68363. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68364. */
  68365. _accessors: IAccessor[];
  68366. /**
  68367. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68368. */
  68369. private _nodes;
  68370. /**
  68371. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68372. */
  68373. private _scenes;
  68374. /**
  68375. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68376. */
  68377. private _meshes;
  68378. /**
  68379. * Stores all the generated material information, which represents the appearance of each primitive
  68380. */
  68381. _materials: IMaterial[];
  68382. _materialMap: {
  68383. [materialID: number]: number;
  68384. };
  68385. /**
  68386. * Stores all the generated texture information, which is referenced by glTF materials
  68387. */
  68388. _textures: ITexture[];
  68389. /**
  68390. * Stores all the generated image information, which is referenced by glTF textures
  68391. */
  68392. _images: IImage[];
  68393. /**
  68394. * Stores all the texture samplers
  68395. */
  68396. _samplers: ISampler[];
  68397. /**
  68398. * Stores all the generated animation samplers, which is referenced by glTF animations
  68399. */
  68400. /**
  68401. * Stores the animations for glTF models
  68402. */
  68403. private _animations;
  68404. /**
  68405. * Stores the total amount of bytes stored in the glTF buffer
  68406. */
  68407. private _totalByteLength;
  68408. /**
  68409. * Stores a reference to the Babylon scene containing the source geometry and material information
  68410. */
  68411. _babylonScene: Scene;
  68412. /**
  68413. * Stores a map of the image data, where the key is the file name and the value
  68414. * is the image data
  68415. */
  68416. _imageData: {
  68417. [fileName: string]: {
  68418. data: Uint8Array;
  68419. mimeType: ImageMimeType;
  68420. };
  68421. };
  68422. /**
  68423. * Stores a map of the unique id of a node to its index in the node array
  68424. */
  68425. private _nodeMap;
  68426. /**
  68427. * Specifies if the Babylon scene should be converted to right-handed on export
  68428. */
  68429. _convertToRightHandedSystem: boolean;
  68430. /**
  68431. * Baked animation sample rate
  68432. */
  68433. private _animationSampleRate;
  68434. private _options;
  68435. private _localEngine;
  68436. _glTFMaterialExporter: _GLTFMaterialExporter;
  68437. private _extensions;
  68438. private static _ExtensionNames;
  68439. private static _ExtensionFactories;
  68440. private _applyExtensions;
  68441. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68442. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68443. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68444. private _forEachExtensions;
  68445. private _extensionsOnExporting;
  68446. /**
  68447. * Load glTF serializer extensions
  68448. */
  68449. private _loadExtensions;
  68450. /**
  68451. * Creates a glTF Exporter instance, which can accept optional exporter options
  68452. * @param babylonScene Babylon scene object
  68453. * @param options Options to modify the behavior of the exporter
  68454. */
  68455. constructor(babylonScene: Scene, options?: IExportOptions);
  68456. /**
  68457. * Registers a glTF exporter extension
  68458. * @param name Name of the extension to export
  68459. * @param factory The factory function that creates the exporter extension
  68460. */
  68461. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68462. /**
  68463. * Un-registers an exporter extension
  68464. * @param name The name fo the exporter extension
  68465. * @returns A boolean indicating whether the extension has been un-registered
  68466. */
  68467. static UnregisterExtension(name: string): boolean;
  68468. /**
  68469. * Lazy load a local engine with premultiplied alpha set to false
  68470. */
  68471. _getLocalEngine(): Engine;
  68472. private reorderIndicesBasedOnPrimitiveMode;
  68473. /**
  68474. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68475. * clock-wise during export to glTF
  68476. * @param submesh BabylonJS submesh
  68477. * @param primitiveMode Primitive mode of the mesh
  68478. * @param sideOrientation the winding order of the submesh
  68479. * @param vertexBufferKind The type of vertex attribute
  68480. * @param meshAttributeArray The vertex attribute data
  68481. * @param byteOffset The offset to the binary data
  68482. * @param binaryWriter The binary data for the glTF file
  68483. */
  68484. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68485. /**
  68486. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68487. * clock-wise during export to glTF
  68488. * @param submesh BabylonJS submesh
  68489. * @param primitiveMode Primitive mode of the mesh
  68490. * @param sideOrientation the winding order of the submesh
  68491. * @param vertexBufferKind The type of vertex attribute
  68492. * @param meshAttributeArray The vertex attribute data
  68493. * @param byteOffset The offset to the binary data
  68494. * @param binaryWriter The binary data for the glTF file
  68495. */
  68496. private reorderTriangleFillMode;
  68497. /**
  68498. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68499. * clock-wise during export to glTF
  68500. * @param submesh BabylonJS submesh
  68501. * @param primitiveMode Primitive mode of the mesh
  68502. * @param sideOrientation the winding order of the submesh
  68503. * @param vertexBufferKind The type of vertex attribute
  68504. * @param meshAttributeArray The vertex attribute data
  68505. * @param byteOffset The offset to the binary data
  68506. * @param binaryWriter The binary data for the glTF file
  68507. */
  68508. private reorderTriangleStripDrawMode;
  68509. /**
  68510. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68511. * clock-wise during export to glTF
  68512. * @param submesh BabylonJS submesh
  68513. * @param primitiveMode Primitive mode of the mesh
  68514. * @param sideOrientation the winding order of the submesh
  68515. * @param vertexBufferKind The type of vertex attribute
  68516. * @param meshAttributeArray The vertex attribute data
  68517. * @param byteOffset The offset to the binary data
  68518. * @param binaryWriter The binary data for the glTF file
  68519. */
  68520. private reorderTriangleFanMode;
  68521. /**
  68522. * Writes the vertex attribute data to binary
  68523. * @param vertices The vertices to write to the binary writer
  68524. * @param byteOffset The offset into the binary writer to overwrite binary data
  68525. * @param vertexAttributeKind The vertex attribute type
  68526. * @param meshAttributeArray The vertex attribute data
  68527. * @param binaryWriter The writer containing the binary data
  68528. */
  68529. private writeVertexAttributeData;
  68530. /**
  68531. * Writes mesh attribute data to a data buffer
  68532. * Returns the bytelength of the data
  68533. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68534. * @param meshAttributeArray Array containing the attribute data
  68535. * @param binaryWriter The buffer to write the binary data to
  68536. * @param indices Used to specify the order of the vertex data
  68537. */
  68538. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68539. /**
  68540. * Generates glTF json data
  68541. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68542. * @param glTFPrefix Text to use when prefixing a glTF file
  68543. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68544. * @returns json data as string
  68545. */
  68546. private generateJSON;
  68547. /**
  68548. * Generates data for .gltf and .bin files based on the glTF prefix string
  68549. * @param glTFPrefix Text to use when prefixing a glTF file
  68550. * @returns GLTFData with glTF file data
  68551. */
  68552. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68553. /**
  68554. * Creates a binary buffer for glTF
  68555. * @returns array buffer for binary data
  68556. */
  68557. private _generateBinaryAsync;
  68558. /**
  68559. * Pads the number to a multiple of 4
  68560. * @param num number to pad
  68561. * @returns padded number
  68562. */
  68563. private _getPadding;
  68564. /**
  68565. * Generates a glb file from the json and binary data
  68566. * Returns an object with the glb file name as the key and data as the value
  68567. * @param glTFPrefix
  68568. * @returns object with glb filename as key and data as value
  68569. */
  68570. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68571. /**
  68572. * Sets the TRS for each node
  68573. * @param node glTF Node for storing the transformation data
  68574. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68575. */
  68576. private setNodeTransformation;
  68577. private getVertexBufferFromMesh;
  68578. /**
  68579. * Creates a bufferview based on the vertices type for the Babylon mesh
  68580. * @param kind Indicates the type of vertices data
  68581. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68582. * @param binaryWriter The buffer to write the bufferview data to
  68583. */
  68584. private createBufferViewKind;
  68585. /**
  68586. * The primitive mode of the Babylon mesh
  68587. * @param babylonMesh The BabylonJS mesh
  68588. */
  68589. private getMeshPrimitiveMode;
  68590. /**
  68591. * Sets the primitive mode of the glTF mesh primitive
  68592. * @param meshPrimitive glTF mesh primitive
  68593. * @param primitiveMode The primitive mode
  68594. */
  68595. private setPrimitiveMode;
  68596. /**
  68597. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68598. * @param meshPrimitive glTF mesh primitive
  68599. * @param attributeKind vertex attribute
  68600. * @returns boolean specifying if uv coordinates are present
  68601. */
  68602. private setAttributeKind;
  68603. /**
  68604. * Sets data for the primitive attributes of each submesh
  68605. * @param mesh glTF Mesh object to store the primitive attribute information
  68606. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68607. * @param binaryWriter Buffer to write the attribute data to
  68608. */
  68609. private setPrimitiveAttributesAsync;
  68610. /**
  68611. * Creates a glTF scene based on the array of meshes
  68612. * Returns the the total byte offset
  68613. * @param babylonScene Babylon scene to get the mesh data from
  68614. * @param binaryWriter Buffer to write binary data to
  68615. */
  68616. private createSceneAsync;
  68617. /**
  68618. * Creates a mapping of Node unique id to node index and handles animations
  68619. * @param babylonScene Babylon Scene
  68620. * @param nodes Babylon transform nodes
  68621. * @param binaryWriter Buffer to write binary data to
  68622. * @returns Node mapping of unique id to index
  68623. */
  68624. private createNodeMapAndAnimationsAsync;
  68625. /**
  68626. * Creates a glTF node from a Babylon mesh
  68627. * @param babylonMesh Source Babylon mesh
  68628. * @param binaryWriter Buffer for storing geometry data
  68629. * @returns glTF node
  68630. */
  68631. private createNodeAsync;
  68632. }
  68633. /**
  68634. * @hidden
  68635. *
  68636. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68637. */
  68638. export class _BinaryWriter {
  68639. /**
  68640. * Array buffer which stores all binary data
  68641. */
  68642. private _arrayBuffer;
  68643. /**
  68644. * View of the array buffer
  68645. */
  68646. private _dataView;
  68647. /**
  68648. * byte offset of data in array buffer
  68649. */
  68650. private _byteOffset;
  68651. /**
  68652. * Initialize binary writer with an initial byte length
  68653. * @param byteLength Initial byte length of the array buffer
  68654. */
  68655. constructor(byteLength: number);
  68656. /**
  68657. * Resize the array buffer to the specified byte length
  68658. * @param byteLength
  68659. */
  68660. private resizeBuffer;
  68661. /**
  68662. * Get an array buffer with the length of the byte offset
  68663. * @returns ArrayBuffer resized to the byte offset
  68664. */
  68665. getArrayBuffer(): ArrayBuffer;
  68666. /**
  68667. * Get the byte offset of the array buffer
  68668. * @returns byte offset
  68669. */
  68670. getByteOffset(): number;
  68671. /**
  68672. * Stores an UInt8 in the array buffer
  68673. * @param entry
  68674. * @param byteOffset If defined, specifies where to set the value as an offset.
  68675. */
  68676. setUInt8(entry: number, byteOffset?: number): void;
  68677. /**
  68678. * Gets an UInt32 in the array buffer
  68679. * @param entry
  68680. * @param byteOffset If defined, specifies where to set the value as an offset.
  68681. */
  68682. getUInt32(byteOffset: number): number;
  68683. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68684. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68685. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68686. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68687. /**
  68688. * Stores a Float32 in the array buffer
  68689. * @param entry
  68690. */
  68691. setFloat32(entry: number, byteOffset?: number): void;
  68692. /**
  68693. * Stores an UInt32 in the array buffer
  68694. * @param entry
  68695. * @param byteOffset If defined, specifies where to set the value as an offset.
  68696. */
  68697. setUInt32(entry: number, byteOffset?: number): void;
  68698. }
  68699. }
  68700. declare module BABYLON.GLTF2.Exporter {
  68701. /**
  68702. * @hidden
  68703. * Interface to store animation data.
  68704. */
  68705. export interface _IAnimationData {
  68706. /**
  68707. * Keyframe data.
  68708. */
  68709. inputs: number[];
  68710. /**
  68711. * Value data.
  68712. */
  68713. outputs: number[][];
  68714. /**
  68715. * Animation interpolation data.
  68716. */
  68717. samplerInterpolation: AnimationSamplerInterpolation;
  68718. /**
  68719. * Minimum keyframe value.
  68720. */
  68721. inputsMin: number;
  68722. /**
  68723. * Maximum keyframe value.
  68724. */
  68725. inputsMax: number;
  68726. }
  68727. /**
  68728. * @hidden
  68729. */
  68730. export interface _IAnimationInfo {
  68731. /**
  68732. * The target channel for the animation
  68733. */
  68734. animationChannelTargetPath: AnimationChannelTargetPath;
  68735. /**
  68736. * The glTF accessor type for the data.
  68737. */
  68738. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68739. /**
  68740. * Specifies if quaternions should be used.
  68741. */
  68742. useQuaternion: boolean;
  68743. }
  68744. /**
  68745. * @hidden
  68746. * Utility class for generating glTF animation data from BabylonJS.
  68747. */
  68748. export class _GLTFAnimation {
  68749. /**
  68750. * @ignore
  68751. *
  68752. * Creates glTF channel animation from BabylonJS animation.
  68753. * @param babylonTransformNode - BabylonJS mesh.
  68754. * @param animation - animation.
  68755. * @param animationChannelTargetPath - The target animation channel.
  68756. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68757. * @param useQuaternion - Specifies if quaternions are used.
  68758. * @returns nullable IAnimationData
  68759. */
  68760. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68761. private static _DeduceAnimationInfo;
  68762. /**
  68763. * @ignore
  68764. * Create node animations from the transform node animations
  68765. * @param babylonNode
  68766. * @param runtimeGLTFAnimation
  68767. * @param idleGLTFAnimations
  68768. * @param nodeMap
  68769. * @param nodes
  68770. * @param binaryWriter
  68771. * @param bufferViews
  68772. * @param accessors
  68773. * @param convertToRightHandedSystem
  68774. */
  68775. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68776. [key: number]: number;
  68777. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68778. /**
  68779. * @ignore
  68780. * Create node animations from the animation groups
  68781. * @param babylonScene
  68782. * @param glTFAnimations
  68783. * @param nodeMap
  68784. * @param nodes
  68785. * @param binaryWriter
  68786. * @param bufferViews
  68787. * @param accessors
  68788. * @param convertToRightHandedSystem
  68789. */
  68790. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68791. [key: number]: number;
  68792. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68793. private static AddAnimation;
  68794. /**
  68795. * Create a baked animation
  68796. * @param babylonTransformNode BabylonJS mesh
  68797. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68798. * @param animationChannelTargetPath animation target channel
  68799. * @param minFrame minimum animation frame
  68800. * @param maxFrame maximum animation frame
  68801. * @param fps frames per second of the animation
  68802. * @param inputs input key frames of the animation
  68803. * @param outputs output key frame data of the animation
  68804. * @param convertToRightHandedSystem converts the values to right-handed
  68805. * @param useQuaternion specifies if quaternions should be used
  68806. */
  68807. private static _CreateBakedAnimation;
  68808. private static _ConvertFactorToVector3OrQuaternion;
  68809. private static _SetInterpolatedValue;
  68810. /**
  68811. * Creates linear animation from the animation key frames
  68812. * @param babylonTransformNode BabylonJS mesh
  68813. * @param animation BabylonJS animation
  68814. * @param animationChannelTargetPath The target animation channel
  68815. * @param frameDelta The difference between the last and first frame of the animation
  68816. * @param inputs Array to store the key frame times
  68817. * @param outputs Array to store the key frame data
  68818. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68819. * @param useQuaternion Specifies if quaternions are used in the animation
  68820. */
  68821. private static _CreateLinearOrStepAnimation;
  68822. /**
  68823. * Creates cubic spline animation from the animation key frames
  68824. * @param babylonTransformNode BabylonJS mesh
  68825. * @param animation BabylonJS animation
  68826. * @param animationChannelTargetPath The target animation channel
  68827. * @param frameDelta The difference between the last and first frame of the animation
  68828. * @param inputs Array to store the key frame times
  68829. * @param outputs Array to store the key frame data
  68830. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68831. * @param useQuaternion Specifies if quaternions are used in the animation
  68832. */
  68833. private static _CreateCubicSplineAnimation;
  68834. private static _GetBasePositionRotationOrScale;
  68835. /**
  68836. * Adds a key frame value
  68837. * @param keyFrame
  68838. * @param animation
  68839. * @param outputs
  68840. * @param animationChannelTargetPath
  68841. * @param basePositionRotationOrScale
  68842. * @param convertToRightHandedSystem
  68843. * @param useQuaternion
  68844. */
  68845. private static _AddKeyframeValue;
  68846. /**
  68847. * Determine the interpolation based on the key frames
  68848. * @param keyFrames
  68849. * @param animationChannelTargetPath
  68850. * @param useQuaternion
  68851. */
  68852. private static _DeduceInterpolation;
  68853. /**
  68854. * Adds an input tangent or output tangent to the output data
  68855. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68856. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68857. * @param outputs The animation data by keyframe
  68858. * @param animationChannelTargetPath The target animation channel
  68859. * @param interpolation The interpolation type
  68860. * @param keyFrame The key frame with the animation data
  68861. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68862. * @param useQuaternion Specifies if quaternions are used
  68863. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68864. */
  68865. private static AddSplineTangent;
  68866. /**
  68867. * Get the minimum and maximum key frames' frame values
  68868. * @param keyFrames animation key frames
  68869. * @returns the minimum and maximum key frame value
  68870. */
  68871. private static calculateMinMaxKeyFrames;
  68872. }
  68873. }
  68874. declare module BABYLON.GLTF2.Exporter {
  68875. /** @hidden */
  68876. export var textureTransformPixelShader: {
  68877. name: string;
  68878. shader: string;
  68879. };
  68880. }
  68881. declare module BABYLON.GLTF2.Exporter.Extensions {
  68882. /**
  68883. * @hidden
  68884. */
  68885. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68886. /** Name of this extension */
  68887. readonly name: string;
  68888. /** Defines whether this extension is enabled */
  68889. enabled: boolean;
  68890. /** Defines whether this extension is required */
  68891. required: boolean;
  68892. /** Reference to the glTF exporter */
  68893. private _exporter;
  68894. constructor(exporter: _Exporter);
  68895. dispose(): void;
  68896. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68897. /**
  68898. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68899. * @param babylonTexture
  68900. * @param offset
  68901. * @param rotation
  68902. * @param scale
  68903. * @param scene
  68904. */
  68905. private _textureTransformTextureAsync;
  68906. }
  68907. }
  68908. declare module BABYLON.GLTF2.Exporter.Extensions {
  68909. /**
  68910. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68911. */
  68912. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68913. /** The name of this extension. */
  68914. readonly name: string;
  68915. /** Defines whether this extension is enabled. */
  68916. enabled: boolean;
  68917. /** Defines whether this extension is required */
  68918. required: boolean;
  68919. /** Reference to the glTF exporter */
  68920. private _exporter;
  68921. private _lights;
  68922. /** @hidden */
  68923. constructor(exporter: _Exporter);
  68924. /** @hidden */
  68925. dispose(): void;
  68926. /** @hidden */
  68927. onExporting(): void;
  68928. /**
  68929. * Define this method to modify the default behavior when exporting a node
  68930. * @param context The context when exporting the node
  68931. * @param node glTF node
  68932. * @param babylonNode BabylonJS node
  68933. * @returns nullable INode promise
  68934. */
  68935. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68936. }
  68937. }
  68938. declare module BABYLON {
  68939. /**
  68940. * Class for generating STL data from a Babylon scene.
  68941. */
  68942. export class STLExport {
  68943. /**
  68944. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68945. * @param meshes list defines the mesh to serialize
  68946. * @param download triggers the automatic download of the file.
  68947. * @param fileName changes the downloads fileName.
  68948. * @param binary changes the STL to a binary type.
  68949. * @param isLittleEndian toggle for binary type exporter.
  68950. * @returns the STL as UTF8 string
  68951. */
  68952. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68953. }
  68954. }
  68955. /**
  68956. * @ignoreChildren
  68957. * @ignore
  68958. */
  68959. declare module "babylonjs-gltf2interface" {
  68960. export = BABYLON.GLTF2;
  68961. }
  68962. /**
  68963. * Module for glTF 2.0 Interface
  68964. * @ignoreChildren
  68965. * @ignore
  68966. */
  68967. declare module BABYLON.GLTF2 {
  68968. /**
  68969. * The datatype of the components in the attribute
  68970. */
  68971. const enum AccessorComponentType {
  68972. /**
  68973. * Byte
  68974. */
  68975. BYTE = 5120,
  68976. /**
  68977. * Unsigned Byte
  68978. */
  68979. UNSIGNED_BYTE = 5121,
  68980. /**
  68981. * Short
  68982. */
  68983. SHORT = 5122,
  68984. /**
  68985. * Unsigned Short
  68986. */
  68987. UNSIGNED_SHORT = 5123,
  68988. /**
  68989. * Unsigned Int
  68990. */
  68991. UNSIGNED_INT = 5125,
  68992. /**
  68993. * Float
  68994. */
  68995. FLOAT = 5126,
  68996. }
  68997. /**
  68998. * Specifies if the attirbute is a scalar, vector, or matrix
  68999. */
  69000. const enum AccessorType {
  69001. /**
  69002. * Scalar
  69003. */
  69004. SCALAR = "SCALAR",
  69005. /**
  69006. * Vector2
  69007. */
  69008. VEC2 = "VEC2",
  69009. /**
  69010. * Vector3
  69011. */
  69012. VEC3 = "VEC3",
  69013. /**
  69014. * Vector4
  69015. */
  69016. VEC4 = "VEC4",
  69017. /**
  69018. * Matrix2x2
  69019. */
  69020. MAT2 = "MAT2",
  69021. /**
  69022. * Matrix3x3
  69023. */
  69024. MAT3 = "MAT3",
  69025. /**
  69026. * Matrix4x4
  69027. */
  69028. MAT4 = "MAT4",
  69029. }
  69030. /**
  69031. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69032. */
  69033. const enum AnimationChannelTargetPath {
  69034. /**
  69035. * Translation
  69036. */
  69037. TRANSLATION = "translation",
  69038. /**
  69039. * Rotation
  69040. */
  69041. ROTATION = "rotation",
  69042. /**
  69043. * Scale
  69044. */
  69045. SCALE = "scale",
  69046. /**
  69047. * Weights
  69048. */
  69049. WEIGHTS = "weights",
  69050. }
  69051. /**
  69052. * Interpolation algorithm
  69053. */
  69054. const enum AnimationSamplerInterpolation {
  69055. /**
  69056. * The animated values are linearly interpolated between keyframes
  69057. */
  69058. LINEAR = "LINEAR",
  69059. /**
  69060. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69061. */
  69062. STEP = "STEP",
  69063. /**
  69064. * The animation's interpolation is computed using a cubic spline with specified tangents
  69065. */
  69066. CUBICSPLINE = "CUBICSPLINE",
  69067. }
  69068. /**
  69069. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69070. */
  69071. const enum CameraType {
  69072. /**
  69073. * A perspective camera containing properties to create a perspective projection matrix
  69074. */
  69075. PERSPECTIVE = "perspective",
  69076. /**
  69077. * An orthographic camera containing properties to create an orthographic projection matrix
  69078. */
  69079. ORTHOGRAPHIC = "orthographic",
  69080. }
  69081. /**
  69082. * The mime-type of the image
  69083. */
  69084. const enum ImageMimeType {
  69085. /**
  69086. * JPEG Mime-type
  69087. */
  69088. JPEG = "image/jpeg",
  69089. /**
  69090. * PNG Mime-type
  69091. */
  69092. PNG = "image/png",
  69093. }
  69094. /**
  69095. * The alpha rendering mode of the material
  69096. */
  69097. const enum MaterialAlphaMode {
  69098. /**
  69099. * The alpha value is ignored and the rendered output is fully opaque
  69100. */
  69101. OPAQUE = "OPAQUE",
  69102. /**
  69103. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69104. */
  69105. MASK = "MASK",
  69106. /**
  69107. * 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)
  69108. */
  69109. BLEND = "BLEND",
  69110. }
  69111. /**
  69112. * The type of the primitives to render
  69113. */
  69114. const enum MeshPrimitiveMode {
  69115. /**
  69116. * Points
  69117. */
  69118. POINTS = 0,
  69119. /**
  69120. * Lines
  69121. */
  69122. LINES = 1,
  69123. /**
  69124. * Line Loop
  69125. */
  69126. LINE_LOOP = 2,
  69127. /**
  69128. * Line Strip
  69129. */
  69130. LINE_STRIP = 3,
  69131. /**
  69132. * Triangles
  69133. */
  69134. TRIANGLES = 4,
  69135. /**
  69136. * Triangle Strip
  69137. */
  69138. TRIANGLE_STRIP = 5,
  69139. /**
  69140. * Triangle Fan
  69141. */
  69142. TRIANGLE_FAN = 6,
  69143. }
  69144. /**
  69145. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69146. */
  69147. const enum TextureMagFilter {
  69148. /**
  69149. * Nearest
  69150. */
  69151. NEAREST = 9728,
  69152. /**
  69153. * Linear
  69154. */
  69155. LINEAR = 9729,
  69156. }
  69157. /**
  69158. * Minification filter. All valid values correspond to WebGL enums
  69159. */
  69160. const enum TextureMinFilter {
  69161. /**
  69162. * Nearest
  69163. */
  69164. NEAREST = 9728,
  69165. /**
  69166. * Linear
  69167. */
  69168. LINEAR = 9729,
  69169. /**
  69170. * Nearest Mip-Map Nearest
  69171. */
  69172. NEAREST_MIPMAP_NEAREST = 9984,
  69173. /**
  69174. * Linear Mipmap Nearest
  69175. */
  69176. LINEAR_MIPMAP_NEAREST = 9985,
  69177. /**
  69178. * Nearest Mipmap Linear
  69179. */
  69180. NEAREST_MIPMAP_LINEAR = 9986,
  69181. /**
  69182. * Linear Mipmap Linear
  69183. */
  69184. LINEAR_MIPMAP_LINEAR = 9987,
  69185. }
  69186. /**
  69187. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69188. */
  69189. const enum TextureWrapMode {
  69190. /**
  69191. * Clamp to Edge
  69192. */
  69193. CLAMP_TO_EDGE = 33071,
  69194. /**
  69195. * Mirrored Repeat
  69196. */
  69197. MIRRORED_REPEAT = 33648,
  69198. /**
  69199. * Repeat
  69200. */
  69201. REPEAT = 10497,
  69202. }
  69203. /**
  69204. * glTF Property
  69205. */
  69206. interface IProperty {
  69207. /**
  69208. * Dictionary object with extension-specific objects
  69209. */
  69210. extensions?: {
  69211. [key: string]: any;
  69212. };
  69213. /**
  69214. * Application-Specific data
  69215. */
  69216. extras?: any;
  69217. }
  69218. /**
  69219. * glTF Child of Root Property
  69220. */
  69221. interface IChildRootProperty extends IProperty {
  69222. /**
  69223. * The user-defined name of this object
  69224. */
  69225. name?: string;
  69226. }
  69227. /**
  69228. * Indices of those attributes that deviate from their initialization value
  69229. */
  69230. interface IAccessorSparseIndices extends IProperty {
  69231. /**
  69232. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69233. */
  69234. bufferView: number;
  69235. /**
  69236. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69237. */
  69238. byteOffset?: number;
  69239. /**
  69240. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69241. */
  69242. componentType: AccessorComponentType;
  69243. }
  69244. /**
  69245. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69246. */
  69247. interface IAccessorSparseValues extends IProperty {
  69248. /**
  69249. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69250. */
  69251. bufferView: number;
  69252. /**
  69253. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69254. */
  69255. byteOffset?: number;
  69256. }
  69257. /**
  69258. * Sparse storage of attributes that deviate from their initialization value
  69259. */
  69260. interface IAccessorSparse extends IProperty {
  69261. /**
  69262. * The number of attributes encoded in this sparse accessor
  69263. */
  69264. count: number;
  69265. /**
  69266. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69267. */
  69268. indices: IAccessorSparseIndices;
  69269. /**
  69270. * 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
  69271. */
  69272. values: IAccessorSparseValues;
  69273. }
  69274. /**
  69275. * 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
  69276. */
  69277. interface IAccessor extends IChildRootProperty {
  69278. /**
  69279. * The index of the bufferview
  69280. */
  69281. bufferView?: number;
  69282. /**
  69283. * The offset relative to the start of the bufferView in bytes
  69284. */
  69285. byteOffset?: number;
  69286. /**
  69287. * The datatype of components in the attribute
  69288. */
  69289. componentType: AccessorComponentType;
  69290. /**
  69291. * Specifies whether integer data values should be normalized
  69292. */
  69293. normalized?: boolean;
  69294. /**
  69295. * The number of attributes referenced by this accessor
  69296. */
  69297. count: number;
  69298. /**
  69299. * Specifies if the attribute is a scalar, vector, or matrix
  69300. */
  69301. type: AccessorType;
  69302. /**
  69303. * Maximum value of each component in this attribute
  69304. */
  69305. max?: number[];
  69306. /**
  69307. * Minimum value of each component in this attribute
  69308. */
  69309. min?: number[];
  69310. /**
  69311. * Sparse storage of attributes that deviate from their initialization value
  69312. */
  69313. sparse?: IAccessorSparse;
  69314. }
  69315. /**
  69316. * Targets an animation's sampler at a node's property
  69317. */
  69318. interface IAnimationChannel extends IProperty {
  69319. /**
  69320. * The index of a sampler in this animation used to compute the value for the target
  69321. */
  69322. sampler: number;
  69323. /**
  69324. * The index of the node and TRS property to target
  69325. */
  69326. target: IAnimationChannelTarget;
  69327. }
  69328. /**
  69329. * The index of the node and TRS property that an animation channel targets
  69330. */
  69331. interface IAnimationChannelTarget extends IProperty {
  69332. /**
  69333. * The index of the node to target
  69334. */
  69335. node: number;
  69336. /**
  69337. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69338. */
  69339. path: AnimationChannelTargetPath;
  69340. }
  69341. /**
  69342. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69343. */
  69344. interface IAnimationSampler extends IProperty {
  69345. /**
  69346. * The index of an accessor containing keyframe input values, e.g., time
  69347. */
  69348. input: number;
  69349. /**
  69350. * Interpolation algorithm
  69351. */
  69352. interpolation?: AnimationSamplerInterpolation;
  69353. /**
  69354. * The index of an accessor, containing keyframe output values
  69355. */
  69356. output: number;
  69357. }
  69358. /**
  69359. * A keyframe animation
  69360. */
  69361. interface IAnimation extends IChildRootProperty {
  69362. /**
  69363. * An array of channels, each of which targets an animation's sampler at a node's property
  69364. */
  69365. channels: IAnimationChannel[];
  69366. /**
  69367. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69368. */
  69369. samplers: IAnimationSampler[];
  69370. }
  69371. /**
  69372. * Metadata about the glTF asset
  69373. */
  69374. interface IAsset extends IChildRootProperty {
  69375. /**
  69376. * A copyright message suitable for display to credit the content creator
  69377. */
  69378. copyright?: string;
  69379. /**
  69380. * Tool that generated this glTF model. Useful for debugging
  69381. */
  69382. generator?: string;
  69383. /**
  69384. * The glTF version that this asset targets
  69385. */
  69386. version: string;
  69387. /**
  69388. * The minimum glTF version that this asset targets
  69389. */
  69390. minVersion?: string;
  69391. }
  69392. /**
  69393. * A buffer points to binary geometry, animation, or skins
  69394. */
  69395. interface IBuffer extends IChildRootProperty {
  69396. /**
  69397. * 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
  69398. */
  69399. uri?: string;
  69400. /**
  69401. * The length of the buffer in bytes
  69402. */
  69403. byteLength: number;
  69404. }
  69405. /**
  69406. * A view into a buffer generally representing a subset of the buffer
  69407. */
  69408. interface IBufferView extends IChildRootProperty {
  69409. /**
  69410. * The index of the buffer
  69411. */
  69412. buffer: number;
  69413. /**
  69414. * The offset into the buffer in bytes
  69415. */
  69416. byteOffset?: number;
  69417. /**
  69418. * The lenth of the bufferView in bytes
  69419. */
  69420. byteLength: number;
  69421. /**
  69422. * The stride, in bytes
  69423. */
  69424. byteStride?: number;
  69425. }
  69426. /**
  69427. * An orthographic camera containing properties to create an orthographic projection matrix
  69428. */
  69429. interface ICameraOrthographic extends IProperty {
  69430. /**
  69431. * The floating-point horizontal magnification of the view. Must not be zero
  69432. */
  69433. xmag: number;
  69434. /**
  69435. * The floating-point vertical magnification of the view. Must not be zero
  69436. */
  69437. ymag: number;
  69438. /**
  69439. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69440. */
  69441. zfar: number;
  69442. /**
  69443. * The floating-point distance to the near clipping plane
  69444. */
  69445. znear: number;
  69446. }
  69447. /**
  69448. * A perspective camera containing properties to create a perspective projection matrix
  69449. */
  69450. interface ICameraPerspective extends IProperty {
  69451. /**
  69452. * The floating-point aspect ratio of the field of view
  69453. */
  69454. aspectRatio?: number;
  69455. /**
  69456. * The floating-point vertical field of view in radians
  69457. */
  69458. yfov: number;
  69459. /**
  69460. * The floating-point distance to the far clipping plane
  69461. */
  69462. zfar?: number;
  69463. /**
  69464. * The floating-point distance to the near clipping plane
  69465. */
  69466. znear: number;
  69467. }
  69468. /**
  69469. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69470. */
  69471. interface ICamera extends IChildRootProperty {
  69472. /**
  69473. * An orthographic camera containing properties to create an orthographic projection matrix
  69474. */
  69475. orthographic?: ICameraOrthographic;
  69476. /**
  69477. * A perspective camera containing properties to create a perspective projection matrix
  69478. */
  69479. perspective?: ICameraPerspective;
  69480. /**
  69481. * Specifies if the camera uses a perspective or orthographic projection
  69482. */
  69483. type: CameraType;
  69484. }
  69485. /**
  69486. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69487. */
  69488. interface IImage extends IChildRootProperty {
  69489. /**
  69490. * 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
  69491. */
  69492. uri?: string;
  69493. /**
  69494. * The image's MIME type
  69495. */
  69496. mimeType?: ImageMimeType;
  69497. /**
  69498. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69499. */
  69500. bufferView?: number;
  69501. }
  69502. /**
  69503. * Material Normal Texture Info
  69504. */
  69505. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69506. /**
  69507. * The scalar multiplier applied to each normal vector of the normal texture
  69508. */
  69509. scale?: number;
  69510. }
  69511. /**
  69512. * Material Occlusion Texture Info
  69513. */
  69514. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69515. /**
  69516. * A scalar multiplier controlling the amount of occlusion applied
  69517. */
  69518. strength?: number;
  69519. }
  69520. /**
  69521. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69522. */
  69523. interface IMaterialPbrMetallicRoughness {
  69524. /**
  69525. * The material's base color factor
  69526. */
  69527. baseColorFactor?: number[];
  69528. /**
  69529. * The base color texture
  69530. */
  69531. baseColorTexture?: ITextureInfo;
  69532. /**
  69533. * The metalness of the material
  69534. */
  69535. metallicFactor?: number;
  69536. /**
  69537. * The roughness of the material
  69538. */
  69539. roughnessFactor?: number;
  69540. /**
  69541. * The metallic-roughness texture
  69542. */
  69543. metallicRoughnessTexture?: ITextureInfo;
  69544. }
  69545. /**
  69546. * The material appearance of a primitive
  69547. */
  69548. interface IMaterial extends IChildRootProperty {
  69549. /**
  69550. * 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
  69551. */
  69552. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69553. /**
  69554. * The normal map texture
  69555. */
  69556. normalTexture?: IMaterialNormalTextureInfo;
  69557. /**
  69558. * The occlusion map texture
  69559. */
  69560. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69561. /**
  69562. * The emissive map texture
  69563. */
  69564. emissiveTexture?: ITextureInfo;
  69565. /**
  69566. * 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
  69567. */
  69568. emissiveFactor?: number[];
  69569. /**
  69570. * The alpha rendering mode of the material
  69571. */
  69572. alphaMode?: MaterialAlphaMode;
  69573. /**
  69574. * The alpha cutoff value of the material
  69575. */
  69576. alphaCutoff?: number;
  69577. /**
  69578. * Specifies whether the material is double sided
  69579. */
  69580. doubleSided?: boolean;
  69581. }
  69582. /**
  69583. * Geometry to be rendered with the given material
  69584. */
  69585. interface IMeshPrimitive extends IProperty {
  69586. /**
  69587. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69588. */
  69589. attributes: {
  69590. [name: string]: number;
  69591. };
  69592. /**
  69593. * The index of the accessor that contains the indices
  69594. */
  69595. indices?: number;
  69596. /**
  69597. * The index of the material to apply to this primitive when rendering
  69598. */
  69599. material?: number;
  69600. /**
  69601. * The type of primitives to render. All valid values correspond to WebGL enums
  69602. */
  69603. mode?: MeshPrimitiveMode;
  69604. /**
  69605. * 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
  69606. */
  69607. targets?: {
  69608. [name: string]: number;
  69609. }[];
  69610. }
  69611. /**
  69612. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69613. */
  69614. interface IMesh extends IChildRootProperty {
  69615. /**
  69616. * An array of primitives, each defining geometry to be rendered with a material
  69617. */
  69618. primitives: IMeshPrimitive[];
  69619. /**
  69620. * Array of weights to be applied to the Morph Targets
  69621. */
  69622. weights?: number[];
  69623. }
  69624. /**
  69625. * A node in the node hierarchy
  69626. */
  69627. interface INode extends IChildRootProperty {
  69628. /**
  69629. * The index of the camera referenced by this node
  69630. */
  69631. camera?: number;
  69632. /**
  69633. * The indices of this node's children
  69634. */
  69635. children?: number[];
  69636. /**
  69637. * The index of the skin referenced by this node
  69638. */
  69639. skin?: number;
  69640. /**
  69641. * A floating-point 4x4 transformation matrix stored in column-major order
  69642. */
  69643. matrix?: number[];
  69644. /**
  69645. * The index of the mesh in this node
  69646. */
  69647. mesh?: number;
  69648. /**
  69649. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69650. */
  69651. rotation?: number[];
  69652. /**
  69653. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69654. */
  69655. scale?: number[];
  69656. /**
  69657. * The node's translation along the x, y, and z axes
  69658. */
  69659. translation?: number[];
  69660. /**
  69661. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69662. */
  69663. weights?: number[];
  69664. }
  69665. /**
  69666. * Texture sampler properties for filtering and wrapping modes
  69667. */
  69668. interface ISampler extends IChildRootProperty {
  69669. /**
  69670. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69671. */
  69672. magFilter?: TextureMagFilter;
  69673. /**
  69674. * Minification filter. All valid values correspond to WebGL enums
  69675. */
  69676. minFilter?: TextureMinFilter;
  69677. /**
  69678. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69679. */
  69680. wrapS?: TextureWrapMode;
  69681. /**
  69682. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69683. */
  69684. wrapT?: TextureWrapMode;
  69685. }
  69686. /**
  69687. * The root nodes of a scene
  69688. */
  69689. interface IScene extends IChildRootProperty {
  69690. /**
  69691. * The indices of each root node
  69692. */
  69693. nodes: number[];
  69694. }
  69695. /**
  69696. * Joints and matrices defining a skin
  69697. */
  69698. interface ISkin extends IChildRootProperty {
  69699. /**
  69700. * 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
  69701. */
  69702. inverseBindMatrices?: number;
  69703. /**
  69704. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69705. */
  69706. skeleton?: number;
  69707. /**
  69708. * 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)
  69709. */
  69710. joints: number[];
  69711. }
  69712. /**
  69713. * A texture and its sampler
  69714. */
  69715. interface ITexture extends IChildRootProperty {
  69716. /**
  69717. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69718. */
  69719. sampler?: number;
  69720. /**
  69721. * The index of the image used by this texture
  69722. */
  69723. source: number;
  69724. }
  69725. /**
  69726. * Reference to a texture
  69727. */
  69728. interface ITextureInfo extends IProperty {
  69729. /**
  69730. * The index of the texture
  69731. */
  69732. index: number;
  69733. /**
  69734. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69735. */
  69736. texCoord?: number;
  69737. }
  69738. /**
  69739. * The root object for a glTF asset
  69740. */
  69741. interface IGLTF extends IProperty {
  69742. /**
  69743. * An array of accessors. An accessor is a typed view into a bufferView
  69744. */
  69745. accessors?: IAccessor[];
  69746. /**
  69747. * An array of keyframe animations
  69748. */
  69749. animations?: IAnimation[];
  69750. /**
  69751. * Metadata about the glTF asset
  69752. */
  69753. asset: IAsset;
  69754. /**
  69755. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69756. */
  69757. buffers?: IBuffer[];
  69758. /**
  69759. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69760. */
  69761. bufferViews?: IBufferView[];
  69762. /**
  69763. * An array of cameras
  69764. */
  69765. cameras?: ICamera[];
  69766. /**
  69767. * Names of glTF extensions used somewhere in this asset
  69768. */
  69769. extensionsUsed?: string[];
  69770. /**
  69771. * Names of glTF extensions required to properly load this asset
  69772. */
  69773. extensionsRequired?: string[];
  69774. /**
  69775. * An array of images. An image defines data used to create a texture
  69776. */
  69777. images?: IImage[];
  69778. /**
  69779. * An array of materials. A material defines the appearance of a primitive
  69780. */
  69781. materials?: IMaterial[];
  69782. /**
  69783. * An array of meshes. A mesh is a set of primitives to be rendered
  69784. */
  69785. meshes?: IMesh[];
  69786. /**
  69787. * An array of nodes
  69788. */
  69789. nodes?: INode[];
  69790. /**
  69791. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69792. */
  69793. samplers?: ISampler[];
  69794. /**
  69795. * The index of the default scene
  69796. */
  69797. scene?: number;
  69798. /**
  69799. * An array of scenes
  69800. */
  69801. scenes?: IScene[];
  69802. /**
  69803. * An array of skins. A skin is defined by joints and matrices
  69804. */
  69805. skins?: ISkin[];
  69806. /**
  69807. * An array of textures
  69808. */
  69809. textures?: ITexture[];
  69810. }
  69811. /**
  69812. * The glTF validation results
  69813. */
  69814. interface IGLTFValidationResults {
  69815. info: {
  69816. generator: string;
  69817. hasAnimations: boolean;
  69818. hasDefaultScene: boolean;
  69819. hasMaterials: boolean;
  69820. hasMorphTargets: boolean;
  69821. hasSkins: boolean;
  69822. hasTextures: boolean;
  69823. maxAttributesUsed: number;
  69824. primitivesCount: number
  69825. };
  69826. issues: {
  69827. messages: Array<string>;
  69828. numErrors: number;
  69829. numHints: number;
  69830. numInfos: number;
  69831. numWarnings: number;
  69832. truncated: boolean
  69833. };
  69834. mimeType: string;
  69835. uri: string;
  69836. validatedAt: string;
  69837. validatorVersion: string;
  69838. }
  69839. /**
  69840. * The glTF validation options
  69841. */
  69842. interface IGLTFValidationOptions {
  69843. uri?: string;
  69844. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69845. validateAccessorData?: boolean;
  69846. maxIssues?: number;
  69847. ignoredIssues?: Array<string>;
  69848. severityOverrides?: Object;
  69849. }
  69850. /**
  69851. * The glTF validator object
  69852. */
  69853. interface IGLTFValidator {
  69854. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69855. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69856. }
  69857. }
  69858. declare module BABYLON {
  69859. /** @hidden */
  69860. export var cellPixelShader: {
  69861. name: string;
  69862. shader: string;
  69863. };
  69864. }
  69865. declare module BABYLON {
  69866. /** @hidden */
  69867. export var cellVertexShader: {
  69868. name: string;
  69869. shader: string;
  69870. };
  69871. }
  69872. declare module BABYLON {
  69873. export class CellMaterial extends BABYLON.PushMaterial {
  69874. private _diffuseTexture;
  69875. diffuseTexture: BABYLON.BaseTexture;
  69876. diffuseColor: BABYLON.Color3;
  69877. _computeHighLevel: boolean;
  69878. computeHighLevel: boolean;
  69879. private _disableLighting;
  69880. disableLighting: boolean;
  69881. private _maxSimultaneousLights;
  69882. maxSimultaneousLights: number;
  69883. private _renderId;
  69884. constructor(name: string, scene: BABYLON.Scene);
  69885. needAlphaBlending(): boolean;
  69886. needAlphaTesting(): boolean;
  69887. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69888. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69889. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69890. getAnimatables(): BABYLON.IAnimatable[];
  69891. getActiveTextures(): BABYLON.BaseTexture[];
  69892. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69893. dispose(forceDisposeEffect?: boolean): void;
  69894. getClassName(): string;
  69895. clone(name: string): CellMaterial;
  69896. serialize(): any;
  69897. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69898. }
  69899. }
  69900. declare module BABYLON {
  69901. export class CustomShaderStructure {
  69902. FragmentStore: string;
  69903. VertexStore: string;
  69904. constructor();
  69905. }
  69906. export class ShaderSpecialParts {
  69907. constructor();
  69908. Fragment_Begin: string;
  69909. Fragment_Definitions: string;
  69910. Fragment_MainBegin: string;
  69911. Fragment_Custom_Diffuse: string;
  69912. Fragment_Before_Lights: string;
  69913. Fragment_Before_Fog: string;
  69914. Fragment_Custom_Alpha: string;
  69915. Fragment_Before_FragColor: string;
  69916. Vertex_Begin: string;
  69917. Vertex_Definitions: string;
  69918. Vertex_MainBegin: string;
  69919. Vertex_Before_PositionUpdated: string;
  69920. Vertex_Before_NormalUpdated: string;
  69921. Vertex_MainEnd: string;
  69922. }
  69923. export class CustomMaterial extends BABYLON.StandardMaterial {
  69924. static ShaderIndexer: number;
  69925. CustomParts: ShaderSpecialParts;
  69926. _isCreatedShader: boolean;
  69927. _createdShaderName: string;
  69928. _customUniform: string[];
  69929. _newUniforms: string[];
  69930. _newUniformInstances: any[];
  69931. _newSamplerInstances: BABYLON.Texture[];
  69932. FragmentShader: string;
  69933. VertexShader: string;
  69934. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69935. ReviewUniform(name: string, arr: string[]): string[];
  69936. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69937. constructor(name: string, scene: BABYLON.Scene);
  69938. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69939. Fragment_Begin(shaderPart: string): CustomMaterial;
  69940. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69941. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69942. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69943. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69944. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69945. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69946. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69947. Vertex_Begin(shaderPart: string): CustomMaterial;
  69948. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69949. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69950. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69951. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69952. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69953. }
  69954. }
  69955. declare module BABYLON {
  69956. export class ShaderAlebdoParts {
  69957. constructor();
  69958. Fragment_Begin: string;
  69959. Fragment_Definitions: string;
  69960. Fragment_MainBegin: string;
  69961. Fragment_Custom_Albedo: string;
  69962. Fragment_Before_Lights: string;
  69963. Fragment_Custom_MetallicRoughness: string;
  69964. Fragment_Custom_MicroSurface: string;
  69965. Fragment_Before_Fog: string;
  69966. Fragment_Custom_Alpha: string;
  69967. Fragment_Before_FragColor: string;
  69968. Vertex_Begin: string;
  69969. Vertex_Definitions: string;
  69970. Vertex_MainBegin: string;
  69971. Vertex_Before_PositionUpdated: string;
  69972. Vertex_Before_NormalUpdated: string;
  69973. Vertex_MainEnd: string;
  69974. }
  69975. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69976. static ShaderIndexer: number;
  69977. CustomParts: ShaderAlebdoParts;
  69978. _isCreatedShader: boolean;
  69979. _createdShaderName: string;
  69980. _customUniform: string[];
  69981. _newUniforms: string[];
  69982. _newUniformInstances: any[];
  69983. _newSamplerInstances: BABYLON.Texture[];
  69984. FragmentShader: string;
  69985. VertexShader: string;
  69986. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69987. ReviewUniform(name: string, arr: string[]): string[];
  69988. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69989. constructor(name: string, scene: BABYLON.Scene);
  69990. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69991. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69992. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69993. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69994. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69995. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69996. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69997. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69998. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69999. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70000. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70001. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70002. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70003. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70004. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70005. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70006. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70007. }
  70008. }
  70009. declare module BABYLON {
  70010. /** @hidden */
  70011. export var firePixelShader: {
  70012. name: string;
  70013. shader: string;
  70014. };
  70015. }
  70016. declare module BABYLON {
  70017. /** @hidden */
  70018. export var fireVertexShader: {
  70019. name: string;
  70020. shader: string;
  70021. };
  70022. }
  70023. declare module BABYLON {
  70024. export class FireMaterial extends BABYLON.PushMaterial {
  70025. private _diffuseTexture;
  70026. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70027. private _distortionTexture;
  70028. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70029. private _opacityTexture;
  70030. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70031. diffuseColor: BABYLON.Color3;
  70032. speed: number;
  70033. private _scaledDiffuse;
  70034. private _renderId;
  70035. private _lastTime;
  70036. constructor(name: string, scene: BABYLON.Scene);
  70037. needAlphaBlending(): boolean;
  70038. needAlphaTesting(): boolean;
  70039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70042. getAnimatables(): BABYLON.IAnimatable[];
  70043. getActiveTextures(): BABYLON.BaseTexture[];
  70044. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70045. getClassName(): string;
  70046. dispose(forceDisposeEffect?: boolean): void;
  70047. clone(name: string): FireMaterial;
  70048. serialize(): any;
  70049. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70050. }
  70051. }
  70052. declare module BABYLON {
  70053. /** @hidden */
  70054. export var furPixelShader: {
  70055. name: string;
  70056. shader: string;
  70057. };
  70058. }
  70059. declare module BABYLON {
  70060. /** @hidden */
  70061. export var furVertexShader: {
  70062. name: string;
  70063. shader: string;
  70064. };
  70065. }
  70066. declare module BABYLON {
  70067. export class FurMaterial extends BABYLON.PushMaterial {
  70068. private _diffuseTexture;
  70069. diffuseTexture: BABYLON.BaseTexture;
  70070. private _heightTexture;
  70071. heightTexture: BABYLON.BaseTexture;
  70072. diffuseColor: BABYLON.Color3;
  70073. furLength: number;
  70074. furAngle: number;
  70075. furColor: BABYLON.Color3;
  70076. furOffset: number;
  70077. furSpacing: number;
  70078. furGravity: BABYLON.Vector3;
  70079. furSpeed: number;
  70080. furDensity: number;
  70081. furOcclusion: number;
  70082. furTexture: BABYLON.DynamicTexture;
  70083. private _disableLighting;
  70084. disableLighting: boolean;
  70085. private _maxSimultaneousLights;
  70086. maxSimultaneousLights: number;
  70087. highLevelFur: boolean;
  70088. _meshes: BABYLON.AbstractMesh[];
  70089. private _renderId;
  70090. private _furTime;
  70091. constructor(name: string, scene: BABYLON.Scene);
  70092. furTime: number;
  70093. needAlphaBlending(): boolean;
  70094. needAlphaTesting(): boolean;
  70095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70096. updateFur(): void;
  70097. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70098. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70099. getAnimatables(): BABYLON.IAnimatable[];
  70100. getActiveTextures(): BABYLON.BaseTexture[];
  70101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70102. dispose(forceDisposeEffect?: boolean): void;
  70103. clone(name: string): FurMaterial;
  70104. serialize(): any;
  70105. getClassName(): string;
  70106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70107. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70108. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70109. }
  70110. }
  70111. declare module BABYLON {
  70112. /** @hidden */
  70113. export var gradientPixelShader: {
  70114. name: string;
  70115. shader: string;
  70116. };
  70117. }
  70118. declare module BABYLON {
  70119. /** @hidden */
  70120. export var gradientVertexShader: {
  70121. name: string;
  70122. shader: string;
  70123. };
  70124. }
  70125. declare module BABYLON {
  70126. export class GradientMaterial extends BABYLON.PushMaterial {
  70127. private _maxSimultaneousLights;
  70128. maxSimultaneousLights: number;
  70129. topColor: BABYLON.Color3;
  70130. topColorAlpha: number;
  70131. bottomColor: BABYLON.Color3;
  70132. bottomColorAlpha: number;
  70133. offset: number;
  70134. scale: number;
  70135. smoothness: number;
  70136. private _disableLighting;
  70137. disableLighting: boolean;
  70138. private _renderId;
  70139. constructor(name: string, scene: BABYLON.Scene);
  70140. needAlphaBlending(): boolean;
  70141. needAlphaTesting(): boolean;
  70142. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70143. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70144. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70145. getAnimatables(): BABYLON.IAnimatable[];
  70146. dispose(forceDisposeEffect?: boolean): void;
  70147. clone(name: string): GradientMaterial;
  70148. serialize(): any;
  70149. getClassName(): string;
  70150. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70151. }
  70152. }
  70153. declare module BABYLON {
  70154. /** @hidden */
  70155. export var gridPixelShader: {
  70156. name: string;
  70157. shader: string;
  70158. };
  70159. }
  70160. declare module BABYLON {
  70161. /** @hidden */
  70162. export var gridVertexShader: {
  70163. name: string;
  70164. shader: string;
  70165. };
  70166. }
  70167. declare module BABYLON {
  70168. /**
  70169. * The grid materials allows you to wrap any shape with a grid.
  70170. * Colors are customizable.
  70171. */
  70172. export class GridMaterial extends BABYLON.PushMaterial {
  70173. /**
  70174. * Main color of the grid (e.g. between lines)
  70175. */
  70176. mainColor: BABYLON.Color3;
  70177. /**
  70178. * Color of the grid lines.
  70179. */
  70180. lineColor: BABYLON.Color3;
  70181. /**
  70182. * The scale of the grid compared to unit.
  70183. */
  70184. gridRatio: number;
  70185. /**
  70186. * Allows setting an offset for the grid lines.
  70187. */
  70188. gridOffset: BABYLON.Vector3;
  70189. /**
  70190. * The frequency of thicker lines.
  70191. */
  70192. majorUnitFrequency: number;
  70193. /**
  70194. * The visibility of minor units in the grid.
  70195. */
  70196. minorUnitVisibility: number;
  70197. /**
  70198. * The grid opacity outside of the lines.
  70199. */
  70200. opacity: number;
  70201. /**
  70202. * Determine RBG output is premultiplied by alpha value.
  70203. */
  70204. preMultiplyAlpha: boolean;
  70205. private _opacityTexture;
  70206. opacityTexture: BABYLON.BaseTexture;
  70207. private _gridControl;
  70208. private _renderId;
  70209. /**
  70210. * constructor
  70211. * @param name The name given to the material in order to identify it afterwards.
  70212. * @param scene The scene the material is used in.
  70213. */
  70214. constructor(name: string, scene: BABYLON.Scene);
  70215. /**
  70216. * Returns wehter or not the grid requires alpha blending.
  70217. */
  70218. needAlphaBlending(): boolean;
  70219. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70220. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70221. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70222. /**
  70223. * Dispose the material and its associated resources.
  70224. * @param forceDisposeEffect will also dispose the used effect when true
  70225. */
  70226. dispose(forceDisposeEffect?: boolean): void;
  70227. clone(name: string): GridMaterial;
  70228. serialize(): any;
  70229. getClassName(): string;
  70230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70231. }
  70232. }
  70233. declare module BABYLON {
  70234. /** @hidden */
  70235. export var lavaPixelShader: {
  70236. name: string;
  70237. shader: string;
  70238. };
  70239. }
  70240. declare module BABYLON {
  70241. /** @hidden */
  70242. export var lavaVertexShader: {
  70243. name: string;
  70244. shader: string;
  70245. };
  70246. }
  70247. declare module BABYLON {
  70248. export class LavaMaterial extends BABYLON.PushMaterial {
  70249. private _diffuseTexture;
  70250. diffuseTexture: BABYLON.BaseTexture;
  70251. noiseTexture: BABYLON.BaseTexture;
  70252. fogColor: BABYLON.Color3;
  70253. speed: number;
  70254. movingSpeed: number;
  70255. lowFrequencySpeed: number;
  70256. fogDensity: number;
  70257. private _lastTime;
  70258. diffuseColor: BABYLON.Color3;
  70259. private _disableLighting;
  70260. disableLighting: boolean;
  70261. private _unlit;
  70262. unlit: boolean;
  70263. private _maxSimultaneousLights;
  70264. maxSimultaneousLights: number;
  70265. private _scaledDiffuse;
  70266. private _renderId;
  70267. constructor(name: string, scene: BABYLON.Scene);
  70268. needAlphaBlending(): boolean;
  70269. needAlphaTesting(): boolean;
  70270. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70271. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70272. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70273. getAnimatables(): BABYLON.IAnimatable[];
  70274. getActiveTextures(): BABYLON.BaseTexture[];
  70275. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70276. dispose(forceDisposeEffect?: boolean): void;
  70277. clone(name: string): LavaMaterial;
  70278. serialize(): any;
  70279. getClassName(): string;
  70280. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70281. }
  70282. }
  70283. declare module BABYLON {
  70284. /** @hidden */
  70285. export var mixPixelShader: {
  70286. name: string;
  70287. shader: string;
  70288. };
  70289. }
  70290. declare module BABYLON {
  70291. /** @hidden */
  70292. export var mixVertexShader: {
  70293. name: string;
  70294. shader: string;
  70295. };
  70296. }
  70297. declare module BABYLON {
  70298. export class MixMaterial extends BABYLON.PushMaterial {
  70299. /**
  70300. * Mix textures
  70301. */
  70302. private _mixTexture1;
  70303. mixTexture1: BABYLON.BaseTexture;
  70304. private _mixTexture2;
  70305. mixTexture2: BABYLON.BaseTexture;
  70306. /**
  70307. * Diffuse textures
  70308. */
  70309. private _diffuseTexture1;
  70310. diffuseTexture1: BABYLON.Texture;
  70311. private _diffuseTexture2;
  70312. diffuseTexture2: BABYLON.Texture;
  70313. private _diffuseTexture3;
  70314. diffuseTexture3: BABYLON.Texture;
  70315. private _diffuseTexture4;
  70316. diffuseTexture4: BABYLON.Texture;
  70317. private _diffuseTexture5;
  70318. diffuseTexture5: BABYLON.Texture;
  70319. private _diffuseTexture6;
  70320. diffuseTexture6: BABYLON.Texture;
  70321. private _diffuseTexture7;
  70322. diffuseTexture7: BABYLON.Texture;
  70323. private _diffuseTexture8;
  70324. diffuseTexture8: BABYLON.Texture;
  70325. /**
  70326. * Uniforms
  70327. */
  70328. diffuseColor: BABYLON.Color3;
  70329. specularColor: BABYLON.Color3;
  70330. specularPower: number;
  70331. private _disableLighting;
  70332. disableLighting: boolean;
  70333. private _maxSimultaneousLights;
  70334. maxSimultaneousLights: number;
  70335. private _renderId;
  70336. constructor(name: string, scene: BABYLON.Scene);
  70337. needAlphaBlending(): boolean;
  70338. needAlphaTesting(): boolean;
  70339. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70340. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70341. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70342. getAnimatables(): BABYLON.IAnimatable[];
  70343. getActiveTextures(): BABYLON.BaseTexture[];
  70344. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70345. dispose(forceDisposeEffect?: boolean): void;
  70346. clone(name: string): MixMaterial;
  70347. serialize(): any;
  70348. getClassName(): string;
  70349. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70350. }
  70351. }
  70352. declare module BABYLON {
  70353. /** @hidden */
  70354. export var normalPixelShader: {
  70355. name: string;
  70356. shader: string;
  70357. };
  70358. }
  70359. declare module BABYLON {
  70360. /** @hidden */
  70361. export var normalVertexShader: {
  70362. name: string;
  70363. shader: string;
  70364. };
  70365. }
  70366. declare module BABYLON {
  70367. export class NormalMaterial extends BABYLON.PushMaterial {
  70368. private _diffuseTexture;
  70369. diffuseTexture: BABYLON.BaseTexture;
  70370. diffuseColor: BABYLON.Color3;
  70371. private _disableLighting;
  70372. disableLighting: boolean;
  70373. private _maxSimultaneousLights;
  70374. maxSimultaneousLights: number;
  70375. private _renderId;
  70376. constructor(name: string, scene: BABYLON.Scene);
  70377. needAlphaBlending(): boolean;
  70378. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70379. needAlphaTesting(): boolean;
  70380. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70381. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70382. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70383. getAnimatables(): BABYLON.IAnimatable[];
  70384. getActiveTextures(): BABYLON.BaseTexture[];
  70385. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70386. dispose(forceDisposeEffect?: boolean): void;
  70387. clone(name: string): NormalMaterial;
  70388. serialize(): any;
  70389. getClassName(): string;
  70390. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70391. }
  70392. }
  70393. declare module BABYLON {
  70394. /** @hidden */
  70395. export var shadowOnlyPixelShader: {
  70396. name: string;
  70397. shader: string;
  70398. };
  70399. }
  70400. declare module BABYLON {
  70401. /** @hidden */
  70402. export var shadowOnlyVertexShader: {
  70403. name: string;
  70404. shader: string;
  70405. };
  70406. }
  70407. declare module BABYLON {
  70408. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70409. private _renderId;
  70410. private _activeLight;
  70411. constructor(name: string, scene: BABYLON.Scene);
  70412. shadowColor: BABYLON.Color3;
  70413. needAlphaBlending(): boolean;
  70414. needAlphaTesting(): boolean;
  70415. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70416. activeLight: BABYLON.IShadowLight;
  70417. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70419. clone(name: string): ShadowOnlyMaterial;
  70420. serialize(): any;
  70421. getClassName(): string;
  70422. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70423. }
  70424. }
  70425. declare module BABYLON {
  70426. /** @hidden */
  70427. export var simplePixelShader: {
  70428. name: string;
  70429. shader: string;
  70430. };
  70431. }
  70432. declare module BABYLON {
  70433. /** @hidden */
  70434. export var simpleVertexShader: {
  70435. name: string;
  70436. shader: string;
  70437. };
  70438. }
  70439. declare module BABYLON {
  70440. export class SimpleMaterial extends BABYLON.PushMaterial {
  70441. private _diffuseTexture;
  70442. diffuseTexture: BABYLON.BaseTexture;
  70443. diffuseColor: BABYLON.Color3;
  70444. private _disableLighting;
  70445. disableLighting: boolean;
  70446. private _maxSimultaneousLights;
  70447. maxSimultaneousLights: number;
  70448. private _renderId;
  70449. constructor(name: string, scene: BABYLON.Scene);
  70450. needAlphaBlending(): boolean;
  70451. needAlphaTesting(): boolean;
  70452. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70453. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70454. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70455. getAnimatables(): BABYLON.IAnimatable[];
  70456. getActiveTextures(): BABYLON.BaseTexture[];
  70457. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70458. dispose(forceDisposeEffect?: boolean): void;
  70459. clone(name: string): SimpleMaterial;
  70460. serialize(): any;
  70461. getClassName(): string;
  70462. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70463. }
  70464. }
  70465. declare module BABYLON {
  70466. /** @hidden */
  70467. export var skyPixelShader: {
  70468. name: string;
  70469. shader: string;
  70470. };
  70471. }
  70472. declare module BABYLON {
  70473. /** @hidden */
  70474. export var skyVertexShader: {
  70475. name: string;
  70476. shader: string;
  70477. };
  70478. }
  70479. declare module BABYLON {
  70480. /**
  70481. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70482. * @see https://doc.babylonjs.com/extensions/sky
  70483. */
  70484. export class SkyMaterial extends BABYLON.PushMaterial {
  70485. /**
  70486. * Defines the overall luminance of sky in interval ]0, 1[.
  70487. */
  70488. luminance: number;
  70489. /**
  70490. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70491. */
  70492. turbidity: number;
  70493. /**
  70494. * Defines the sky appearance (light intensity).
  70495. */
  70496. rayleigh: number;
  70497. /**
  70498. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70499. */
  70500. mieCoefficient: number;
  70501. /**
  70502. * Defines the amount of haze particles following the Mie scattering theory.
  70503. */
  70504. mieDirectionalG: number;
  70505. /**
  70506. * Defines the distance of the sun according to the active scene camera.
  70507. */
  70508. distance: number;
  70509. /**
  70510. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70511. * "inclined".
  70512. */
  70513. inclination: number;
  70514. /**
  70515. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70516. * an object direction and a reference direction.
  70517. */
  70518. azimuth: number;
  70519. /**
  70520. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70521. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70522. */
  70523. sunPosition: BABYLON.Vector3;
  70524. /**
  70525. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70526. * .sunPosition property.
  70527. */
  70528. useSunPosition: boolean;
  70529. /**
  70530. * Defines an offset vector used to get a horizon offset.
  70531. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70532. */
  70533. cameraOffset: BABYLON.Vector3;
  70534. private _cameraPosition;
  70535. private _renderId;
  70536. /**
  70537. * Instantiates a new sky material.
  70538. * This material allows to create dynamic and texture free
  70539. * effects for skyboxes by taking care of the atmosphere state.
  70540. * @see https://doc.babylonjs.com/extensions/sky
  70541. * @param name Define the name of the material in the scene
  70542. * @param scene Define the scene the material belong to
  70543. */
  70544. constructor(name: string, scene: BABYLON.Scene);
  70545. /**
  70546. * Specifies if the material will require alpha blending
  70547. * @returns a boolean specifying if alpha blending is needed
  70548. */
  70549. needAlphaBlending(): boolean;
  70550. /**
  70551. * Specifies if this material should be rendered in alpha test mode
  70552. * @returns false as the sky material doesn't need alpha testing.
  70553. */
  70554. needAlphaTesting(): boolean;
  70555. /**
  70556. * Get the texture used for alpha test purpose.
  70557. * @returns null as the sky material has no texture.
  70558. */
  70559. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70560. /**
  70561. * Get if the submesh is ready to be used and all its information available.
  70562. * Child classes can use it to update shaders
  70563. * @param mesh defines the mesh to check
  70564. * @param subMesh defines which submesh to check
  70565. * @param useInstances specifies that instances should be used
  70566. * @returns a boolean indicating that the submesh is ready or not
  70567. */
  70568. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70569. /**
  70570. * Binds the submesh to this material by preparing the effect and shader to draw
  70571. * @param world defines the world transformation matrix
  70572. * @param mesh defines the mesh containing the submesh
  70573. * @param subMesh defines the submesh to bind the material to
  70574. */
  70575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70576. /**
  70577. * Get the list of animatables in the material.
  70578. * @returns the list of animatables object used in the material
  70579. */
  70580. getAnimatables(): BABYLON.IAnimatable[];
  70581. /**
  70582. * Disposes the material
  70583. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70584. */
  70585. dispose(forceDisposeEffect?: boolean): void;
  70586. /**
  70587. * Makes a duplicate of the material, and gives it a new name
  70588. * @param name defines the new name for the duplicated material
  70589. * @returns the cloned material
  70590. */
  70591. clone(name: string): SkyMaterial;
  70592. /**
  70593. * Serializes this material in a JSON representation
  70594. * @returns the serialized material object
  70595. */
  70596. serialize(): any;
  70597. /**
  70598. * Gets the current class name of the material e.g. "SkyMaterial"
  70599. * Mainly use in serialization.
  70600. * @returns the class name
  70601. */
  70602. getClassName(): string;
  70603. /**
  70604. * Creates a sky material from parsed material data
  70605. * @param source defines the JSON representation of the material
  70606. * @param scene defines the hosting scene
  70607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70608. * @returns a new sky material
  70609. */
  70610. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70611. }
  70612. }
  70613. declare module BABYLON {
  70614. /** @hidden */
  70615. export var terrainPixelShader: {
  70616. name: string;
  70617. shader: string;
  70618. };
  70619. }
  70620. declare module BABYLON {
  70621. /** @hidden */
  70622. export var terrainVertexShader: {
  70623. name: string;
  70624. shader: string;
  70625. };
  70626. }
  70627. declare module BABYLON {
  70628. export class TerrainMaterial extends BABYLON.PushMaterial {
  70629. private _mixTexture;
  70630. mixTexture: BABYLON.BaseTexture;
  70631. private _diffuseTexture1;
  70632. diffuseTexture1: BABYLON.Texture;
  70633. private _diffuseTexture2;
  70634. diffuseTexture2: BABYLON.Texture;
  70635. private _diffuseTexture3;
  70636. diffuseTexture3: BABYLON.Texture;
  70637. private _bumpTexture1;
  70638. bumpTexture1: BABYLON.Texture;
  70639. private _bumpTexture2;
  70640. bumpTexture2: BABYLON.Texture;
  70641. private _bumpTexture3;
  70642. bumpTexture3: BABYLON.Texture;
  70643. diffuseColor: BABYLON.Color3;
  70644. specularColor: BABYLON.Color3;
  70645. specularPower: number;
  70646. private _disableLighting;
  70647. disableLighting: boolean;
  70648. private _maxSimultaneousLights;
  70649. maxSimultaneousLights: number;
  70650. private _renderId;
  70651. constructor(name: string, scene: BABYLON.Scene);
  70652. needAlphaBlending(): boolean;
  70653. needAlphaTesting(): boolean;
  70654. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70655. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70656. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70657. getAnimatables(): BABYLON.IAnimatable[];
  70658. getActiveTextures(): BABYLON.BaseTexture[];
  70659. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70660. dispose(forceDisposeEffect?: boolean): void;
  70661. clone(name: string): TerrainMaterial;
  70662. serialize(): any;
  70663. getClassName(): string;
  70664. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70665. }
  70666. }
  70667. declare module BABYLON {
  70668. /** @hidden */
  70669. export var triplanarPixelShader: {
  70670. name: string;
  70671. shader: string;
  70672. };
  70673. }
  70674. declare module BABYLON {
  70675. /** @hidden */
  70676. export var triplanarVertexShader: {
  70677. name: string;
  70678. shader: string;
  70679. };
  70680. }
  70681. declare module BABYLON {
  70682. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70683. mixTexture: BABYLON.BaseTexture;
  70684. private _diffuseTextureX;
  70685. diffuseTextureX: BABYLON.BaseTexture;
  70686. private _diffuseTextureY;
  70687. diffuseTextureY: BABYLON.BaseTexture;
  70688. private _diffuseTextureZ;
  70689. diffuseTextureZ: BABYLON.BaseTexture;
  70690. private _normalTextureX;
  70691. normalTextureX: BABYLON.BaseTexture;
  70692. private _normalTextureY;
  70693. normalTextureY: BABYLON.BaseTexture;
  70694. private _normalTextureZ;
  70695. normalTextureZ: BABYLON.BaseTexture;
  70696. tileSize: number;
  70697. diffuseColor: BABYLON.Color3;
  70698. specularColor: BABYLON.Color3;
  70699. specularPower: number;
  70700. private _disableLighting;
  70701. disableLighting: boolean;
  70702. private _maxSimultaneousLights;
  70703. maxSimultaneousLights: number;
  70704. private _renderId;
  70705. constructor(name: string, scene: BABYLON.Scene);
  70706. needAlphaBlending(): boolean;
  70707. needAlphaTesting(): boolean;
  70708. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70709. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70710. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70711. getAnimatables(): BABYLON.IAnimatable[];
  70712. getActiveTextures(): BABYLON.BaseTexture[];
  70713. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70714. dispose(forceDisposeEffect?: boolean): void;
  70715. clone(name: string): TriPlanarMaterial;
  70716. serialize(): any;
  70717. getClassName(): string;
  70718. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70719. }
  70720. }
  70721. declare module BABYLON {
  70722. /** @hidden */
  70723. export var waterPixelShader: {
  70724. name: string;
  70725. shader: string;
  70726. };
  70727. }
  70728. declare module BABYLON {
  70729. /** @hidden */
  70730. export var waterVertexShader: {
  70731. name: string;
  70732. shader: string;
  70733. };
  70734. }
  70735. declare module BABYLON {
  70736. export class WaterMaterial extends BABYLON.PushMaterial {
  70737. renderTargetSize: BABYLON.Vector2;
  70738. private _bumpTexture;
  70739. bumpTexture: BABYLON.BaseTexture;
  70740. diffuseColor: BABYLON.Color3;
  70741. specularColor: BABYLON.Color3;
  70742. specularPower: number;
  70743. private _disableLighting;
  70744. disableLighting: boolean;
  70745. private _maxSimultaneousLights;
  70746. maxSimultaneousLights: number;
  70747. /**
  70748. * @param {number}: Represents the wind force
  70749. */
  70750. windForce: number;
  70751. /**
  70752. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70753. */
  70754. windDirection: BABYLON.Vector2;
  70755. /**
  70756. * @param {number}: Wave height, represents the height of the waves
  70757. */
  70758. waveHeight: number;
  70759. /**
  70760. * @param {number}: Bump height, represents the bump height related to the bump map
  70761. */
  70762. bumpHeight: number;
  70763. /**
  70764. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70765. */
  70766. private _bumpSuperimpose;
  70767. bumpSuperimpose: boolean;
  70768. /**
  70769. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70770. */
  70771. private _fresnelSeparate;
  70772. fresnelSeparate: boolean;
  70773. /**
  70774. * @param {boolean}: bump Waves modify the reflection.
  70775. */
  70776. private _bumpAffectsReflection;
  70777. bumpAffectsReflection: boolean;
  70778. /**
  70779. * @param {number}: The water color blended with the refraction (near)
  70780. */
  70781. waterColor: BABYLON.Color3;
  70782. /**
  70783. * @param {number}: The blend factor related to the water color
  70784. */
  70785. colorBlendFactor: number;
  70786. /**
  70787. * @param {number}: The water color blended with the reflection (far)
  70788. */
  70789. waterColor2: BABYLON.Color3;
  70790. /**
  70791. * @param {number}: The blend factor related to the water color (reflection, far)
  70792. */
  70793. colorBlendFactor2: number;
  70794. /**
  70795. * @param {number}: Represents the maximum length of a wave
  70796. */
  70797. waveLength: number;
  70798. /**
  70799. * @param {number}: Defines the waves speed
  70800. */
  70801. waveSpeed: number;
  70802. /**
  70803. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70804. * will avoid calculating useless pixels in the pixel shader of the water material.
  70805. */
  70806. disableClipPlane: boolean;
  70807. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70808. private _mesh;
  70809. private _refractionRTT;
  70810. private _reflectionRTT;
  70811. private _reflectionTransform;
  70812. private _lastTime;
  70813. private _lastDeltaTime;
  70814. private _renderId;
  70815. private _useLogarithmicDepth;
  70816. private _waitingRenderList;
  70817. private _imageProcessingConfiguration;
  70818. private _imageProcessingObserver;
  70819. /**
  70820. * Gets a boolean indicating that current material needs to register RTT
  70821. */
  70822. readonly hasRenderTargetTextures: boolean;
  70823. /**
  70824. * Constructor
  70825. */
  70826. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70827. useLogarithmicDepth: boolean;
  70828. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70829. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70830. addToRenderList(node: any): void;
  70831. enableRenderTargets(enable: boolean): void;
  70832. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70833. readonly renderTargetsEnabled: boolean;
  70834. needAlphaBlending(): boolean;
  70835. needAlphaTesting(): boolean;
  70836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70837. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70838. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70839. private _createRenderTargets;
  70840. getAnimatables(): BABYLON.IAnimatable[];
  70841. getActiveTextures(): BABYLON.BaseTexture[];
  70842. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70843. dispose(forceDisposeEffect?: boolean): void;
  70844. clone(name: string): WaterMaterial;
  70845. serialize(): any;
  70846. getClassName(): string;
  70847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70848. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70849. }
  70850. }
  70851. declare module BABYLON {
  70852. /** @hidden */
  70853. export var asciiartPixelShader: {
  70854. name: string;
  70855. shader: string;
  70856. };
  70857. }
  70858. declare module BABYLON {
  70859. /**
  70860. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70861. *
  70862. * It basically takes care rendering the font front the given font size to a texture.
  70863. * This is used later on in the postprocess.
  70864. */
  70865. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70866. private _font;
  70867. private _text;
  70868. private _charSize;
  70869. /**
  70870. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70871. */
  70872. readonly charSize: number;
  70873. /**
  70874. * Create a new instance of the Ascii Art FontTexture class
  70875. * @param name the name of the texture
  70876. * @param font the font to use, use the W3C CSS notation
  70877. * @param text the caracter set to use in the rendering.
  70878. * @param scene the scene that owns the texture
  70879. */
  70880. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70881. /**
  70882. * Gets the max char width of a font.
  70883. * @param font the font to use, use the W3C CSS notation
  70884. * @return the max char width
  70885. */
  70886. private getFontWidth;
  70887. /**
  70888. * Gets the max char height of a font.
  70889. * @param font the font to use, use the W3C CSS notation
  70890. * @return the max char height
  70891. */
  70892. private getFontHeight;
  70893. /**
  70894. * Clones the current AsciiArtTexture.
  70895. * @return the clone of the texture.
  70896. */
  70897. clone(): AsciiArtFontTexture;
  70898. /**
  70899. * Parses a json object representing the texture and returns an instance of it.
  70900. * @param source the source JSON representation
  70901. * @param scene the scene to create the texture for
  70902. * @return the parsed texture
  70903. */
  70904. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70905. }
  70906. /**
  70907. * Option available in the Ascii Art Post Process.
  70908. */
  70909. export interface IAsciiArtPostProcessOptions {
  70910. /**
  70911. * The font to use following the w3c font definition.
  70912. */
  70913. font?: string;
  70914. /**
  70915. * The character set to use in the postprocess.
  70916. */
  70917. characterSet?: string;
  70918. /**
  70919. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70920. * This number is defined between 0 and 1;
  70921. */
  70922. mixToTile?: number;
  70923. /**
  70924. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70925. * This number is defined between 0 and 1;
  70926. */
  70927. mixToNormal?: number;
  70928. }
  70929. /**
  70930. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70931. *
  70932. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70933. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70934. */
  70935. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70936. /**
  70937. * The font texture used to render the char in the post process.
  70938. */
  70939. private _asciiArtFontTexture;
  70940. /**
  70941. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70942. * This number is defined between 0 and 1;
  70943. */
  70944. mixToTile: number;
  70945. /**
  70946. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70947. * This number is defined between 0 and 1;
  70948. */
  70949. mixToNormal: number;
  70950. /**
  70951. * Instantiates a new Ascii Art Post Process.
  70952. * @param name the name to give to the postprocess
  70953. * @camera the camera to apply the post process to.
  70954. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70955. */
  70956. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70957. }
  70958. }
  70959. declare module BABYLON {
  70960. /** @hidden */
  70961. export var digitalrainPixelShader: {
  70962. name: string;
  70963. shader: string;
  70964. };
  70965. }
  70966. declare module BABYLON {
  70967. /**
  70968. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70969. *
  70970. * It basically takes care rendering the font front the given font size to a texture.
  70971. * This is used later on in the postprocess.
  70972. */
  70973. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70974. private _font;
  70975. private _text;
  70976. private _charSize;
  70977. /**
  70978. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70979. */
  70980. readonly charSize: number;
  70981. /**
  70982. * Create a new instance of the Digital Rain FontTexture class
  70983. * @param name the name of the texture
  70984. * @param font the font to use, use the W3C CSS notation
  70985. * @param text the caracter set to use in the rendering.
  70986. * @param scene the scene that owns the texture
  70987. */
  70988. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70989. /**
  70990. * Gets the max char width of a font.
  70991. * @param font the font to use, use the W3C CSS notation
  70992. * @return the max char width
  70993. */
  70994. private getFontWidth;
  70995. /**
  70996. * Gets the max char height of a font.
  70997. * @param font the font to use, use the W3C CSS notation
  70998. * @return the max char height
  70999. */
  71000. private getFontHeight;
  71001. /**
  71002. * Clones the current DigitalRainFontTexture.
  71003. * @return the clone of the texture.
  71004. */
  71005. clone(): DigitalRainFontTexture;
  71006. /**
  71007. * Parses a json object representing the texture and returns an instance of it.
  71008. * @param source the source JSON representation
  71009. * @param scene the scene to create the texture for
  71010. * @return the parsed texture
  71011. */
  71012. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71013. }
  71014. /**
  71015. * Option available in the Digital Rain Post Process.
  71016. */
  71017. export interface IDigitalRainPostProcessOptions {
  71018. /**
  71019. * The font to use following the w3c font definition.
  71020. */
  71021. font?: string;
  71022. /**
  71023. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71024. * This number is defined between 0 and 1;
  71025. */
  71026. mixToTile?: number;
  71027. /**
  71028. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71029. * This number is defined between 0 and 1;
  71030. */
  71031. mixToNormal?: number;
  71032. }
  71033. /**
  71034. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71035. *
  71036. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71037. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71038. */
  71039. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71040. /**
  71041. * The font texture used to render the char in the post process.
  71042. */
  71043. private _digitalRainFontTexture;
  71044. /**
  71045. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71046. * This number is defined between 0 and 1;
  71047. */
  71048. mixToTile: number;
  71049. /**
  71050. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71051. * This number is defined between 0 and 1;
  71052. */
  71053. mixToNormal: number;
  71054. /**
  71055. * Instantiates a new Digital Rain Post Process.
  71056. * @param name the name to give to the postprocess
  71057. * @camera the camera to apply the post process to.
  71058. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71059. */
  71060. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71061. }
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var oceanPostProcessPixelShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * Option available in the Ocean Post Process.
  71073. */
  71074. export interface IOceanPostProcessOptions {
  71075. /**
  71076. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71077. */
  71078. reflectionSize?: number | {
  71079. width: number;
  71080. height: number;
  71081. } | {
  71082. ratio: number;
  71083. };
  71084. /**
  71085. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71086. */
  71087. refractionSize?: number | {
  71088. width: number;
  71089. height: number;
  71090. } | {
  71091. ratio: number;
  71092. };
  71093. }
  71094. /**
  71095. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71096. *
  71097. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71098. * Example usage:
  71099. * var pp = new OceanPostProcess("myOcean", camera);
  71100. * pp.reflectionEnabled = true;
  71101. * pp.refractionEnabled = true;
  71102. */
  71103. export class OceanPostProcess extends BABYLON.PostProcess {
  71104. /**
  71105. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71106. */
  71107. /**
  71108. * Sets weither or not the real-time reflection is enabled on the ocean.
  71109. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71110. */
  71111. reflectionEnabled: boolean;
  71112. /**
  71113. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71114. */
  71115. /**
  71116. * Sets weither or not the real-time refraction is enabled on the ocean.
  71117. * Is set to true, the refraction render target texture will be used as refraction texture.
  71118. */
  71119. refractionEnabled: boolean;
  71120. /**
  71121. * Gets wether or not the post-processes is supported by the running hardware.
  71122. * This requires draw buffer supports.
  71123. */
  71124. readonly isSupported: boolean;
  71125. /**
  71126. * This is the reflection mirror texture used to display reflections on the ocean.
  71127. * By default, render list is empty.
  71128. */
  71129. reflectionTexture: BABYLON.MirrorTexture;
  71130. /**
  71131. * This is the refraction render target texture used to display refraction on the ocean.
  71132. * By default, render list is empty.
  71133. */
  71134. refractionTexture: BABYLON.RenderTargetTexture;
  71135. private _time;
  71136. private _cameraRotation;
  71137. private _cameraViewMatrix;
  71138. private _reflectionEnabled;
  71139. private _refractionEnabled;
  71140. private _geometryRenderer;
  71141. /**
  71142. * Instantiates a new Ocean Post Process.
  71143. * @param name the name to give to the postprocess.
  71144. * @camera the camera to apply the post process to.
  71145. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71146. */
  71147. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71148. /**
  71149. * Returns the appropriate defines according to the current configuration.
  71150. */
  71151. private _getDefines;
  71152. /**
  71153. * Computes the current camera rotation as the shader requires a camera rotation.
  71154. */
  71155. private _computeCameraRotation;
  71156. }
  71157. }
  71158. declare module BABYLON {
  71159. /** @hidden */
  71160. export var brickProceduralTexturePixelShader: {
  71161. name: string;
  71162. shader: string;
  71163. };
  71164. }
  71165. declare module BABYLON {
  71166. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71167. private _numberOfBricksHeight;
  71168. private _numberOfBricksWidth;
  71169. private _jointColor;
  71170. private _brickColor;
  71171. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71172. updateShaderUniforms(): void;
  71173. numberOfBricksHeight: number;
  71174. numberOfBricksWidth: number;
  71175. jointColor: BABYLON.Color3;
  71176. brickColor: BABYLON.Color3;
  71177. /**
  71178. * Serializes this brick procedural texture
  71179. * @returns a serialized brick procedural texture object
  71180. */
  71181. serialize(): any;
  71182. /**
  71183. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71184. * @param parsedTexture defines parsed texture data
  71185. * @param scene defines the current scene
  71186. * @param rootUrl defines the root URL containing brick procedural texture information
  71187. * @returns a parsed Brick Procedural BABYLON.Texture
  71188. */
  71189. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71190. }
  71191. }
  71192. declare module BABYLON {
  71193. /** @hidden */
  71194. export var cloudProceduralTexturePixelShader: {
  71195. name: string;
  71196. shader: string;
  71197. };
  71198. }
  71199. declare module BABYLON {
  71200. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71201. private _skyColor;
  71202. private _cloudColor;
  71203. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71204. updateShaderUniforms(): void;
  71205. skyColor: BABYLON.Color4;
  71206. cloudColor: BABYLON.Color4;
  71207. /**
  71208. * Serializes this cloud procedural texture
  71209. * @returns a serialized cloud procedural texture object
  71210. */
  71211. serialize(): any;
  71212. /**
  71213. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71214. * @param parsedTexture defines parsed texture data
  71215. * @param scene defines the current scene
  71216. * @param rootUrl defines the root URL containing cloud procedural texture information
  71217. * @returns a parsed Cloud Procedural BABYLON.Texture
  71218. */
  71219. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71220. }
  71221. }
  71222. declare module BABYLON {
  71223. /** @hidden */
  71224. export var fireProceduralTexturePixelShader: {
  71225. name: string;
  71226. shader: string;
  71227. };
  71228. }
  71229. declare module BABYLON {
  71230. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71231. private _time;
  71232. private _speed;
  71233. private _autoGenerateTime;
  71234. private _fireColors;
  71235. private _alphaThreshold;
  71236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71237. updateShaderUniforms(): void;
  71238. render(useCameraPostProcess?: boolean): void;
  71239. static readonly PurpleFireColors: BABYLON.Color3[];
  71240. static readonly GreenFireColors: BABYLON.Color3[];
  71241. static readonly RedFireColors: BABYLON.Color3[];
  71242. static readonly BlueFireColors: BABYLON.Color3[];
  71243. autoGenerateTime: boolean;
  71244. fireColors: BABYLON.Color3[];
  71245. time: number;
  71246. speed: BABYLON.Vector2;
  71247. alphaThreshold: number;
  71248. /**
  71249. * Serializes this fire procedural texture
  71250. * @returns a serialized fire procedural texture object
  71251. */
  71252. serialize(): any;
  71253. /**
  71254. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71255. * @param parsedTexture defines parsed texture data
  71256. * @param scene defines the current scene
  71257. * @param rootUrl defines the root URL containing fire procedural texture information
  71258. * @returns a parsed Fire Procedural BABYLON.Texture
  71259. */
  71260. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71261. }
  71262. }
  71263. declare module BABYLON {
  71264. /** @hidden */
  71265. export var grassProceduralTexturePixelShader: {
  71266. name: string;
  71267. shader: string;
  71268. };
  71269. }
  71270. declare module BABYLON {
  71271. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71272. private _grassColors;
  71273. private _groundColor;
  71274. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71275. updateShaderUniforms(): void;
  71276. grassColors: BABYLON.Color3[];
  71277. groundColor: BABYLON.Color3;
  71278. /**
  71279. * Serializes this grass procedural texture
  71280. * @returns a serialized grass procedural texture object
  71281. */
  71282. serialize(): any;
  71283. /**
  71284. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71285. * @param parsedTexture defines parsed texture data
  71286. * @param scene defines the current scene
  71287. * @param rootUrl defines the root URL containing grass procedural texture information
  71288. * @returns a parsed Grass Procedural BABYLON.Texture
  71289. */
  71290. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /** @hidden */
  71295. export var marbleProceduralTexturePixelShader: {
  71296. name: string;
  71297. shader: string;
  71298. };
  71299. }
  71300. declare module BABYLON {
  71301. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71302. private _numberOfTilesHeight;
  71303. private _numberOfTilesWidth;
  71304. private _amplitude;
  71305. private _jointColor;
  71306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71307. updateShaderUniforms(): void;
  71308. numberOfTilesHeight: number;
  71309. amplitude: number;
  71310. numberOfTilesWidth: number;
  71311. jointColor: BABYLON.Color3;
  71312. /**
  71313. * Serializes this marble procedural texture
  71314. * @returns a serialized marble procedural texture object
  71315. */
  71316. serialize(): any;
  71317. /**
  71318. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71319. * @param parsedTexture defines parsed texture data
  71320. * @param scene defines the current scene
  71321. * @param rootUrl defines the root URL containing marble procedural texture information
  71322. * @returns a parsed Marble Procedural BABYLON.Texture
  71323. */
  71324. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71325. }
  71326. }
  71327. declare module BABYLON {
  71328. /** @hidden */
  71329. export var normalMapProceduralTexturePixelShader: {
  71330. name: string;
  71331. shader: string;
  71332. };
  71333. }
  71334. declare module BABYLON {
  71335. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71336. private _baseTexture;
  71337. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71338. updateShaderUniforms(): void;
  71339. render(useCameraPostProcess?: boolean): void;
  71340. resize(size: any, generateMipMaps: any): void;
  71341. baseTexture: BABYLON.Texture;
  71342. /**
  71343. * Serializes this normal map procedural texture
  71344. * @returns a serialized normal map procedural texture object
  71345. */
  71346. serialize(): any;
  71347. /**
  71348. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71349. * @param parsedTexture defines parsed texture data
  71350. * @param scene defines the current scene
  71351. * @param rootUrl defines the root URL containing normal map procedural texture information
  71352. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71353. */
  71354. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71355. }
  71356. }
  71357. declare module BABYLON {
  71358. /** @hidden */
  71359. export var perlinNoiseProceduralTexturePixelShader: {
  71360. name: string;
  71361. shader: string;
  71362. };
  71363. }
  71364. declare module BABYLON {
  71365. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71366. time: number;
  71367. timeScale: number;
  71368. translationSpeed: number;
  71369. private _currentTranslation;
  71370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71371. updateShaderUniforms(): void;
  71372. render(useCameraPostProcess?: boolean): void;
  71373. resize(size: any, generateMipMaps: any): void;
  71374. /**
  71375. * Serializes this perlin noise procedural texture
  71376. * @returns a serialized perlin noise procedural texture object
  71377. */
  71378. serialize(): any;
  71379. /**
  71380. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71381. * @param parsedTexture defines parsed texture data
  71382. * @param scene defines the current scene
  71383. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71384. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71385. */
  71386. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71387. }
  71388. }
  71389. declare module BABYLON {
  71390. /** @hidden */
  71391. export var roadProceduralTexturePixelShader: {
  71392. name: string;
  71393. shader: string;
  71394. };
  71395. }
  71396. declare module BABYLON {
  71397. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71398. private _roadColor;
  71399. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71400. updateShaderUniforms(): void;
  71401. roadColor: BABYLON.Color3;
  71402. /**
  71403. * Serializes this road procedural texture
  71404. * @returns a serialized road procedural texture object
  71405. */
  71406. serialize(): any;
  71407. /**
  71408. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71409. * @param parsedTexture defines parsed texture data
  71410. * @param scene defines the current scene
  71411. * @param rootUrl defines the root URL containing road procedural texture information
  71412. * @returns a parsed Road Procedural BABYLON.Texture
  71413. */
  71414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71415. }
  71416. }
  71417. declare module BABYLON {
  71418. /** @hidden */
  71419. export var starfieldProceduralTexturePixelShader: {
  71420. name: string;
  71421. shader: string;
  71422. };
  71423. }
  71424. declare module BABYLON {
  71425. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71426. private _time;
  71427. private _alpha;
  71428. private _beta;
  71429. private _zoom;
  71430. private _formuparam;
  71431. private _stepsize;
  71432. private _tile;
  71433. private _brightness;
  71434. private _darkmatter;
  71435. private _distfading;
  71436. private _saturation;
  71437. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71438. updateShaderUniforms(): void;
  71439. time: number;
  71440. alpha: number;
  71441. beta: number;
  71442. formuparam: number;
  71443. stepsize: number;
  71444. zoom: number;
  71445. tile: number;
  71446. brightness: number;
  71447. darkmatter: number;
  71448. distfading: number;
  71449. saturation: number;
  71450. /**
  71451. * Serializes this starfield procedural texture
  71452. * @returns a serialized starfield procedural texture object
  71453. */
  71454. serialize(): any;
  71455. /**
  71456. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71457. * @param parsedTexture defines parsed texture data
  71458. * @param scene defines the current scene
  71459. * @param rootUrl defines the root URL containing startfield procedural texture information
  71460. * @returns a parsed Starfield Procedural BABYLON.Texture
  71461. */
  71462. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /** @hidden */
  71467. export var woodProceduralTexturePixelShader: {
  71468. name: string;
  71469. shader: string;
  71470. };
  71471. }
  71472. declare module BABYLON {
  71473. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71474. private _ampScale;
  71475. private _woodColor;
  71476. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71477. updateShaderUniforms(): void;
  71478. ampScale: number;
  71479. woodColor: BABYLON.Color3;
  71480. /**
  71481. * Serializes this wood procedural texture
  71482. * @returns a serialized wood procedural texture object
  71483. */
  71484. serialize(): any;
  71485. /**
  71486. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71487. * @param parsedTexture defines parsed texture data
  71488. * @param scene defines the current scene
  71489. * @param rootUrl defines the root URL containing wood procedural texture information
  71490. * @returns a parsed Wood Procedural BABYLON.Texture
  71491. */
  71492. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71493. }
  71494. }